Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
import numpy as np
def seachPrimeNum(N):
  max_ = int(np.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  if len(seachList) == 0:
    return 0
  while seachList[0] <= max_:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

p_list = []
max_n = max(A,B)
min_n = min(A,B)
list_ = seachPrimeNum(min_n)
if list_ == 0:
  print(1)
else:
  for i in list_:
    if A%i == 0 and B%i == 0:
      p_list.append(i)
  print(len(p_list)+1)
    

  

Fixed submission:
import fractions
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])


    return arr

A,B = map(int,input().split())
print(len(factorization(fractions.gcd(A,B)))+1)

Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
def cf(x1,x2):
  cf=[]
  for i in range(2,min(x1,x2)+1):
    if x1 % i == 0 and x2 % i == 0:
      cf.append(i)
  return cf

cf_list = cf(A,B)
p = []
for num in cf_list:
  for n in range(2,num):
    if num%n == 0:
      break
  else:
    p.append(num)
print(len(p)+1)

  

Fixed submission:
import fractions
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])


    return arr

A,B = map(int,input().split())
print(len(factorization(fractions.gcd(A,B)))+1)
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]

for i in range(1,N+1):
  plus = A.count(i)
  if K - (Q-plus) <= 0:
    print("No")
  else:
    print("Yes")



Fixed submission:
N,K,Q = map(int,input().split())
minas = [-Q]*N
A = [int(input()) for _ in range(Q)]
for i in A:
  minas[i-1] += 1
  
for i in minas:
  if  K + i<= 0:
    print("No")
  else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
mod = 0
if N == 1:
  print(0)
else:
  print(sum(range(2,N))+1)
  

Fixed submission:
N = int(input())
mod = 0
if N == 1:
  print(0)
