Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())

def lcm(a,b):
	return a*b//math.gcd(a,b)

def lcm3(a,b,c):
	return lcm(lcm(a,b),c)

def lcm4(a,b,c,d):
	return lcm(lcm(a,b),lcm(c,d))

a=[0]*(n*n)
x=set([1])
s=2
for i in range(0,n*n):
	if (i//n+i%n)%2==0:
		a[i]=s
		x.add(s)
		s+=1
#print(a)
for i in range(0,n*n):
	if a[i]==0:
		j=i//n
		k=i%n
		if j==0 and k==n-1:
			m=lcm(a[i-1],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif j==n-1 and k==0:
			m=lcm(a[i+1],a[i-n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif j==0:
			m=lcm3(a[i-1],a[i+1],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif j==n-1:
			m=lcm3(a[i-1],a[i+1],a[i-n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif k==0:
			m=lcm3(a[i+1],a[i-n],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif k==n-1:
			m=lcm3(a[i-1],a[i-n],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		else:
			m=lcm4(a[i+1],a[i-1],a[i-n],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)

for i in range(n):
	print(' '.join(map(str,a[i*n:i*n+n])))


Fixed submission:
z=int(input())
n=500

def gcd(a,b):
	while b:
		a,b=b,a%b
	return a

def lcm(a,b):
	return a*b//gcd(a,b)

def lcm3(a,b,c):
	return lcm(lcm(a,b),c)

def lcm4(a,b,c,d):
	return lcm(lcm(a,b),lcm(c,d))

a=[0]*(n*n)
x=set([1])
for i in range(n*n//4)[::-1]:
	j=i//((n*n)//16)
	if j==0:
		y1=0
		y2=0
	elif j==1:
		y1=1
		y2=1
	elif j==2:
		y1=0
		y2=1
	else:
		y1=1
		y2=0
	k=i%((n*n)//16)
	m=i+2
	a[n*(4*(k//(n//4))+2*y1)+4*(k%(n//4))+2*y2]=m
	x.add(m)
	while m in x:
		m+=i+2
	a[n*(4*(k//(n//4))+2*y1+1)+4*(k%(n//4))+2*y2+1]=m
	x.add(m)
#print(a)
for i in range(0,n*n):
	if a[i]==0:
		j=i//n
		k=i%n
		if j==0 and k==n-1:
			m=lcm(a[i-1],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif j==n-1 and k==0:
			m=lcm(a[i+1],a[i-n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif j==0:
			m=lcm3(a[i-1],a[i+1],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif j==n-1:
			m=lcm3(a[i-1],a[i+1],a[i-n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif k==0:
			m=lcm3(a[i+1],a[i-n],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		elif k==n-1:
			m=lcm3(a[i-1],a[i-n],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)
		else:
			m=lcm4(a[i+1],a[i-1],a[i-n],a[i+n])
			l=m+1
			while l in x:
				l+=m
			a[i]=l
			x.add(l)

#print(max(x))

for i in range(z):
	print(' '.join(map(str,a[i*n:i*n+z])))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
#import math
#from collections import deque

n=int(input())
s=list(input())

t=s[:n][::-1]
u=s[n:]
dic=dict()
for i in itertools.product(range(2),repeat=n):
	t_=[[] for _ in range(2)]
	u_=[[] for _ in range(2)]
	for j in range(n):
		t_[i[j]].append(t[j])
		u_[i[j]].append(u[j])
	t0=tuple(t_[0])
	t1=tuple(t_[1])
	u0=tuple(u_[0])
	u1=tuple(u_[1])
	if (t0,t1) not in dic:
		dic[(t0,t1)]=[1,0]
	else:
		dic[(t0,t1)][0]+=1
	if (u0,u1) not in dic:
		dic[(u0,u1)]=[0,1]
	else:
		dic[(u0,u1)][1]+=1

ans=0
for i in dic.keys():
	ans+=dic[i][0]*dic[i][1]
print(ans)



Fixed submission:
import itertools
#import math
#from collections import deque

n=int(input())
s=input()

t=s[:n][::-1]
u=s[n:]
dic=dict()
for i in itertools.product(range(2),repeat=n):
	t_=[""]*2
	u_=[""]*2
	for j in range(n):
		t_[i[j]]+=t[j]
		u_[i[j]]+=u[j]
	if (t_[0],t_[1]) not in dic:
		dic[(t_[0],t_[1])]=[1,0]
	else:
		dic[(t_[0],t_[1])][0]+=1
	if (u_[0],u_[1]) not in dic:
		dic[(u_[0],u_[1])]=[0,1]
	else:
		dic[(u_[0],u_[1])][1]+=1

ans=0
for i in dic.keys():
	ans+=dic[i][0]*dic[i][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
#import math
#from collections import deque

n=int(input())
s=list(input())

dic=dict()
for i in itertools.product(range(2),repeat=n):
	t=s[:n][::-1]
	u=s[n:]
	t_=[[] for _ in range(2)]
	u_=[[] for _ in range(2)]
	for j in range(n):
		k=t.pop()
		l=u.pop()
		t_[i[j]].append(k)
		u_[i[j]].append(l)
	t0=tuple(t_[0])
	t1=tuple(t_[1])
	u0=tuple(u_[0])
	u1=tuple(u_[1])
	if (t0,t1) not in dic:
		dic[(t0,t1)]=[1,0]
	else:
		dic[(t0,t1)][0]+=1
	if (u0,u1) not in dic:
		dic[(u0,u1)]=[0,1]
	else:
		dic[(u0,u1)][1]+=1

ans=0
for i in dic.keys():
	ans+=dic[i][0]*dic[i][1]
print(ans)



Fixed submission:
import itertools
#import math
#from collections import deque

n=int(input())
s=input()

t=s[:n][::-1]
u=s[n:]
dic=dict()
for i in itertools.product(range(2),repeat=n):
	t_=[""]*2
	u_=[""]*2
	for j in range(n):
		t_[i[j]]+=t[j]
		u_[i[j]]+=u[j]
	if (t_[0],t_[1]) not in dic:
		dic[(t_[0],t_[1])]=[1,0]
	else:
		dic[(t_[0],t_[1])][0]+=1
	if (u_[0],u_[1]) not in dic:
		dic[(u_[0],u_[1])]=[0,1]
	else:
		dic[(u_[0],u_[1])][1]+=1

ans=0
for i in dic.keys():
	ans+=dic[i][0]*dic[i][1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]

s=sum(a)
ans=s
b=a[0]
for i in range(n-3):
	b=0
	for l in range(i+2):
		b+=a[l]
	c=s-b
	j=0
	k=0
	while k-b/2<0:
		k+=a[j]
		j+=1
	if k-b/2>b/2+a[j-1]-k:
		k-=a[j-1]
	x=min(k,b-k)
	y=max(k,b-k)
	j=-1
	k=0
	while k-c/2<0:
		k+=a[j]
		j-=1
	if k-c/2>c/2+a[j+1]-k:
		k-=a[j+1]
	z=min(k,c-k)
	w=max(k,c-k)
	t=max(y,w)-min(x,z)
	if ans>t:
		ans=t
print(ans)

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

s=[a[0]]
for i in range(n-1):
	s.append(s[i]+a[i+1])
ans=s[n-1]
j=0
k=2
for i in range(1,n-2):
	while abs(s[i]-2*s[j]) > abs(s[i]-2*s[j+1]):
		j=j+1
	while abs(s[n-1]-2*s[k]+s[i]) > abs(s[n-1]-2*s[k+1]+s[i]):
		k=k+1
	t=max(s[j],s[i]-s[j],s[k]-s[i],s[n-1]-s[k])-min(s[j],s[i]-s[j],s[k]-s[i],s[n-1]-s[k])
	if ans>t:
		ans=t
print(ans)
Buggy python submission (verdict: Runtime Error):
    S=input()
     
    j=0
    for i in range(4):
     if S[i]=="+":
      j=j+1
     else:
      j=j-1
    print(j)

Fixed submission:
S=input()
         
j=0
for i in range(4):
	if S[i]=="+":
		j=j+1
	else:
		j=j-1
print(j)

Buggy python submission (verdict: Runtime Error):
S=input()

j=0
for i in range(4):
 if S[i]=="+":
  j=j+1
 else
  j=j-1
print(j)

Fixed submission:
S=input()
         
j=0
for i in range(4):
	if S[i]=="+":
		j=j+1
	else:
		j=j-1
print(j)
Buggy python submission (verdict: Time Limit Exceeded):
n,c=map(int,input().split())
d=[]
for _ in range(c):
	d.append([int(i) for i in input().split()])
e=[]
for _ in range(n):
	e.append([int(i) for i in input().split()])

i0=[]
i1=[]
i2=[]
for k in range(c):
	re=[0,0,0]
	for i in range(n):
		for j in range(n):
			re[(i+j)%3]+=d[e[i][j]-1][k]
	i0.append([k,re[0]])
	i1.append([k,re[1]])
	i2.append([k,re[2]])

i0.sort(key=lambda x:x[1])
i1.sort(key=lambda x:x[1])
i2.sort(key=lambda x:x[1])

ans=float('inf')
for i in range(3):
	for j in range(3):
		if i0[i][0]!=i1[j][0]:
			for k in range(3):
				if i0[i][0]!=i2[k][0] and i1[j][0]!=i2[k][0]:
					l=i0[i][1]+i1[j][1]+i2[k][1]
					if ans>l:
						ans=l
print(ans)


Fixed submission:
import numpy as np

n,c=map(int,input().split())
d=[]
for _ in range(c):
	d.append([int(i) for i in input().split()])
e=[]
for _ in range(n):
	e.append([int(i) for i in input().split()])
dd=np.matrix(d)

re=np.matrix([[0]*c for _ in range(3)])
for i in range(n):
	for j in range(n):
		re[(i+j)%3,e[i][j]-1]+=1

mul=np.dot(re,dd)
ind=np.argsort(mul)

ans=float('inf')
for i in range(3):
	for j in range(3):
		if ind[0,i]!=ind[1,j]:
			for k in range(3):
				if ind[0,i]!=ind[2,k] and ind[1,j]!=ind[2,k]:
					l=mul[0,ind[0,i]]+mul[1,ind[1,j]]+mul[2,ind[2,k]]
					if ans>l:
						ans=l
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()

j=n
for i in range(n):
	k=s[:i].count("W")+s[(i+1):].count("E")
	if j>k:
		j=k
print(j)


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

j=s[1:].count("E")
t=[j]
for i in range(n-1):
	t.append(t[i]+s[i].count("W")-s[i+1].count("E"))
	if j>t[i+1]:
		j=t[i+1]
print(j)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
a=[[int(i) for i in s.split()]]
b=[[int(i) for i in s.split()]]

ans=n
for i in range(n-1):
	a1=[]
	b1=[]
	for j in range(n-i-1):
		a1.append(a[i][j]^a[0][i+j+1])
		b1.append(b[i][j]+b[0][i+j+1])
		if a1[j]==b1[j]:
			ans+=1
	a.append(a1)
	b.append(b1)
print(ans)


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

ans=0
b=0
j=0
for i in range(n):
	while j<n and b^a[j]==b+a[j]:
		b^=a[j]
		j=j+1
	ans += j-i
	b^=a[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
k=int(input())

se=set()
for i in range(len(s)):
	for j in range(i,len(s)):
		se.add(s[i:j+1])
print(sorted(list(se))[k-1])


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

se=set()
for i in range(len(s)):
	for j in range(i,i+5):
		se.add(s[i:j+1])
print(sorted(list(se))[k-1])
Buggy python submission (verdict: Runtime Error):
a=input()
d=input()

if a[2]==d[0] and a[1]==d[1] and a[0]==d[2]:
    print("YES")
else:
    NO

Fixed submission:

a=input()
d=input()

if a[2]==d[0] and a[1]==d[1] and a[0]==d[2]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
flag=True
for i in range(n):
    w.append(input())
    
for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:
        #print(i,"out1")
        flag=False

for i in range(n-1):
    for j in range(i+1,n):
        if(w[i]==w[j]):
            #print(i,j,"out2")
            flag=False

if flag==True:
    print("Yes")
else:
    print("No")




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]:
        #print(i,"out1")
        flag=False

for i in range(n-1):
    for j in range(i+1,n):
        if(w[i]==w[j]):
            #print(i,j,"out2")
            flag=False

if flag==True:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
n,s=map(int,input().split())
x=list(map(int,input().split()))
#print(x)

for i in range(n):
    x[i]=abs(x[i]-s)

gcd=reduce(math.gcd,x)

print(gcd)

Fixed submission:
import fractions
from functools import reduce
n,s=map(int,input().split())
x=list(map(int,input().split()))
#print(x)

for i in range(n):
    x[i]=abs(x[i]-s)

print(reduce(fractions.gcd,x))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
n,s=map(int,input().split())
x=list(map(int,input().split()))
#print(x)

for i in range(n):
    x[i]=abs(x[i]-s)

gcd=reduce(math.gcd,x)

print(gcd)

Fixed submission:
import fractions
from functools import reduce
n,s=map(int,input().split())
x=list(map(int,input().split()))
#print(x)

for i in range(n):
    x[i]=abs(x[i]-s)

print(reduce(fractions.gcd,x))

Buggy python submission (verdict: Runtime Error):
import math

n,s=map(int,input().split())
x=list(map(int,input().split()))
ans=0
#print(x)

for i in range(n-1):
    ans=math.gcd(abs(x[i]-s),abs(x[i+1]-s))

print(ans)

Fixed submission:
import fractions
from functools import reduce
n,s=map(int,input().split())
x=list(map(int,input().split()))
#print(x)

for i in range(n):
    x[i]=abs(x[i]-s)

print(reduce(fractions.gcd,x))
Buggy python submission (verdict: Runtime Error):
import numpy as np
h,w=map(int,input().split())
icon=list()
for i in range(h):
    icon.append(list(input().split()))

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if icon[i][j]=='#':
            row[i]=True
            col[j]=True

for  i in range(h):
    if row[i]==True:
        for j in range(w):
            if col[j]==True:
                print(icon[i][j],end='')
        print()  

Fixed submission:
n,i=map(int,input().split())
print(n+1-i)
Buggy python submission (verdict: Runtime Error):
import numpy as np
h,w=map(int,input().split())
"""
入力はスペースなしだった
文字列としてリストの行にぶち込む必要あり
icon=list()
for i in range(h):
    icon.append(list(input().split()))

"""
icon=[''] * h
for i in range(h):
    a[i]=input()


row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if icon[i][j]=='#':
            row[i]=True
            col[j]=True

for  i in range(h):
    if row[i]==True:
        for j in range(w):
            if col[j]==True:
                print(icon[i][j],end='')
        print()  


Fixed submission:
import numpy as np
h,w=map(int,input().split())
"""
入力はスペースなしだった
文字列としてリストの行にぶち込む必要あり
icon=list()
for i in range(h):
    icon.append(list(input().split()))

"""
icon=[''] * h
for i in range(h):
    icon[i]=input()


row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if icon[i][j]=='#':
            row[i]=True
            col[j]=True

for  i in range(h):
    if row[i]==True:
        for j in range(w):
            if col[j]==True:
                print(icon[i][j],end='')
        print()

Buggy python submission (verdict: Runtime Error):
import numpy as np
h,w=map(int,input().split())
icon=list()
for i in range(h):
    icon.append(list(input().split()))

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if icon[i][j]=='#':
            row[i]=True
            col[j]=True

for  i in range(h):
    if row[i]==True:
        for j in range(w):
            if col[j]==True:
                print(icon[i][j],end='')
        print()  

Fixed submission:
import numpy as np
h,w=map(int,input().split())
"""
入力はスペースなしだった
文字列としてリストの行にぶち込む必要あり
icon=list()
for i in range(h):
    icon.append(list(input().split()))

"""
icon=[''] * h
for i in range(h):
    icon[i]=input()


row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if icon[i][j]=='#':
            row[i]=True
            col[j]=True

for  i in range(h):
    if row[i]==True:
        for j in range(w):
            if col[j]==True:
                print(icon[i][j],end='')
        print()
Buggy python submission (verdict: Runtime Error):
n=int(input())
flag=False
for i in range(int(n/4)+1):
    for j in range(int(n/7)+1):
        if(i*4+j*7==n):
            flag=True

if(flag==True):
    print("Yes")
else:
    print("No")


Fixed submission:
n,k=map(int,input().split())
if(n%k==0):
    print("0")
else:
    print("1")

Buggy python submission (verdict: Runtime Error):
n=int(input())
flag=False
for i in range(int(n/4)):
    for j in range(int(n/7)):
        if(i*4+j*7==n):
            flag=True

if(flag==True):
    print("Yes")
else:
    print("No")


Fixed submission:
n,k=map(int,input().split())
if(n%k==0):
    print("0")
else:
    print("1")
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(n/4):
    for j in range(n/7):
        if(i*4+j*7==n):
            flag=True

if(flag==True):
    print("Yes")
else:
    print("No")


Fixed submission:
n=int(input())
flag=False
for i in range(int(n/4)+1):
    for j in range(int(n/7)+1):
        if(i*4+j*7==n):
            flag=True

if(flag==True):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
count=1
n-k
while(n>0):
    n-(k-1)
    count+=1
print(count)


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
count=1
n=n-k
while(n>0):
    n=n-(k-1)
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
#print(n)
#print(a)
count=0
flag=True
while(flag):
    flag=False
    for i in range(n):
        if(a[i]%2==0):
            #print(i)
            #a=list(map(lambda x:x*3,a))
            a[i]=int(a[i]/2)
            #print(a)
            count+=1
            flag=True
            break
print(count)

Fixed submission:
a,b = map(int,input().split())
#if((a<0 or a>16) or (b<0 or b>16) or (a+b>16)):
    #print("error\n")
count=16
flag=False
pic=0 # 0=a,1=b
while(count>0):
    if(pic==0):
        a-=1
        count-=1
        pic=1    
    elif(pic==1):
        pic=0
        b-=1
        count-=1
    if(a<=0 and b<=0):
        flag=True
        break
if(flag==True):
    print("Yay!")
else:
    print(":(")

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
#print(n)
#print(a)
count=0
i=0
flag=True
while(flag):
    flag=False
    for i in range(n):
        if(flag==True):
            a[i]=a[i]*3
        elif(a[i]%2==0):
            #print(i)
            a[i]=a[i]/2
            count+=1
            flag=True
        else:
            a[i]=a[i]*3
print(count)

Fixed submission:
a,b = map(int,input().split())
#if((a<0 or a>16) or (b<0 or b>16) or (a+b>16)):
    #print("error\n")
count=16
flag=False
pic=0 # 0=a,1=b
while(count>0):
    if(pic==0):
        a-=1
        count-=1
        pic=1    
    elif(pic==1):
        pic=0
        b-=1
        count-=1
    if(a<=0 and b<=0):
        flag=True
        break
if(flag==True):
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
n = int(input())
*w, = open(0).read().split()
for i in range(1,n):
  if w.count(w[i]) > 1 or w[i-1][-1] == w[i][0]:
    print('No')
    break
  else: 
    print('Yes')

Fixed submission:
n = int(input())
w=[]
for i in range(n):
    w.append(input())
a=0
for i in range(1,n):
    if w.count(w[i])==1 and w[i-1][-1]==w[i][0]:
       a += 1
    else:
        print('No')
        break
    if a==n-1:
        print('Yes')
    else:
        pass

Buggy python submission (verdict: Runtime Error):
n = int(input())
*w, = open(0).read().split()
for i in range(1,n):
  if w.count(w[i])==1 and w[i-1][-1] == w[i][0]:
    pass
  else:
    print('No')
    break
  if i == n-1:
    print('Yes)

Fixed submission:
n = int(input())
w=[]
for i in range(n):
    w.append(input())
a=0
for i in range(1,n):
    if w.count(w[i])==1 and w[i-1][-1]==w[i][0]:
       a += 1
    else:
        print('No')
        break
    if a==n-1:
        print('Yes')
    else:
        pass

Buggy python submission (verdict: Runtime Error):
n = int(input())
*w,=open(0).read().split()
for i in range(1,n):
  if w.count(w[i]) == 1 and w[i-1][-1] == w[i][0]:
    pass
  else:
    print('No')
    break
  if i == n-1:
    print('Yes')
  else:
    pass

Fixed submission:
n = int(input())
w=[]
for i in range(n):
    w.append(input())
a=0
for i in range(1,n):
    if w.count(w[i])==1 and w[i-1][-1]==w[i][0]:
       a += 1
    else:
        print('No')
        break
    if a==n-1:
        print('Yes')
    else:
        pass
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
if(N % 500 =< A):
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
A = int(input())
if(N % 500 <= A):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce
def func():
    n,x0 = map(int,input().split())
    x = [int(i) for i in input().split()]
    x.append(x0)
    x.sort()
    x.reverse()
    
    l = []
    before = 0
    before = None
    for xi in x:
        if before == None:
            before = xi
            continue
        l.append(xi-before)
        before = xi
    
    print(abs(reduce(fractions.gcd,l)))
func()

Fixed submission:
def func():
    a,b = map(int,input().split())
    if a & 1 == 1 and b & 1 == 1:
        print("Yes")
    else:
        print("No")
func()
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def func():
    n,x0 = map(int,input().split())
    x = [int(i) for i in input().split()]
    x.append(x0)
    x.sort()
    x.reverse()
    
    l = []
    before = 0
    before = None
    for xi in x:
        if before == None:
            before = xi
            continue
        l.append(xi-before)
        before = xi
    
    print(reduce(math.gcd,l))
func()

Fixed submission:
import fractions
from functools import reduce
def func():
    n,x0 = map(int,input().split())
    x = [int(i) for i in input().split()]
    x.append(x0)
    x.sort()
    x.reverse()
    
    l = []
    before = 0
    before = None
    for xi in x:
        if before == None:
            before = xi
            continue
        l.append(xi-before)
        before = xi
    
    print(abs(reduce(fractions.gcd,l)))
func()
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))


S = [0]
for i in range(1, N + 1):
    S.append(A[i - 1] + S[i-1])


ans = 0
for l in range(0, N):
    for r in range(l + 1, N + 1):
        if (S[r] - S[l]) % M == 0:
            ans += 1


print(ans)


Fixed submission:
from collections import defaultdict

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

S = [0]
m = defaultdict(lambda: 0)
for i in range(1, N + 1):
    tmp = (A[i - 1] + S[i - 1]) % M
    S.append(tmp)

ans = 0
for i in range(N + 1):
    ans += m[S[i]]
    m[S[i]] += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

dp = [[0 for _ in range(3 + 1)] for _ in range(len(S) + 1)]

dp[0][0] = 1
for i in range(1, len(S) + 1):
    if S[i - 1] == 'A':
        dp[i][0] += dp[i - 1][0]
        dp[i][1] += dp[i - 1][1]
        dp[i][2] += dp[i - 1][2]
        dp[i][3] += dp[i - 1][3]

        dp[i][1] += dp[i - 1][0]
    elif S[i - 1] == 'B':
        dp[i][0] += dp[i - 1][0]
        dp[i][1] += dp[i - 1][1]
        dp[i][2] += dp[i - 1][2]
        dp[i][3] += dp[i - 1][3]

        dp[i][2] += dp[i - 1][1]
    elif S[i - 1] == 'C':
        dp[i][0] += dp[i - 1][0]
        dp[i][1] += dp[i - 1][1]
        dp[i][2] += dp[i - 1][2]
        dp[i][3] += dp[i - 1][3]

        dp[i][3] += dp[i - 1][2]
    else:
        dp[i][0] += dp[i - 1][0] * 3
        dp[i][1] += dp[i - 1][1] * 3
        dp[i][2] += dp[i - 1][2] * 3
        dp[i][3] += dp[i - 1][3] * 3

        dp[i][1] += dp[i - 1][0]
        dp[i][2] += dp[i - 1][1]
        dp[i][3] += dp[i - 1][2]

B = 10 ** 9 + 7
print(dp[len(S)][3] % B)

Fixed submission:

S = input()

dp = [[0 for _ in range(3+ 1)] for _ in range(len(S) + 1)]
dp[0][0] = 1

B = 10 ** 9 + 7
for i in range(1, len(S) + 1):
    if S[i - 1] == 'A':
        dp[i][0] += dp[i - 1][0]
        dp[i][1] += dp[i - 1][1]
        dp[i][2] += dp[i - 1][2]
        dp[i][3] += dp[i - 1][3]

        dp[i][1] += dp[i - 1][0]
    elif S[i - 1] == 'B':
        dp[i][0] += dp[i - 1][0]
        dp[i][1] += dp[i - 1][1]
        dp[i][2] += dp[i - 1][2]
        dp[i][3] += dp[i - 1][3]

        dp[i][2] += dp[i - 1][1]
    elif S[i - 1] == 'C':
        dp[i][0] += dp[i - 1][0]
        dp[i][1] += dp[i - 1][1]
        dp[i][2] += dp[i - 1][2]
        dp[i][3] += dp[i - 1][3]

        dp[i][3] += dp[i - 1][2]
    else:
        dp[i][0] += dp[i - 1][0] * 3
        dp[i][1] += dp[i - 1][1] * 3
        dp[i][2] += dp[i - 1][2] * 3
        dp[i][3] += dp[i - 1][3] * 3

        dp[i][1] += dp[i - 1][0]
        dp[i][2] += dp[i - 1][1]
        dp[i][3] += dp[i - 1][2]

    for k in range(4):
        dp[i][k] %= B


print(dp[len(S)][3])
Buggy python submission (verdict: Runtime Error):
N = input()
S = list(input())

ans = 0
for i in range(1, N):
    left = set(S[:i])
    right = set(S[:i])

    both = left & right
    ans = max(len(both), ans)


print(ans)


Fixed submission:
N = int(input())
S = list(input())

ans = 0
for i in range(1, N):
    left = set(S[:i])
    right = set(S[i:])
    both = left & right
    ans = max(len(both), ans)


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)

d = []
for i in range(1, N+2):
    d.append(A[i] - A[i-1])

for i in range(N):
    dd = d.copy()
    a = dd[i]
    b = dd[i+1]
    dd[i] = a + b
    dd.pop(i+1)
    print(sum(map(abs, dd)))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)

d = []
s = 0
for i in range(1, N+2):
    diff = A[i] - A[i-1]
    d.append(diff)
    s += abs(diff)


for i in range(N):
    ss = s
    ss -= abs(d[i]) + abs(d[i+1]) - abs(d[i] + d[i+1])
    print(ss)