Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
dic = {}　#空の辞書を定義
def combinations_count(n,r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0

for k in dic.values():
    ans += combinations_count(k,2)

print(ans)


Fixed submission:
import math
n = int(input())
dic = {}
def combinations_count(n,r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0

for k in dic.values():
    if k >= 2:
        ans += combinations_count(k,2)
    else:
        ans = ans
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
dic = {}　#空の辞書を定義

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0

for k in dic.values():
    cnt = 0
    for i in range(k):
        cnt += i
    ans += cnt
print(ans)


Fixed submission:
import math
n = int(input())
dic = {}
def combinations_count(n,r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0

for k in dic.values():
    if k >= 2:
        ans += combinations_count(k,2)
    else:
        ans = ans
print(ans)
Buggy python submission (verdict: Runtime Error):
l,r = map(int,input().split())

if r - l >= 2018 :
    print(0)
else:
    ans = 2019
    for i in range(l,r-1):
        for j in range(l+1,r)
            ans = min(ans,(i*j)%2019)
    print(ans)


Fixed submission:
l,r = map(int,input().split())

if r - l >= 2018:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%2019)
    print(ans)

Buggy python submission (verdict: Runtime Error):
l,r = map(int,input().split())

if r - l >= 2018 :
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i + 1,r + 1)
            ans = min(ans,(i*j)%2019)
    print(ans)


Fixed submission:
l,r = map(int,input().split())

if r - l >= 2018:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%2019)
    print(ans)

Buggy python submission (verdict: Runtime Error):
l,r = map(int,input().split())

if r - l >= 2018 :
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(l + 1,r + 1)
            ans = min(ans,(i*j)%2019)
    print(ans)


Fixed submission:
l,r = map(int,input().split())

if r - l >= 2018:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%2019)
    print(ans)

Buggy python submission (verdict: Runtime Error):
l,r = map(int,input().split())

for i in range(l,r-1):
    for j in range(l+1,r):
        if i == l and j == l+1:
            ans = (i*j)%2019
        else:
            res = (i*j)%2019
            ans = min(ans,res)
print(ans)


Fixed submission:
l,r = map(int,input().split())

if r - l >= 2018:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%2019)
    print(ans)

Buggy python submission (verdict: Runtime Error):
l,r = map(int,input().split())

for i in range(l,r-1):
    for j in range(l+1,r):
        if i == l and j == l+1:
            ans = (i*j)%2019
        else:
            res = (i*j)%2019
            ans = min(ans,res)
print(ans)


Fixed submission:
l,r = map(int,input().split())

if r - l >= 2018:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%2019)
    print(ans)

Buggy python submission (verdict: Runtime Error):
l,r = map(int,input().split())

for i in range(l,r):
    for j in range(l+1,r):
        if i == l and j == l+1:
            ans = (i*j)%2019
        else:
            res = (i*j)%2019
            ans = min(ans,res)
print(ans)


Fixed submission:
l,r = map(int,input().split())

if r - l >= 2018:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,(i*j)%2019)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
arr_input = list(map(int,input().split()))

arr = sorted(arr_input)

ans = arr[n/2] - arr[n/2-1]

if ans == 0:
    print(0)
else:
    print(ans)


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

arr = sorted(arr_input)
i = int(n/2)

ans = arr[i] - arr[i-1]

if ans == 0:
    print(0)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
arr = list(map(int,input().split()))
chk = 0

for i in range(len(arr)-1):
    if i == 0:
        chk = 0
    else:
        chk = chk + arr[i]

    if chk <= x:
        count =+ 1
    else:
        print(count)
        exit()

 print(count)


Fixed submission:
n,x = map(int,input().split())
arr = list(map(int,input().split()))
chk = 0
cnt = 1
for i in range(len(arr)):
    chk = chk + arr[i]

    if chk <= x:
        cnt += 1
    else:
        print(cnt)
        exit()

print(cnt)
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = input()
if a >= 3200:
  print(S)
else:
  print('red')

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
K = 0
if (A+B)%2 == 0:
  K = (A+B) /2
else:
  K = 'IMPOSSIBLE'
  
print(int(K))


Fixed submission:
A,B = map(int,input().split())
K = 0
if (A+B)%2 == 0:
  K = int((A+B) /2)
else:
  K = 'IMPOSSIBLE'
  
print(K)

Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
K = 0
if (A+B)%2 == 0:
  while abs(A-K) - abs(B-K) != 0:
    K += 1
else:
  K = 'IMPOSSIBLE'
  
print(K)

Fixed submission:
A,B = map(int,input().split())
K = 0
if (A+B)%2 == 0:
  K = int((A+B) /2)
