Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
n=int(input())
s=[[]for i in range(n+1)]
m=10**9+7
for i in range(n-1):
    x,y=map(int,input().split())
    s[x].append(y)
    s[y].append(x)
t=[[0,0]for i in range(n+1)]
def f(a,b):
    t[a][0]=t[a][1]=1
    for i in s[a]:
        if i!=b:
            f(i,a)
            t[a][0]*=t[i][0]+t[i][1]
            t[a][1]*=*t[i][0]
f(1,0)
print(sum(t[1])%m)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n=int(input())
s=[[]for i in range(n+1)]
m=10**9+7
for i in range(n-1):
    x,y=map(int,input().split())
    s[x].append(y)
    s[y].append(x)
t=[[0,0]for i in range(n+1)]
def f(a,b):
    t[a][0]=t[a][1]=1
    for i in s[a]:
        if i!=b:
            f(i,a)
            t[a][0]*=t[i][0]+t[i][1]
            t[a][1]*=t[i][0]
f(1,0)
print(sum(t[1])%m)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[[]for i in range(n+1)]
m=10**9+7
for i in range(n-1):
    x,y=map(int,input().split())
    s[x].append(y)
    s[y].append(x)
t=[[0,0]for i in range(n+1)]
def f(a,b):
    t[a][0]=t[a][1]=1
    for i in s[a]:
        if i!=b:
            f(i,a)
            t[a][0]=(t[a][0]*(t[i][0]+t[i][1]))%m
            t[a][1]=(t[a][1]*t[i][0])%m
f(1,0)
print(sum(t[1]))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n=int(input())
s=[[]for i in range(n+1)]
m=10**9+7
for i in range(n-1):
    x,y=map(int,input().split())
    s[x].append(y)
    s[y].append(x)
t=[[0,0]for i in range(n+1)]
def f(a,b):
    t[a][0]=t[a][1]=1
    for i in s[a]:
        if i!=b:
            f(i,a)
            t[a][0]*=t[i][0]+t[i][1]
            t[a][1]*=t[i][0]
f(1,0)
print(sum(t[1])%m)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
s=[0]*(n+1)
t=np.zeros(n+1)
h=list(map(int,input().split()))
a=list(map(int,input().split()))
for i in range(n):
    s[h[i]]=t[h[i]]+a[i]
    t[h[i]:]=np.maximum(t[h[i]:],s[h[i]])
print(int(t[-1]))

Fixed submission:
n=int(input())
def f(x):
    s=0
    while x>0:
        s=max(s,t[x])
        x-=x&-x
    return s
def g(x,y):
    while x<n+1:
        t[x]=max(y,t[x])
        x+=x&-x
t=[0]*(n+1)
h=list(map(int,input().split()))
a=list(map(int,input().split()))
for i in range(n):
    g(h[i],f(h[i]-1)+a[i])
print(max(t))
Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int,input().split())
if n==1:
    print(p)
else:
    d=int(p**(1/n))
    k=1
    for i in range(d+1,0,-1):
        if p%(i**n)==0:
            k=i
            print(k)
            break
    else:
        print(k)

Fixed submission:
n,p=map(int,input().split())
if n==1:
    print(p)
else:
    def r(n,p):
        d=int(p**(1/n))
        k=1
        for i in range(1,d+1):
            if p%(i**n)==0:
                k=i
        return k
    c=1
    while r(n,p)!=1:
        s=r(n,p)
        c*=s
        p=p/(s**n)
    print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int,input().split())
if n==1:
    print(p)
elif n>p:
    print(1)
else:
    d=int(p**(1/n))
    i=1
    k=1
    c=1
    while i<=d+2:
        if p%(i**n)==0:
            k=i
            c=i
            i+=c
        else:
            i+=c
    else:
        print(k)

Fixed submission:
n,p=map(int,input().split())
if n==1:
    print(p)
