Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input
count=0
for i in range(1,n):
  if s[i]=='E':
    count+=1
m=count
for i in range(1,n):
  if s[i-1]=='W':
    count+=1
  if s[i]=='E':
    count-=1
  m=min(m,count)
print(m)

Fixed submission:
n=int(input())
s=input()
count=0
for i in range(1,n):
  if s[i]=='E':
    count+=1
m=count
for i in range(1,n):
  if s[i-1]=='W':
    count+=1
  if s[i]=='E':
    count-=1
  m=min(m,count)
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())
mx=1
for i in range(2,32):
  p=2
  while i**p<=x:
    if i**p > mx:
      mx = i**p
      p+=1
print(mx)

Fixed submission:
x=int(input())
mx=1
for i in range(2,32):
  p=2
  while i**p<=x:
    if i**p > mx:
      mx = i**p
    p+=1
print(mx)
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
t=set(s)
t.append(s)
n=len(s)-1
for i in range(n):
  t.append(s[i:i+2])
  if i == n:
    break
  t.append(s[i:i+3])
  if i == n-1:
    continue
  t.append(s[i:i+4])
t.sort()
print(t[k])


Fixed submission:
s = input()
K = int(input())
N = len(s)

ans = []

for i in range(min(K, N)):
  for j in range(N-i):
    ans.append(s[j:j+i+1])
  
ans.sort()
count = 0
now = '0'
for i in range(len(ans)):
  if ans[i] != now:
    count += 1
    now = ans[i]
    if count == K:
      print(now)
      exit()

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
t=set(s)
t.append(s)
for i in range(len(s)-1):
  t.append(s[i:i+1])
  if i == len(s)-1:
    break
  t.append(s[i:i+2])
  if i == len(s)-2:
    continue
  t.append(s[i:i+3])
t.sort()
print(t[k])


Fixed submission:
s = input()
K = int(input())
N = len(s)

ans = []

for i in range(min(K, N)):
  for j in range(N-i):
    ans.append(s[j:j+i+1])
  
ans.sort()
count = 0
now = '0'
for i in range(len(ans)):
  if ans[i] != now:
    count += 1
    now = ans[i]
    if count == K:
      print(now)
      exit()

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
t=set(s)
t.append(s)
for i in range(len(s)-1):
  t.append(s[i]+s[i+1])
  if i == len(s)-1:
    break
  t.append(s[i]+s[i+1]+s[i+2])
  if i == len(s)-2:
    continue
  t.append(s[i]+s[i+1]+s[i+2]+s[i+3])
t.sort()
print(t[k])


Fixed submission:
s = input()
K = int(input())
N = len(s)

ans = []

for i in range(min(K, N)):
  for j in range(N-i):
    ans.append(s[j:j+i+1])
  
ans.sort()
count = 0
now = '0'
for i in range(len(ans)):
  if ans[i] != now:
    count += 1
    now = ans[i]
    if count == K:
      print(now)
      exit()

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
t=set(s)
t.apprnd(s)
for i in range(len(s)-1):
  t.append(s[i]+s[i+1])
  if i == len(s)-1:
    break
  t.append(s[i]+s[i+1]+s[i+2])
  if i == len(s)-2:
    continue
  t.append(s[i]+s[i+1]+s[i+2]+s[i+3])
t.sort()
print(t[k])

Fixed submission:
s = input()
K = int(input())
N = len(s)

ans = []

for i in range(min(K, N)):
  for j in range(N-i):
    ans.append(s[j:j+i+1])
  
ans.sort()
count = 0
now = '0'
for i in range(len(ans)):
  if ans[i] != now:
    count += 1
    now = ans[i]
    if count == K:
      print(now)
      exit()
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())

