Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
total = 0
index = 0
for i in range(N):
    total += num_list_s[i]
    if total > X:
        break
    else:
        index += 1
if sum(num_list) < x:
    print(index-1)
else:
    print(index)

Fixed submission:
N,X = map(int,input().split(' '))
num_list = list(map(int,input().split(' ')))
num_list_s = sorted(num_list)
total = 0
index = 0
for i in range(N):
    total += num_list_s[i]
    if total > X:
        break
    else:
        index += 1
if sum(num_list) < X:
    print(index-1)
else:
    print(index)
Buggy python submission (verdict: Runtime Error):
N = input()
Dig = len(N)
if Dig == 1:
    print(N)
else:
    for i in range(Dig):
        if N[i] != 9:
            num = i
            break
        else:
            continue
    list_num = list(N)
    target = int(list_num[num]) -1
    ans = 9*(num -1) + target + 9*(DIg)
    print(ans)

Fixed submission:
N = input()
Dig = len(N)
num = None
if Dig == 1:
    print(N)
else:
    for i in range(Dig-1):
        if N[i+1] != str(9):
            num = i
            break
        else:
            continue
    list_num = list(N)
    if not num == None:
        target = int(list_num[num]) -1
        array = list(map(int,N))
        ans = sum(array[:num]) + target + 9*(Dig-num-1)
        print(ans)
    else:
        array = list(map(int,N))
        print(sum(array))
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input())
num_list = [A,B,C]
list_s = sorted(num_list)
if A % 2 == 1 and B % 2 == 1 and C % 2 == 1:
    print(list_s[0]*list_s[1])
else:
    print(0)

Fixed submission:
A,B,C = map(int,input().split(' '))
num_list = [A,B,C]
list_s = sorted(num_list)
if A % 2 == 1 and B % 2 == 1 and C % 2 == 1:
    print(list_s[0]*list_s[1])
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input())
num_list = [A,B,C]
 list_s = sorted(num_list)
if A % 2 == 1 and B % 2 == 1 and C % 2 == 1:
    print(list_s[0]*list_s[1])
else:
    print(0)

    

Fixed submission:
A,B,C = map(int,input().split(' '))
num_list = [A,B,C]
list_s = sorted(num_list)
if A % 2 == 1 and B % 2 == 1 and C % 2 == 1:
    print(list_s[0]*list_s[1])
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
input();l=input().split();x=1
for j in sorted(l):
  x:=x*int(j)if x>1e18or x<0else-1
print(x)

Fixed submission:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)

Buggy python submission (verdict: Runtime Error):
input();l=input().split();x=not'0'in l
for j in l:
  x=x*int(j)if x>1e18or x<0
print(x)

Fixed submission:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)

Buggy python submission (verdict: Runtime Error):
input();l=input().split();x=1
for j in sorted(l):x*=int(j)
  if x>1e18:x=-1;break
print(x)

Fixed submission:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)

Buggy python submission (verdict: Runtime Error):
input();l=input().split();x=not'0'in l
for j in l:
  x*=int(j);if x>1e18:x=-1;break
print(x)

Fixed submission:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
input();l=input().split();x=1
for j in sorted(l):x*=int(j);
if x>1e18:x=-1
print(x)

Fixed submission:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
i=input;i();l=i().split();x=1-('0'in l)
for j in l:x*=int(j);
if x>1e18:x=-1
print(x)

Fixed submission:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)

Buggy python submission (verdict: Runtime Error):
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j);if x>1e18:x=-1;break
print(x)


Fixed submission:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)

Buggy python submission (verdict: Runtime Error):
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=j-48
  if x>1e18:
    print(-1);quit()
print(x)


Fixed submission:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
n, m = map(int, input().split())
# nC2+mC2を求めればよい
print(comb(n, 2, exact=True) + comb(m, 2, exact=True))