else:
    def r(n,p):
        d=int(p**(1/n))
        k=1
        for i in range(1,d+1):
            if p%(i**n)==0:
                k=i
        return k
    c=1
    while r(n,p)!=1:
        s=r(n,p)
        c*=s
        p=p/(s**n)
    print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int,input().split())
if n==1:
    print(p)
else:
    d=int(p**(1/n))
    k=1
    for i in range(1,d+2):
        if p%(i**n)==0:
            k=i
    else:
        print(k)

Fixed submission:
n,p=map(int,input().split())
if n==1:
    print(p)
else:
    def r(n,p):
        d=int(p**(1/n))
        k=1
        for i in range(1,d+1):
            if p%(i**n)==0:
                k=i
        return k
    c=1
    while r(n,p)!=1:
        s=r(n,p)
        c*=s
        p=p/(s**n)
    print(c)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
k=s.count("W")
c=0
for i in range(k):
    t=s.index("W")
    c+=t-i
    s[t]=0
print(c)

Fixed submission:
s=list(input())
c=0
p=0
for i in range(len(s)):
    if s[i]=="W":
        c+=i-p
        p+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as b
n=int(input())
a=sorted(list(map(int,input().split())))
s=n-1
c=0
while s>0:
    t=2**(len(bin(a[s]))-2)
    if t-a[s] in a:
        d=b(a,t-a[s])
        if d<s and a[d]==t-a[s]:
            a.pop(d)
            c+=1
            s-=1
    s-=1
print(c)

Fixed submission:
from collections import defaultdict as d
n=int(input())
a=sorted(list(map(int,input().split())))
b=d(int)
for i in a:
    b[i]+=1
s=n-1
c=0
while s>0:
    if b[a[s]]>0:
        t=2**(len(bin(a[s]))-2)
        b[a[s]]-=1
        if b[t-a[s]]>0:
            b[t-a[s]]-=1
            c+=1
    s-=1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as b
n=int(input())
a=sorted(list(map(int,input().split())))
s=n-1
c=0
while s>0:
    t=2**(len(bin(a[s]))-2)
    d=b(a,t-a[s])
    if d<s and a[d]==t-a[s]:
        a.pop(d)
        c+=1
        s-=2
    else:
        s-=1
print(c)

Fixed submission:
from collections import defaultdict as d
n=int(input())
a=sorted(list(map(int,input().split())))
b=d(int)
for i in a:
    b[i]+=1
s=n-1
c=0
while s>0:
    if b[a[s]]>0:
        t=2**(len(bin(a[s]))-2)
        b[a[s]]-=1
        if b[t-a[s]]>0:
            b[t-a[s]]-=1
            c+=1
    s-=1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as b
n=int(input())
a=sorted(list(map(int,input().split())))
s=n-1
c=0
while s>0:
    t=2**(len(bin(a[s]))-2)
    d=b(a,t-a[s])
    if d<s and a[d]==t-a[s]:
        a.pop(d)
        c+=1
        s-=2
    else:
        s-=1
print(c)

Fixed submission:
from collections import defaultdict as d
n=int(input())
a=sorted(list(map(int,input().split())))
b=d(int)
for i in a:
    b[i]+=1
s=n-1
c=0
while s>0:
    if b[a[s]]>0:
        t=2**(len(bin(a[s]))-2)
        b[a[s]]-=1
        if b[t-a[s]]>0:
            b[t-a[s]]-=1
            c+=1
    s-=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c=map(int,input().split())
e=0
f=[[1,1]]
k=[[1,1,1],[2,1,1,1,2],[3,2,2,1,2,2,3],[5,3,3,2,4,2,3,3,5],[8,5,5,3,6,4,6,3,5,5,8],[12,8,8,5,10,6,9,6,10,5,8,8,12],[21,13,13,8,16,10,15,9,15,10,16,8,13,13,21]]
if b==1:
    print(1)