s = ['.'*(W+2)] + ['.'+input()+'.' for _ in range(H)] + ['.'*(W+2)]
for hi in range(1, W+1):
  for wi in range(1, H+1):
    if s[hi][wi] == '.':
      continue
    if s[hi-1][wi]=='.' and s[hi+1][wi]=='.':
      if s[hi][wi-1]=='.' and s[hi][wi+1]=='.':
        print('No')
        exit()
        
print('Yes')

Fixed submission:
H, W = map(int, input().split())

s = ['.'*(W+2)] + ['.'+input()+'.' for _ in range(H)] + ['.'*(W+2)]
for hi in range(1, H+1):
  for wi in range(1, W+1):
    if s[hi][wi] == '.':
      continue
    if s[hi-1][wi]=='.' and s[hi+1][wi]=='.':
      if s[hi][wi-1]=='.' and s[hi][wi+1]=='.':
        print('No')
        exit()
        
print('Yes')

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=[]
white=[]
for i in range(w):
  white.append(".")
s.append(white)
for i in range(h):
  a=[]
  a.append(".")
  for j in range(w):
    wh=list(map(int,input().split()))
    a.append(wh)
  a.append(".")
s.append(white)

for i in range(1,h+1):
  for j in range(1,w+1):
    if s[w-1][h]=="." and s[w+1][h]=="." and s[w][h-1]=="." and s[w][h+1]=="."
      print("No")
      exit()
print("Yes")

Fixed submission:
H, W = map(int, input().split())

s = ['.'*(W+2)] + ['.'+input()+'.' for _ in range(H)] + ['.'*(W+2)]
for hi in range(1, H+1):
  for wi in range(1, W+1):
    if s[hi][wi] == '.':
      continue
    if s[hi-1][wi]=='.' and s[hi+1][wi]=='.':
      if s[hi][wi-1]=='.' and s[hi][wi+1]=='.':
        print('No')
        exit()
        
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
mx=0
alarge=a[n-1]
if a[0]>=alarge/2:
  asmall=0
  comb=1
  for i in range(1,asmall+1): comb*=(alarge-i+1)/i
else:
  j=0
  while a[j]<alarge/2:
    j+=1
  if alarge<=a[j-1]+a[j]:
    asmall=a[j-1]
  else:
    asmall=a[j]
  comb=1
  for i in range(1,asmall+1): comb*=(alarge-i+1)/i
print("{} {}".format(alarge,asmall))


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
alarge=a[n-1]
if a[0]>=alarge/2:
  asmall=a[0]
else:
  j=0
  while a[j]<alarge/2:
    j+=1
  if alarge<=a[j-1]+a[j]:
    asmall=a[j-1]
  else:
    asmall=a[j]
print("{} {}".format(alarge,asmall))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
mx=0
alarge=a[n-1]
if a[0]>=alarge/2:
  asmall=0
  comb=1
  for i in range(1,asmall+1): comb*=alarge-i+1
  for i in range(1,asmall+1): comb/=i
else:
  j=0
  while a[j]<alarge/2:
    j+=1
  if alarge<=a[j-1]+a[j]:
    asmall=a[j-1]
  else:
    asmall=a[j]
  comb=1
  for i in range(1,asmall+1): comb*=alarge-i+1
  for i in range(1,asmall+1): comb/=i
print("{} {}".format(alarge,asmall))


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
alarge=a[n-1]
if a[0]>=alarge/2:
  asmall=a[0]
else:
  j=0
  while a[j]<alarge/2:
    j+=1
  if alarge<=a[j-1]+a[j]:
    asmall=a[j-1]
  else:
    asmall=a[j]
print("{} {}".format(alarge,asmall))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
grid=[['#' for i in range(60)] for i in range(20)]
grid=grid+[['.' for i in range(60)] for i in range(20)]

for i in range(1200):
  amari=i%60
  shou=int(i/60)
  if (amari + shou)%2==0:
    grid[shou][amari]='.'
    a-=1
  if a==1:
    break

for i in range(1200):
  if (amari + shou)%2==0:
    grid[shou+22][amari]='#'
    b-=1
  if b==1:
    break

