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

Fixed submission:
n,*x=map(int,open(0).read().split());a=0;t=1;x.sort()
while x:a+=t*x.pop();t*=-1
print(a)

Buggy submission (verdict: Runtime Error):
n,*t=map(int,open(0).read().split())
print(sum([i*(-1)**i for i in t])
Problem p03435 (python)

Fixed submission:
d,e,f=[int(i) for i in input().split()]
x,y,z=[int(i) for i in input().split()]
s,t,u=[int(i) for i in input().split()]
b=x-d
c=s-d
if b+e==y and b+f==z and c+e==t and c+f==u:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
import numpy.linalg as LA
a=[int(i) for i in input().split()]
a=[a,[int(i) for i in input().split()]]
a.append([int(i) for i in input().split()])
a = np.array(a)
if LA.det(a)==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
import numpy.linalg as LA
a=[int(i) for i input().split()]
a=[a,[int(i) for i input().split()]]
a.appedn([int(i) for i input().split()])
a = np.array(a)
if LA.det(a)==0:
  print('Yes')
else:
  print('No')
Problem p03437 (python)

Fixed submission:
x,y=map(int,input().split())
print(x if x%y!=0 else -1)

Buggy submission (verdict: Runtime Error):
print(x if x%y==0 else -1)
Problem p03450 (python)

Fixed submission:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n,m=LI()
c=[]
x=[inf]*n
ans=True
g=[[] for _ in range(n)]
for i in range(m):
    l,r,d=LI_()
    d+=1
    g[l].append((r,d))
    g[r].append((l,-d))
    c.append((l,r,d))

v=[inf]*n
vs=[-1]*n

def bfs(st):
    if v[st]!=inf:
        return True
    q=[st]
    v[st]=0
    vs[st]=0
    while q:
        
        c=q.pop()
        for nb,d in g[c]:
            if vs[nb]==0:
                continue
            else:
                q.append(nb)
                vs[nb]=0
                if v[nb]==inf:
                    v[nb]=v[c]+d
                elif v[nb]!=v[c]+d:
                    show(c+1,nb+1,v)
                    return False
    return True

for i in range(n):
    if bfs(i):
        continue
    else:
        print('No')
        exit()

for i in range(m):
    l,r,d=c[i]
    if v[l]+d!=v[r]:
        print('No')
        exit()
        
print('Yes')

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
x=int(input())
cnt=0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k==x:
        cnt+=1
print(cnt)
Problem p03469 (python)

Fixed submission:
print(input().replace('017','018'))

Buggy submission (verdict: Runtime Error):
print(input().replace('017','018')
Problem p03477 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
if a+b==c+d:
  print('Balanced')
elif a+b>c+d:
  print('Left')
else:
  print('Right')

Buggy submission (verdict: Runtime Error):
a
Problem p03478 (python)

Fixed submission:
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  k=str(i)
  keta=0
  for j in range(len(k)):
    keta+=int(k[j])
  if keta>=a and keta<=b:
    ans+=i
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  k=str(i)
  keta=0
  for j in range(len(k)):
    keta+=k[j]
  if k>=a and k<=b:
    ans+=i
print(ans)
Problem p03485 (python)

Fixed submission:
a,b=map(int,input().split())
if (a+b )%2==1:
  print(int((a+b+1)/2))
else:
  print(int((a+b)/2))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if (a+b )%2==1:
  print(int((a+b+1)/2)
else:
  print(int((a+b)/2)

Buggy submission (verdict: Runtime Error):
a
Problem p03487 (python)

Fixed submission:
n=input()
dc=dict()
for j in input().split():
    i=int(j)
    if i in dc:
        dc[i]+=1
    else:
        dc[i]=1
ans=0
for i in dc:
    if dc[i]>i:
        ans+=dc[i]-i
    elif dc[i]<i:
        ans+=dc[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
dc=dict()
for j in input().split():
    i=int(j)
    if i in dc:
        dc[i]+=1
    else:
        dc[i]=1
ans=0
for i in dc:
    if dc[i]>i:
        ans+=dc[i]-i,0
    elif dc[i]<i:
        ans+=dc[i]
print(ans)
Problem p03488 (python)

Fixed submission:
s=input()
s+='T'
x,y=map(int,input().split())
n=len(s)
f=0
d=0
xx=[]
yy=[]
for i in range(n):
    if s[i]=='F':
        f+=1
    else: #=='T'
        if f==0:
            0
        else:
            if d==0:
                xx.append(f)
                f=0
            else:
                yy.append(f)
                f=0
        d=1-d
#print(xx,yy)
def judg(a,b):
    if len(a)==0 and b==0:
        return True
    else:
        dp=set()
        pdp=set()
        for i in a:
            pdp=dp
            if len(pdp)==0:
                pdp.add(i)
                pdp.add(-i)
            else:
                dp=set()
                for j in pdp:
                    dp.add(j-i)
                    dp.add(j+i)
                    #print(dp)
        if b in dp:
            return True
        else:
            return False
    
if s[0]!='T' and len(xx)>0:
    t=xx[0]
    xx.remove(xx[0])
else:
    t=0



if judg(xx,x-t) and judg(yy,y):
    ans='Yes'
else:
    ans='No'
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
s+='T'
x,y=map(int,input().split())
n=len(s)
f=0
d=0
xx=[]
yy=[]
for i in range(n):
    if s[i]=='F':
        f+=1
    else: #=='T'
        if f==0:
            0
        else:
            if d==0:
                xx.append(f)
                f=0
            else:
                yy.append(f)
                f=0
        d=1-d

if len(x)>0:
    x[0]=t
    x.remove(x[0])
    xx.append(abs(x-t))
else:
    xx.append(abs(x))
yy.append(abs(y))

#rint(xx,yy)
def judg(a):
    tot=sum(a)
    if tot%2==1:
        return False
    else:
        dp=[0]*(tot+1)
        for i in a:
            dp[i]=1
            for j in range(tot+1):
                if dp[j]==1 and j+i<=tot:
                    dp[j+i]=1
        if dp[int(tot/2)]==1:
            return True
        else:
            return False
if judg(xx) and judg(yy):
    ans='Yes'
else:
    ans='No'
print(ans)
Problem p03502 (python)

Fixed submission:
x=int(input())
s=str(x)
keta=0
for i in s:
  keta+=int(i)
if x%keta==0:
  ans='Yes'
else:
  ans='No'
print(ans)

Buggy submission (verdict: Runtime Error):
import time

n=int(input())
x=(n%15)*0.001*100
a=0.037
#time.sleep(x+a)
ls=[for i in range((n%100)*10**6)]
print('Yes')
Problem p03543 (python)

Fixed submission:
n=int(input())
print('Yes' if (n//10)%111==0 or (n%1000)%111==0 else 'No')

Buggy submission (verdict: Runtime Error):
n=int(input())
print(‘Yes’ if (n//10)%111==0 or (n%1000)%111==0 else ‘No’)
Problem p03546 (python)

Fixed submission:
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
graph=[]
h,w=map(int,input().split())
for i in range(10):
    graph.append(list(map(int,input().split())))
graph = csr_matrix(graph)

d, p = floyd_warshall(csgraph=graph, directed=True, return_predecessors=True)
#print(d)
dic={-1:0}
for i in range(10):
    dic[i]=d[i][1]
ans=0
for i in range(h):
    for j in map(int,input().split()):
        ans+=dic[j]
print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
graph=[]
h,w=map(int,input().split())
for i in range(10):
    graph.append(list(map(int,input().split())))
graph = csr_matrix(graph)

d, p = floyd_warshall(csgraph=graph, directed=True, return_predecessors=True)
#print(d)
dic={-1:0}
for i in range(10):
    dic[i]=d[i][1]
ans=0
for i in range(h):
    for j in map(int,input().split()):
        ans+=dic[j]
print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
graph=[]
h,w=map(int,input().split())
for i in range(10):
    graph.append(list(map(int,input().split())))
graph = csr_matrix(graph)

d, p = floyd_warshall(csgraph=graph, directed=True, return_predecessors=True)
#print(d)
dic={-1:0}
for i in range(10):
    dic[i]=d[i][1]
ans=0
for i in range(h):
    for j in map(int,input().split()):
        ans+=dic[j]
print(int(ans))
Problem p03550 (python)

Fixed submission:
n,z,w=map(int,input().split())
a=[int(i) for i in input().split()]
if n>=2:
    print(max(abs(a[-1]-w),abs(a[-1]-a[-2]) ))
else:
    print(abs(a[-1]-w))

Buggy submission (verdict: Runtime Error):
n,z,w=map(int,input().split())
a=[int(i) for i in input().split()]
if n>=2:
    print(max(abs(a[-1]-w),abs(a[-1]-a[-2]) ))
else:
    print(max(abs(a[-1]-w)))

Buggy submission (verdict: Runtime Error):
n,z,w=map(int,input().split())
a=[int(i) for i in input().split()]
print(max(abs(a[-1]-w),abs(a[-1]-a[-2]) ))

Buggy submission (verdict: Runtime Error):
n,z,w=map(int,input())
a=[int(i) for i in input().split()]
print(max(abs(a[-1]-w),abs(a[-1]-a[-2])))
Problem p03565 (python)

Fixed submission:
# coding: utf-8
# Your code here!

s=input()
t=input()
b=[]

if len(s)-len(t)<0:
    flg=False
else:
    for i in range(len(s)-len(t)+1):
        ans=s
        for j in range(len(t)):
            flg=True
            if s[i+j]=='?' or s[i+j]==t[j]:
                #print(ans)
                ans=ans[:i+j]+t[j]+('' if i+j+1>len(s) else ans[i+j+1:])
            else:
                flg=False
                break
        if flg==True:
            b.append(ans.replace('?','a'))
#print(b)
b.sort()

print(b[0] if len(b)>0 else 'UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

s=input()
t=input()
if len(s)-len(t)<0:
    flg=False
else:
    for i in range(len(s)-len(t)):
        ans=s
        for j in range(len(t)):
            flg=True
            if t[-1-j]==s[-1-j-i] or s[-1-j-i]=='?':
                #print(ans)
                ans=ans[:-1-j-i]+t[-1-j]+('' if -1-i-j+1==0 else ans[-1-i-j+1:])
            else:
                flg=False
                break
        if flg==True:
            break
ans=ans.replace('?','a')
print(ans if flg else 'UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

s=input()
t=input()

for i in range(len(s)-len(t)):
    ans=s
    for j in range(len(t)):
        flg=True
        if t[-1-j]==s[-1-j-i] or s[-1-j-i]=='?':
            #print(ans)
            ans=ans[:-1-j-i]+t[-1-j]+('' if -1-i-j+1==0 else ans[-1-i-j+1:])
        else:
            flg=False
            break
    if flg==True:
        break
ans=ans.replace('?','a')
print(ans if flg else 'UNRESTORABLE')
Problem p03567 (python)

Fixed submission:
print(' YNeos'['AC'in input()::2])

Buggy submission (verdict: Runtime Error):
print('YNeos'[['AC' not in input()]::2])
Problem p03577 (python)

Fixed submission:
print(input()[:-8])

Buggy submission (verdict: Runtime Error):
print(input().replace('FESTIVAL','')
Problem p03597 (python)

Fixed submission:
print(eval(input()+'**2-'+input()))

Buggy submission (verdict: Runtime Error):
print(eval(open(0).read().replace(' ','**2-')))
Problem p03614 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]

ans=0
t=0
while t<n:
    if a[t]==t+1:
        if t+1<n and a[t+1]==t+2:
            ans+=1
            t+=2
        else:
            ans+=1
            t+=2
    else:
        t+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
r=0
t=0
while t<n:
    if a[t]==t+1:
            r+=1
      t+=1+r
print(r)
Problem p03635 (python)

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

Buggy submission (verdict: Runtime Error):
c
Problem p03637 (python)

Fixed submission:
a1,a2,a4=0,0,0

for i in range(1):
    # Start Input code ---------------------------------------
    n=int(input())
    y=map(int,input().split())
    for x in y:
        
        if x%4==0:
            a4+=1
        elif x%2==0:
            a2=1
        else:
            a1+=1
ans='Yes' if a1+a2<=a4+1 else 'No'
print(ans)

Buggy submission (verdict: Runtime Error):
a1,a2,a4=0,0,0

for i in range(1):
    # Start Input code ---------------------------------------
    n=int(input())
    for i in range(n):
        x=int(input())
        if x%4==0:
            a4+=1
        elif x%2==0:
            a2=1
        else:
            a1+=1
ans='Yes' if a1+a2<=a4+1 else 'No'
print(ans)
Problem p03645 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import sys
def input():
    return sys.stdin.readline()
n,m=map(int,input().split())
a=[0]*(m+1)
b=[0]*(m+1)
c=[0]*(n+1)
f1=[]
f2=[]
for i in range(m):
    a[i],b[i]=map(int,input().split())
    if a[i]==1:
        c[b[i]]=1

ans='IMPOSSIBLE'
for i in range(m):
    if b[i]==n:
        if c[a[i]]==1:
            ans='POSSIBLE'
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import sys
def input():
    return sys.stdin.readline()
n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
c=[0]*(n+1)
f1=[]
f2=[]
for i in range(m):
    a[i],b[i]=map(int,input().split())
    if a[i]==1:
        c[b[i]]=1

ans='IMPOSSIBLE'
for i in range(m):
    if b[i]==n:
        if c[a[i]]==1:
            ans='POSSIBLE'
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import sys
def input():
    return sys.stdin.readline()
n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
f1=[]
f2=[]
for i in range(m):
    a[i],b[i]=map(int,input().split())
    if a[i]==1:
        f1.append(b[i])
    if b[i]==n:
        f2.append(i)
        

ans='IMPOSSIBLE'
for i in f2:
    if a[i] in f1:
        ans='POSSIBLE'
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
f1=[]
f2=[]
for i in range(m):
    a[i],b[i]=map(int,input().split())
    if a[i]==1:
        f1.append(b[i])
    if b[i]==n:
        f2.append(i)
        

ans='IMPOSSIBLE'
for i in f2:
    if a[i] in f1:
        ans='POSSIBLE'
print(ans)

Buggy submission (verdict: Runtime Error):

n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
pos=[]
for i in range(m):
    a[i],b[i]=map(int,input().split())
    if a[i]==1:
        pos.append(b[i])

ans='IMPOSSIBLE'
for i in range(m):
    if b[i]==n:
        if a[i] in pos:
            ans='POSSIBLE'
print(ans)
Problem p03672 (python)

Fixed submission:
s=input()
n=len(s)
print(max([n-i for i in range(2,n,2)if s[:(n-i)//2]==s[(n-i)//2:-i]]))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
print(max([n-i for i in range(0,n//2,2) if  s[:(n-i)//2]==s[(n-i)//2:-i]]))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
print(max([n-i for i in range(0,n//2,2) if  s[:(n-i)//2]==s[(n-i)//2:-i]]))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
prnt(max([n-i for i in range(0,n//2,2) if  s[:(n-i)//2]==s[(n-i)//2:-i]]))
Problem p03681 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
mo=10**9+7
def fact(x):
  if x==0:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit
mo=10**9+7
def fact(x):
  if x==0:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)

Buggy submission (verdict: Runtime Error):
mo=10**9+7
def fact(x):
  if x==0:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)

Buggy submission (verdict: Runtime Error):
mo=10**9+7
def fact(x):
  if x==1:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)

Buggy submission (verdict: Runtime Error):
mo=10**9+7
def fact(x):
  if x==1:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((fact(m)*fact(n)*2)%mo)
else:
  print(fact(m)*fact(n)%mo)

Buggy submission (verdict: Runtime Error):
mo=10**9+7
def fact(x):
  if x==1:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((fact(m)*fact(n)*2)%mo)
else:
  print(fact(m)*fact(n))
Problem p03693 (python)

Fixed submission:
a,b,c=map(int,input().split())
print('YNEOS'[(b*10+c)%4!=0::2])

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print('YNEOS'[(b*10+c%)4!=0::2])
Problem p03697 (python)

Fixed submission:
a,b=map(int,input().split())
if a+b>=10:
  ans='error'
else:
  ans=a+b
print(ans)

Buggy submission (verdict: Runtime Error):
g
Problem p03699 (python)

Fixed submission:
n=int(input())
a=[]
b=[]
for i in range(n):
  x=int(input())
  if x%10==0:
    b.append(x)
  else:
    a.append(x)
a.sort()
ans=sum(a)+sum(b)
if ans%10==0:
  if len(a)>0:
    ans-=a[0]
  else:
    ans=0
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
b=[]
for i in range(n):
  x=int(input())
  c.append(x)
  if x%10==0:
    b.append(x)
  else:
    a.append(x)
a.sort()
ans=sum(a)+sum(b)
if ans%10==0:
  if len(a)>0:
    ans-=a[0]
  else:
    ans=0

    
dp=[0]
for i in range(n):
  for v in dp:
    dp.append(v+c[i])
#dp.sort()[::-1]
ans=0
for i in dp:
  if dp[i]%10!=0:
    ans=max(dp[i],ans) 
print(ans)
Problem p03700 (python)

Fixed submission:
# coding: utf-8
# Your code here!
n,a,b=map(int,input().split())
h=[]
for i in range(n):
    x=int(input())
    h.append(x)

def check(t):
    c=0
    for i in range(n):
        c+=1+(max(0,h[i]-b*t)-1)//(a-b)
    return t>=c

l=0
r=3+max(h)//b
while r-l>1:
    mid=(r-l)//2+l
    if check(mid):
        r=mid
    else:
        l=mid
ans=l
if check(r):
    ans=r
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n,a,b=map(int,input().split())
h=[]
for i in range(n):
    x=int(input())
    h.append(x)

def check(t):
    c=0
    for i in range(n):
        c+=1+(max(0,h[i]-b*t)-1)//(a-b)
    return t>=c

l=1
r=1+max(h)//b
while r-l>1:
    mid=(r-l)//2+l
    if check(mid):
        r=mid
    else:
        l=mid
ans=l
if check(r):
    #ans=r
print(ans)
Problem p03719 (python)

Fixed submission:
a,b,c=map(int,input().split());print('NYoe s'[a<=c<=b::2])

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split());print('
NYoe s'[a<=c<=b::2])
Problem p03731 (python)

Fixed submission:
n,T=map(int,input().split())
t=[int(i) for i in input().split()]
ans=0
pre=t[0]
for i in range(1,n):
    c=t[i]
    if c-pre>T:
        ans+=T
    else:
        ans+=c-pre
    pre=c
print(ans+T)

Buggy submission (verdict: Runtime Error):
_,T,*a=map(int,open(0).read().split())
print(sum([min(i-j,t) for i,j in zip(a,[0]+a)]))

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
a=[int(i) for i in input().split()]
p=a[0]
c=0
for i a:
  c+=t-i if p+t>i else t
print(c)
Problem p03746 (python)

Fixed submission:
from collections import deque
n,m=map(int,input().split())
g=[[] for i in range(1+n)]
v=[0]*(1+n)
for i in range(m):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)
    if i==0:
        q=[a,b]
        v[a]=v[b]=1

p=[q[-1]]
path=[]
while p:
    cur=p.pop()
    path.append(cur)
    v[cur]=1
    flg=True
    for i in g[cur]:
        if v[i]==0:
            p.append(i)
            flg=False
    if flg:
        break
ans=path

p=[q[0]]
path=[]
while p:
    cur=p.pop()
    path.append(cur)
    v[cur]=1
    flg=True
    for i in g[cur]:
        if v[i]==0:
            p.append(i)
            flg=False
    if flg:
        break
ans=path[::-1]+ans
print(len(ans))
print(*ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
g=[[] for i in range(1+n)]
v=[0]*(1+n)
for i in range(m):
    if i==1:
        q=[a,b]
        v[a]=v[b]=1
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)

p=[q[-1]]
path=[]
while p:
    cur=p.pop()
    path.append(cur)
    v[cur]=1
    flg=True
    for i in g[cur]:
        if v[i]==0:
            p.append(i)
            flg=False
    if flg:
        break
ans=path

p=[q[0]]
path=[]
while p:
    cur=p.pop()
    path.append(cur)
    v[cur]=1
    flg=True
    for i in g[cur]:
        if v[i]==0:
            p.append(i)
            flg=False
    if flg:
        break
ans=path[::-1]+ans
print(len(ans))
print(*ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
g=[[] for i in range(1+n)]
v=[0]*(1+n)
for i in range(m):
    if i==1:
        q=[a,b]
        v[a]=v[b]=1
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)

p=deque(q[-1:])
path=[]
while p:
    cur=p.pop()
    path.append(cur)
    v[cur]=1
    flg=True
    for i in g[cur]:
        if v[i]==0:
            p.append(i)
            flg=False
    if flg:
        break
ans=path

p=deque(q[0:1])
path=[]
while p:
    cur=p.pop()
    path.append(cur)
    v[cur]=1
    flg=True
    for i in g[cur]:
        if v[i]==0:
            p.append(i)
            flg=False
    if flg:
        break
ans=path[::-1]+ans
print(len(ans))
print(*ans)
Problem p03762 (python)

Fixed submission:
mo=10**9+7
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
X,Y=0,0
for i in range(n):
    X+=x[i]*(n-2*i-1)
    X%=mo
for i in range(m):
    Y+=y[i]*(m-2*i-1)
    Y%=mo
print(X*Y%mo)

Buggy submission (verdict: Runtime Error):
mo=10**9+7
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
X,Y=0,0
for i in range(n):
    X+=x[i]*(n-2*i-1)
    X%=mo
for i in range(n):
    Y+=y[i]*(n-2*i-1)
    Y%=mo
print(X*Y%mo)
Problem p03779 (python)

Fixed submission:
x=int(input())
for i in range(int(2*x**0.5)+100):
  if i*(i+1)//2>=x:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
x=int(input())
for i in range(x**0.5+100):
  if i*(i+1)//2>=x:
    print(i)
    break
Problem p03807 (python)

Fixed submission:
n=int(input())
a=sum([int(i) for i in input().split()])

print('YES' if a%2==0 else 'NO')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=sum([int(i) for i in input().split()]

print('YES' if a%2==0 else 'NO')