else:
    d=k[b-2]
    for i in range(0,a):
        l=len(f)
        for j in range(0,l):
            f.append([f[j][0],f[j][1]*d[2*(f[j][0]-1)]])
            if f[j][0]-1>0 and f[j][0]-1>=c-(a-i):
                f.append([f[j][0]-1,f[j][1]*d[1+2*(f[j][0]-2)]])
            if f[j][0]+1<=b and f[j][0]+1<=c+(a-i):
                f.append([f[j][0]+1,f[j][1]*d[2*(f[j][0]-1)+1]])
            j+=1
        else:
            del f[:l]
    else:
        for i in range(0,len(f)):
            if f[i][0]==c:
                e+=f[i][1]
        print(e%(10**9+7))

Fixed submission:
a,b,c=map(int,input().split())
s=[[0]*b for i in range(a+1)]
s[0][0]=1
k=[[1,1,1],[2,1,1,1,2],[3,2,2,1,2,2,3],[5,3,3,2,4,2,3,3,5],[8,5,5,3,6,4,6,3,5,5,8],[13,8,8,5,10,6,9,6,10,5,8,8,13],[21,13,13,8,16,10,15,9,15,10,16,8,13,13,21]]
if b==1:
    print(1)
elif c-a>=2:
    print(0)    
else:
    d=k[b-2]
    for i in range(1,a+1):
        s[i][b-1]=s[i-1][b-1]*d[2*(b-1)]+s[i-1][b-2]*d[2*(b-1)-1]
        for j in range(0,b-1):
            if j==0:
                s[i][0]=s[i-1][0]*d[0]+s[i-1][1]*d[1]
            else:    
                s[i][j]=s[i-1][j-1]*d[2*j-1]+s[i-1][j]*d[2*j]+s[i-1][j+1]*d[2*j+1]
    print(s[a][c-1]%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c=map(int,input().split())
e=0
f=[[1,1]]
k=[[1,1,1],[2,1,1,1,2],[3,2,2,1,2,2,3],[5,3,3,2,4,2,3,3,5],[8,5,5,3,6,4,6,3,5,5,8],[12,8,8,5,10,6,9,6,10,5,8,8,12],[21,13,13,8,16,10,15,9,15,10,16,8,13,13,21]]
if b==1:
    print(1)
else:
    d=k[b-2]
    for i in range(0,a):
        j=0
        l=len(f)
        while j<l:
            f.append([f[j][0],f[j][1]*d[2*(f[j][0]-1)]])
            if f[j][0]-1>0:
                f.append([f[j][0]-1,f[j][1]*d[1+2*(f[j][0]-2)]])
            if f[j][0]+1<=b:
                f.append([f[j][0]+1,f[j][1]*d[2*(f[j][0]-1)+1]])
            j+=1
        else:
            del f[:l]
    else:
        for i in range(0,len(f)):
            if f[i][0]==c:
                e+=f[i][1]
        print(e%(10**9+7))        

Fixed submission:
a,b,c=map(int,input().split())
s=[[0]*b for i in range(a+1)]
s[0][0]=1
k=[[1,1,1],[2,1,1,1,2],[3,2,2,1,2,2,3],[5,3,3,2,4,2,3,3,5],[8,5,5,3,6,4,6,3,5,5,8],[13,8,8,5,10,6,9,6,10,5,8,8,13],[21,13,13,8,16,10,15,9,15,10,16,8,13,13,21]]
if b==1:
    print(1)
elif c-a>=2:
    print(0)    
else:
    d=k[b-2]
    for i in range(1,a+1):
        s[i][b-1]=s[i-1][b-1]*d[2*(b-1)]+s[i-1][b-2]*d[2*(b-1)-1]
        for j in range(0,b-1):
            if j==0:
                s[i][0]=s[i-1][0]*d[0]+s[i-1][1]*d[1]
            else:    
                s[i][j]=s[i-1][j-1]*d[2*j-1]+s[i-1][j]*d[2*j]+s[i-1][j+1]*d[2*j+1]
    print(s[a][c-1]%(10**9+7))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)