for i in range(40):
  print(''.join(grid[i]))

Fixed submission:
a,b=map(int,input().split())
k=32
m=2*k
grid=[['#' for i in range(m)] for i in range(k)]
grid=grid+[['.' for i in range(m)] for i in range(k)]

for i in range(m*k):
  if a==1:
    break
  grid[2*int(i*2/m)][(i*2)%m]='.'
  a-=1

for i in range(m*k):
  if b==1:
    break
  grid[k+1+2*int(i*2/m)][(i*2)%m]='#'
  b-=1

print(str(2*k)+' '+str(2*k))
for i in range(k*2):
  print(''.join(grid[i]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[]
t=[]
for i in range(n):
  s.append(input())
m=int(input())
for i in range(m):
  t.append(input())
max=0
for i in range(len(s)):
  get=0
  for j in range(len(s[i:n])):
    if s[i]==s[j]:
      get+=1
  for k in range(len(t)):
    if s[i]==s[k]:
      get-=1
  if get>max:
    max=get
print(max) 

Fixed submission:
N = int(input())
worddict = {}
for i in range(N):
  s = input()
  if s in worddict:
    worddict[s] += 1
  else:
    worddict[s] = 1
    
M = int(input())
for i in range(M):
  t = input()
  if t in worddict:
    worddict[t] -= 1
    
maxyen = 0
for i in worddict:
  maxyen = max(maxyen, worddict[i])
print(maxyen)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
c=0
for b in range(k,n+1):
  p=int(n/b)
  r=n%b
  c+=(b-k)*p
  if r>=k:
    c+=r-k+1
if k==0:
  print(c-1)
else:
  print(c)

Fixed submission:
n,k=map(int,input().split())
c=0
if k==0:
 print(n**2)
else:
  for b in range(k,n+1):
    p=int(n/b)
    r=n%b
    c+=(b-k)*p
    if r>=k:
      c+=r-k+1
  print(c)
Buggy python submission (verdict: Runtime Error):
N = int(input())

march = 'MARCH'
mdict = {s:0 for s in march}

for i in range(N):
  S = input()
  mdict[S[0]] += 1
  
lst = [mdict[key] for key in mdict]
ans = 0
for i in range(3):
  for j in range(i+1, 4):
    for k in range(j+1, 5):
      ans += lst[i] * lst[j] * lst[k]
      
print(ans)


Fixed submission:
N = int(input())

march = 'MARCH'
mdict = {s:0 for s in march}

for i in range(N):
  S = input()
  if S[0] in march:
    mdict[S[0]] += 1
  
lst = [mdict[key] for key in mdict]
ans = 0
for i in range(3):
  for j in range(i+1, 4):
    for k in range(j+1, 5):
      ans += lst[i] * lst[j] * lst[k]
      
print(ans)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
print(mint(N*A, B))

Fixed submission:
N, A, B = map(int, input().split())
print(min(N*A, B))
Buggy python submission (verdict: Runtime Error):
S = input()
N = int(input())
fN = sum([int(S[i]) for i in range(len(S))])
if N%fN == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
S = input()
N = int(S)
fN = sum([int(si) for si in S])
if N%fN == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
print((1900*M+100*(N-M))2**M)


Fixed submission:
N, M = map(int, input().split())
print((1900*M+100*(N-M))*(2**M))
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
now = 1
for i in range(N):
  if now <= K:
    now += 2
  else:
    now += K
print(ans)

Fixed submission:
N = int(input())
K = int(input())
now = 1
for i in range(N):
  if now <= K:
    now *= 2
  else:
    now += K
print(now)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
for i in range(R):
  r[i] -= 1

d = [[10000000000]*N for _ in range(N)]
for i in range(N):
  d[i][i] = 0

for i in range(M):
  A, B, C = map(int, input().split())
  d[A-1][B-1] = C
  d[B-1][A-1] = C
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j] = min(d[i][j], d[i][k]+d[k][j])
      
perms = permutations(r, R)
ans = 10000000000
for perm in perms:
  now = 0
  for i in range(R-1):
    now += d[perm[i]][perm[i+1]]
  ans = min(ans, now)
  
print(ans)


Fixed submission:
from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
for i in range(R):
  r[i] -= 1

d = [[10000000000]*N for _ in range(N)]
for i in range(N):
  d[i][i] = 0

for i in range(M):
  A, B, C = map(int, input().split())
  d[A-1][B-1] = C
  d[B-1][A-1] = C
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j] = min(d[i][j], d[i][k]+d[k][j])
      