else:
  print(N+N*(N-1)//2-N)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
mod = 0
if N == 1:
  print(0)
else:
  for i in range(1,N+1):
    if i == 1:
      mod += 1
    elif i == N:
      mod += 0
    else:
      mod += i
  print(mod)
  

Fixed submission:
N = int(input())
mod = 0
if N == 1:
  print(0)
else:
  print(N+N*(N-1)//2-N)
Buggy python submission (verdict: Runtime Error):
MOD = 10**9 + 7

N,K = map(int,input().split())
A = list(map(int,input().split()))
B = A*2
d = []

for i in range(N*2):
  num = B[i]
  target = B[i+1:]
  d.append(len([n for n in target if num > n]))
  
d_each = sum(d[:N]) - sum(d[N:])
first = sum(d[N:])
print(int( K/2*((2*first)+((K-1)*d_each)) )%MOD)


Fixed submission:
M,D = map(int,input().split())
count = 0
for m in range(1,M+1):
  for d in range(20,D+1):
    d_10 = d//10
    d_1 = d-10*d_10
    if d_10>=2 and d_1>=2 and d_10*d_1 == m:
      count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
  target = A[0:i] + A[i+1:N]
  print(max(target))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

max_num = max(A)
max_ind = A.index(max(A))
for i in range(N):
  if max_ind == i:
    print(max(A[0:i]+A[i+1:N]))
  else:
    print(max_num)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
if N == 1:
  print(1)
else:
  d = defaultdict(int)
  for i in range(N):
    xi,yi = xy[i]
    for j in range(N):
      if i==j:
        continue
      else:
        xj,yj = xy[j]
      d[(xj-xi,yj-yi)] += 1
max_v = max(d.values())
print(N-max_v)



Fixed submission:
from collections import defaultdict

N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
if N == 1:
  print(1)
else:
  d = defaultdict(int)
  for i in range(N):
    xi,yi = xy[i]
    for j in range(N):
      if i==j:
        continue
      else:
        xj,yj = xy[j]
      d[(xj-xi,yj-yi)] += 1
  max_v = max(d.values())
  print(N-max_v)
Buggy python submission (verdict: Runtime Error):
import math
N,M = map(int,input().split())
a = []
flg = False

for i in range(M):
  a_ = int(input())
  a.append(a_)
  if a_ - a[i-1] == 1:
    flg = True

if flg == True:
  print(0)
else:
  before = 0
  ans = 1
  for i in a:
    step = i-before
    two = (step-1)//2
    p = 0
    if two < 1:
      p = 1
    else:
      for j in range(1,two+1):
        p += math.factorial(step-1-j)/math.factorial(j)/math.factorial(step-1-j-j)
      p += 1
      ans = ans * p
      ans = ans % 1000000007
      before = i
  step = N-before
  two = (step-1)//2
  p = 0
  if two < 1:
    p = 1
  else:
    for j in range(1,two+1):
      p += math.factorial(step-1-j)/math.factorial(j)/math.factorial(step-1-j-j)
    p += 1
  ans = ans * p
  ans = ans % 1000000007
  print(int(ans))
    
       
      

Fixed submission:
N,M = map(int,input().split())
num = 1000000007

hole = [False]*(N+1)
a = [int(input()) for _ in range(M)]
for i in a:
  hole[i] = True
  
dp = [0]*(N+1)
dp[0] = 1


for i in range(1,N+1):
  if i == 1:
    if hole[i] == True:
      dp[i] = 0
    else:
      dp[i] = dp[0]
  else:
    if hole[i] == True:
      dp[i] = 0
    else:
      dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%num)
Buggy python submission (verdict: Runtime Error):
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(N//R+1):
  for g in range((N-R*r)//G+1):
    if (N-R*r-G*g)%B == 0:
      cnt += 1
print(cnt)



Fixed submission:
N,K = map(int,input().split())
print(N-K+1)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
count = 0
for r in range(N//R+1):
  for g in range((N-r*R)//G+1):
    b = (N-R*r-G*g)/B
    if b.is_integer() and b >= 0:
      count += 1
print(count)



Fixed submission:
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(N//R+1):
  for g in range((N-R*r)//G+1):
    if (N-R*r-G*g)%B == 0:
      cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
count = 0
for r in range(N//R+1):
  for g in range((N-R*r)//G+1):
    if (N-R*r-G*g)%B == 0 and (N-R*r-G*g) > -1:
      count += 1
print(count)



Fixed submission:
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(N//R+1):
  for g in range((N-R*r)//G+1):
    if (N-R*r-G*g)%B == 0:
      cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
count = 0
for r in range(N//R+1):
  for g in range(N//G+1):
    if (N-R*r-G*g)%B == 0 and (N-R*r-G*g) > -1:
      count += 1
print(count)



Fixed submission:
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(N//R+1):
  for g in range((N-R*r)//G+1):
    if (N-R*r-G*g)%B == 0:
      cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for _ in range(q)]

for l,r in lr:
  print(s[l-1:r].count("AC"))
  

Fixed submission:
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)

for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]


for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*N
for i in range(N-1):
  if S[i] == 'A' and S[i+1] == 'C':
    ac_list[i] = 'a'
#print(ac_list)
for i in range(Q):
  print(ac_list[point[i][0]-1:point[i][1]-1].count('a'))



Fixed submission:
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)

for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]


for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
  target = S[point[i][0]-1:point[i][1]]
  print(target.count('AC'))



Fixed submission:
N,Q = map(int,input().split())
S = input()
point = [list(map(int,input().split())) for i in range(Q)]
ac_list = [0]*(N+1)

for i in range(N):
  if S[i:i+2] == 'AC':
    ac_list[i+1] = ac_list[i] + 1
  else:
    ac_list[i+1] = ac_list[i]


for i in range(Q):
  print(ac_list[point[i][1]-1] - ac_list[point[i][0]-1])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)

for i in range(int(len(S)/2)):
  zero_i = S.find("01")
  one_i = S.find("10")
  if zero_i > -1:
    S = S[:zero_i] + S[zero_i+2:]
  elif one_i > -1:
    S = S[:one_i] + S[one_i+2:]
  else:
    break

print(N - len(S))

Fixed submission:
S = list(input())
print(min(S.count('0'),S.count("1"))*2)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = np.zeros(N)
  
for i in range(N):
  if i < K:
    dp[i] = abs(h[0]-h[i])
  else:
    cost = [dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,K+1)]
    dp[i] = min(cost)
print(int(dp[N-1]))

Fixed submission:
import numpy as np
import sys
sys.setrecursionlimit(10**6)

N = int(input())
h = list(map(int,input().split()))

memo = np.zeros(N) - 1

def search(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(h[i] - h[i-1])
  if memo[i] != -1:
    return memo[i]
  
  c1 = search(i-1) + abs(h[i]-h[i-1])
  c2 = search(i-2) + abs(h[i]-h[i-2])
  memo[i] = min(c1,c2)
  return min(c1,c2)

print(int(search(N-1)))

Buggy python submission (verdict: Runtime Error):
import numpy as np

N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = np.zeros(N)
  
for i in range(N):
  if i < K:
    dp[i] = abs(h[0]-h[i])
  else:
    cost = [dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,K+1)]
    dp[i] = min(cost)
print(int(dp[N-1]))

Fixed submission:
import numpy as np
import sys
sys.setrecursionlimit(10**6)

N = int(input())
h = list(map(int,input().split()))

memo = np.zeros(N) - 1

def search(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(h[i] - h[i-1])
  if memo[i] != -1:
    return memo[i]
  
  c1 = search(i-1) + abs(h[i]-h[i-1])
  c2 = search(i-2) + abs(h[i]-h[i-2])
  memo[i] = min(c1,c2)
  return min(c1,c2)

print(int(search(N-1)))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
h = list(map(int,input().split()))

memo = np.zeros(N) - 1

def search(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(h[i] - h[i-1])
  if memo[i] != -1:
    return memo[i]
  
  c1 = search(i-1) + abs(h[i]-h[i-1])
  c2 = search(i-2) + abs(h[i]-h[i-2])
  memo[i] = min(c1,c2)
  return min(c1,c2)

print(int(search(N-1)))

Fixed submission:
import numpy as np
import sys
sys.setrecursionlimit(10**6)

N = int(input())
h = list(map(int,input().split()))

memo = np.zeros(N) - 1

def search(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(h[i] - h[i-1])
  if memo[i] != -1:
    return memo[i]
  
  c1 = search(i-1) + abs(h[i]-h[i-1])
  c2 = search(i-2) + abs(h[i]-h[i-2])
  memo[i] = min(c1,c2)
  return min(c1,c2)

print(int(search(N-1)))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
h = list(map(int,input().split()))

memo = np.zeros(N) - 1
memo[0] = 0
memo[1] = abs(h[1] - h[0])

def search(i):
  if memo[i] != -1:
    return memo[i]
  
  c1 = search(i-1) + abs(h[i]-h[i-1])
  c2 = search(i-2) + abs(h[i]-h[i-2])
  memo[i] = min(c1,c2)
  return min(c1,c2)

print(int(search(N-1)))

Fixed submission:
import numpy as np
import sys
sys.setrecursionlimit(10**6)

N = int(input())
h = list(map(int,input().split()))

memo = np.zeros(N) - 1

def search(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(h[i] - h[i-1])
  if memo[i] != -1:
    return memo[i]
  
  c1 = search(i-1) + abs(h[i]-h[i-1])
  c2 = search(i-2) + abs(h[i]-h[i-2])
  memo[i] = min(c1,c2)
  return min(c1,c2)

print(int(search(N-1)))
Buggy python submission (verdict: Runtime Error):
import numpy as np

N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp = np.zeros(N,dtype=int)
  
for i in range(N):
  if i <= K:
    dp[i] = abs(h[0]-h[i])
  else:
    cost = min(dp[i-K:i]+abs(h[i]-h[i-K:i]))
    dp[i] = cost
print(dp[N-1])

Fixed submission:
import numpy as np

N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp = np.zeros(N,dtype=int)
  
for i in range(N):
  if i <= K:
    dp[i] = abs(h[0]-h[i])
  else:
    cost = min(dp[i-K:i]+abs(h[i]-h[i-K:i]))
    dp[i] = cost
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = np.zeros(N)
#print(h)
  
for i in range(N):
  if i < K:
    dp[i] = abs(h[0]-h[i])
  else:  
    cost = [dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,K+1)]
    dp[i] = min(cost)
    #print(cost)
  #print(dp)
print(int(dp[N-1]))

Fixed submission:
import numpy as np

N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp = np.zeros(N,dtype=int)
  
for i in range(N):
  if i <= K:
    dp[i] = abs(h[0]-h[i])
  else:
    cost = min(dp[i-K:i]+abs(h[i]-h[i-K:i]))
    dp[i] = cost
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache
@lru_cache(maxsize=3000)
def burger(str_b,level):
  if(level == 0):
    return str_b + 'p'
  str_b += 'B'
  str_b = burger(str_b,level-1)
  str_b += 'p'
  str_b = burger(str_b,level-1)
  str_b += 'B'
  return str_b


str_b = ''
N,X = map(int,input().split())
str_b = burger(str_b,N)
b_list = list(str_b)
eat_list = b_list[::-1]
eat_list = b_list[0:X]
print(eat_list.count('p'))

Fixed submission:
n,x = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(2*a[i]+3)
  p.append(2*p[i]+1)

def f(N,X):
  if N==0:
    return 0 if X<=0 else 1
  elif X <= 1+a[N-1]:
    return f(N-1,X-1)
  else:
    return p[N-1]+1+f(N-1,X-2-a[N-1])
print(f(n,x))

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
#@lru_cache(maxsize=3000)
@memoize
def burger(str_b,level):
  if(level == 0):
    return str_b + 'p'
  str_b += 'B'
  str_b = burger(str_b,level-1)
  str_b += 'p'
  str_b = burger(str_b,level-1)
  str_b += 'B'
  return str_b


str_b = ''
N,X = map(int,input().split())
str_b = burger(str_b,N)
b_list = list(str_b)
eat_list = b_list[::-1]
eat_list = b_list[0:X]
print(eat_list.count('p'))

Fixed submission:
n,x = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(2*a[i]+3)
  p.append(2*p[i]+1)

def f(N,X):
  if N==0:
    return 0 if X<=0 else 1
  elif X <= 1+a[N-1]:
    return f(N-1,X-1)
  else:
    return p[N-1]+1+f(N-1,X-2-a[N-1])
print(f(n,x))
Buggy python submission (verdict: Runtime Error):
import itertools
def calc_num(S,S_len):
  result = 0;
  l = [3,5,7];
  i = 3;
  while i <= S_len
  	for v in itertools.product(l,repeat=i):
      if int("".join(map(str,v))) <= S and list(srt(v) & set(l)) == l;
        result = result + 1;
    i = i + 1;
  return result
  
S = list(map(int,input()))
S_len = len(S)
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

Fixed submission:
import itertools
def calc_num(S,S_len):
  result = 0;
  l = [3,5,7];
  i = 3;
  while i <= S_len:
    for v in itertools.product(l,repeat=i):
      if int("".join(map(str,v))) <= S and list(set(v) & set(l)) == l:
        result = result + 1;
    i = i + 1;
  return result
  
S = list(map(int,input()));
S_len = len(S);
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

Buggy python submission (verdict: Runtime Error):
import itertools
def calc_num(S,S_len):
  result = 0;
  l = [3,5,7];
  i = 3;
  while i <= S_len
  	for v in itertools.product(l,repeat=i):
   		if int("".join(map(str,v))) <= S and list(srt(v) & set(l)) == l;
        	result = result + 1;
    i = i + 1;
  return result
  
S = list(map(int,input()))
S_len = len(S)
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

Fixed submission:
import itertools
def calc_num(S,S_len):
  result = 0;
  l = [3,5,7];
  i = 3;
  while i <= S_len:
    for v in itertools.product(l,repeat=i):
      if int("".join(map(str,v))) <= S and list(set(v) & set(l)) == l:
        result = result + 1;
    i = i + 1;
  return result
  
S = list(map(int,input()));
S_len = len(S);
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

Buggy python submission (verdict: Runtime Error):
import itertools
def calc_num(S,S_len):
  	result = 0;
    l = [3,5,7];
    i = 3;
    while i <= S_len
    	for v in itertools.product(l,repeat=i):
        	if int("".join(map(str,v))) <= S and list(srt(v) & set(l)) == l;
          		result = result + 1;
        i = i + 1;
    return result
  
S = list(map(int,input()))
S_len = len(S)
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)

Fixed submission:
import itertools
def calc_num(S,S_len):
  result = 0;
  l = [3,5,7];
  i = 3;
  while i <= S_len:
    for v in itertools.product(l,repeat=i):
      if int("".join(map(str,v))) <= S and list(set(v) & set(l)) == l:
        result = result + 1;
    i = i + 1;
  return result
  
S = list(map(int,input()));
S_len = len(S);
S = int("".join(map(str, S)));
result = calc_num(S,S_len);
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N,M = map(int,input().split())
p_list = []
y_list = []
for i in range(M):
  p,y = map(int,input().split())
  p_list.append(p)
  y_list.append(y)
p_list_sorted = []
y_list_sorted = []
  
  

for i in range(max(p_list)):
  y_tmp = []
  for j in range(M):
    if i+1 == p_list[j]:
      p_list_sorted.append(i+1)
      y_tmp.append(y_list[j])
  y_tmp.sort()
  for k in range(len(y_tmp)):
    y_list_sorted.append(y_tmp[k])
    
for i in range(M):
  N = p_list.count(p_list[i])
  ind = p_list_sorted.index(p_list[i])
  for j in range(N):
    if y_list[i] == y_list_sorted[j+ind]:
      y = str(j+1).zfill(6)
      break
  p = str(p_list[i]).zfill(6)
  print(p+y)
    
  

Fixed submission:
N, M = map(int,input().split())
PY = [list(map(int,input().split())) + [0] for _ in range(M)]
sort_PY = sorted(PY, key = lambda x: x[1])

city = {}
for i in range(M):
  p, y = sort_PY[i][0], sort_PY[i][1]
  if p in city:
    city[p] += 1
  else:
    city[p] = 1
  sort_PY[i][2] = city[p]
for p, y, z in PY:
  print(str(p).zfill(6)+str(z).zfill(6))
Buggy python submission (verdict: Runtime Error):
N = int(input())
num_list = [111*i for i in range(1,10)]
nums = [num_list[i]-N for i in range(len(num_list)) if num_list[i]-N > 0]
n = min(nums)
print(N+n) 

Fixed submission:
N = int(input())
num_list = [111*i for i in range(1,10)]
nums = [num_list[i]-N for i in range(len(num_list)) if num_list[i]-N >= 0]
n = min(nums)
print(N+n)
Buggy python submission (verdict: Runtime Error):
S = list(input())
if 'C' in S[2:-1]:
    Cj = True
else:
    Cj = False

if S[0] == 'A':
    Aj = True
else:
    Aj = false

Supper = [s for s in S if s.isupper()]
if Supper == ['A','C']:
    SupperJ = True
else:
    SupperJ = False

if(Cj and Aj and SupperJ):
        print("AC")
else:
    print("WA")

Fixed submission:
S = input()
count = 0
if( S[0] == 'A' and S[2:-1].count('C') == 1):
    for i in range(len(S)):
        if S[i].isupper():
            count += 1
            if count == 3:
                print("WA")
                exit()
    print("AC")
else:
    print("WA")

Buggy python submission (verdict: Runtime Error):
S = list(input())
if(S[0]=='A' and 'C' in S[2:-1]):
    del S[0]
    S[2:-1].remove('C')
    if [s for s in S if s.isupper()] == []:
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Fixed submission:
S = input()
count = 0
if( S[0] == 'A' and S[2:-1].count('C') == 1):
    for i in range(len(S)):
        if S[i].isupper():
            count += 1
            if count == 3:
                print("WA")
                exit()
    print("AC")
else:
    print("WA")
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
c = 1
for b in range(1,X):
  for p in range(2,X):
    if b**p <= X: c=max(c,b**p)
print(c)

Fixed submission:
X = int(input())
max_n = 1
for i in range(2,32):
  for j in range(2,10):
    tmp = i**j
    if X >= tmp and max_n < tmp:
      max_n = tmp
print(max_n)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
c = 1
for b in range(1,X+1):
  for p in range(2,X+1):
    if b**p <= X: c=max(c,b**p)
print(c)

Fixed submission:
X = int(input())
max_n = 1
for i in range(2,32):
  for j in range(2,10):
    tmp = i**j
    if X >= tmp and max_n < tmp:
      max_n = tmp
print(max_n)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
max_n = 1
for i in range(2,X+1):
  for j in range(2,X+1):
    tmp = i**j
    if X >= tmp and max_n < tmp:
      max_n = tmp
print(max_n)

Fixed submission:
X = int(input())
max_n = 1
for i in range(2,32):
  for j in range(2,10):
    tmp = i**j
    if X >= tmp and max_n < tmp:
      max_n = tmp
print(max_n)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [list("."+input()+".") for _ in range(w)]
s=["."*(w+2)]+s+["."*(w+2)]
flg = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
        flg = 0
print("Yes" if flg == 0 else "No")
    

Fixed submission:
h,w = map(int,input().split())
s = [list("."+input()+".") for _ in range(h)]
s=["."*(w+2)]+s+["."*(w+2)]
flg = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
        flg = 1
print("Yes" if flg == 0 else "No")

Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [list("."+input()+".") for _ in range(w)]
s=["."*(w+2)]+s+["."*(w+2)]
flg = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      if s[i-1][j]=="#" or s[i+1][j]=="#" or s[i][j-1]=="#" or s[i][j+1]=="#":
        flg = 0
      else:
        flg = 1
print("Yes" if flg == 0 else "No")
    

Fixed submission:
h,w = map(int,input().split())
s = [list("."+input()+".") for _ in range(h)]
s=["."*(w+2)]+s+["."*(w+2)]
flg = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
        flg = 1
print("Yes" if flg == 0 else "No")

Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [list(input()) for _ in range(w)]

def search(i,j):
  flg = False
  if 0<=i-1:
    if s[i-1][j] == "#":
      flg = True
  if i+1 < h:
    if s[i+1][j] == "#":
      flg = True 
  if 0<=j-1:
    if s[i][j-1] == "#":
      flg = True
  if j+1 < w:
    if s[i][j+1] == "#":
      flg = True
  return flg
  
for i in range(h):
  for j in range(w):
    if s[i][j]=="#" and search(i,j)==False:
      print("No")
      break
  else:
    continue
  break
else:
  print("Yes")
    

Fixed submission:
h,w = map(int,input().split())
s = [list("."+input()+".") for _ in range(h)]
s=["."*(w+2)]+s+["."*(w+2)]
flg = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
        flg = 1
print("Yes" if flg == 0 else "No")