n,m=map(int,input().split())
s=input()
t=input()
w=min(m,n)
l=w//gcd(m,n)
d=lcm(m,n)
p=d//n
q=d//m
h=lcm(p,q)
for i in range(0,l-1):
    g=i*h
    if s[g//p]!=t[g//q]:
        print(-1)
        break
else:
    print(d)

Fixed submission:
from fractions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)
n,m=map(int,input().split())
s=input()
t=input()
d=lcm(n,m)
p=d//n
q=d//m
h=lcm(p,q)
l=d//h
for i in range(0,l):
    g=i*h
    if s[g//p]!=t[g//q]:
        print(-1)
        break
else:
    print(d)

Buggy python submission (verdict: Runtime Error):
from flactions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)
n,m=map(int,input().split())
s=input()
t=input()
w=min(m,n)
l=w//gcd(m,n)
d=lcm(m,n)
p=d//n
q=d//m
h=lcm(p,q)
for i in range(0,l-1):
    g=i*h
    if s[g//p]!=t[g//q]:
        print(-1)
        break
else:
    print(d)

Fixed submission:
from fractions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)
n,m=map(int,input().split())
s=input()
t=input()
d=lcm(n,m)
p=d//n
q=d//m
h=lcm(p,q)
l=d//h
for i in range(0,l):
    g=i*h
    if s[g//p]!=t[g//q]:
        print(-1)
        break
else:
    print(d)

Buggy python submission (verdict: Runtime Error):
from fraction import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)
n,m=map(int,input().split())
s=input()
t=input()
if s[0]!=t[0]:
    print(-1)
else:
    d=lcm(m,n)
    f=max(m,n)%min(m,n)
    if f!=0:
        print(d)
    else:
        g=max(m,n)//min(m,n)
        if max(m,n)==m:
            k=t
            q=s
            l=n
        else:
            k=s
            q=t
            l=m
        for i in range(0,l):
            if k[g*i]!=q[i]:
                print(-1)
                break
        else:
            print(m+n-l)

Fixed submission:
from fractions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)
n,m=map(int,input().split())
s=input()
t=input()
d=lcm(n,m)
p=d//n
q=d//m
h=lcm(p,q)
l=d//h
for i in range(0,l):
    g=i*h
    if s[g//p]!=t[g//q]:
        print(-1)
        break
else:
    print(d)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int,input().split()))
