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

Fixed submission:
import sys
sys.setrecursionlimit(1<<20)
h,w=[int(x) for x in input().split()]
ch,cw=[int(x) for x in input().split()]
dh,dw=[int(x) for x in input().split()]
ch-=1
cw-=1
dh-=1
dw-=1

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

nxt=[[ch,cw,0]]
#再起
def rcl(y,x,now):
    
    if y==dh and x==dw:
        print(now)
        exit()
    
    if s[y][x]=='#':
        return
    
    s[y][x]='#'
    # 四方を見る
    for i in range(4):
        yy,xx=-1,0
        if i==1:yy,xx=0,1
        if i==2:yy,xx=1,0
        if i==3:yy,xx=0,-1
        
        if y+yy<0 or h<=y+yy or x+xx<0 or w<=x+xx:
            continue
        if s[y+yy][x+xx]=='#':
            continue
        
        rcl(y+yy,x+xx,now)
    #5*5
    for i in range(-2,3):
        for j in range(-2,3):
            if i==0 and j==0:
                continue
            if y+i<0 or h<=y+i or x+j<0 or w<=x+j:
                continue
            if s[y+i][x+j]=='.':
                nxt.append([y+i,x+j,now+1])
                s[y+i][x+j]=now+1


while nxt:
    i=nxt.pop(0)
    if i[0]==dh and i[1]==dw:
        print(i[2])
        exit()
    rcl(i[0],i[1],i[2])
print(-1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1<<20)
h,w=[int(x) for x in input().split()]
ch,cw=[int(x) for x in input().split()]
dh,dw=[int(x) for x in input().split()]
ch-=1
cw-=1
dh-=1
dw-=1

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

nxt=[[ch,cw,0]]
#再起
def rcl(y,x,now):
    
    if y==dh and x==dw:
        print(now)
        exit()
    
    if s[y][x]=='#':
        return
    
    s[y][x]='#'
    # 四方を見る
    for i in range(4):
        yy,xx=-1,0
        if i==1:yy,xx=0,1
        if i==2:yy,xx=1,0
        if i==3:yy,xx=0,-1
        
        if y+yy<0 or h<=y+yy or x+xx<0 or w<=x+xx:
            continue
        if s[y+yy][x+xx]=='#':
            continue
        
        rcl(y+yy,x+xx,now)
    #5*5
    for i in range(-2,3):
        for j in range(-2,3):
            if i==0 and j==0:
                continue
            if y+i<0 or h<=y+i or x+j<0 or w<=x+j:
                continue
            if s[y+i][x+j]=='.':
                nxt.append([y+i,x+j,now+1])
                s[y+i][x+j]=now+1


idx=0
while i==len(nxt):
    i=nxt[idx]
    i+=1
    if i[0]==dh and i[1]==dw:
        print(i[2])
        exit()
    rcl(i[0],i[1],i[2])
print(-1)
Problem p02585 (python)

Fixed submission:
n,k=[int(x) for x in input().split()]
p=[int(x)-1 for x in input().split()]
c=[int(x) for x in input().split()]

ans=max(c)
if ans<0:
    print(ans)
    exit()

for i in range(n):
    #最後に自分という順番
    nxt=i
    lp=[]
    while 1:
        nxt=p[nxt]
        lp.append(nxt)
        if nxt==i:
            break
    lpc=sum(c[x] for x in lp)
    nxt=i
    lpl=len(lp)
    wks=0
    for j in range(lpl):
        nxt=p[nxt]
        wks+=c[nxt]
        ans=max(ans,(k-j-1)//lpl*max(0,lpc)+wks)
        if j==k-1:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
mi=-(10**)
n,k=[int(x) for x in input().split()]
p=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]

#ループの最大値を求める
mxs=mi
otl=mi
lpc={-1:1}
for i in range(n):
    chkr={i:1}
    wks=0
    nxt=i
    for _ in range(n):
        nxt=p[nxt]-1
        if chkr.get(nxt):
            wks+=c[nxt]
            break
        chkr[nxt]=1
        wks+=c[nxt]
        otl=max(otl,wks)
    if mxs<wks:
        mxs=wks
        lpc=chkr
dv=k//len(lpc)
rst=k%len(lpc)