Fixed submission:
from scipy.misc import comb
n, m = map(int, input().split())
# nC2+mC2を求めればよい
print(comb(n, 2, exact=True) + comb(m, 2, exact=True))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
c=max(a)
check=False
for i in range(n):
    if a[i]==c&&check==False:
        b=a[:i]+a[i+1:]
        d=max(b)
        print(d)
    elif a[i]==c&&check==True:
        print(d)
    else:
        print(c)

Fixed submission:
r=int(input())
print(3*r**2)
Buggy python submission (verdict: Runtime Error):
l,n=map(int,input().split())
x_lst=[int(input())for i in range(n)]
ans=0
a=0
while len(x_lst):
    if x_lst[0]>l-x_lst[-1]:
        a=x_lst.pop(0)
        ans+=a
        x_lst=list(map(lambda x:x-a,x_lst))
    else:
        a=x_lst.pop(-1)
        ans+=l-a
        x_lst=list(map(lambda x:[x+l-a,x-a][x>=a],x_lst))
print(ans)


Fixed submission:
def abg(a,b,c):
    if c>a+b:
        return a+2*b+1
    else:
        return b+c
a,b,c=map(int,input().split())
print(abg(a,b,c))
Buggy python submission (verdict: Runtime Error):
x=input();print(["NO","YES"][x in ["3","5","7"])

Fixed submission:
x=int(input())
if x==5 or x==7 or x==3:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
x=input();a=999
while i<len(x)-2:a=min(abs(int(x[i:i+3])-753),a);i+=1
print(a)

Fixed submission:
x=input()
ans=abs(int(x[0:3])-753)
for i in range(len(x)-2):
    if abs(int(x[i:i+3])-753)<ans:
        ans=abs(int(x[i:i+3])-753)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lst=list(list(map(int,input().split())) for i in range(m))
l=sorted(lst,key =lambda x:x[1])
l=sorted(l,key =lambda x:x[0])
i=0
b=lst[0][0]
for e in l:
    if b==e[0]:
        i+=1
    else:
        i=1
    e.append("%06d"%e[0]+"%06d"%i)
    b=e[0]
for a in lst:
    for b in l:
        if a[1]==b[1]:
            print(b[2])
            continue
            continue

Fixed submission:
n,m=map(int,input().split())
l=list(list(map(int,input().split())) for i in range(m))
for i in range(m):
    l[i].append(i)
l.sort(key =lambda x:x[1])
l.sort(key =lambda x:x[0])
i=0
b=l[0][0]
for e in l:
    if b==e[0]:
        i+=1
    else:
        i=1
    e.append("%06d"%e[0]+"%06d"%i)
    b=e[0]
l.sort(key=lambda x:x[2])
for e in l:
    print(e[3])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=input()
t=input()
#l=n*m//
import fractions

def agc(n,m,s,t):
    if s[0]!=t[0]:
        return -1
    g=fractions.gcd(n,m)
    l=n*m//g
    if s[int(l//m)]!=t[int(l//n)]:
        return -1
    return  int(l)
print(agc(n,m,s,t))


Fixed submission:
n,m=map(int,input().split())
s=input()
t=input()
#l=n*m//
import fractions

def agc(n,m,s,t):
    if s[0]!=t[0]:
        return -1
    g=fractions.gcd(n,m)
    if g==1:
        return  n*m
    l=n*m//g
    i=1
    while l*i<m*n:
        if s[int(l*i//m)]!=t[int(l*i//n)]:
            return -1
        i+=1
    return  int(l)
print(agc(n,m,s,t))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=input()
t=input()
#l=n*m*k
import math


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def agc(n,m,s,t):
    if s[0]!=t[0]:
        return -1
    g=math.gcd(n,m)
    if g==1:
        return  n*m
    l=n*m/g

    if s[int(l//m)]!=t[int(l//n)]:
        return -1
    return  int(l)
print(agc(n,m,s,t))


Fixed submission:
n,m=map(int,input().split())
s=input()
t=input()
#l=n*m//
import fractions

def agc(n,m,s,t):
    if s[0]!=t[0]:
        return -1
    g=fractions.gcd(n,m)
    if g==1:
        return  n*m
    l=n*m//g
    i=1
    while l*i<m*n:
        if s[int(l*i//m)]!=t[int(l*i//n)]:
            return -1
        i+=1
    return  int(l)
print(agc(n,m,s,t))
Buggy python submission (verdict: Runtime Error):
def main(n:int,lst:list)->int:
    b = True
    lst1 = []
    lst2 = []
    for e in lst:
        if b:
            lst1.append(e)
        else:
            lst2.append(e)
        b = not b
    lst1.sort()
    lst2.sort()
    c1 = [["",0],0]
    c2 = [["",0],0]
    last =lst1[0]
    a = 0
    for e in lst1:
        if last == e:
            a +=1
        else:
            if a >= c1[0][1]:
                c1[1] = c1[0][1]
                c1[0][0] = e
                c1[0][1] = a
            elif a > c1[1]:
                c1[1] = a
            last = e
            a = 1
    if a >= c1[0][1]:
        c1[1] = c1[0][1]
        c1[0][0] = e
        c1[0][1] = a
    elif a > c1[1]:
        c1[1] = a

    last =lst2[0]
    a = 0
    for e in lst2:
        if last == e:
            a +=1
        else:
            if a >= c2[0][1]:
                c2[1] = c2[0][1]
                c2[0][0] = e
                c2[0][1] = a
            elif a > c2[1]:
                c2[1] = a
            last = e
            a = 1
    if a >= c2[0][1]:
        c2[1] = c2[0][1]
        c2[0][0] = e
        c2[0][1] = a
    elif a > c2[1]:
        c2[1] = a

    if c1[0][0] == c2[0][0]:
        if c1[0][1] > c2[0][1] or(c1[0][1] == c2[0][1] and c2[1] > c1[1]):
            return n - c1[0][1] - c2[1]
        else:
            return n - c2[0][1] - c1[1]
    else:
        return n - c1[0][1] - c2[0][1]

n = int(input())
lst = input().split()
print(main(n,lst))


Fixed submission:
print(input().replace("1","a").replace("9","1").replace("a","9"))

Buggy python submission (verdict: Runtime Error):
import collections
def main(n:int,lst:list)->int:
    b = True
    lst1 = []
    lst2 = []
    for e in lst:
        if b:
            lst1.append(e)
        else:
            lst2.append(e)
        b = not b
    c1 = collections.Counter(lst1).most_common()
    c2 = collections.Counter(lst2).most_common()
    if c1[0][0] == c2[0][0]:
        if c1[0][1] > c2[0][1]:
            if len(c2) == 1:
                return n - c1[0][1]
            else:
                return n - c1[0][1] - c2[1][1]
        else:
            if len(c1) == 1:
                return n - c2[0][1]
            else:
                return n - c2[0][1] - c1[1][1]
    else:
        return n - c1[0][1] - c2[0][1]

n = int(input())
lst = list(map(int,input().split()))
print(main(n,lst))


Fixed submission:
print(input().replace("1","a").replace("9","1").replace("a","9"))
Buggy python submission (verdict: Time Limit Exceeded):
def main(s,t):
    n = len(s)
    for i in range(n):
        if t[i]!=s[i]:
            rep =s[i]
            s=s.replace(rep,"A")
            s=s.replace(t[i],rep)
            s=s.replace("A",t[i])
    if s == t:
        print("Yes")
    else:
        print("No")
s=input()
t=input()
main(s,t)


Fixed submission:
def main(s,t):
    n = len(s)
    for i in range(n):
        if t[i]!=s[i]:
            rep =s[i]
            s=s.replace(rep,"A")
            s=s.replace(t[i],rep)
            s=s.replace("A",t[i])
            if t[:i] !=s [:i]:
                return "No"
    if s == t:
        return "Yes"
    else:
        return "No"
s=input()
t=input()
print(main(s,t))
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
lst=list(input() for i in range(h))
n_h=h
for i in range(len(lst)):
    if "#" not in lst[h-i-1]:
        n_h-=1
        lst.pop(h-i-1)
lst=list(map(list,lst))
for i in range(w):
    T=True
    for b in range(n_h):
        if lst[b][w-i-1]=="#":
            T=False
            break
    if T:
        for b in range(h):
            lst[b].pop(w-i-1)
for a in lst:
    print("".join(a))

Fixed submission:
N,i=map(int,input().split())
print(N-i+1)
Buggy python submission (verdict: Runtime Error):
print(len(list(filter(lambda x:x<=int(input()),[105, 135, 165, 189, 195]))))

Fixed submission:
n=int(input())
ansList=[105, 135, 165, 189, 195]
m=len(list(filter(lambda x:x<=n,ansList)))
print(m)
Buggy python submission (verdict: Runtime Error):
n= int(input())
if 4*(2n//7) -n>=0:
    print("Yes")
else:
    print("No")

Fixed submission:
n= int(input())
if 4*(2*n//7) -n>=0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
input()
lst=list(map(int,input().split())).sort()
print(lst[-1]-lst[0])

Fixed submission:
input()
lst=list(map(int,input().split()))
lst.sort()
print(lst[-1]-lst[0])
Buggy python submission (verdict: Runtime Error):
print("AB"+["C","D"][len(input()<4)])


Fixed submission:
print("AB"+["D","C"][len(input())<4])
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
lst=list(map(int,input().split()))
lst.sort()
a=lst[-A:]
print(sum(a)/A)
b=lst.count(a[0])
c=lst.count(a[0])
print(b!/(c!*(b-c)!))

Fixed submission:
import math
N,A,B=map(int,input().split())
lst=list(map(int,input().split()))
lst.sort()
a=lst[-A:]
print(sum(a)/A)
b=lst.count(a[0])
c=a.count(a[0])
if c!=A:
    print(int(math.factorial(b)/(math.factorial(c)*math.factorial(b-c))))
else:
    l=[]
    i=min([b-c,B-A])
    for k in range(0,i+1):
        l.append(math.factorial(b)/(math.factorial(c+k)*math.factorial(b-c-k)))
    print(int(sum(l)))
Buggy python submission (verdict: Runtime Error):
str = input()
arr = input.split(' ')
A = int(arr[0])
B = int(arr[1])

print(A * B)

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B)
print(A * B)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for i in range(m)]

good=[i for i in range(1,n+1)]

for i in ab:
  a,b=h[i[0]-1],h[i[1]-1]
  if a<b:
    try:
      good.remove(i[0])
    except ValueError:
      pass
  elif a>b:
    try:
      good.remove(i[1])
    except ValueError:
      pass
  else:
    try:
      good.remove(i[0])
    except ValueError:
      pass
    try:
      good.remove(i[1])
    except ValueError:
      pass
print(len(good))

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for i in range(m)]

bad=[]
for i in ab:
  a,b=h[i[0]-1],h[i[1]-1]
  if a<b:
    bad+=[i[0]]
  elif a>b:
    bad+=[i[1]]
  else:
    bad+=[i[0],i[1]]
print(n-len(set(bad)))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
ans=0

for i in range(n+1):
  ans=max(ans,(a*i)//b-a*(i//b))
  if a*(i//b)!=0:
    break
print(ans)

Fixed submission:
a,b,n=map(int,input().split())
if b-1<=n:
  ans=(a*(b-1))//b-a*((b-1)//b)
else:
  ans=(a*n)//b-a*(n//b)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
  print(collections.Counter(a)[i])

Fixed submission:
import collections
n=int(input())
c=collections.Counter(list(map(int,input().split())))
for i in range(1,n+1):
  print(c[i])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
  print(a.count(i))

Fixed submission:
import collections
n=int(input())
c=collections.Counter(list(map(int,input().split())))
for i in range(1,n+1):
  print(c[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
  for j in range(i+1,n+1):
    d_o=j-i
    if i<=x and i<=y and j<=x and j<=y:
      d_d=10**9
    elif i>=x and i>=y and j>=x and j>=y:
      d_d=10**9
    elif i<=x and i<=y and j>=x and j>=y:
      d_d=x-i+1+j-y
    elif i<=x and i<=y and x<=j<=y:
      d_d=x-i+1+(y-j)
    elif x<=i<=y and j>=x and j>=y:
      d_d=i-x+1+j-y
    elif x<=i<=y and x<=j<=y:
      d_d=i-x+1+y-j
    else:
      print("###")
    tmp=min(d_o,d_d)
    ans[tmp-1]+=1

for i in ans:
  print(i)

Fixed submission:
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
  for j in range(i+1,n+1):
    d_o=j-i
    if i<=x and i<=y and j<=x and j<=y:
      d_d=10**4
    elif i>=x and i>=y and j>=x and j>=y:
      d_d=10**4
    elif i<=x and i<=y and j>=x and j>=y:
      d_d=x-i+1+j-y
    elif i<=x and i<=y and x<=j<=y:
      d_d=x-i+1+(y-j)
    elif x<=i<=y and j>=x and j>=y:
      d_d=i-x+1+j-y
    elif x<=i<=y and x<=j<=y:
      d_d=i-x+1+y-j
    else:
      print("###")
    tmp=min(d_o,d_d)
    ans[tmp-1]+=1

for i in ans:
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
flg=1
for i in range(q):
  inp=input()
  if inp=='1':
    flg*=-1
  else:
    inp=inp.split()
    f,c=inp[1],inp[2]
    if f=='1'and flg==1:
      s=c+s
    elif f=='2' and flg==-1:
      s=c+s
    else:
      s+=c
if flg==-1:
  s = ''.join(list(reversed(s)))
print(s)

Fixed submission:
s=input()
q=int(input())
flg=1
mae,ushiro='',''
for i in range(q):
  inp=input()
  if inp=='1':
    flg*=-1
  else:
    f,c=inp[2],inp[4]
    if f=='1'and flg==1:
      mae+=c
    elif f=='2' and flg==-1:
      mae+=c
    else:
      ushiro+=c

s=mae[::-1]+s+ushiro
if flg==-1:
  s=s[::-1]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
tmp=10**20
for i in range(1,n):
  tmp=min(tmp,abs(sum(a[:i])-sum(a[i:])))
print(tmp)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
total=sum(a)
ideal=sum(a)/2
tmp=10**20
goukei=0
for i in range(n):
  goukei+=a[i]
  if tmp>abs(ideal-goukei):
    tmp=min(tmp,abs(ideal-goukei))
  else:
    break
print(int(tmp*2))
Buggy python submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
s=[list(map(int,input().replace("#",'1').replace(".",'0'))) for i in range(h)]
a=s
tmp=1

for i in range(h):
  if sum(s[i])>0:
    for j in range(w):
      if s[i][j] == 1 and sum(s[i][j+1:])>0:
        a[i][j]=tmp
        tmp+=1
      elif j==w-1:
        a[i][j]=tmp
        tmp+=1
      else:
        a[i][j]=tmp

flg=0
for i in range(h):
  if flg>0 and sum(s[i])==0:
    s[i]=s[i-1]
  else:
    flg=i
for i in reversed(range(h)):
  if sum(s[i])==0:
    s[i]=s[i+1]
for i in range(h):
  print(' '.join(list(map(str,a[i]))))

Fixed submission:
h,w,k=map(int,input().split())
s=[list(map(int,input().replace("#",'1').replace(".",'0'))) for i in range(h)]
a=s
tmp=1
for i in range(h):
  if sum(s[i])>0:
    for j in range(w):
      if s[i][j] == 1 and sum(s[i][j+1:])>0:
        a[i][j]=tmp
        tmp+=1
      elif j==w-1:
        a[i][j]=tmp
        tmp+=1
      else:
        a[i][j]=tmp

flg=0
for i in range(h):
  if flg>0 and sum(s[i])==0:
    s[i]=s[i-1]
  else:
    flg=1
for i in reversed(range(h)):
  if sum(s[i])==0:
    s[i]=s[i+1]
for i in range(h):
  print(' '.join(list(map(str,a[i]))))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
i=0
while i+1 < len(s):
  if s[i]==s[i+1]:
    s=s[:i]+s[i+1:]
  else:
    i+=1
print(len(s))

Fixed submission:
n = int(input())
s = list(input())
cnt=1
for i in range(n-1):
  if s[i] != s[i+1]:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
h,w,a,b=map(int,input().split())
arr=np.array([[0]*w]*h)
while 1<3:
  flg=0
  for i in range(h):
    for j in range(w):
      sum1=np.sum(arr, axis=1)[i]
      sum2=np.sum(arr, axis=0)[j]
      if sum1 not in [a,w-a] and sum2 not in [b,h-b]:
        arr[i,j]=1
        flg=1
  for i in range(h):
    for j in range(w):
      sum1=np.sum(arr, axis=1)[i]
      sum2=np.sum(arr, axis=0)[j]
      if sum1 not in [a,w-a] or sum2 not in [b,h-b]:
        arr[i,j]=1
        flg=1
  if flg==0:
    break

for i in range(h):
  s=''
  for j in range(w):
    s+=str(arr[i,j])
  print(s)

Fixed submission:
h,w,a,b=map(int,input().split())
for i in range(b):
  s=''
  for j in range(a):
    s+='1'
  for j in range(w-a):
    s+='0'
  print(s)
for i in range(h-b):
  s=''
  for j in range(a):
    s+='0'
  for j in range(w-a):
    s+='1'
  print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[''.join(sorted(input())) for i in range(n)]
a=list(set(s))
cnt=0
for i in a:
  j=s.count(i)
  cnt+=j*(j-1)//2
print(cnt)

Fixed submission:
n=int(input())
s=sorted([''.join(sorted(input())) for i in range(n)])

c=[]
i=0
while i<n-1:
  cnt=0
  while i<n-1 and s[i]==s[i+1]:
    cnt+=1
    i+=1
  c+=[cnt+1]
  i+=1
ans=0
for i in c:
  if i>1:
    ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=sorted([''.join(sorted(input())) for i in range(n)])
a=list(set(s))
cnt=0
for i in a:
  j=s.count(i)
  cnt+=j*(j-1)//2
print(cnt)

Fixed submission:
n=int(input())
s=sorted([''.join(sorted(input())) for i in range(n)])

c=[]
i=0
while i<n-1:
  cnt=0
  while i<n-1 and s[i]==s[i+1]:
    cnt+=1
    i+=1
  c+=[cnt+1]
  i+=1
ans=0
for i in c:
  if i>1:
    ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=sorted([''.join(sorted(input())) for i in range(n)])
a=list(set(s))
cnt=0
for i in a:
  j=s.count(i)
  cnt+=j*(j-1)//2
print(cnt)

Fixed submission:
n=int(input())
s=sorted([''.join(sorted(input())) for i in range(n)])

c=[]
i=0
while i<n-1:
  cnt=0
  while i<n-1 and s[i]==s[i+1]:
    cnt+=1
    i+=1
  c+=[cnt+1]
  i+=1
ans=0
for i in c:
  if i>1:
    ans+=i*(i-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
  print(max(a[:i]+a[i+1:]))

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_max = max(a)
a_max_cnt = a.count(a_max)
a_max_i = a.index(a_max)

if a_max_cnt == 1:
  for i in range(n):
    if i==a_max_i:
      print(sorted(set(a))[-2])
    else:
      print(a_max)
else:
  for i in range(n):
    print(a_max)