def solve():
    for i in range(m//n, 0, -1):
        if m % i == 0:
            print(i)
            break
solve()

Fixed submission:
n=int(input())
if n==1:
  print("Hello World")
else:
  t=[int(input()) for i in range(2)] 
  print(t[0]+t[1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
h=0
for x in range(0,101):
    for y in range(0,101):
        f=0
        if e[f][2]==0:
            f+=1
        else:
            k=abs(x-e[f][0])+abs(y-e[f][1])+e[f][2]
        for i in range(0,len(e)):
            if e[i][2]!=max(k-abs(x-e[i][0])-abs(y-e[i][1]),0):
                break
        else:
            print(x,y,k)

Fixed submission:
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
h=0
for a in range(n):
    if e[a][2]>0:
        s=a
        break
for x in range(0,101):
    for y in range(0,101):
            k=abs(x-e[s][0])+abs(y-e[s][1])+e[s][2]
            for i in range(0,n):
                if e[i][2]!=max(k-abs(x-e[i][0])-abs(y-e[i][1]),0):
                    break
            else:
                print(x,y,k)
Buggy python submission (verdict: Runtime Error):
from function import gcd
n,x=map(int,input().split())
s=list(map(int,input().split()))
b=s[0]
t=abs(b-x)
for i in range(1,n):
    t=gcd(t,abs(s[i]-x))   
print(t)    

Fixed submission:
from fractions import gcd 
n,x=map(int,input().split())
s=list(map(int,input().split()))
b=s[0]
t=abs(b-x)
for i in range(1,n):
    t=gcd(t,abs(s[i]-x))   
print(t)

Buggy python submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
s=list(map(int,input().split()))
b=s[0]
t=abs(b-x)
for i in range(1,n):
    t=math.gcd(t,abs(s[i]-x))   
print(t)    

Fixed submission:
from fractions import gcd 
n,x=map(int,input().split())
s=list(map(int,input().split()))
b=s[0]
t=abs(b-x)
for i in range(1,n):
    t=gcd(t,abs(s[i]-x))   
print(t)

Buggy python submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
s=list(map(int,input().split()))
b=s[0]
t=abs(s[0]-x)
for i in range(1,n):
    t=math.gcd(t,abs(s[i]-x))   
print(t)    

Fixed submission:
from fractions import gcd 
n,x=map(int,input().split())
s=list(map(int,input().split()))
b=s[0]
t=abs(b-x)
for i in range(1,n):
    t=gcd(t,abs(s[i]-x))   
print(t)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[]
if n==1:
    print(a[0])
else:
    for i in range(n-k+1):
        if a[i]<=0 and 0<=a[i+k-1]:
            s.append(min(2*a[i+k-1]-a[i],a[i+k-1]-2*a[i]))
        elif a[i+k]<=2:
            s.append(-a[i])
        else:
            s.append(a[i+k-1])
    print(min(s))

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[]
if n==1:
    print(a[0])
else:
    for i in range(n-k+1):
        if a[i]<=0 and 0<=a[i+k-1]:
            s.append(min(2*a[i+k-1]-a[i],a[i+k-1]-2*a[i]))
        elif a[i+k-1]<=0:
            s.append(-a[i])
        else:
            s.append(a[i+k-1])
    print(min(s))

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[]
if n==1:
    print(a[0])
else:
    for i in range(n-k):
        if a[i]<=0 and 0<=a[i+k-1]:
            s.append(min(2*a[i+k-1]-a[i],a[i+k-1]-2*a[i]))
        elif a[i+k]<=2:
            s.append(-a[i])
        else:
            s.append(a[i+k-1])
    print(min(s))

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=[]
if n==1:
    print(a[0])
else:
    for i in range(n-k+1):
        if a[i]<=0 and 0<=a[i+k-1]:
            s.append(min(2*a[i+k-1]-a[i],a[i+k-1]-2*a[i]))
        elif a[i+k-1]<=0:
            s.append(-a[i])
        else:
            s.append(a[i+k-1])
    print(min(s))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(a)]
def f(t,s):
    if t==0:
        return 10000007
    else:
        l=min(s//(t*100),c[t][0])
        k=100*i*l
        if n==c[t][0]:
            l+=s[t][1]
        if l<G:
            n+=f(t-1,s-l)
        return min(n,f(t-1,s))
print(f(a,b))

Fixed submission:
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(a)]
def f(t,s):
    if t==0:
        return 10**9
    l=min(s//(t*100),c[t][0])
    k=100*t*l
    if l==c[t][0]:
        k+=c[t][1]
    if k<s:
        l+=f(t-1,s-k)
    return min(l,f(t-1,s))
print(f(a,b))

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(n)]
def f(s,t):
    if t==0:
        return 10000007
    else:
        l=min(s//(i*100),c[i][0])
        k=100*i*l
        if n==c[i][0]:
            l+=s[i][1]
        if l<G:
            n+=f(s-l,i-1)
        return min(n,f(s,i-1))
print(f(b,a))

Fixed submission:
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(a)]
def f(t,s):
    if t==0:
        return 10**9
    l=min(s//(t*100),c[t][0])
    k=100*t*l
    if l==c[t][0]:
        k+=c[t][1]
    if k<s:
        l+=f(t-1,s-k)
    return min(l,f(t-1,s))
print(f(a,b))

Buggy python submission (verdict: Runtime Error):
a,b=int(input())
c=[0]+[list(map(int,input().split()))for i in range(n)]
def f(s,t):
    if t==0:
        return 10000007
    else:
        l=min(s//(i*100),c[i][0])
        k=100*i*l
        if n==c[i][0]:
            l+=s[i][1]
        if l<G:
            n+=f(s-l,i-1)
        return min(n,f(s,i-1))
print(f(b,a))

Fixed submission:
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(a)]
def f(t,s):
    if t==0:
        return 10**9
    l=min(s//(t*100),c[t][0])
    k=100*t*l
    if l==c[t][0]:
        k+=c[t][1]
    if k<s:
        l+=f(t-1,s-k)
    return min(l,f(t-1,s))
print(f(a,b))
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=a[i]-i-1
a.sort()
if n%2==1:
    p=a[n//2]
    print(abs(sum(a[:n//2])-p*(n//2))+sum(a[n//2+1:])-p*(n//2))
else:
    l=a[n//2-1]+a[n//2]
    s=math.fllor(l/2)
    t=math.ceil(l/2)
    print(min(abs(sum(a[:n//2]))-s*n//2+sum(a[n//2:])-s*(n//2),abs(sum(a[:n//2]))-t*n//2+sum(a[n//2:])-t*(n//2)))

Fixed submission:
import math
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=a[i]-i-1
a.sort()
k=a[n//2]
c=0
for i in range(n):
    c+=abs(a[i]-k)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,c=map(int,input().split())
d=[list(map(int,input().split()))for i in range(c)]
s=[i for i in range(c)]
p=list(itertools.permutations(s))
h=[list(map(int,input().split()))for i in range(n)]
a=[[]for i in range(3)]
for i in range(n):
    for j in range(n):
        a[(i+j+2)%3].append(h[i][j])
c=float("inf")
for x in range(len(p)):
    g=0
    for i in range(3):
        for j in range(len(a[i])):
            g+=d[a[i][j]-1][p[x][i]]
    c=min(c,g)
print(c)

Fixed submission:
from collections import defaultdict
n,c=map(int,input().split())
x=[list(map(int,input().split()))for i in range(c)]
e=[[0]*c for i in range(3)]
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(n):
        e[(i+j+2)%3][a[j]-1]+=1
p=float("inf")
for i in range(c):
    for j in range(c):
            if i!=j:
                for h in range(c):
                    if i!=h and j!=h:
                        p=min(p,sum([x[s][i]*d for s,d in enumerate(e[0])]+[x[s][j]*d for s,d in enumerate(e[1])]+[x[s][h]*d for s,d in enumerate(e[2])]))
print(p)
Buggy python submission (verdict: Runtime Error):
p=int(input())
a=input()
b=[]
for i in range(1,p-1):
    c=0
    t=list(set(a[:i]))
    k=a[i:]
    for j in range(len(t)):
        if t[j]in k:
            c+=1
    b.append(c)
print(max(b))

Fixed submission:
p=int(input())
a=input()
b=[]
for i in range(0,p):
    c=0
    t=list(set(a[:i]))
    k=a[i:]
    for j in range(len(t)):
        if t[j]in k:
            c+=1
    b.append(c)
print(max(b))
Buggy python submission (verdict: Runtime Error):
input();a=sorted(list(map(int,input().split())));print(a[-1],sorted(a,key=lambda x:abs(a[-1]-2*x))[0])

Fixed submission:
a,b,x=map(int,input().split())
print("YES"if a+b>=x>=a else"NO")

Buggy python submission (verdict: Runtime Error):
input();a=list(map(int,input().split()))[::-1];print(a[0],min(sorted(a,key=lambda x:abs(a[0]-2*x))))

Fixed submission:
a,b,x=map(int,input().split())
print("YES"if a+b>=x>=a else"NO")

Buggy python submission (verdict: Runtime Error):
input();a=list(map(int,input().split()))[::-1];print(a[0],sorted(a,key=lambda x:abs(a[0]-2*x))[0])

Fixed submission:
a,b,x=map(int,input().split())
print("YES"if a+b>=x>=a else"NO")
Buggy python submission (verdict: Runtime Error):
input();a=list(map(int,input().split()))[::-1];print(a[0],sorted(a,key=lambda x:abs(a[0]-2*x))

Fixed submission:
input();a=sorted(list(map(int,input().split())));print(a[-1],sorted(a,key=lambda x:abs(a[-1]-2*x))[0])
Buggy python submission (verdict: Runtime Error):
n=input()
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
if n=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    if len(n)==26:
        q=a.index(n[-1])
        c=0
        d=[n[-1]]
        for i in range(24,0,-1):
            c+=1
            d.append(n[i])
            d.sort()
            if d.index(n[i])<len(d)-1:
                print(n[:26-c-1]+d[d.index(n[i])+1])
                break
        else:
            print(a[a.index(n[i])+1])
    else:
        for i in range(len(n)):
            a.pop(a.index(n[i]))
        print(n+a[0])

Fixed submission:
n=input()
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
if n=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    if len(n)==26:
        q=a.index(n[-1])
        c=0
        d=[n[-1]]
        for i in range(24,-1,-1):
            c+=1
            d.append(n[i])
            d.sort()
            if d.index(n[i])<len(d)-1:
                print(n[:26-c-1]+d[d.index(n[i])+1])
                break
    else:
        for i in range(len(n)):
            a.pop(a.index(n[i]))
        print(n+a[0])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.append(0)
a.insert(0,0)
e=[]
for i in range(1,n+2):
    e.append(abs(a[i]-a[i-1]))
for i in range(1,n+1):
    print(sum(e)-sum(e[i-1:i+1])+abs(a[i+1]-a[i-1]))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.append(0)
a.insert(0,0)
e=0
for i in range(1,n+2):
    e+=abs(a[i]-a[i-1])
for i in range(1,n+1):
    print(e-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))
Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
s=[["#"]*(w+2)]+[["#"]+list(input())+["#"]for i in range(h)]+[["#"]*(w+2)]
p=[[1,1]]
d=0
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]==".":
            d+=1
s[1][1]="#"
k=0
while [h,w] not in p:
    k+=1
    g=[]
    for i in range(len(p)):
        x,y=p[i][0],p[i][1]
        if s[x-1][y]==".":
            s[x-1][y]="Q"
            g.append([x-1,y])
        if s[x+1][y]==".":
            s[x+1][y]="Q"
            g.append([x+1,y])
        if s[x][y+1]==".":
            s[x][y+1]="Q"
            g.append([x,y+1])
        if s[x][y-1]==".":
            s[x][y-1]="Q"
            g.append([x,y-1])
    else:
        p=g
print(d-k-1)

Fixed submission:
h,w=map(int,input().split())
s=[["#"]*(w+2)]+[["#"]+list(input())+["#"]for i in range(h)]+[["#"]*(w+2)]
p=[[1,1]]
d=0
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]==".":
            d+=1
s[1][1]="#"
k=0
while [h,w] not in p:
    k+=1
    g=[]
    for i in range(len(p)):
        x,y=p[i][0],p[i][1]
        if s[x-1][y]==".":
            s[x-1][y]="Q"
            g.append([x-1,y])
        if s[x+1][y]==".":
            s[x+1][y]="Q"
            g.append([x+1,y])
        if s[x][y+1]==".":
            s[x][y+1]="Q"
            g.append([x,y+1])
        if s[x][y-1]==".":
            s[x][y-1]="Q"
            g.append([x,y-1])
    else:
        p=g
        if len(p)==0:
            print(-1)
            break
else:
    print(d-k-1)