mxr=0
for i in lpc.keys():
    wks=0
    nxt=i
    for _ in range(rst):
        nxt=p[nxt]-1
        wks+=c[nxt]
        mxr=max(mxr,wks)

ans=max(dv*mxs+mxr,otl)
print(ans)

Buggy submission (verdict: Runtime Error):
mi=-(10**9+1)
n,k=[int(x) for x in input().split()]
p=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]

#ループの最大値を求める
mxs=mi
otl=mi
lpc={}
for i in range(n):
    chkr={i:1}
    wks=0
    wks2=0
    nxt=i
    for _ in range(n):
        nxt=p[nxt]-1
        if chkr.get(nxt):
            wks+=c[nxt]
            break
        chkr[nxt]=1
        wks+=c[nxt]
        otl=max(otl,wks)
    if mxs<wks:
        mxs=wks
        lpc=chkr
dv=k//len(lpc)
rst=k%len(lpc)

mxr=0
for i in lpc.keys():
    wks=0
    nxt=i
    for _ in range(rst):
        nxt=p[nxt]-1
        wks+=c[nxt]
        mxr=max(mxr,wks)

ans=max(dv*mxs+mxr,otl)
print(ans)

Buggy submission (verdict: Runtime Error):
mi=-(10**9+1)
n,k=[int(x) for x in input().split()]
p=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]

#ループの最大値を求める
mxs=mi
otl=mi
lpc={}
for i in range(n):
    chkr={i:1}
    wks=0
    wks2=0
    nxt=i
    for _ in range(n):
        nxt=p[nxt]-1
        if chkr.get(nxt):
            wks+=c[nxt]
            break
        chkr[nxt]=1
        wks+=c[nxt]
        otl=max(otl,wks)
    if mxs<wks:
        mxs=wks
        lpc=chkr
dv=k//len(lpc)
rst=k%len(lpc)

mxr=0
for i in lpc.keys():
    wks=0
    nxt=i
    for _ in range(rst):
        nxt=p[nxt]-1
        wks+=c[nxt]
        mxr=max(mxr,wks)

ans=max(dv*mxs+mxr,otl)
print(ans)
Problem p02639 (python)