perms = permutations(r, R)
ans = 10000000000
for perm in perms:
  now = 0
  for i in range(R-1):
    now += d[perm[i]][perm[i+1]]
  ans = min(ans, now)
  
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split())).sort()
print(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):
A, B, C = map(int, input().split())
if (A[-1]==B[0]) and (B[-1]==C[0]):
  print('YES')
else:
  print('NO')

Fixed submission:
A, B, C = input().split()
if (A[-1]==B[0]) and (B[-1]==C[0]):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
student = [list(map(int, input().split())) for _ in range(N)]
cp = [list(map(int, input().split())) for _ in range(M)]

idou = []
for a, b in student:
  idousaki = -1
  nearest = 1000000000
  for i, x, y in enumerate(cp):
    d = abs(x-a) + abs(y-b)
    if d < nearest:
      nearest = d
      idousaki = i+1
      
  idou.append(idousaki)
  
for i in idou:
  print(i)


Fixed submission:
A, B = map(int, input().split())
print((A+B) % 24)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
student = [list(map(int, input().split())) for _ in range(N)]
cp = [list(map(int, input().split())) for _ in range(M)]

idou = []
for a, b in student:
  idousaki = -1
  nearest = 1000000000
  for i, x, y in enumerate(cp):
    d = abs(x-a) + abs(y-b)
    if d < nearest:
      nearest = d
      idousaki = i+1
      
  idou.append(idousaki)
  
for i in idou:
  print(i)


Fixed submission:
N, M = map(int, input().split())
student = [list(map(int, input().split())) for _ in range(N)]
cp = [list(map(int, input().split())) for _ in range(M)]

idou = []
for a, b in student:
  idousaki = -1
  nearest = 1000000000
  for i, xy in enumerate(cp):
    d = abs(xy[0]-a) + abs(xy[1]-b)
    if d < nearest:
      nearest = d
      idousaki = i+1
      
  idou.append(idousaki)
  
for i in idou:
  print(i)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(N)]

for i in range(N-M+1):
  for j in range(N-M+1):
    
    for k in range(M):
      if A[i+k][j:j+M] != B[k]:
        break
    else:
      print('Yes')
      exit()
      
    break

print('No')

Fixed submission:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M+1):
  for j in range(N-M+1):
    
    for k in range(M):
      if A[i+k][j:j+M] != B[k]:
        break
    else:
      print('Yes')
      exit()

print('No')
Buggy python submission (verdict: Runtime Error):
s = input()
for i in range(len(s)):
  if s[i] == 'A':
    left = i
    break
    
for i in range(len(s)):
  if s[N-1-i] == 'Z':
    right = N-1-i
    break
    
print(right - left + 1)


Fixed submission:
s = input()
N = len(s)
for i in range(N):
  if s[i] == 'A':
    left = i
    break
    
for i in range(N):
  if s[N-1-i] == 'Z':
    right = N-1-i
    break
    
print(right - left + 1)

Buggy python submission (verdict: Runtime Error):
s = input()
for i in range(N):
  if s[i] == 'A':
    left = i
    break
    
for i in range(N):
  if s[N-1-i] == 'Z':
    right = N-1-i
    
print(right - left + 1)

