Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())
a=32
b=0
while x < a**5:
    a=a//2
while a**5 < x:
    a+=1
a-=1
while a**5 - b**5 != x and a**5 + b**5 != x:
    b+=1
if a**5 - b**5 == x:
    print(a,b)
else:
    print(a,b*-1)

Fixed submission:
x = int(input())
for a in range(1001):
    for b in range(1001):
        if (a**5)-(b**5)==x:
            print(a,b)
            exit()
        if (a**5)+(b**5)==x:
            print(a,-1*b)
            exit()
        if (b**5)-(a**5)==x:
            print(-1*a,-1*b)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())
a=0
b=0
while a**5 < x:
    a+=1
a-=1
while a**5 - b**5 != x and a**5 + b**5 != x:
    b+=1
if a**5 - b**5 == x:
    print(a,b)
else:
    print(a,b*-1)

Fixed submission:
x = int(input())
for a in range(1001):
    for b in range(1001):
        if (a**5)-(b**5)==x:
            print(a,b)
            exit()
        if (a**5)+(b**5)==x:
            print(a,-1*b)
            exit()
        if (b**5)-(a**5)==x:
            print(-1*a,-1*b)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N= map(int,input().split())
max_num = 0
N = N%(B+1)+1
a = A/B
for x in range(N):
    n = int(a*x)-(A*int(x/B))
    max_num = max(max_num,n)
print(max_num)

Fixed submission:
A,B,N= map(int,input().split())
max_num = 0
x = min(B-1,N)
print(int((A*x)/B)-(A*int(x/B)))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N= map(int,input().split())
max_num = 0
for x in range(N,0,-1):
    n = int((A*x)/B)-(A*int(x/B))
    max_num = max(max_num,n)
print(max_num)