Fixed submission:
x=[int(x) for x in input().split()]
print(x.index(0)+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
max=a[-1]
dp=[False for _ in range(max+1)]
Problem p02642 (python)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
max=a[-1]
dp=[False for _ in range(max+1)]

for i in a:
    if dp[i]==False:
        j=1
        while 1:
            j+=1
            if i*j>max:
                break
            dp[i*j]=True
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        dp[a[i]]=True
cnt=0
for i in a:
    if dp[i]==False:
        cnt+=1

print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
max=a[-1]
dp=[False for _ in range(max+1)]

for i in a:
    if dp[i]==False:
        j=1
        while 1:
            j+=1
            if i*j>max:
                break
            dp[i*j]=True1
for i in a:
    if a.count(i)>1:
        dp[i]=True
cnt=0
for i in a:
    if dp[i]:
        cnt+=1

print(cnt)
Problem p03068 (python)

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

c = s[k-1]
a = ""
for t in list(s):
 if t == c:
  a += c
 else:
  a += "*"
print(a)

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

c = s[k]
a = ""
for t in list(s):
 if t == c:
  a += c
 else:
  a += "*"
print(a)
Problem p03130 (python)

Fixed submission:
a = [0]*5
for i in range(3):
  x,y = map(int,input().split())
  a[x] += 1
  a[y] += 1
if sorted(a) == [0,1,1,2,2]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a = [0]*5
for i in range(3):
  x,y = map(int,input().split())
  a[x] += 1
  a[y] += 1
if sorted(a) = [0,1,1,2,2]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a = [0]*4
for i in range(3):
  x,y = map(int,input().split())
  a[x] += 1
  a[y] += 1
if sorted(a) = [1,1,2,2]:
  print("YES")
else:
  print("NO")
Problem p03241 (python)

Fixed submission:
n,m = map(int, input().split())
if n*n <= m:
  k = n
  while k*k <= m:
    if m%k == 0:
      print(m//k)
      exit()
    k += 1
else:
  n = m//n

k = n
while True:
  if m%k == 0:
    print(k)
    exit()
  k -= 1

Buggy submission (verdict: Runtime Error):
n,m = map(int,input())
while n <= m:
  if m%n == 0:
    print(m%n)
    break
  n += 1

Buggy submission (verdict: Runtime Error):
n,m = map(int,input())
while n <= m:
  if m%n == 0:
    print(m%n)
  n += 1
break
Problem p03251 (python)

Fixed submission:
n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
print("No War" if max(max(a),x)<min(min(b),y) else "War")

Buggy submission (verdict: Runtime Error):
n,m,x,y = map(int,input().split())
a = max(max(list(map(int,input().split())),x)
b = min(min(list(map(int,input().split())),y)
print("No War" if a<b else "War")
Problem p03261 (python)

Fixed submission:
n = int(input())
w = []
Flag = True 
for i in range(n):
  w.append(input())
for i in range(n-1):
  if w[i][-1] != w[i+1][0]:
    Flag = False
if len(w) != len(set(w)):
  Flag = False
print("Yes" if Flag else "No")

Buggy submission (verdict: Runtime Error):
n = input()
w = []
Flag = Trure 
for i in range(n):
  w.append(input())
for i in range(n-1):
  if w[i][-1] != w[i+1][0]:
    Flag = False
if len(w) = len(set(w)):
  Flag = False
print("Yes" if Flag else "No")
Problem p03274 (python)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
if 0 in a:
  a.remove(0)
  n -= 1
  k -= 1
if k == 0:
  print(0)
  exit()
m = 300000000
for i in range(n+1-k):
  if a[i+k-1] < 0:
    x = -a[i]
  elif a[i] > 0:
    x = a[i+k-1]
  else:
    x = (a[i+k-1]-a[i]) + min(-a[i],a[i+k-1])
  m = min(m,x)
print(m)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
if 0 in a:
  a.remove(0)
  n -= 1
  k -= 1
m = 300000000
for i in range(n+1-k):
  if a[i+k-1] < 0:
    x = -a[i]
  if a[i] > 0:
    x = a[i+k-1]
  else:
    x = (a[i+k-1]-a[i]) + min(-a[i],a[i+k-1])
  m = min(m,x)
print(m)
Problem p03288 (python)

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

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

Fixed submission:
s = input()
t = input()
flag = False
for i in range(len(s)):
  if s == t:
    flag = True
    break
  s = s[1:] + s[0]
print("Yes" if flag else "No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
flag = False
for i in range(len(i)):
  if s == t:
    flag = True
    break
  s = s[1:] + s[0]
print("Yes" if flag else "No")
Problem p03353 (python)

Fixed submission:
s = input()
n = len(s)
k = int(input())
l = set()
for t in range(1,k+1):
  for i in range(max(n-t+1,0)):
    l.add(s[i:i+t])
a = list(l)
a.sort()
print(a[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
k = int(input())
l = set()
for t in range(1,k+1):
  for i in range(n):
    if i+t>=n:
      break
    l.add(s[i:i+t])
a = list(l)
a.sort()
print(a[k-1])
Problem p03379 (python)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n//2-1]
b = y[n//2]
for i in range(n):
  if x[i] <= a:
    print(b)
  else:
    print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n//2-1]
b = y[n//2+1]
for i in range(n):
  if x[i] <= a:
    print(b)
  else:
    print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
a = x[n//2-1]
b = x[n//2+1]
for i in range(n):
  if x[i] <= a:
    print(b)
  else:
    print(a)
Problem p03386 (python)

Fixed submission:
a,b,k = map(int,input().split())
if b-a<2*k:
  for x in range(a,b+1):
    print(x)
else:
  for x in range(a,a+k):
    print(x)
  for x in range(b-k+1,b+1):
    print(x)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
if b-a<2*k:
  for x in range(a,b+1):
    print(x)
else:
  for x in range(a,a+k)+range(b-k+1,b+1):
    print(x)
Problem p03402 (python)

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

p = [["."]*100 for _ in range(20)]
q = [["#"]*100 for _ in range(21)]

for t in range(b-1):
  p[t//50*2][t%50*2] = "#"
for t in range(a-1):
  q[t//50*2+1][t%50*2] = "."
  
print(41, 100)
for l in p+q:
  print("".join(l))

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

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
  
print(41, 50)
for l in p+q:
  print("".join(l))

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

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
  
print(41, 50)
for l in q:
  print("".join(l))

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

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
  
print(41, 50)
for l in p + q:
  print(" ".join(l))

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

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
for l in p:
  print(" ".join(l))
Problem p03424 (python)

Fixed submission:
n = int(input())
a = list(input())
for i in range(n):
  if a[i] == "Y":
    print("Four")
    exit()
    
print("Three")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(input())
flag = False
for i in range(n):
  if a[i] == "Y":
    flag = True

if flag == Ture:
  print("Four")
else:
  print("Three")
Problem p03435 (python)

Fixed submission:
c = []
for _ in [0]*3:
  c += [list(map(int, input().split()))]

flag = True
for i in [0,1]:
  for j in [0,1]:
    if c[i][j] + c[i+1][j+1] != c[i+1][j] + c[i][j+1]:
      flag = False
print("Yes" if flag else "No")

Buggy submission (verdict: Runtime Error):
c = []
for _ in [0]*3:
  c += [list(map(int, input().split()))]

flag = True
for i in [0,1]:
  for j in [0,1]:
    if c[i][j] + c[i+1][j+1] != c[i+1][j] + c[i][j+1]:
      flag = False
print("Yes" if Flag else "No")
Problem p03447 (python)

Fixed submission:
print( (int(input())-int(input())) % int(input()))

Buggy submission (verdict: Runtime Error):
print( (int(input())-int(input())) % input())
Problem p03456 (python)

Fixed submission:
import math
x0, x1 = input().split()
y = math.sqrt(int(x0+x1))
if y == int(y):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import math
x = int(input()+input())
y = math.sqrt(x)
if y == int(y):
  print("Yes")
else:
  print("No")
Problem p03471 (python)

Fixed submission:
n,y = map(int,input().split())
y //= 1000
flag = False

for k in range(0,n+1):
  a = n-k
  b = y-10*k-a
  if b%4 == 0 and b <= 4*a and b>=0:
    flag = True
    break
    
if flag:
  print(k,b//4,a-b//4)
else:
  print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
y /= 1000
flag = 0

a = 0
while 10*a <= y:
  b = 0
  while 5*b + 10*a <=y:
    r = y - 10*a - 5*b
    if n = a + b + r:
      print(a)
      print(b)
      print(r)
      flag = 1
      break
    b += 1
  if flag = 1:
    break
  a += 1
  
if flag = 0:
  print(-1)
  print(-1)
  print(-1)
Problem p03474 (python)

Fixed submission:
a, b = map(int,input().split())
s = list(input())
if s.pop(a) != "-":
  print("No")
  exit()
if "".join(s).isdigit():
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = input()
if s[a] == "-":
  s[a] = "0"
else:
  print("No")
  exit()
if s.isdigit():
  print("Yes")
else:
  print("No")
Problem p03476 (python)

Fixed submission:
N = 10**5
p = [0]*(N+1)
q = [0]*(N+1)

p[2] = 1
primes = [2]

for i in range(3,N+1):
  f = 1
  for t in primes:
    if t*t > i:
      break
    if i%t == 0:
      f = 0
      break
  if f == 1:
    primes.append(i)
    p[i] = 1
    if p[(i+1)//2]:
      q[i] = 1
m = 0
s = [0]*(N+1)
for i in range(1,N+1):
  m += q[i]
  s[i] = m
  
for i in range(int(input())):
  l,r = map(int,input().split())
  print(s[r]-s[l-1])

Buggy submission (verdict: Runtime Error):
p,q,r = [2],[],[]
k = 3
while k < 100000:
  flag = True
  for t in p:
    if t*t > k:
      break
    if k%t == 0:
      flag = False
  if flag:
    p.append(k)
  k += 2
for t in p[1:]:
  if (t+1)//2 in p:
    q.append(t)
q.append(100000+3)
k = 0
for i in range(99999//2):
  while q[k]<=2*i+1:
    k += 1
  r.append(k)
c = int(input())
while c>0:
  x,y = map(int,input().split())
  print(r[y//2]-r[max(x,3)//2-1])
  c -= 1

Buggy submission (verdict: Runtime Error):
k = 3
p,q,r = [2],[],[]
while k < 100000:
  flag = True
  for t in p:
    if t*t > k:
      break
    if k%t == 0:
      flag = False
  if flag:
    p.append(k)
  k += 2
for t in p[1:]:
  if (t+1)//2 in p:
    q.append(t)
q.append(100000+3)
k = 0
for i in range(99999//2):
  while q[k]<=2*i+1:
    k += 1
  r.append(k)
for _ in [0]*int(input()):
  x,y = map(int,input().split())
  print(r[y//2]-r[max(x,3)//2-1])
Problem p03478 (python)

Fixed submission:
n,a,b = map(int,input().split())
s = 0
for k in range(1,n+1):
  x = sum(list(map(int, list(str(k))))) 
  if x >= a and x <= b:
         s += k 
print(s)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
c = 0
for k in range(a,b+1):
  if sum(list(map(int, list(str(k)))):
         c += 1
print(c)
Problem p03547 (python)

Fixed submission:
x, y = input().split()
d = int(x,16)-int(y,16)
if d > 0:
  print(">")
elif d < 0:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
x = int(input(),16)-int(input(),16)
if x > 0:
  print(">")
elif x < 0:
  print("<")
else:
  print("=")
Problem p03556 (python)

Fixed submission:
import math
print(int(math.sqrt(int(input())))**2)

Buggy submission (verdict: Runtime Error):
print(int(sqrt(int(input())))^2)
Problem p03565 (python)

Fixed submission:
a = input()
t = input()
n = len(a)
m = len(t)
if n<m:
  print("UNRESTORABLE")
  exit()
for i in range(n-m+1)[::-1]:
  flag = True
  for j in range(m):
    if a[i+j] != t[j] and a[i+j] != "?":
      flag = False
  if flag:
    b = a.replace("?","a")
    print(b[:i] + t + b[i+m:])
    exit()
        
print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
a = input()
t = input()
n = len(a)
m = len(t)
if n<m:
  print(UNRESTORABLE)
  exit()
for i in range(n-m+1)[::-1]:
  flag = True
  for j in range(m):
    if a[i+j] != t[j] and a[i+j] != "?":
      flag = False
  if flag:
    b = a.replace("?","a")
    print(b[:i] + t + b[i+m:])
    exit()
        
print(UNRESTORABLE)
Problem p03567 (python)

Fixed submission:
s = input()
l = []
for i in range(len(s)-1):
  l.append(s[i:i+2])
print("Yes" if "AC" in l else "No")

Buggy submission (verdict: Runtime Error):
s = int(input())
l = []
for i in range(len(s)-1):
  l.append(s[i:i+2])
print("Yes" if "AC" in l else "No")
Problem p03587 (python)

Fixed submission:
l = list(input())
a = [int(x) for x in l]
print(sum(a))

Buggy submission (verdict: Runtime Error):
l = list(input())
a = [int(x) for x in l]
prtint(sum(a))
Problem p03605 (python)

Fixed submission:
a = list(input())
if a[0] == "9" or a[1] == "9":
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = list(input())
if a[0] == "9" or a[1] == "9":
  print(Yes)
else:
  print(No)

Buggy submission (verdict: Runtime Error):
a = list(input())
if a[0] = "9" or a[1] = "9":
  print(Yes)
else:
  print(No)

Buggy submission (verdict: Runtime Error):
a = list(input())
if a[0] = 9 or a[1] = 9:
  print(Yes)
else:
  print(No)
Problem p03607 (python)

Fixed submission:
n = int(input())
d = {}
for _ in [0]*n:
  k = int(input())
  if k in d:
    d[k] = 1-d[k]
  else:
    d[k]=1
print(sum(d.values()))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [0]*(1000000001)
for _ in [0]*n:
  k = int(input())
  a[k] = 1-a[k]
print(sum(a))
Problem p03611 (python)

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
l = []
for x in a:
  l +=[x-1,x,x+1]
c = collections.Counter(l)
print(c.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(int,input().split()))
l = []
for x in a:
  l +=[a-1,a,a+1]
c = collections.Counter(l)
print(c.most_common()[1])
Problem p03645 (python)

Fixed submission:
p=[]
q=[]
n,m = map(int,input().split())
for _ in [0]*m:
  a,b = map(int,input().split())
  if a == 1:
    p += [b]
  elif b == n:
    q += [a]
p.sort()
q.sort()
i,j = 0,0
while i<len(p) and j<len(q):
    if p[i]<q[j]:
      i += 1
    elif p[i]>q[j]:
      j += 1
    else:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
p=[]
q=[]
n,m = map(int,input().split())
for _ in [0]*m:
  a,b = map(int,input().split())
  if a == 1:
    p += [b]
  elif b == n:
    q += [a]
p.sort()
q.sort()
i,j = 0,0
while i<len(p) or j<len(q):
    if p[i]<q[j]:
      i += 1
    elif p[i]>q[j]:
      j += 1
    else:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
p=[]
q=[]
n,m = map(int,input().split())
for _ in [0]*m:
  a,b = map(int,input().split())
  if a == 1:
    p += [b]
  elif b == n:
    q += [a]
p.sort()
q.sort()
i,j = 0,0
while i<m or j<m:
    if p[i]<q[j]:
      i += 1
    elif p[i]>q[j]:
      j += 1
    else:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
p=[]
q=[]
n,m = map(int,input().split())
for _ in [0]*m:
  a,b = map(int,input().split())
  if a == 1:
    p += [b]
  elif b == n:
    q += [a]
p.sort()
q.sort()
i,j = 0,0
while i<n or j<n:
    if p[i]<q[j]:
      i += 1
    elif p[i]>q[j]:
      j += 1
    else:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
p=[]
q=[]
n,m = map(int,input().spplit())
for _ in [0]*m:
  a,b = map(int,input().spplit())
  if a == 1:
    p += [b]
  elif b == n:
    q += [a]
for x in p:
  if x in q:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")
Problem p03659 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = sum(a[1:])-a[0]
m = abs(s)
for i in range(1,n-1):
  s -= 2*a[i]
  m = min(m,abs(s))
print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
s = sum(a)
x = a[0]
m = abs(s-2*x)
for i in range(1,n-1):
  x += a[i]
  m = min(m,abs(s-2*x))
print(s)
Problem p03680 (python)

Fixed submission:
n = int(input())
a=[0]
for i in range(n):
  a.append(int(input()))
c = 1
k = a[1]
while c <= n:
  if k == 2:
    print(c)
    exit()
  k = a[k]
  c += 1
print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a=[]
for i in range(n):
  a.append(int(input()))
c = 1
k = a[1]
while k != 1:
  if k == 2:
    print(c)
  k = a[k]
  c += 1
print(-1)
Problem p03681 (python)

Fixed submission:
n,m = map(int,input().split())
if n<m:
  n,m = m,n
if n == m:
  s = 1
  for i in range(1,m+1):
    s = s*i%1000000007
  s = s*s*2%1000000007
elif n == m+1:
  s = 1
  for i in range(1,m+1):
    s = s*i%1000000007
  s = s*s*n%1000000007
else:
  s = 0
print(s)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
if n<m:
  n,m = m,n
if n == m:
  s = 1
  for in range(1,m+1):
    s = s*i%1000000007
  s = s*s*2%1000000007
elif n == m+1:
  s = 1
  for for in range(1,m+1):
    s = s*i%1000000007
  s = s*s*n%1000000007
else:
  s = 0
print(s)
Problem p03698 (python)

Fixed submission:
s = list(input())
print("yes" if len(s) == len(set(s)) else "no")

Buggy submission (verdict: Runtime Error):
s = list(input())
if("yes" if len(s) == len(set(s)) else "no")
Problem p03720 (python)

Fixed submission:
n, m = map(int, input().split())
a = []
for i in range(m):
  x, y = map(int, input().split())
  a.append(x)
  a.append(y)
for i in range(n):
  print(a.count(i+1))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = []
for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  a.append(y)
for i in range(m):
  print(a.count(i+1))
Problem p03729 (python)

Fixed submission:
a, b, c = map(list, input().split())
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a = list(input())
b = list(input())
c = list(input())

if a[len(a)] == b[0] and b[len(b)] == c[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a = list(input())
b = list(input())
c = list(input())

if a[len(a)] = b[0] and b[len(b)] = c[0]:
  print("YES")
else:
  print("NO")