Fixed submission:
s = input()
N = len(s)
for i in range(N):
  if s[i] == 'A':
    left = i
    break
    
for i in range(N):
  if s[N-1-i] == 'Z':
    right = N-1-i
    break
    
print(right - left + 1)
Buggy python submission (verdict: Runtime Error):
print(' '.join(input().split(','))

Fixed submission:
print(input().replace(',', ' '))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
d=[[100000]*n for _ in range(n)]
a=[0]*m
b=[0]*m
c=[0]*m
for i in range(m):
  a0,b0,c0=map(int,input().split())
  a[i]=a0-1
  b[i]=b0-1
  c[i]=c0
  d[a0-1][b0-1]=c0
  d[b0-1][a0-1]=c0
for i in range(n):
  d[i][i]=0
for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
count=0
for edge in range(m):
  flag=False
  for j in range(n):
    for k in range(n):
      if d[j][a[edge]]+c[edge]==d[j][b[edge]]:
        flag=True
        break
    if flag:
      break
  else:
    count+=1
print(count)


Fixed submission:
import sys
from copy import deepcopy
input = sys.stdin.readline
n,m=map(int,input().split())
d=[[100000]*n for _ in range(n)]
a=[0]*m
b=[0]*m
c=[0]*m
for i in range(m):
  a0,b0,c0=map(int,input().split())
  a[i]=a0-1
  b[i]=b0-1
  c[i]=c0
  d[a0-1][b0-1]=c0
  d[b0-1][a0-1]=c0
for i in range(n):
  d[i][i]=0
d2=deepcopy(d)
for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
count=0
for i in range(n):
  for j in range(i):
    if d2[i][j] != 100000 and d[i][j]!=d2[i][j]:
      count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
d=[[100000]*n for _ in range(n)]
a=[0]*m
b=[0]*m
c=[0]*m
for i in range(m):
  a0,b0,c0=map(int,input().split())
  a[i]=a0-1
  b[i]=b0-1
  c[i]=c0
  d[a0-1][b0-1]=c0
  d[b0-1][a0-1]=c0
for i in range(n):
  d[i][i]=0
for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
count=0
for edge in range(m):
  flag=False
  for j in range(n):
    for k in range(n):
      if d[j][a[edge]]+c[edge]+d[b[edge]][k]==d[j][k]:
        flag=True
        break
    if flag:
      break
  else:
    count+=1
print(count)

Fixed submission:
import sys
from copy import deepcopy
input = sys.stdin.readline
n,m=map(int,input().split())
d=[[100000]*n for _ in range(n)]
a=[0]*m
b=[0]*m
c=[0]*m
for i in range(m):
  a0,b0,c0=map(int,input().split())
  a[i]=a0-1
  b[i]=b0-1
  c[i]=c0
  d[a0-1][b0-1]=c0
  d[b0-1][a0-1]=c0
for i in range(n):
  d[i][i]=0
d2=deepcopy(d)
for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
count=0
for i in range(n):
  for j in range(i):
    if d2[i][j] != 100000 and d[i][j]!=d2[i][j]:
      count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
C = [input() for _ in range(H)]
for i in raneg(2*H):
  print(C[i//2])


Fixed submission:
H, W = map(int, input().split())
C = [input() for _ in range(H)]
for i in range(2*H):
  print(C[i//2])

Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
C = [input() for _ in range(H)]
for i in raneg(2*H):
  print(C[i//2 +1])


Fixed submission:
H, W = map(int, input().split())
C = [input() for _ in range(H)]
for i in range(2*H):
  print(C[i//2])
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
if s[0]==s[-1] ^ n%2==0:
  print('Second')
else:
  print('First')

Fixed submission:
n,x=map(int,input().split())
a=list(map(int,input().split()))
eat=0
for i in range(n-1):
  wa=a[i]+a[i+1]
  if wa>x:
    sa=wa-x
    eat+=sa
    if sa<=a[i+1]:
      a[i+1]-=sa
    else:
      a[i+1]=0
print(eat)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
if s[0]==s[-1] ^ n%2==0:
  print('Second')
else:
  print('First')

Fixed submission:
s=input()
n=len(s)
moji1=s[0]
moji2=s[1]
count=0
flag=False
for i in range(n-2):
  if (i+count)%2==0:
    if s[i+2]!=moji1:
      count+=1
      if i+2==n-1:
        flag=True
  else:
    if s[i+2]!=moji2:
      count+=1
      if i+2==n-1:
        flag=True
  if count==2:
    break
if count==0:
  print('Second')
  exit()
if count==1:
  if flag:
    if (n-2)%2==0:
      print('Second')
    else:
      print('First')
  else:
    print('First')
  exit()
if s[0]==s[-1]:
  if (n-3)%2==0:
    print('Second')
  else:
    print('First')
else:
  if (n-2)%2==0:
    print('Second')
  else:
    print('First')
Buggy python submission (verdict: Runtime Error):
W, H, N = map(int, input().split())

left = 0
right = W
bottom = 0
top = H

for i in range(N):
  x, y, a = map(int, input().split())
  if a == 1:
    left = max(left, x)
  elif a == 2:
    right = min(right, x)
  elif a == 3:
    bottom = max(bottom, y)
  else:
    top = min(top, y)
    
print((right-left) * (top-bottom))

Fixed submission:
abc = list(map(int, input().split()))
abc.sort()
if abc[0]+abc[1] == abc[2]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
h,w,n=map(int,input().split())
jl=[0]*10
ab=[]
if n==0:
  print((w-2)*(h-2))
  for i in range(9):
    print(0)
  exit()
for i in range(n):
  a,b=map(int,input().split())
  a-=1
  b-=1
  for j in range(max(0,b-2),min(w-2,b+1)):
    for k in range(max(0,a-2),min(h-2,a+1)):
      ab=ab+[[k,j]]

ab.sort(key=lambda x: x[1])
ab.sort()
flag=False
count=1
now=ab[0]
for i in ab[1:]:
  if i==now:
    count+=1
  else:
    jl[count]+=1
    count=1
    now=i
jl[count]+=1
jl[0]=(h-2)*(w-2)-sum(jl[1:])
for i in range(10):
  print(jl[i])

Fixed submission:
h,w,n=map(int,input().split())
jl=[0]*10
cnt={}
if n==0:
  print((w-2)*(h-2))
  for i in range(9):
    print(0)
  exit()
for i in range(n):
  a,b=map(int,input().split())
  a-=1
  b-=1
  for j in range(max(0,b-2),min(w-2,b+1)):
    for k in range(max(0,a-2),min(h-2,a+1)):
      if (k, j) in cnt:
        cnt[(k, j)]+=1
      else:
        cnt[(k, j)]=1
jl[0]=(h-2)*(w-2)
for i in cnt.values():
  jl[0]-=1
  jl[i]+=1
for i in jl:
  print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
print(min(K, N)*X + max(0, N-K)*Y

Fixed submission:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
print(min(K, N)*X + max(0, N-K)*Y)
Buggy python submission (verdict: Runtime Error):
n,a=map(int,input().split())
x=list(map(int,input().split()))
y=[i-a for i in x]
y.sort()
minus=[-i for i in y if i<0]
minus.sort()
plus=[i for i in y if i>0]
zero=len([i for i in y if i==0])

ma=max(y)*n
ny=ma*2
dp=[[0]*(ny+1) for _ in range(n+1)]
for i in range(n+1):
  for j in range(ny+1):
    if i==0 and j==ma:
      dp[i][j]=1
    elif i>=1:
      sa=j-y[i-1]
      if sa<0 or sa>ny:
        dp[i][j]=dp[i-1][j]
      else:
        dp[i][j]=dp[i-1][j]+dp[i-1][sa]
print(dp[n][ma]-1)

Fixed submission:
n,a=map(int,input().split())
x=list(map(int,input().split()))
y=[i-a for i in x]
y.sort()

ma=max(max(y),-1*min(y))*n
ny=ma*2
dp=[[0]*(ny+1) for _ in range(n+1)]
for i in range(n+1):
  for j in range(ny+1):
    if i==0 and j==ma:
      dp[i][j]=1
    elif i>=1:
      sa=j-y[i-1]
      if sa<0 or sa>ny:
        dp[i][j]=dp[i-1][j]
      else:
        dp[i][j]=dp[i-1][j]+dp[i-1][sa]
print(dp[n][ma]-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=int(input())
if n==s:
  print(n+1)
  exit()
for b in range(2,int(n**(1/2)+1)):
  m=n
  wa=0
  while m>0:
    wa+=m%b
    m=m//b
  if wa==s:
    print(b)
    exit()

for p in range(int(n**(1/2)),0,-1):
  if (n-s)%p==0:
    b=(n-s)//p+1
    if p+n%b==s:
      print(b)
      exit()
print('-1')


Fixed submission:
n=int(input())
s=int(input())
if n==s:
  print(n+1)
  exit()
if n<s:
  print(-1)
  exit()
for b in range(2,int(n**(1/2))+1):
  m=n
  wa=0
  while m>0:
    wa+=m%b
    m=m//b
  if wa==s:
    print(b)
    exit()

for p in range(int((n-1)**(1/2)),0,-1):
  if (n-s)%p==0:
    b=(n-s)//p+1
    if p+n%b==s:
      print(b)
      exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=int(input())
if n==s:
  print(n+1)
  exit()
for b in range(2,int(n**(1/2))+1):
  m=n
  wa=0
  while m>0:
    wa+=m%b
    m=m//b
  if wa==s:
    print(b)
    exit()

for p in range(int(n**(1/2)),0,-1):
  if (n-s)%p==0:
    b=(n-s)//p+1
    if p+n%b==s:
      print(b)
      exit()
print(-1)   

Fixed submission:
n=int(input())
s=int(input())
if n==s:
  print(n+1)
  exit()
if n<s:
  print(-1)
  exit()
for b in range(2,int(n**(1/2))+1):
  m=n
  wa=0
  while m>0:
    wa+=m%b
    m=m//b
  if wa==s:
    print(b)
    exit()

for p in range(int((n-1)**(1/2)),0,-1):
  if (n-s)%p==0:
    b=(n-s)//p+1
    if p+n%b==s:
      print(b)
      exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int, input().split())
S=input()
for i in range(Q):
  l,r=map(int, input().split())
  print(S[l-1:r].count("AC"))

Fixed submission:
N,Q=map(int, input().split())
S=input()
list=[0]*N
#計算量が多いので、さきに文字列のACの数を数えておく。
for i in range(1,N):
  if S[i-1:i+1]=="AC":
    list[i]=list[i-1]+1
  else:
    list[i]=list[i-1]
for i in range(Q):
  l,r=map(int,input().split())
  print(list[r-1]-list[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K=map(int,input().split())
for i in range(A,B+1):
  if i<=A+K-1 or i>=B-K+1:print(i)
  else:A+=0

Fixed submission:
a,b,k=map(int, input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):print(i)
Buggy python submission (verdict: Runtime Error):
n=int(input())
L=[int(input()) for i in range(n)]
print(len(set(A)))

Fixed submission:
n=int(input())
L=[int(input()) for i in range(n)]
print(len(set(L)))
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int, input().split())
count=0
for i in range(0,K+1):
  for j in range(0,K+1):
    for k in range(0,K+1):
      if i+j+k==S:count+=1
print(count)

Fixed submission:
K,S=map(int, input().split())
print(len([1 for x in range(K+1) for y in range(K+1) if 0<=S-x-y<=K]))