Fixed submission:
A,B,N= map(int,input().split())
max_num = 0
x = min(B-1,N)
print(int((A*x)/B)-(A*int(x/B)))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
x=0
while int(x//b)==0 and x<=n:
    x+=1
print((int((a*(x-1))//b) - a*(int((x-1)//b))))

Fixed submission:
A,B,N= map(int,input().split())
max_num = 0
x = min(B-1,N)
print(int((A*x)/B)-(A*int(x/B)))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
max=0
x=0
while int(x//b)==0 and x<=n:
    if max < (int((a*x)//b) - a*(int(x//b))):
        max=(int((a*x)//b) - a*(int(x//b)))  
    x+=1
print(max)

Fixed submission:
A,B,N= map(int,input().split())
max_num = 0
x = min(B-1,N)
print(int((A*x)/B)-(A*int(x/B)))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
max=0
for i in range(n,-1,-1):
    if max < (int((a*i)//b) - a*(int(i//b))):
        max=(int((a*i)//b) - a*(int(i//b)))
    if (int((a*i)//b) - a*(int(i//b))) < 0:
        break
print(max)


Fixed submission:
A,B,N= map(int,input().split())
max_num = 0
x = min(B-1,N)
print(int((A*x)/B)-(A*int(x/B)))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd (*numbers):
    return reduce(math.gcd,numbers)
k = int(input())
total = 0

for i in range(1,k+1):
    for j in range(1,k+1):
        for x in range(1,k+1):
            total += gcd(i,j,x)
print(total)

Fixed submission:
import math

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        ab = math.gcd(a,b)
        if ab == 1:
            ans += k

        else:
            for c in range(1,k+1):
                ans += math.gcd(ab,c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math

def combinations_count(n, r): # 組み合わせ nCr
    if n < r or n == 0:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
a = list(map(int,input().split()))
a_set = collections.Counter(a)
b = list(a_set)
total = 0

for v in b: # 全通り
    if 2 <= a_set[v]:
        total += combinations_count(a_set[v],2)

for v in a:
    if a_set[v] < 2:
        print(total)
    else:
        print(total-combinations_count(a_set[v],2)+combinations_count(a_set[v]-1,2))



Fixed submission:
import collections
import math

N = int(input())
a = list(map(int,input().split()))
a_counter = collections.Counter(a)

res = 0

for v in a_counter: # 全通り
    res += a_counter[v]*(a_counter[v]-1)//2

for v in a:
    befor = a_counter[v]*(a_counter[v]-1)//2
    after = (a_counter[v]-1)*(a_counter[v]-2)//2
    print(res-befor+after)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math

def combinations_count(n, r): # 組み合わせ nCr
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
a = list(map(int,input().split()))
a_set = collections.Counter(a)
b = list(a_set)
total = 0

for v in b: # 全通り
    if 2 <= a_set[v]:
        total += combinations_count(a_set[v],2)

max_num = max(a_set.values()) # 最大個数
pair_list = [0]*max_num

for n in range(2,max_num+1): # 個数ごとの組み合わせ数を格納
    pair_list[n-1] = combinations_count(n,2)

for v in a:
    if a_set[v] < 2:
        print(total-pair_list[a_set[v]-1])
    else:
        print(total-pair_list[a_set[v]-1]+pair_list[a_set[v]-2])



Fixed submission:
import collections
import math

N = int(input())
a = list(map(int,input().split()))
a_counter = collections.Counter(a)

res = 0

for v in a_counter: # 全通り
    res += a_counter[v]*(a_counter[v]-1)//2

for v in a:
    befor = a_counter[v]*(a_counter[v]-1)//2
    after = (a_counter[v]-1)*(a_counter[v]-2)//2
    print(res-befor+after)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s1=[input() for x in range(n)]
s2=list(set(s1))
ans_s=[]
max_num=0
for num in s2:
    if max_num < s1.count(num):
        max_num=s1.count(num)
        ans_s.clear()
        ans_s.append(num)
    elif max_num == s1.count(num):
        ans_s.append(num)
ans_s.sort()
[print(x) for x in ans_s]

Fixed submission:
n = int(input())

data = dict()

for i in range(n):
    s = input()
    if s in data:
        data[s] += 1
    else:
        data.setdefault(s,1)
ans = sorted(data.items(),key=lambda x:x[1],reverse=True)
max_num = ans[0][1]
A = []
for item,i in ans:
    if i == max_num:
        A.append(item)
A.sort()

for item in A:
    print(item)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())

a = list(map(int,input().split()))
r_a = 0
ele = K
expected_value = 0
# 範囲の初めの値と範囲外の値を比較
for i in range(K,N+1):
    if r_a < sum(a[i-K:i]):
        r_a = sum(a[i-K:i])
        ele = i
s_ele = ele-K
for n in range(s_ele,ele):
    expected_value += (a[n]*0.5)+0.5
print(expected_value)


Fixed submission:
N,K = map(int,input().split())

a = list(map(int,input().split()))
sum_a = [0]

for i in range(K):
    sum_a[0] += a[i]

j = 0

max_v = sum_a[0]
ele = K-1
expected_value = 0
# 範囲の初めの値と範囲外の値を比較
for i in range(K,N):
    sum_a.append(sum_a[j]+(a[i]-a[i-K]))
    if max_v < sum_a[j+1]:
        max_v = sum_a[j+1]
        ele = i
    j += 1
s_ele = ele+1-K
for n in range(s_ele,ele+1):
    expected_value += (a[n]*0.5)+0.5
print(expected_value)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
if len(h) < k:
    print(0)
else:
    [h.pop(0) for x in range(k)]
    print(sum(h))

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
total = 0
h.sort(reverse=True)
for i in range(k,n):
    total += h[i]
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
a=[]
cnt =0
for i in range(n):
    for j in range(i+1):
        a.append(p[j])
    if min(a) < p[i]:
        cnt += 1
    a.clear() 
print(n-cnt)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
cnt =0
mi=n + 1
for i in range(1,n+1):
    mi = min(mi,p[~-i])
    if mi == p[i-1]:
        cnt+=1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
cnt =0
for i in range(n):
    flg = True
    for j in range(i):
        if p[i] > p[j]:
            flg = False
            break
    if flg:
        cnt += 1
print(cnt)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
cnt =0
mi=n + 1
for i in range(1,n+1):
    mi = min(mi,p[~-i])
    if mi == p[i-1]:
        cnt+=1

print(cnt)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
num = [1]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC'
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
else:
    WA_cnt += 1
print(AC_cnt,WA_cnt)


Fixed submission:
n,m=map(int,input().split())
num = [1]*(n + 1)
pena = [0]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC':
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
            WA_cnt += pena[int(p)]
    else:
        pena[int(p)] += 1
print(AC_cnt,WA_cnt)
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
if K < A:
  print(A - k, B)
elif A <= K and K < (A + B):
  print(0, B - (K - A))
else:
  print(0,0)

Fixed submission:
A,B,K = map(int,input().split())
if K < A:
  print(A - K, B)
elif A <= K and K < (A + B):
  print(0, B - (K - A))
else:
  print(0,0)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
if K < A:
  print(A - k, B)
elif A < K and K < A + B:
  print(0, B - (K - A))
else:
  print(0,0)

Fixed submission:
A,B,K = map(int,input().split())
if K < A:
  print(A - K, B)
elif A <= K and K < (A + B):
  print(0, B - (K - A))
else:
  print(0,0)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
if K < A:
  print(A - k, B)
elif A <= K and K < A + B:
  print(0, B - (K - A))
else:
  print(0,0)

Fixed submission:
A,B,K = map(int,input().split())
if K < A:
  print(A - K, B)
elif A <= K and K < (A + B):
  print(0, B - (K - A))
else:
  print(0,0)
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
if (a < b):
    if b % a == 0:
        print(b)
    else:
        print(b * (a // math.gcd(a, b)))
else:
    if a % b == 0:
        print(a)
    else:
        print(a * (b // math.gcd(a, b)))


Fixed submission:
import fractions
a,b = map(int,input().split())
if (a < b):
    if b % a == 0:
        print(b)
    else:
        print(b * (a // fractions.gcd(a, b)))
else:
    if a % b == 0:
        print(a)
    else:
        print(a * (b // fractions.gcd(a, b)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

for i in range(1,N):
    print(A.index(i) + 1,end=' ')
print(A.index(N) + 1)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
Q = [''] * N
for i in range(N):
    Q[A[i] - 1] = str(i + 1)
print(' '.join(Q))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
out_A = []

for i in range(1,N+1):
    out_A.append(A.index(i) + 1)
for i in range(N-1):
    print(out_A[i],end=' ')
print(out_A[N-1])

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
Q = [''] * N
for i in range(N):
    Q[A[i] - 1] = str(i + 1)
print(' '.join(Q))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

a = list(map(int,input().split()))
res = sum(a)
dis = 0
a.sort(reverse=True)
i = 0
while 0 < M:
    dis += a[0] - a[0]//2
    a[0] //= 2
    M -= 1
    while a[i] < a[i+1] and M != 0:
        a[i+1],a[i] = a[i],a[i+1]
        i += 1
        if len(a) < i:break
    i = 0
print(res-dis-M)


Fixed submission:
import heapq

N,M = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for _ in range(M):
    heapq.heappush(a,((heapq.heappop(a)*(-1))//2)*(-1))
print(abs(sum(a)))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())

a = list(map(int,input().split()))
res = sum(a)
dis = 0
for v in range(M):
    a.sort(reverse=True)
    dis += a[0] - a[0]//2
    a[0] //=2
print(res-dis)


Fixed submission:
import heapq

N,M = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for _ in range(M):
    heapq.heappush(a,((heapq.heappop(a)*(-1))//2)*(-1))
print(abs(sum(a)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

H = list(map(int,input().split()))

c = 0
max_c = 0

for i in range(N-1):
    for j in range(i+1,N):
        if H[i] < H[j]:
            break
        else:
            c += 1
            i += 1
    if max_c < c:
        max_c = c
    c = 0

print(max_c)

Fixed submission:
N = int(input())

H = list(map(int,input().split()))

c = 0
max_c = 0
i = 0

while i < N-1:
    j = i+1
    while j < N:
        if H[i] < H[j]:
            i = j
            break
        else:
            c += 1
            j += 1
            i += 1
    if max_c < c:
        max_c = c
    c = 0

print(max_c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
res = 0
for i in range(1,n):
    res += i%(i+1)
print(res)

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
res = 0
for i in range(1,n):
    res += i
print(res)

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())

s = [''.join(sorted(list(input()))) for x in range(n)]

ans = 0

for i in range(n-1):
    for j in range(i+1,n):
        if s[i] == s[j]:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
s = [''.join(sorted(list(input()))) for x in range(n)]
ans = 0
s_dict = dict()
for v in s:
    if v in s_dict:
      ans += s_dict[v]
      s_dict[v] += 1
    else:
        s_dict[v] = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

H = list(map(int,input().split()))

for i in range(N-1):
    for j in range(i+1,N):
        if H[j] - (H[i]-1) < 0:
            print('No')
            exit()
print('Yes')

Fixed submission:
N = int(input())

H = list(map(int,input().split()))

for i in range(N-1,0,-1):
    if 2 <= H[i-1] - H[i]:
        print('No')
        exit()
    else:
        if (H[i-1] - 1) == H[i]:
            H[i-1] -= 1
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
for K in range(1,max(A,B)+1):
  if abs(A-K) == abs(B-K):
    print(K)
    exit()
print('IMPOSSIBLE')


Fixed submission:
A,B = map(int,input().split())
if ((A+B)/2)-((A+B)//2)==0:
  print(((A+B)//2))
else:
  print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = []

[A.append(int(input())) for x in range(N)]

max_num = 0

for i in range(N):
    for j in range(N):
        if j != i and max_num < A[j]:
            max_num = A[j]
    print(max_num)
    max_num = 0


Fixed submission:
N = int(input())

A = []

[A.append(int(input())) for x in range(N)]

max_num = max(A)
num = A.index(max(A))
A[num] = 0

st_max_num = max(A)

for i in range(num):
    print(max_num)
print(st_max_num)

for i in range(num+1,N):
    print(max_num)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())

j_cnt = 0
i_cnt = 0
i = L
j = L+1
min_num = 2020
while i <= R:
    j = i+1
    while j <= R:
        min_num = min(min_num,((i%2019)*j)%2019)
        if not min_num:
            break
        j += 1
    i += 1
print(min_num)

Fixed submission:
L,R = map(int,input().split())
 
cnt = 0
i = L
j = L+1
min_num = 2020
while i <= R and cnt <= 2019:
    j = i+1
    while j <= R:
        min_num = min(min_num,(i*j)%2019)
        if not min_num:
            break
        j += 1
    i += 1
    cnt += 1
print(min_num)

Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())

j_cnt = 0
i_cnt = 0
i = L
j = L+1
min_num = 2020
while i <= R and i_cnt <= 2019:
    j = i+1
    while j <= R and j_cnt <= 2019:
        min_num = min(min_num,((i%2019)*j)%2019)
        j += 1
        j_cnt += 1
    i += 1
    i_cnt += 1
    j_cnt = 0
print(min_num)

Fixed submission:
L,R = map(int,input().split())
 
cnt = 0
i = L
j = L+1
min_num = 2020
while i <= R and cnt <= 2019:
    j = i+1
    while j <= R:
        min_num = min(min_num,(i*j)%2019)
        if not min_num:
            break
        j += 1
    i += 1
    cnt += 1
print(min_num)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
num = b-a+1
ac = int((a-1)/c)
ad = int((a-1)/d)
bc = int(b/c)
bd = int(b/d)
e = c*d//(math.gcd(c,d))
a = int(a/e)
b = int(b/e)
c = bc-ac
d = bd-ad
e = b-a
print(num-(c+d-e))

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
num = b-a+1
ac = int((a-1)//c)
ad = int((a-1)//d)
bc = int(b//c)
bd = int(b//d)
e = c*d//(fractions.gcd(c,d))
a = int((a-1)//e)
b = int(b//e)
c = bc-ac
d = bd-ad
e = b-a
print(num-(c+d-e))
Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = [0]*(N+1)
x = 0
for i in range(1,N+2):
  D[i] = D[i-1]+L[i-1]
while D[x] <= X:
  x += 1
print(x)

Fixed submission:
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = [0]*(N+1)
x = 0
for i in range(1,N+1):
  D[i] = D[i-1]+L[i-1]
for i in D:
  if i <= X:
    x += 1
print(x)

Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = [0]*(N+1)
x = 0
for i in range(1,N+1):
  D[i] = D[i-1]+L[i-1]
while D[x] <= X:
  x += 1
print(x)

Fixed submission:
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = [0]*(N+1)
x = 0
for i in range(1,N+1):
  D[i] = D[i-1]+L[i-1]
for i in D:
  if i <= X:
    x += 1
print(x)
Buggy python submission (verdict: Runtime Error):
#動的計画法(DP)
#ブログ「けんちょんの競プロ精進記録」参考
#URL: https://drken1215.hatenablog.com/entry/2019/06/10/140000


N,M = map(int,input().split())
MOD = 1000000007
issafe = [True]*N # issafe[v]: v段目が壊れていないかどうか

for _ in range(M):
    i = int(input())
    issafe[i] = False # i 段目は壊れている

#DPテーブル
dp = [0]*(N+1)

#初期条件
dp[0] = 1
if issafe[1]:dp[1] = 1

#ループ
for n in range(2,N+1):
    if issafe[n-1]: dp[n] += dp[n-1]
    if issafe[n-2]: dp[n] += dp[n-2]
    dp[n] %= MOD

print(dp[N])


Fixed submission:
#動的計画法(DP)
#ブログ「けんちょんの競プロ精進記録」参考
#URL: https://drken1215.hatenablog.com/entry/2019/06/10/140000


N,M = map(int,input().split())
MOD = 1000000007
issafe = [True]*(N+1) # issafe[v]: v段目が壊れていないかどうか

for _ in range(M):
    i = int(input())
    issafe[i] = False # i 段目は壊れている

#DPテーブル
dp = [0]*(N+1)

#初期条件
dp[0] = 1
if issafe[1]:dp[1] = 1

#ループ
for n in range(2,N+1):
    if issafe[n-1]: dp[n] += dp[n-1]
    if issafe[n-2]: dp[n] += dp[n-2]
    dp[n] %= MOD

print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

max_L = []
min_R = []

cnt = 0
for i in range(m):
    L,R = map(int,input().split())
    max_L.append(L)
    min_R.append(R)

for i in range(1,n+1):
    if max(max_L) <= i <= min(min_R):
        cnt += 1
print(cnt)

Fixed submission:
n,m = map(int,input().split())

max_L = []
min_R = []

cnt = 0
for i in range(m):
    L,R = map(int,input().split())
    max_L.append(L)
    min_R.append(R)
if max(max_L) <= min(min_R):
    print(min(min_R)-max(max_L)+1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
cnt = 0
num = '1'
    s = input()
    for i in range(len(s)):
        if s[i] == num:
            cnt += 1
        if num == '1':
            num = '0'
        else:
            num = '1'
    print(min(int(len(s)-cnt),cnt))

Fixed submission:
cnt = 0
num = '1'
s = input()
for i in range(len(s)):
    if s[i] == num:
        cnt += 1
    if num == '1':
        num = '0'
    else:
        num = '1'
print(min(int(len(s)-cnt),cnt))
Buggy python submission (verdict: Runtime Error):
N = int(input())
Carry = []
for i in range(5):
    Carry.append(int(input()))
min_num = min(Carry)
if N % min_num == 0:
    print((N//min(max_Carry)))
else:
    print((N//min(max_Carry))+5)

Fixed submission:
N = int(input())
Carry = []
for i in range(5):
    Carry.append(int(input()))
min_num = min(Carry)
if N < min_num:
    print(5)
elif min_num == 1:
    print((N//min_num)+4)
elif N % min_num == 0:
    print((N//min_num))
else:
    print((N//min_num)+5)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())

s = list(input())

ans = 0

for _ in range(Q):
    L,R = map(int,input().split())
    for i in range(L-1,R-1):
        if s[i] == 'A' and s[i+1] == 'C': 
            ans += 1
    print(ans)
    ans = 0

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

flg = True
i = 0
cnt = 0

while flg:
    flg = False
    while i < len(s)-1:
        if s[i]+s[i+1] == '01' or s[i]+s[i+1] == '10':
            s.pop(i)
            s.pop(i)
            flg = True
            cnt += 2
        else:
            i += 1
    i = 0

print(cnt)

Fixed submission:
s = list(input())

print(min(s.count('0'),s.count('1'))*2)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

a = list(map(int,input().split()))

gcd = math.gcd(a[0],a[1])

for i in range(2,N):
    gcd = math.gcd(a[i],gcd)
print(gcd)

Fixed submission:
# 解説確認後

import fractions #val 3.4

N = int(input())

a = list(map(int,input().split()))

gcd = fractions.gcd(a[0],a[1])

for i in range(2,N):
    gcd = fractions.gcd(a[i],gcd)
print(gcd)
Buggy python submission (verdict: Runtime Error):
s = list(map(int,input().split()))

c = [1,,4,7,9]

if s == c:
    print('YES')
else:
    print('NO')

Fixed submission:
s = list(map(int,input().split()))
s.sort()
c = [1,4,7,9]

if s == c:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(int,input().split()))
v_odd = []
v_even = []
for i,v in enumerate(v):
    if i % 2:
        v_even.append(v)
    else:
        v_odd.append(v)
odd_n = len(v_odd)
even_n = len(v_even)
v_odd = collections.Counter(v_odd)
v_odd = sorted(v_odd.items(), key=lambda x:x[1],reverse=True)
v_even = collections.Counter(v_even)
v_even = sorted(v_even.items(), key=lambda x:x[1],reverse=True)

if v_odd[0] == v_even[0]:
    if v_odd[1][1] < v_even[1][1]:
        v_even.pop(0)
    elif v_odd[1][1] > v_even[1][1]:
        v_odd.pop(0)

num = v_odd[0][0]

ans = odd_n-v_odd[0][1]
st = 0
for i,v in v_even:
    if num == i:
        continue
    else:
        st = v
        break
print(ans+(even_n-st))

Fixed submission:
import collections
n = int(input())
v = list(map(int,input().split()))
v_odd = []
v_even = []
for i,v in enumerate(v):
    if i % 2:
        v_even.append(v)
    else:
        v_odd.append(v)
odd_n = len(v_odd)
even_n = len(v_even)
v_odd = collections.Counter(v_odd)
v_odd = sorted(v_odd.items(), key=lambda x:x[1],reverse=True)
v_even = collections.Counter(v_even)
v_even = sorted(v_even.items(), key=lambda x:x[1],reverse=True)

if v_odd[0] == v_even[0] and 2 <= len(v_odd) and 2 <= len(v_even):
    if v_odd[1][1] < v_even[1][1]:
        v_even.pop(0)
    elif v_odd[1][1] > v_even[1][1]:
        v_odd.pop(0)

num = v_odd[0][0]

ans = odd_n-v_odd[0][1]
st = 0
for i,v in v_even:
    if num == i:
        continue
    else:
        st = v
        break
print(ans+(even_n-st))
Buggy python submission (verdict: Runtime Error):
import math
N,X = map(int,input().split())

x = list(map(int,input().split()))
st = []
x.append(X)

x.sort()

gcd = x[0]

for i in range(N):
    gcd = math.gcd(gcd,x[i+1]-x[i])
    st.append(x[i+1]-x[i])
st.sort()
for v in st:
    if not v % gcd:
        print(v)
        break


Fixed submission:
import fractions
N,X = map(int,input().split())

x = list(map(int,input().split()))
st = []
x.append(X)

x.sort()

gcd = 0

for i in range(N):
    if i == 0:
        gcd = x[i+1]-x[i]
    else:
        gcd = fractions.gcd(gcd,x[i+1]-x[i])
    st.append(x[i+1]-x[i])
print(gcd)