else:
  K = 'IMPOSSIBLE'
  
print(K)
Buggy python submission (verdict: Runtime Error):
T = int(input())
X = int(input())
#世界Bで　X * t = 世界Aで　t ⇒　T = X * t  t = T / X
print(T / X)

Fixed submission:
T,X = map(int,input().split())
#世界Bで　X * t = 世界Aで　t ⇒　T = X * t  t = T / X
print(T/X)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K, Q = map(int, input().split())
A = np.array([0]*Q)
N = np.array([K]*N)


for i in range(Q):
  A[i] = int(input())

for i in range(Q):
  N[A[i]-1] += 1
  N -= 1

for i in range (N.size):
  if N[i] <= 0:
    print('No')
  else:
    print('Yes')
    

Fixed submission:
N,K,Q = map(int,input().split())
score = [0]*N

for i in range(Q):
  score[int(input())-1] += 1

for j in score:
  print('Yes' if Q-j < K else 'No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int, input().split()))

B.sort()
A=[]
A.append([B[0]])

for i in range(N):
    if i>0 && i < N-1 :
        A.append(min(B[i-1],B[i],B[i+1]))
    if i == N-1:
        A.append(B[N-1])
print(sum(A))

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

A=[]
A.append(B[0])
for i in range(0,N-2):
    if i>=1 & i < N-2:
      A.append(min(B[i],B[i+1]))
      
A.append(B[-1])
print(sum(A))
Buggy python submission (verdict: Runtime Error):
N=int(input())
print(N**3

Fixed submission:
N=int(input())
print(N**3)
Buggy python submission (verdict: Runtime Error):
N=int(input())

n=len(str(N))//2
full=0
for i in range(n):
    full+=int('9'+'0'*i*2)

if len(str(N))%2==0:
    b=0
else:
    nines=int('9'*(len(str(N))-1))
    b=N-nines
ans=full+b
print(ans)

Fixed submission:
N=int(input())

n=len(str(N))//2
full=0
for i in range(n):
    full+=int('9'+'0'*i*2)

if len(str(N))%2==0:
    b=0
else:
    times=len(str(N))-1
    if times==0:
        nines=0
    else:
        nines=int('9'*times)
    b=N-nines
ans=full+b
print(ans)
Buggy python submission (verdict: Runtime Error):
7
1 2 3 4 5 6 7

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

cnt=0
for i in range(N):
    if i+1!=p[i]:
        cnt+=1
if cnt==0 or cnt==2:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
if K==1:
    print(0)
else:
    print(N-K

Fixed submission:
N,K=map(int,input().split())
if K==1:
    print(0)
else:
    print(N-K)
Buggy python submission (verdict: Runtime Error):
N=int(input())
W=list(map(int,input().split()))

diff=[]
for i in range(N-1):
    diff.append(abs(sum(W[:i+1])-sum(W[i+1:])))
print(min(diff))

Fixed submission:
A=list(map(int,input().split()))

A=sorted(A)
print(A[0]+A[1])
Buggy python submission (verdict: Runtime Error):
N=int(input())
W=list(map(int,input().split()))

diff=[]
for i in range(N-1):
    diff.append(abs(sum(W[:i+1])-sum(W[i+1:])))
print(min(diff)

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

diff=[]
for i in range(N-1):
    diff.append(abs(sum(W[:i+1])-sum(W[i+1:])))
print(min(diff))
Buggy python submission (verdict: Time Limit Exceeded):
import fractions

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

ans2=0
for i in range(N):
    AA=A[:i]+A[i+1:]
    ans=0
    for j in range(N-1):
        ans=fractions.gcd(ans,AA[j])
    ans2=max(ans,ans2)
    #print(AA,ans,ans2)

print(ans2)

Fixed submission:
import fractions

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

L=[0,A[0]]
R=[0,A[-1]]
for i in range(N-1):
    #l=fractions.gcd(L[i+1],A[i+1])
    #r=fractions.gcd(R[i+1],A[N-i-2])
    L.append(fractions.gcd(L[i+1],A[i+1]))
    R.append(fractions.gcd(R[i+1],A[N-i-2]))
    #print(L[i+1],A[i+1],R[i+1],A[N-i-2])
#print(L)
#print(R)
arr=[]
for i in range(N):
    a=fractions.gcd(L[i],R[N-i-1])
    arr.append(a)
    #print(i,L[i],R[N-i-1],a,arr)
print(max(arr))

Buggy python submission (verdict: Runtime Error):
import math

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

A.sort()
A[1]=A[0]
ans=A[0]
for i in range(N):
    ans=math.gcd(ans,A[i])
print(ans)

Fixed submission:
import fractions

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

L=[0,A[0]]
R=[0,A[-1]]
for i in range(N-1):
    #l=fractions.gcd(L[i+1],A[i+1])
    #r=fractions.gcd(R[i+1],A[N-i-2])
    L.append(fractions.gcd(L[i+1],A[i+1]))
    R.append(fractions.gcd(R[i+1],A[N-i-2]))
    #print(L[i+1],A[i+1],R[i+1],A[N-i-2])
#print(L)
#print(R)
arr=[]
for i in range(N):
    a=fractions.gcd(L[i],R[N-i-1])
    arr.append(a)
    #print(i,L[i],R[N-i-1],a,arr)
print(max(arr))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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

num=0
x=A[0]
for i in range(N):
    x=A[i]
    A[i]=max(A)
    num=max(num,reduce(math.gcd,A))
    A[i]=x
print(num)

Fixed submission:
import fractions

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

L=[0,A[0]]
R=[0,A[-1]]
for i in range(N-1):
    #l=fractions.gcd(L[i+1],A[i+1])
    #r=fractions.gcd(R[i+1],A[N-i-2])
    L.append(fractions.gcd(L[i+1],A[i+1]))
    R.append(fractions.gcd(R[i+1],A[N-i-2]))
    #print(L[i+1],A[i+1],R[i+1],A[N-i-2])
#print(L)
#print(R)
arr=[]
for i in range(N):
    a=fractions.gcd(L[i],R[N-i-1])
    arr.append(a)
    #print(i,L[i],R[N-i-1],a,arr)
print(max(arr))
Buggy python submission (verdict: Runtime Error):
`a=[0]*5
for i in range(5):
    a[i]=int(input().strip())
k=int(input().strip())
d=max(a)-min(a)
if d<=k:
    print("Yay!")
else:
    print(":(")

Fixed submission:
a=[0]*5
for i in range(5):
    a[i]=int(input().strip())
k=int(input().strip())
d=max(a)-min(a)
if d<=k:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=str(input().strip())
arr=[]
for i in range(len(S)-1):
    if S[i]=="A" and S[i+1]=="C":
        arr.append(1)
    else:
        arr.append(0)
arr.append(0)
num=[]
for i in range(Q):
    l,r=map(int,input().split())
    num.append(sum(arr[l-1:r-1]))

for i in num:
    print(i)


Fixed submission:
N,Q=map(int,input().split())
S=str(input())

cnt=0
cntlist=[0]
for i in range(N-1):
    if S[i:i+2]=='AC':
        cnt+=1
    cntlist.append(cnt)
for i in range(Q):
    l,r=map(int,input().split())
    print(cntlist[r-1]-cntlist[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=str(input().strip())
lr=[]
for i in range(Q):
    l,r=map(int,input().split())
    lr.append([l,r])

for i in lr:
    print(S[i[0]-1:i[1]].count("AC"))

Fixed submission:
N,Q=map(int,input().split())
S=str(input())

cnt=0
cntlist=[0]
for i in range(N-1):
    if S[i:i+2]=='AC':
        cnt+=1
    cntlist.append(cnt)
for i in range(Q):
    l,r=map(int,input().split())
    print(cntlist[r-1]-cntlist[l-1])
Buggy python submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())
l=[]
for _ in range(N):
    l.append(int(input()))

def dfs(counter,a,b,c):
    if a==A and b==B and c==C:
            return counter
    ret1=dfs(counter+1,a+l[counter],b,c)+10
    ret2=dfs(counter+1,a,b+l[counter],c)+10
    ret3=dfs(counter+1,a,b,c+l[counter])+10
    ret4=dfs(counter+1,a+1,b,c)+1
    ret5=dfs(counter+1,a,b+1,c)+1
    ret6=dfs(counter+1,a,b,c+1)+1
    return min(ret1,ret2,ret3,ret4,ret5,ret6)

print(dfs(0,0,0,0))

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

def dfs(counter,a,b,c):
    if counter==N:
        #lの中の適当な棒を持った時点から正味スタート
        if a>0 and b>0 and c>0:
            offset=10*3
            return abs(A-a)+abs(B-b)+abs(C-c)-offset
        else:
            #棒を持っていないものは候補外
            return 10**9
    #合成魔法
    #何もしなかった分も含めて、ちょっと足りない、ちょっと長すぎは
    #上のif内で調整
    ret0=dfs(counter+1,a,b,c)
    ret1=dfs(counter+1,a+l[counter],b,c)+10
    ret2=dfs(counter+1,a,b+l[counter],c)+10
    ret3=dfs(counter+1,a,b,c+l[counter])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

while len(set(A))!=1:
#for i in range(2):
    A.sort()
    for i in range(len(A)-1):
        if A.count(0):
            A.remove(0)
            break
        A[i+1]=A[i+1]%A[0]

print(max(A))

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

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

while len(set(A)!=1:
#for i in range(2):
    A.sort()
    for i in range(len(A)-1):
        if A.count(0):
            A.remove(0)
            break
        A[i+1]=A[i+1]%A[0]

print(max(A))

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

while len(set(A))!=1:
#for i in range(2):
    A.sort()
    for i in range(len(A)-1):
        if A.count(0):
            A.remove(0)
            break
        A[i+1]=A[i+1]%A[0]

print(max(A))

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

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

A.sort()
y=A[0]
for i in range(1,N):
    y=gcd(y,A[i])
print(y)

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

while len(A)!=1:
#for i in range(2):
    A.sort()
    for i in range(len(A)-1):
        if A.count(0):
            A.remove(0)
            break
        A[i+1]=A[i+1]%A[0]

print(max(A))

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

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

A.sort()
y=A[0]
for i in range(1,N):
    y=gcd(y,A[i])
print(y)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

while len(A)!=1:
#for i in range(2):
    A.sort()
    if A.count(0):A.remove(0)
    for i in range(len(A)-1):            
        A[i+1]=A[i+1]%A[0]

print(max(A))

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

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

A.sort()
y=A[0]
for i in range(1,N):
    y=gcd(y,A[i])
print(y)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
X=list(map(int,input().split()))

X.sort()
diff=[]
for i in range(M-1):
    diff.append(X[i+1]-X[i])
gap=[]
for i in range(N-1):
    for j in range(M-1):
        x=diff.index(max(diff))
        gap.append(x)
        diff[x]=0
        break
gap.append(M-1)
gap=list(set(gap))
gap.sort()
offset=0
cnt=0
for i in gap:
    cnt+=X[i]-X[offset]
    offset=i+1
print(cnt)

Fixed submission:
N,M=map(int,input().split())
X=list(map(int,input().split()))

X.sort()
diff=[]
for i in range(M-1):
    diff.append(X[i+1]-X[i])
diff.sort()
to=M-N
if to<=0:
    ans=0
else:
    ans=sum(diff[:to])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
h=[]
for i in range(N):
    h.append(int(input()))
h.sort()

mindiff=max(h)-min(h)
for i in range(N-K+1):
    maxmin=max(h[i:i+K])-min(h[i:i+K])
    mindiff=min(mindiff,maxmin)
print(mindiff)


Fixed submission:
N,K=map(int,input().split())
h=[]
for i in range(N):
    h.append(int(input()))
h.sort()

d=max(h)-min(h)
for i in range(N-K+1):
    d=min(d,h[i+K-1]-h[i])
print(d)
Buggy python submission (verdict: Runtime Error):
N=input()

if len(N)<3:
    print(0)
else:
    arr=set([357, 375, 537, 573, 735, 753])
    for i in range(len(N)-3):
        new=set()
        for num in arr:
            for j in range(len(str(num))+1):
                n=str(num)[:j]+'3'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'5'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'7'+str(num)[j:]
                new.add(int(n))
        arr |= new

arr=list(arr)
arr.sort()
cnt=0
for i in range(len(arr)):
    if arr[i]<=int(N):
        cnt+=1
    else:
        break
print(cnt)

Fixed submission:
N=input()

if len(N)<3:
    print(0)
else:
    arr=set([357, 375, 537, 573, 735, 753])
    for i in range(len(N)-3):
        new=set()
        for num in arr:
            for j in range(len(str(num))+1):
                n=str(num)[:j]+'3'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'5'+str(num)[j:]
                new.add(int(n))
                n=str(num)[:j]+'7'+str(num)[j:]
                new.add(int(n))
        arr |= new

    arr=list(arr)
    arr.sort()
    cnt=0
    for i in range(len(arr)):
        if arr[i]<=int(N):
            cnt+=1
        else:
            break
    print(cnt)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
PY=[]
for i in range(M):
    array=list(map(int,input().strip().split()))
    PY.append(array)

PY.sort()
city=0
order=0
for i in range(M):
    newcity=PY[i][0]
    if(newcity!=city):
        city=newcity
        order=1
    strcity=str(PY[i][0])
    strorder=str(order)
    upper='0'*(6-len(strcity))+strcity
    lower='0'*(6-len(strorder))+strorder
    order=order+1
    print(upper+lower)

Fixed submission:
X,Y=map(int,input().split())
print(X+int(Y/2))
Buggy python submission (verdict: Runtime Error):
for i in range(M):
    array=list(map(int,input().strip().split()))
    PY.append(array)

PY.sort()
city=0
order=0
for i in range(M):
    newcity=PY[i][0]
    if(newcity!=city):
        city=newcity
        order=1
    strcity=str(PY[i][0])
    strorder=str(order)
    upper='0'*(6-len(strcity))+strcity
    lower='0'*(6-len(strorder))+strorder
    order=order+1
    print(upper+lower)

Fixed submission:
N,M=map(int,input().split())
birth=[]
for i in range(M):
    p,y=map(int,input().split())
    birth.append([i,p,y])

birth.sort(key=lambda x:(x[1],x[2]))

birth[0].append(0)
cnt=0
for i in range(M-1):
    if birth[i][1]==birth[i+1][1]:
        cnt+=1
    else:
        cnt=0
    birth[i+1].append(cnt)

birth.sort(key=lambda x:x[0])
for i in range(M):
    ans=str(birth[i][1]).zfill(6)+str(birth[i][3]+1).zfill(6)
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X) #len(x)=N+1
x.sort()

def gcd(a,b):
    if b%a==0:
        return a
    else:
        a,b=b%a,a

init=x[0]
x=[i-init for i in x]
d=x[1]
for i in range(N-1):   # 0 2 4 6 10 14   N=5
    d=gcd(d,x[i+2])
print(d)

Fixed submission:
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X) #len(x)=N+1
x.sort()

def gcd(a,b):
    if b%a==0:
        return a
    else:
        return gcd(b%a,a)

init=x[0]
x=[i-init for i in x]
d=x[1]
for i in range(N-1):   # 0 2 4 6 10 14   N=5
    if d==0:
        d=x[i+2]
    else:
        d=gcd(d,x[i+2])
print(d)

Buggy python submission (verdict: Runtime Error):
import math

N,X=map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x.sort()
d=[]
for i in range(N):
    d.append(x[i+1]-x[i])
n=d[0]
for i in range(N-1):
    n=math.gcd(n,d[i+1])
print(n)

Fixed submission:
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X) #len(x)=N+1
x.sort()

def gcd(a,b):
    if b%a==0:
        return a
    else:
        return gcd(b%a,a)

init=x[0]
x=[i-init for i in x]
d=x[1]
for i in range(N-1):   # 0 2 4 6 10 14   N=5
    if d==0:
        d=x[i+2]
    else:
        d=gcd(d,x[i+2])
print(d)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
x=list(map(int,input().split()))

#ゼロに最も近い正負の要素を含むようにK個の配列を舐める
#全部負または全部正(max*min>=0)ならabs(max-min)
#正負またぐ負場合(max*min<0)、
# min(負の絶対値最大*2+正の最大,負の絶対値最大+正の最大*2)

#符号切り替わりサーチ
for i in range(N):
    if x[i]>=0:
        pos_start=i
        break

#K個の配列をスライド
ans=2*(max(x)-min(x))   #ans init. 考えられる最大プラスアルファ?
for i in range(K+1):
    start=pos_start-K+i
    end=pos_start+i
    #print('search start,end ',start,end)
    if start>=0 and end<=N:
        #print('start,end ',start,end)
        obj_arr=x[start:end]
        M=max(obj_arr)
        m=min(obj_arr)
        if M*m>=0:
            ans=min(ans,max(abs(M),abs(m)))
        else:
            ans=min(ans,min(abs(m)*2+M,abs(m)+M*2))
print(ans)


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

# min( 左端に到達し右へ, 右端に到達し左へ)
ans=10**9
for i in range(N-K+1):
    l=abs(x[i])+abs(x[i]-x[i+K-1])
    r=abs(x[i+K-1])+abs(x[i]-x[i+K-1])
    ans=min(ans,min(l,r))
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
num=0
for j in range(1,N+1,2):
  	cnt=0
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
#    print("---")
print(num)


Fixed submission:
A,B=map(int,input().split())
print((A-1)*(B-1))

Buggy python submission (verdict: Runtime Error):
import math

N=int(input())
cnt=0
num=0
for j in range(1,N+2,2):
    for i in range(1,j+1):
#        print(i)
#        print(j)
        if j%i==0 :
            cnt=cnt+1
    if cnt==8 :
#        print(cnt)
        num+=1
    cnt=0
#    print("---")
print(num)

Fixed submission:
A,B=map(int,input().split())
print((A-1)*(B-1))