Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from copy import deepcopy

from bisect import bisect_left as bl

N,M=map(int,input().split())
n=N
A=list(map(int,input().split()))
dic={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dict=defaultdict(int)
list=[]
L=[]
for key in range(9,0,-1):
    if key in A:
        if dic[key] in dict.values():
            continue
        dict[key]=dic[key]
        list.append([key,dic[key]])
        L.append(key)
list.sort(key=lambda x:x[1])
cost=[]
for i in list:
    cost.append(i[1])
num=len(dict.keys())

dp=[[-1 for i in range(num+1)] for j in range(N+1)]
dp[0]=[0]*(num+1)
#dp[i] N=iでの最大値
Non=[-1]*(num+1)
for i in range(N):
    ini=[]
    for j in range(num):
        if i+1-cost[j]>=0 and dp[i+1-cost[j]]!=Non:
            a=dp[i+1-cost[j]][:]
            a[j+1]+=1
            a[0]+=1
            ini.append(a)
    if ini:
        dp[i+1]=max(ini)
s=""
s1=""
Num=N
Keys=dic.keys()
Keys.reverse()
for i in range(dp[N][0]):
    for k in Keys:
        if Num-dic[k]>=0 and dp[Num][0]-1==dp[Num-dic[k]][0]:
            s1+=str(k)
            Num-=dic[k]
            break
print(s1)


Fixed submission:
from collections import defaultdict
from copy import deepcopy

from bisect import bisect_left as bl

N,M=map(int,input().split())
n=N
A=list(map(int,input().split()))
dic={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dict=defaultdict(int)
list=[]
L=[]
for key in range(9,0,-1):
    if key in A:
        if dic[key] in dict.values():
            continue
        dict[key]=dic[key]
        list.append([key,dic[key]])
        L.append(key)
list.sort(key=lambda x:x[0],reverse=True)
cost=[]
for i in list:
    cost.append(i[1])
num=len(dict.keys())

dp=[[-1 for i in range(num+1)] for j in range(N+1)]
dp[0]=[0]*(num+1)
#dp[i] N=iでの最大値
Non=[-1]*(num+1)
for i in range(N):
    ini=[]
    for j in range(num):
        if i+1-cost[j]>=0 and dp[i+1-cost[j]]!=Non:
            a=dp[i+1-cost[j]][:]
            a[j+1]+=1
            a[0]+=1
            ini.append(a)
    if ini:
        dp[i+1]=max(ini)
s=""


for l in L:
    for i in range(num):
        key,cost=list[i]
        if l==key:
            s+=str(key)*dp[N][i+1]

print(s)
Buggy python submission (verdict: Runtime Error):
AB,BC,CA=map(int,input()split())
print(AB*BC/2)

Fixed submission:
AB,BC,CA=map(int,input().split())
print(int(AB*BC/2))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
td=[]
for i in range(N):
    t,d=map(int,input().split())
    td.append([t,d])
td.sort(key=lambda x:x[1],reverse=True)
A=td[:K]
B=[]
s2=set()
for i,j in td[K:]:
    if not(i in s2):
        s2.add(i)
        B.append([i,j])
s1=set()
n=0
C=[]
sum=0
for i,j in A:
    if not(i in s1):
        s1.add(i)
        n+=1
        sum+=j
    else:
        C.append([i,j])
        sum+=j
sum+=n**2
B.reverse()
D=[]
for i,j in B:
    if not(i in s1):
        D.append([i,j])
list=[sum]
while(C):
    if D:
        i,j=D.pop()
        list.append(list[-1]+2*n+1+(j-C[-1][1]))
        n+=1
        C.pop()
print(max(list))


Fixed submission:
N,K=map(int,input().split())
td=[]
for i in range(N):
    t,d=map(int,input().split())
    td.append([t,d])
td.sort(key=lambda x:x[1],reverse=True)
A=td[:K]
B=[]
s2=set()
for i,j in td[K:]:
    if not(i in s2):
        s2.add(i)
        B.append([i,j])
s1=set()
n=0
C=[]
sum=0
for i,j in A:
    if not(i in s1):
        s1.add(i)
        n+=1
        sum+=j
    else:
        C.append([i,j])
        sum+=j
sum+=n**2
B.reverse()
D=[]
for i,j in B:
    if not(i in s1):
        D.append([i,j])
list=[sum]

while(C):
    if D:
        i,j=D.pop()
        list.append(list[-1]+2*n+1+(j-C[-1][1]))
        n+=1
    C.pop()
print(max(list))

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
td=[]
for i in range(N):
    t,d=map(int,input().split())
    td.append([t,d])
td.sort(key=lambda x:x[1],reverse=True)
A=td[:K]
B=[]
s2=set()
for i,j in td[K:]:
    if not(i in s2):
        s2.add(i)
        B.append([i,j])
s1=set()
n=0
C=[]
sum=0
for i,j in A:
    if not(i in s1):
        s1.add(i)
        n+=1
        sum+=j
    else:
        C.append([i,j])
        sum+=j
sum+=n**2
B.reverse()
D=[]
for i,j in B:
    if not(i in s1):
        D.append([i,j])
list=[sum]
while(D):
    i,j=D.pop()
    list.append(list[-1]+2*n+1+(j-A[-1][1]))
    n+=1
    A.pop()
    if n==K:
        break
print(max(list))


Fixed submission:
N,K=map(int,input().split())
td=[]
for i in range(N):
    t,d=map(int,input().split())
    td.append([t,d])
td.sort(key=lambda x:x[1],reverse=True)
A=td[:K]
B=[]
s2=set()
for i,j in td[K:]:
    if not(i in s2):
        s2.add(i)
        B.append([i,j])
s1=set()
n=0
C=[]
sum=0
for i,j in A:
    if not(i in s1):
        s1.add(i)
        n+=1
        sum+=j
    else:
        C.append([i,j])
        sum+=j
sum+=n**2
B.reverse()
D=[]
for i,j in B:
    if not(i in s1):
        D.append([i,j])
list=[sum]

while(C):
    if D:
        i,j=D.pop()
        list.append(list[-1]+2*n+1+(j-C[-1][1]))
        n+=1
    C.pop()
print(max(list))
Buggy python submission (verdict: Runtime Error):
N=int(input())
def nCr(n,r):
    if n<r:
        return 0
    a=factorial(n)
    b=factorial(n-r)
    c=factorial(r)
    return a//(b*c)
f=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
a=0
b=0
c=0
d=0
e=0
for F in f:
    s=sum([N/(F**i) for i in range(1,7)])
    if s>=74:
        e+=1
    elif s>=24:
        d+=1
    elif s>=14:
        c+=1
    elif s>=4:
        b+=1
    elif s>=2:
        a+=1
print(nCr(b+c+d+e,2)*a+nCr(b+c+d+e,3)*3+(c+d+e)*(b+c+d+e-1)+(e+d)*(a+b+c+d+e-1)+e)


Fixed submission:
from math import factorial
from math import sqrt
from math import ceil
from itertools import permutations
from heapq import *
from collections import defaultdict
from copy import deepcopy
from math import log

N=int(input())
def nCr(n,r):
    if n<r:
        return 0
    a=factorial(n)
    b=factorial(n-r)
    c=factorial(r)
    return a//(b*c)
f=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
a=0
b=0
c=0
d=0
e=0
for F in f:
    s=sum([(N//(F**i)) for i in range(1,7)])
    if s>=74:
        e+=1
    elif s>=24:
        d+=1
    elif s>=14:
        c+=1
    elif s>=4:
        b+=1
    elif s>=2:
        a+=1

print(nCr(b+c+d+e,2)*a+nCr(b+c+d+e,3)*3+(c+d+e)*(max(b+c+d+e-1,0))+(e+d)*(max(0,a+b+c+d+e-1))+e)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N,M=map(int,input().split())
PY=[]
pY=[[] for i in range(N+1)]
for i in range(M):
    P,Y=map(int,input().split())
    PY.append([P,Y])
    pY[P].append(Y)
"""
N=2
M=3
PY=[[1,32],[2,63],[1,12]]
pY=[[],
   [32,12],
   [63]]
"""
py=[[]]
for i in range(1,len(pY)):
    pY[i].sort()
    py.append(pY[i])
for P in PY:
    for i in range(len(py[P[0]])):
        if py[P[0]][i]==P[1]:
            print(str(P[0]).zfill(6)+str(i+1).zfill(6))
            break


Fixed submission:
from bisect import bisect_right
N,M=map(int,input().split())
PY=[]
record=[[] for i in range(N+1)]
for i in range(M):
    P,Y=map(int,input().split())
    PY.append([P,Y])
    record[P].append(Y)
for i in range(1,N+1):
    record[i].sort()
for i in range(M):
    p,y=PY[i][0],PY[i][1]
    order=bisect_right(record[p],y)
    print(str(p).zfill(6)+str(order).zfill(6))

Buggy python submission (verdict: Time Limit Exceeded):
N, M=map(int,input().split())
listP=[]
listY=[]
ni=[]
for i in range(N+1):
    ni.append([])
for i in range(M):
    P,Y=map(int,input().split())
    listP.append(P)
    listY.append(Y)
    ni[P].append(Y)
for i in listP:
  ni[i].sort()
for i in range(M):
    A="%06d" % listP[i]
    k=ni[listP[i]].index(listY[i])+1
    B="%06d" % k
    print(A+B)

Fixed submission:
from bisect import bisect_right
N,M=map(int,input().split())
PY=[]
record=[[] for i in range(N+1)]
for i in range(M):
    P,Y=map(int,input().split())
    PY.append([P,Y])
    record[P].append(Y)
for i in range(1,N+1):
    record[i].sort()
for i in range(M):
    p,y=PY[i][0],PY[i][1]
    order=bisect_right(record[p],y)
    print(str(p).zfill(6)+str(order).zfill(6))
Buggy python submission (verdict: Runtime Error):
H,W,K=map(int,input().split())
if W==1:
    print(1)
    quit()

INF=1e9+7
dp=[[0]*W for i in range(H+1)]
dp[0][0]=1
d=W-1
a=max(0,d-1)
b=max(0,d-2)
dic={0:0,1:1,2:2,3:4,4:7,5:12,6:20}
a=dic[a]+1
b=dic[b]+1
def func(w):
    c=dic[w-1]+1
    e=dic[d-w-1]+1
    return c*e
def func1(w):
    c=dic[w-1-1]+1
    e=dic[d-w-1]+1
    return c*e
def func2(w):
    c=dic[w-1]+1
    e=dic[d-w-1-1]+1
    return c*e
for i in range(H):
    for w in range(W):
        if w==0:
            dp[i+1][w]=(dp[i][w]*a)+(dp[i][w+1]*b)
            dp[i+1][w]%=INF
        elif w==W-1:
            dp[i+1][w]=(dp[i][w]*a)+(dp[i][w-1]*b)
            dp[i+1][w]%=INF
        elif w==1 :
            dp[i+1][w]=(dp[i][w]*b)+(dp[i][w-1]*b)+(dp[i][w+1]*func2(w))
            dp[i+1][w]%=INF
        elif w==W-2:
            dp[i+1][w]=(dp[i][w]*b)+(dp[i][w-1]*func1(w))+(dp[i][w+1]*b)
            dp[i+1][w]%=INF
        else:
            dp[i+1][w]=(dp[i][w]*func(w))+(dp[i][w-1]*func1(w))+(dp[i][w+1]*func2(w))
            dp[i+1][w]%=INF

print(int(dp[H][K-1]%INF))


Fixed submission:
H,W,K=map(int,input().split())
if W==1:
    print(1)
    quit()

INF=1e9+7
dp=[[0]*W for i in range(H+1)]
dp[0][0]=1
d=W-1
a=max(0,d-1)
b=max(0,d-2)
f=max(0,d-3)
dic={0:0,1:1,2:2,3:4,4:7,5:12,6:20}
a=dic[a]+1
b=dic[b]+1
f=dic[f]+1
def func(w):
    c=dic[w-1]+1
    e=dic[d-w-1]+1
    return c*e
def func1(w):
    c=dic[w-1-1]+1
    e=dic[d-w-1]+1
    return c*e
def func2(w):
    c=dic[w-1]+1
    e=dic[d-w-1-1]+1
    return c*e
for i in range(H):
    for w in range(W):
        if w==0:
            dp[i+1][w]=(dp[i][w]*a)+(dp[i][w+1]*b)
            dp[i+1][w]%=INF
        elif w==W-1:
            dp[i+1][w]=(dp[i][w]*a)+(dp[i][w-1]*b)
            dp[i+1][w]%=INF
        elif w==1 :
            dp[i+1][w]=(dp[i][w]*b)+(dp[i][w-1]*b)+(dp[i][w+1]*f)
            dp[i+1][w]%=INF
        elif w==W-2:
            dp[i+1][w]=(dp[i][w]*b)+(dp[i][w-1]*f)+(dp[i][w+1]*b)
            dp[i+1][w]%=INF
        else:
            dp[i+1][w]=(dp[i][w]*func(w))+(dp[i][w-1]*func1(w))+(dp[i][w+1]*func2(w))
            dp[i+1][w]%=INF

print(int(dp[H][K-1]%INF))
Buggy python submission (verdict: Runtime Error):
S=input()
if len(S)==2:
    print(S)
else:
    S.reverse()
    print(S)

Fixed submission:
S=input()
if len(S)==2:
    print(S)
else:
    print(S[::-1])
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
S=input()
T=input()
g=gcd(N,M)
m=(N//g)*(M//g)*g
a=0
b=0
A=m//N
B=m//M
t=True
while(a<N):
    if S[a]==T[b]:
        a+=B
        b+=A
    else:
        print(-1)
        quit()
print(m)


Fixed submission:
from fractions import gcd
from math import sqrt
from heapq import *
from math import factorial
from collections import defaultdict

N,M=map(int,input().split())
S=input()
T=input()
g=gcd(N,M)
m=(N//g)*(M//g)*g
a=0
b=0
A=m//N
B=m//M
t=True
while(a<N):
    if S[a]==T[b]:
        a+=B
        b+=A
    else:
        print(-1)
        quit()
print(m)
Buggy python submission (verdict: Runtime Error):
N=int(input())
xyh=[]
for i in range(N):
  xyh.append(list(map(int,input().split())))
def height(x,y,h,Cx,Cy,):
  height=h+abs(x-Cx)+abs(y-Cy)
  return height
def find(N):
  for Cx in range(101):
    for Cy in range(101):
      Height=height(xyh[0][0],xyh[0][1],xyh[0][2],Cx,Cy)
      for i in range(1,N):
        Height_=height(xyh[i][0],xyh[i][1],xyh[i][2],Cx,Cy)
        if Height==Height_:
          if i==N-1:
            return (Cx,Cy,Height)
          continue
        else:
          break
Cx,Cy,H=find(N)
print(Cx,"",Cy," ",H)

Fixed submission:
N=int(input())

xyh=[]
for i in range(N):
    xi,yi,hi=map(int,input().split())
    xyh.append([xi,yi,hi])
xyh.sort(reverse=True,key=lambda x:x[2])
for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(N):
            X=xyh[i][0]
            Y=xyh[i][1]
            h=xyh[i][2]
            if i==0:
                H=h+abs(X-Cx)+abs(Y-Cy)
                continue
            H_=h+abs(X-Cx)+abs(Y-Cy)
            if h==0:
                if H_<H:
                    break
            elif H!=H_:
                break
            if i==N-1:
                print(Cx,Cy,H)
                quit()
Buggy python submission (verdict: Runtime Error):
import bisect
from collections import deque
from collections import defaultdict
#from math import factorial
from math import sqrt
n=int(input())
v=map(int,input().split())

a=[]
b=[]
for i in range(n):
    if i%2==0:
        a.append(v[i])
    else:
        b.append(v[i])

A=defaultdict(int)
B=defaultdict(int)
for i in a:
    A[i]+=1
for i in b:
    B[i]+=1
A[0]=0
B[0]=0
Amax=0
Akey=0
Bmax=0
Bkey=0

for key in A.keys():
    if Amax<A[key]:
        Akey=key
        Amax=A[key]
for key in B.keys():
    if Bmax<B[key]:
        Bkey=key
        Bmax=B[key]
min=10**5
n_=n/2
for i in B.keys():
    min_=(n_-Amax)+(n_-B[i])
    if Akey!=i and min>min_:
        min=min_
for i in A.keys():
    min_=(n_-A[i])+(n_-Bmax)
    if Bkey!=i and min>min_:
        min=min_
print(min)


Fixed submission:
import bisect
from collections import deque
from collections import defaultdict
#from math import factorial
from math import sqrt
n=int(input())
v=list(map(int,input().split()))

a=[]
b=[]
for i in range(n):
    if i%2==0:
        a.append(v[i])
    else:
        b.append(v[i])

A=defaultdict(int)
B=defaultdict(int)
for i in a:
    A[i]+=1
for i in b:
    B[i]+=1
A[0]=0
B[0]=0
Amax=0
Akey=0
Bmax=0
Bkey=0

for key in A.keys():
    if Amax<A[key]:
        Akey=key
        Amax=A[key]
for key in B.keys():
    if Bmax<B[key]:
        Bkey=key
        Bmax=B[key]
min=10**5
n_=int(n/2)
for i in B.keys():
    min_=(n_-Amax)+(n_-B[i])
    if Akey!=i and min>min_:
        min=min_
for i in A.keys():
    min_=(n_-A[i])+(n_-Bmax)
    if Bkey!=i and min>min_:
        min=min_
print(min)
Buggy python submission (verdict: Runtime Error):
A=list(map(int,input().split()))
sum=1
for i in A:
    sum*=i
if sum%2=1:
    print('Yes')
else:
    print("No")


Fixed submission:
A,B=map(int,input().split())
if (A*B)%2==1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np
x1,y1,x2,y2=map(int,input().split())
p1=np.array([x1,y1])
p2=np.array([x2,y2])
d=p2-p1
d=np.array([-d[1],d[0]])
p3=p2+d
d=np.array([-d[1],d[0]])

p4=p3+d
x3=p3[0]
y3=p3[1]
x4=p4[0]
y4=p4[1]
print(x3,y3,x4,y4)


Fixed submission:
#S=input()
#N=int(input())
x1,y1,x2,y2=map(int,input().split())
x3=x2-(y2-y1)
y3=y2+(x2-x1)
x4=x3-(y3-y2)
y4=y3+(x3-x2)
print(x3," ",y3," ",x4," ",y4)
Buggy python submission (verdict: Runtime Error):
S=input()
K=input()
num=-1
for i in range(len(S)):
    if S[i]!="1":
        num=i
        T=int(S[i])
        break
if K-1<num:
    print(1)
else:
    print(T)


Fixed submission:
S=input()
K=int(input())
num=100000
for i in range(len(S)):
    if S[i]!="1":
        num=i
        T=int(S[i])
        break
if K-1<num:
    print(1)
else:
    print(T)
Buggy python submission (verdict: Runtime Error):
while(N):
    if (N-1)%(-2)==0:
        ans+="1"
        N-=1
        N//=(-2)

    else:
        ans+="0"
        N//=(-2)

print(ans[::-1])


Fixed submission:
N=int(input())
if N==0:
    print(0)
    quit()
S=""
i=0
while(N):
    if (N-(-2)**i)%2**(i+1)==0:
        S+="1"
        N-=(-2)**i
    else:
        S+="0"
    i+=1
S=S[::-1]
I=False
t=0
for i in S:
    if i=="1":
        break
    else:
        t+=1
print(S[t:])
Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy
from collections import deque

N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

"""
N=10**5
M=10**5
ab=[]
for i in range(1,N):
    ab.append([i,i+1])
"""
AB=copy(ab)
ab.sort(key=lambda x :x[1])
AB.sort()
ab=deque(ab)
AB=deque(AB)
num=0
while(ab):
    p=ab.popleft()
    AB.remove(p)
    num+=1
    e=p[1]
    Q=copy(AB)
    for I in AB:
        if I[0]<e:
            Q.remove(I)
            ab.remove(I)
        else:
            break
    AB=Q
print(num)

Fixed submission:
from collections import deque
N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

ab.sort(key=lambda x :x[1])
ans=deque()
for i in ab:
    if len(ans)>0:
        if i[0]<ans[-1] :
            continue
    ans.append(i[1])
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

ab.sort(key=lambda x :x[1])
ab=deque(ab)
num=0
while(ab):
    p=ab.popleft()
    num+=1
    e=p[1]
    q=deque()
    for i in range(len(ab)):
        if ab[i][0]>=e:
            q.append(ab[i])
    ab=q
print(num)

Fixed submission:
from collections import deque
N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

ab.sort(key=lambda x :x[1])
ans=deque()
for i in ab:
    if len(ans)>0:
        if i[0]<ans[-1] :
            continue
    ans.append(i[1])
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])
ab.sort(key=lambda x :x[1])
num=0
while(ab):
    p=ab.pop(0)
    num+=1
    e=p[1]
    for i in reversed(range(len(ab))):
        if ab[i][0]<e:
            ab.pop(i)
print(num)

Fixed submission:
from collections import deque
N,M=map(int,input().split())
ab=[]
for i in range(M):
    a,b=map(int,input().split())
    ab.append([a,b])

ab.sort(key=lambda x :x[1])
ans=deque()
for i in ab:
    if len(ans)>0:
        if i[0]<ans[-1] :
            continue
    ans.append(i[1])
print(len(ans))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
A.sort()
prit(A[-1]-A[0])


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A.sort()
print(A[-1]-A[0])
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    B.append(A[i]-(i+1))
B.sort()
b=B[N/2]
ans=0
for i in B:
    ans+=abs(i-b)
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    B.append(A[i]-(i+1))
B.sort()
b=B[N//2]
ans=0
for i in B:
    ans+=abs(i-b)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
s=0
S=str(N):
for i in S:
    s+=int(i)
if N%s==0:
    print("Yes")
else:
    print("No")


Fixed submission:
N=int(input())
s=0
S=str(N)
for i in S:
    s+=int(i)
if N%s==0:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N=int(input())
s=0
S=str(N):
for i in S:
    s+=i
if N%s==0:
    print("Yes")
else:
    print("No")


Fixed submission:
N=int(input())
s=0
S=str(N)
for i in S:
    s+=int(i)
if N%s==0:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N=int(input())
s=0
S=str(N):
for i in S:
    s+=i
if S%s==0:
    print("Yes")
else:
    print("No")


Fixed submission:
N=int(input())
s=0
S=str(N)
for i in S:
    s+=int(i)
if N%s==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
D,N=map(int,input().split())
if N==100:
    print(2/0)
print((100**D)*N)


Fixed submission:
D,N=map(int,input().split())
if N==100:
    N+=1
print((100**D)*N)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
S="E"+S+"W"
E=[0]*(N+2)
W=[0]*(N+2)
for i in range(len(S)-1):
    if S[i]=="W":
        E[i+1]=E[i]+1
    else:
        E[i+1]=E[i]
 
for i in range(len(S)-1,0,-1):
    if S[i]=="E":
         W[i-1]=W[i]+1
    else:
         W[i-1]=W[i]
ans=10**9
for i in range(N):
    ans=min(ans,E[i+1]+W[i+1])
print(ans)
N=int(input())
S=input()
S="E"+S+"W"
E=[0]*(N+2)
W=[0]*(N+2)
for i in range(len(S)-1):
    if S[i]=="W":
        E[i+1]=E[i]+1
    else:
        E[i+1]=E[i]

for i in range(len(S)-1,0,-1):
    if S[i]=="E":
         W[i-1]=W[i]+1
    else:
         W[i-1]=W[i]
ans=10**9
for i in range(N):
    ans=min(ans,E[i+1]+W[i+1])
print(ans)


Fixed submission:
N=int(input())
S=input()
S="E"+S+"W"
E=[0]*(N+2)
W=[0]*(N+2)
for i in range(len(S)-1):
    if S[i]=="W":
        E[i+1]=E[i]+1
    else:
        E[i+1]=E[i]

for i in range(len(S)-1,0,-1):
    if S[i]=="E":
         W[i-1]=W[i]+1
    else:
         W[i-1]=W[i]
ans=10**9
for i in range(N):
    ans=min(ans,E[i+1]+W[i+1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
B=[0]*(N+1)
C=[0]*(N+1)
for i in range(N):
    B[i+1]=B[i]+A[i]
    C[i+1]=C[i]^A[i]
ans=0
for l in range(1,N+1):
    for r in range(l,N+1):
        if C[r]^C[l-1]==B[r]-B[l-1]:
            ans+=1
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=0
right=0
sum=0
for left in range(N):
    while(right<N and (sum^A[right])==(sum+A[right])):
        sum+=A[right]
        right+=1
    ans+=right-left
    if left==right:
        right+=1
    else:
        sum-=A[left]
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    S.append(s)
for i in range(H):
    for j in range(W):
        if S[j][i]==".":
            continue
        l=[(j-1,i),(j+1,i),(j,i+1),(j,i-1)]
        koritu=True
        for y,x in l:
            if 0<=y<=H-1 and  0<=x<=W-1:
                koritu=koritu and S[y][x]=="."
        if koritu:
            print("No")
            quit()
print("Yes")


Fixed submission:
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    S.append(s)
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            continue
        l=[(j-1,i),(j+1,i),(j,i+1),(j,i-1)]
        koritu=True
        for x,y in l:
            if 0<=y<=H-1 and  0<=x<=W-1:
                koritu=koritu and S[y][x]=="."
        if koritu:
            print("No")
            quit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate


N=int(input())
A=list(map(int,input().split()))
sums=list(accumulate([0]+A))
def nCr(n,r):
    a=factorial(n)
    b=factorial(n-r)
    c=factorial(r)
    return int(a//(b*c))
dic=defaultdict(int)
for i in sums:
    dic[i]+=1
ans=0
for i in dic.keys():
    if dic[i]>=2:
        ans+=nCr(dic[i],2)
print(ans)


Fixed submission:
from math import factorial
from math import sqrt
from math import ceil
from itertools import permutations
from heapq import *
from collections import defaultdict
from copy import deepcopy
from math import log
from itertools import accumulate


N=int(input())
A=list(map(int,input().split()))
sums=list(accumulate([0]+A))
def nCr(n,r):
    a=factorial(n)
    b=factorial(n-r)
    c=factorial(r)
    return int(a//(b*c))
dic=defaultdict(int)
for i in sums:
    dic[i]+=1
ans=0
for i in dic.keys():
    if dic[i]>=2:
        ans+=nCr(dic[i],2)
print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=[]
for i in range(29):
  T=2**i
  B_=list(B)
  A_=list(A)
  t=0
  for j in range(N):
    B_[j]%=2*T
    A_[j]%=2*T
  B_.sort()
  for j in range(N):
    a=A_[j]
    p=bisect.bisect_left(B_,T-a)
    q=bisect.bisect_left(B_,2*T-a)
    r=bisect.bisect_left(B_,3*T-a)
    s=bisect.bisect_left(B_,4*T-a)
    t+=(q-p)+(s-r)
  ans.append(t%2)
a=0
for i in range(29):
  a+=2**i*ans[i]
print(a)


Fixed submission:
N,C=map(int,input().split())
xv=[(0,0)]
xv_=[]
for i in range(N):
    x,v=map(int,input().split())
    xv.append((x,v))
    xv_.append((x,v))
xv_.append((C,0))
xv_.reverse()
r=[0]*(N+1)
r_=[0]*(N+1)
for i in range(N):
    r[i+1]=r[i]-(xv[i+1][0]-xv[i][0])+xv[i+1][1]
    r_[i+1]=max(r_[i],r[i+1]-xv[i+1][0])
l=[0]*(N+1)
l_=[0]*(N+1)
for i in range(N):
    l[i+1]=l[i]-abs(xv_[i+1][0]-xv_[i][0])+xv_[i+1][1]
    l_[i+1]=max(l_[i],l[i+1]-(C-xv_[i+1][0]))
ans=0
for i in range(1,N+1):
    ans=max(r[i]+l_[N-i],ans)
    ans=max(l[i]+r_[N-i],ans)
print(ans)