Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):


import sys
def 解():
    iN,iM = [int(_) for _ in input().split()]
    d1 = set()
    dN = set()
    for _ in range(iM):
        a,b = [int(_) for _ in sys.stdin.readline().split()]
        if a == 1 :
            d1.add(b)
        if b == iN:
            dN.add(a)
        if d1 & dN :
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")
解()


Fixed submission:
import sys
def 解():
    iN,iM = [int(_) for _ in input().split()]
    aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
    dT = {}
    def addTree(dT,a,b):
        if a in dT:
            dT[a].add(b)
        else:
            dT[a] = {b}
    for a,b in aAB:
        addTree(dT,a,b)
        addTree(dT,b,a)
    if  1 not in dT or iN  not in dT:
        print("IMPOSSIBLE")
    elif 0 < len(dT[1] & dT[iN]) :
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
解()
Buggy python submission (verdict: Runtime Error):

import sys
iN = int(input())
aA = [int(_) for _ in input().split()]

aCol = [0]*(4800//400)
for a in aA:
    aCol[a//400] += 1
iMin = 0
for i in range(8):
    if aCol[i]:
        iMin += 1
iMax = iMin + sum(aCol[8:])
print(iMin,iMax)


Fixed submission:
import sys
iN = int(input())
aA = [int(_)//400 for _ in input().split()]

aCol = [0]*(4800//400 +1)
for a in aA:
    aCol[a] += 1
iMin = 0
for i in range(8):
    if aCol[i]:
        iMin += 1
iMax = iMin + sum(aCol[8:])
if iMin == 0:
    iMin = 1
print(iMin,iMax)
Buggy python submission (verdict: Runtime Error):
def 解()
    iN = int(input())
    aA = [int(_) for _ in input().split()]
    iL = len(aA)


    iStart = 0
    if sum(aA[0::2]) < sum(aA[2::2]):
        iStart = 1


    iC = 0
    aD = [0]*iL
    if 0 % 2 == iStart :
        if aA[0] < 0:
            aA[0] = 1
            iC += -1 * aA[0] + 1
    else:
        if 0 < aA[0] :
            aA[0] = -1
            iC += aA[0] + 1

    aD[0] = aA[0]
    for i in range(1,iL):
        aD[i] = aD[i-1]+aA[i]
        if i % 2 == iStart:
            if aD[i] <= 0:
                iC += -1*aD[i] +1
                aD[i] = 1
        else:
            if aD[i] >= 0:
                iC += aD[i] +1
                aD[i] = -1
    print(iC)
解()


Fixed submission:
#結局これもパターン全列挙(2パターン)か。
#判別しようと無駄な努力をしてしまった。
def 解():
    iN = int(input())
    aA = [int(_) for _ in input().split()]
    def buildDiff(bF):
        iC = 0
        iS = 0
        for a in aA:
            iS += a
            if bF:
                if iS >= 0:
                    iC += iS + 1
                    iS = -1
                bF = 0
            else:
                if iS <= 0:
                    iC += -1 * iS + 1
                    iS = 1
                bF = 1
        return iC
    print(min(buildDiff(1),buildDiff(0)))
解()
Buggy python submission (verdict: Runtime Error):
def 解():
    iN = int(input())
    iD = 10**9 + 7


    if iN < 3:
        print(iN)
        exit()

    d素={2:1}
    for i in range(2,iN + 1):
        b素 = 1
        for j in range(2,int(i**0.5)+2):
            if i % j == 0:
                b素 = 0
                break
        if b素 :
            d素[i]=1
    for i in range(2,iN+1):
        for i素 in d素:
            while i % i素 == 0:
                d素[i素]+=1
                i //= i素
           if i == 0:
                break
    iAns = 1
    for i素,num in d素.items():
        iAns *= num
        iAns %= iD
    print(iAns)
解()


Fixed submission:

def 解():
    iN = int(input())
    iD = 10**9 + 7


    if iN < 3:
        print(iN)
        exit()

    d素={2:1}
    for i in range(2,iN + 1):
        b素 = 1
        for j in range(2,int(i**0.5)+2):
            if i % j == 0:
                b素 = 0
                break
        if b素 :
            d素[i]=1
    for i in range(2,iN+1):
        for i素 in d素:
            while i % i素 == 0:
                d素[i素]+=1
                i //= i素
    iAns = 1
    for i素,num in d素.items():
        iAns *= num
        iAns %= iD
    print(iAns)
解()
Buggy python submission (verdict: Time Limit Exceeded):
iN,iT = [int(_) for _ in input().split()]
aA = [int(_) for _ in input().split()]
iL = len(aA)

aMaxD = [0]
aMin=[aA[0]]
iV = 0

def checkMax(aMaxD,aMin,iB):
    iMaxD = 0
    for iMin in aMin:
        iMaxD = max(iMaxD,iB - iMin)
    if aMaxD[0] < iMaxD:
        aMaxD = [iMaxD]
    elif aMaxD[0] == iMaxD:
        aMaxD.append(iMaxD)
    return aMaxD

for i in range(1,iL):
    iB = aA[i-1]
    iN = aA[i]
    if iB - iN > 0:
        if iV >= 0:
            aMaxD = checkMax(aMaxD,aMin,iB)
        iV = -1
    elif iB - iN < 0:
        if iV <= 0:
            aMin.append(iB)
        if i == iL -1 :
            aMaxD = checkMax(aMaxD,aMin,iN)
        iV = 1
print( len(aMaxD) )


Fixed submission:

iN,iT = [int(_) for _ in input().split()]
aA = [int(_) for _ in input().split()]
iL = len(aA)

aMaxD = [0]
iMin = aA[0]
iV = 0

def checkMax(aMaxD,iMaxD):
    if aMaxD[0] < iMaxD:
        aMaxD = [iMaxD]
    elif aMaxD[0] == iMaxD:
        aMaxD.append(iMaxD)
    return aMaxD

for i in range(1,iL):
    iB = aA[i-1]
    iN = aA[i]
    if iB - iN > 0:
        if iV >= 0:
            aMaxD = checkMax(aMaxD,iB-iMin)
        iV = -1
    elif iB - iN < 0:
        if iV <= 0:
            iMin = min(iB,iMin)
        iV = 1
aMaxD = checkMax(aMaxD,aA[-1] - iMin)
print( len(aMaxD) )

Buggy python submission (verdict: Time Limit Exceeded):
iN,iT = [int(_) for _ in input().split()]
aA = [int(_) for _ in input().split()]
iL = len(aA)

aMaxD = [0]
aMin=[aA[0]]
iV = 0

def checkMax(aMaxD,aMin,iB):
    iMaxD = 0
    for iMin in aMin:
        iMaxD = max(iMaxD,iB - iMin)
    if aMaxD[0] < iMaxD:
        aMaxD = [iMaxD]
    elif aMaxD[0] == iMaxD:
        aMaxD.append(iMaxD)
    return aMaxD

for i in range(1,iL):
    iB = aA[i-1]
    iN = aA[i]
    if iB - iN > 0:
        if iV >= 0:
            aMaxD = checkMax(aMaxD,aMin,iB)
        iV = -1
    elif iB - iN < 0:
        if iV <= 0:
            aMin.append(iB)
        if i == iL -1 :
            aMaxD = checkMax(aMaxD,aMin,iN)
        iV = 1
print( len(aMaxD) )


Fixed submission:

iN,iT = [int(_) for _ in input().split()]
aA = [int(_) for _ in input().split()]
iL = len(aA)

aMaxD = [0]
iMin = aA[0]
iV = 0

def checkMax(aMaxD,iMaxD):
    if aMaxD[0] < iMaxD:
        aMaxD = [iMaxD]
    elif aMaxD[0] == iMaxD:
        aMaxD.append(iMaxD)
    return aMaxD

for i in range(1,iL):
    iB = aA[i-1]
    iN = aA[i]
    if iB - iN > 0:
        if iV >= 0:
            aMaxD = checkMax(aMaxD,iB-iMin)
        iV = -1
    elif iB - iN < 0:
        if iV <= 0:
            iMin = min(iB,iMin)
        iV = 1
aMaxD = checkMax(aMaxD,aA[-1] - iMin)
print( len(aMaxD) )
Buggy python submission (verdict: Runtime Error):
import sys
def 解()
    iH,iW,iN = [int(_) for _ in input().split()]
    aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

    iMax = (iH - 2) * (iW -2)
    #print (iMax)

    dC={}
    for i in range(10):
        dC[i]=0

    #愚直 無理 つらい
    #for i in range(1,iH -1):
    #   for j in range(1,iW-1):
    #       tmp = 0
    #       for a in aD:
    #           if j<= a[1] <=j+2 and i<= a[0] <= i+2:
    #               tmp +=1
    #       dC[tmp] +=1

    #なんというか、面倒くさくなって解法みても
    #面倒くさがらずやれとしか書いてなくてつらい
    dM = {}
    for a in aD:
        y=a[0]
        x=a[1]
        for aP in [(y-2,x-2),(y-2,x-1),(y-2,x),(y-1,x-2),(y-1,x-1),(y-1,x),(y,x-2),(y,x-1),(y,x)]:
            if 0< aP[0]<iH-1 and 0 < aP[1] < iW-1:
                iP = aP[0]*iW + aP[1]
                if iP in dM: #もう最初から足したったらええんや
                    dM[iP] += 1
                else:
                    dM[iP] = 1
    for i in dM:
        dC[dM[i]]+=1

    iAllBM=0
    for i in range(1,10):
        iAllBM+=dC[i]
    dC[0] = iMax -iAllBM #点のないマス0は引き算で出せる

    for i in range(10):
        print(dC[i])
解()


Fixed submission:
import sys
iH,iW,iN = [int(_) for _ in input().split()]
aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

iMax = (iH - 2) * (iW -2)
#print (iMax)

dC={}
for i in range(10):
    dC[i]=0

#愚直 無理 つらい
#for i in range(1,iH -1):
#   for j in range(1,iW-1):
#       tmp = 0
#       for a in aD:
#           if j<= a[1] <=j+2 and i<= a[0] <= i+2:
#               tmp +=1
#       dC[tmp] +=1
dM = {}
for a in aD:
    y=a[0]
    x=a[1]
    for aP in [(y-2,x-2),(y-2,x-1),(y-2,x),(y-1,x-2),(y-1,x-1),(y-1,x),(y,x-2),(y,x-1),(y,x)]:
        if 0< aP[0]<iH-1 and 0 < aP[1] < iW-1:
            iP = aP[0]*iW + aP[1]
            if iP in dM:
                dM[iP] += 1
            else:
                dM[iP] = 1
for i in dM:
    dC[dM[i]]+=1

iAllBM=0
for i in range(1,10):
    iAllBM+=dC[i]
dC[0] = iMax -iAllBM

for i in range(10):
    print(dC[i])
Buggy python submission (verdict: Time Limit Exceeded):
iN,iA =[int(x) for x in input().split()]
#aX = [int(x) - iA for x in input().split()]
aX = [int(x) for x in input().split()]

#解法1
#すげーな動的計画法
iMX = max(aX + [iA])
dp = [[[0]*(iN*iMX + 1) for _ in range(iN+1)] for _ in range(iN + 1)]

dp[0][0][0] = 1
for j in range(1,iN+1):
    for k in range(0,iN+1):
        for s in range(0,iN*iMX + 1):
            if  s < aX[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif k >= 1 and  s >= aX[j-1]:
                dp[j][k][s] = dp[j-1][k][s]+dp[j-1][k-1][s- aX[j-1]]
            else:
                dp[j][k][s] = 0
iRet = 0
for k in range(1,iN+1):
    iRet += dp[iN][k][k*iA]
print(iRet)


Fixed submission:
iN,iA =[int(x) for x in input().split()]
aX = [int(x) - iA for x in input().split()]

#解法2

iMX = max(aX + [iA])
dp = [[0]*(2 * iN*iMX + 1) for _ in range(iN+1)]

for j in range(0,iN+1):
    for t in range(0,2*iN*iMX):
        if j == 0 and t == iN * iMX :
            dp[j][t] = 1
        elif j >= 0 and ( t - aX[j-1] < 0 or t - aX[j-1] > 2*iN*iMX):
            dp[j][t] = dp[j-1][t]
        elif j >= 0 and ( 0 <= t - aX[j-1] <= 2*iN*iMX):
            dp[j][t] = dp[j-1][t] + dp[j-1][t-aX[j-1]]
        else:
            dp[j][t] = 0
print(dp[iN][iN*iMX] -1 )

Buggy python submission (verdict: Time Limit Exceeded):
iN,iA =[int(x) for x in input().split()]
#aX = [int(x) - iA for x in input().split()]
aX = [int(x) for x in input().split()]

#解法1を愚直にそのまま組んでみた
#すげーな動的計画法
iMX = max(aX + [iA])
dp = [[[0]*(iN*iMX + 1) for _ in range(iN+1)] for _ in range(iN + 1)]

for j in range(iN+1):
    for k in range(iN+1):
        for s in range(iN*iMX + 1):

            if j == 0 and k == 0 and s == 0:
                dp[j][k][s] = 1
            elif j >= 1 and s < aX[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s >= aX[j-1]:
                dp[j][k][s] = dp[j-1][k][s]+dp[j-1][k-1][s- aX[j-1]]
            else:
                dp[j][k][s] = 0
iRet = 0
for k in range(1,iN+1):
    iRet += dp[iN][k][k*iA]
print(iRet)


Fixed submission:
iN,iA =[int(x) for x in input().split()]
aX = [int(x) - iA for x in input().split()]

#解法2

iMX = max(aX + [iA])
dp = [[0]*(2 * iN*iMX + 1) for _ in range(iN+1)]

for j in range(0,iN+1):
    for t in range(0,2*iN*iMX):
        if j == 0 and t == iN * iMX :
            dp[j][t] = 1
        elif j >= 0 and ( t - aX[j-1] < 0 or t - aX[j-1] > 2*iN*iMX):
            dp[j][t] = dp[j-1][t]
        elif j >= 0 and ( 0 <= t - aX[j-1] <= 2*iN*iMX):
            dp[j][t] = dp[j-1][t] + dp[j-1][t-aX[j-1]]
        else:
            dp[j][t] = 0
print(dp[iN][iN*iMX] -1 )
Buggy python submission (verdict: Runtime Error):
sS = input().rstrip()
iL = len(sS)
for i in range(iL-1):
    if sS[i] == sS[i+1] :
        print(i+1,i+2)
        exit()
if sS[0] == sS[2]:
    print("1 3")
    exit()
print("-1 -1")


Fixed submission:
sS = input().rstrip()
iL = len(sS)
if iL == 2:
    if sS[0] == sS[1]:
        print ("1 2")
    else:
        print("-1 -1")
    exit()
for i in range(iL-2):
    if sS[i] == sS[i+1] or sS[i] == sS[i+2]:
        print(i+1,i+3) #あぁ..
        exit()
print("-1 -1")

Buggy python submission (verdict: Runtime Error):
sS = input().rstrip()
iL = len(sS)
if iL == 2:
    print("-1 -1")
    exit()
for i in range(iL-1):
    if sS[i] == sS[i+1] or sS[i] == sS[i+2]:
        print(i+1,i+3) #あぁ..
        exit()
print("-1 -1")



Fixed submission:
sS = input().rstrip()
iL = len(sS)
if iL == 2:
    if sS[0] == sS[1]:
        print ("1 2")
    else:
        print("-1 -1")
    exit()
for i in range(iL-2):
    if sS[i] == sS[i+1] or sS[i] == sS[i+2]:
        print(i+1,i+3) #あぁ..
        exit()
print("-1 -1")
Buggy python submission (verdict: Time Limit Exceeded):
iH,iW,iA,iB = [int(x) for x in input().split()]
iD = 1000000007

def fFr(iX,iR=1):
    if iR == 0 or iX == 0:
        return 1
    else :
        iRet = 1
        for i in range(iR,iX+1):
            iRet *= i
        return iRet

def fnCr(iN,iR):
    if iR == 0:
        return 1
    else:
        return fFr(iN,iR+1) // fFr(iN-iR)

iRet = 0
for iL in range(0,iH-iA):
    iRet += (fnCr(iL+iB-1,iL) * fnCr(iW-iB+iH-iL-2,iW-iB-1))%iD
    iRet %= iD
iRet %= iD
print(iRet)


Fixed submission:
iH,iW,iA,iB = [int(x) for x in input().split()]
iD = 10**9+7 #法

#初等整数論勉強して解説通りキッチリ実装したった

#二分累乗法 iDを法として
def fBiPow(iX,iN,iD):
    iY = 1
    while iN > 0:
        if iN % 2 == 0:
            iX = iX * iX % iD
            iN = iN // 2
        else:
            iY = iX * iY % iD
            iN = iN - 1
    return iY

#nCr = n!/r!(n-r)!
#ループ回すだけ版や
def fFr(iX,iR=1):
    if iR == 0 or iX == 0:
        return 1
    else :
        iRet = 1
        for i in range(iR,iX+1):
            iRet *= i
        return iRet

def fnCr(iN,iR):
    if iR == 0:
        return 1
    else:
        return fFr(iN,iR+1) // fFr(iN-iR)

#階乗(iDを法とした)の配列
aM = [1]*(iH+iW-1)
for i in range(1,iH+iW-1):
    aM[i]=aM[i-1]*i %iD
#各階乗のiDを法とした逆元の配列
aInvM = [1]*(iH+iW-1)
aInvM[iH+iW-2] = fBiPow(aM[iH+iW-2],iD-2,iD)
for i in range(iH+iW-2,0,-1):
    aInvM[i-1]=aInvM[i]*i % iD

iRet = 0
for iL in range(0,iH-iA):
    #iRet += (fnCr(iL+iB-1,iL) * fnCr(iW-iB+iH-iL-2,iW-iB-1))%iD
    iRet += (aM[iL+iB-1]*aInvM[iL]*aInvM[iB-1]) % iD * (aM[iW-iB+iH-iL-2]*aInvM[iW-iB-1]*aInvM[iH-iL-1])%iD
    iRet %= iD
iRet %= iD
print(iRet)
Buggy python submission (verdict: Runtime Error):
input_a = ()
input_b = ()
input_c = ()
input_d = ()
input_e = ()
input_k = ()
if (input_a - input_e) < input_k:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if (e - a) <= k:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
a = input().split()
if int(a[6]) < 4:
  print("Heise")
elif int(a[6]) == 4 and int(a[8]) < 3:
  print("Heisei")
else:
  print("TBD")

Fixed submission:
a = input().split("/")
if int(a[1]) < 4:
  print("Heisei")
elif int(a[1]) == 4 and int(a[2]) <= 30:
  print("Heisei")
else:
  print("TBD")

Buggy python submission (verdict: Runtime Error):
a = input().split()
if a[6] < 4:
  print("Heisei")
elif a[6] == 4 and a[8] < 3:
  print("Heisei")
else:
  print("TBD")

Fixed submission:
a = input().split("/")
if int(a[1]) < 4:
  print("Heisei")
elif int(a[1]) == 4 and int(a[2]) <= 30:
  print("Heisei")
else:
  print("TBD")
Buggy python submission (verdict: Runtime Error):
import sys
a, b = sys.stdin.readlines()
c = a*b
if (c % 2) == 0:
    print("Even")
else:
    print("Odd")

Fixed submission:
a, b = map(int, input().split())
if ((a*b) % 2) == 0:
    print("Even")
else:
    print("Odd")

Buggy python submission (verdict: Runtime Error):
import sys
a, b = sys.stdin.readline()
c = a*b
if (c % 2) == 0:
  print("Even")
else:
  print("Odd")

Fixed submission:
a, b = map(int, input().split())
if ((a*b) % 2) == 0:
    print("Even")
else:
    print("Odd")

Buggy python submission (verdict: Runtime Error):
input1 = int(input())
input2 = int(input())
result = input1 * input2
if (result % 2) == 0:
    print("Even")
else:
    print("Odd")


Fixed submission:
a, b = map(int, input().split())
if ((a*b) % 2) == 0:
    print("Even")
else:
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a,b = int(input())
c = a*b
if (c % 2) == 0:
    print("Even")
else:
    print("Odd")


Fixed submission:
a, b = map(int, input().split())
if ((a*b) % 2) == 0:
    print("Even")
else:
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = a*b
if (c%2) == 0:
    print("Even")
else:
    print("Odd")


Fixed submission:
a, b = map(int, input().split())
if ((a*b) % 2) == 0:
    print("Even")
else:
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = a*b
if (c%2) == 0:
    print("Even")
else:
    print("Odd")


Fixed submission:
a, b = map(int, input().split())
if ((a*b) % 2) == 0:
    print("Even")
else:
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = a*b
if (c%2) == 0:
    print("Even")
else:
    print("Odd")


Fixed submission:
a, b = map(int, input().split())
if ((a*b) % 2) == 0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import copy

fline = input().rstrip().split(' ')
a, b, x = int(fline[0]), int(fline[1]), int(fline[2])

count = 0
for i in range(a, b+1):
    if i%x==0:
        count = count+1
print(count)

Fixed submission:
import sys
import copy

fline = input().rstrip().split(' ')
a, b, x = int(fline[0]), int(fline[1]), int(fline[2])

y = (a-1)//x
z = b//x
print(z-y)
Buggy python submission (verdict: Runtime Error):
inf = float("inf")
N, M = map(int, input().split())
A = map(int, input().split())
C = [2, 5, 5, 4, 5, 6, 3, 7, 6]
costs = {m: C[m - 1] for m in A}
dp = [0]
for i in range(1, N + 1):
    dp.append(
        max([dp[i - c] if i - c >= 0 else -inf for c in costs.values()]) + 1)

digits = list(costs.keys())
digits = sorted(digits, reverse=True)
num = N
result = []
for _ in range(dp[N]):
    for digit in digits:
        if dp[num - costs[digit]] != -inf and dp[num - costs[digit]] == dp[num] - 1:
            result.append(str(digit))
            num -= costs[digit]
            break
print("".join(result))


Fixed submission:
inf = float("inf")
N, M = map(int, input().split())
A = map(int, input().split())
C = [2, 5, 5, 4, 5, 6, 3, 7, 6]
costs = {m: C[m - 1] for m in A}
dp = [0]
for i in range(1, N + 1):
    dp.append(
        max([dp[i - c] if i - c >= 0 else -inf for c in costs.values()]) + 1)

digits = list(costs.keys())
digits = sorted(digits, reverse=True)
num = N
result = []
for _ in range(dp[N]):
    for digit in digits:
        if num >= costs[digit] and dp[num - costs[digit]] != -inf and dp[num - costs[digit]] == dp[num] - 1:
            result.append(str(digit))
            num -= costs[digit]
            break
print("".join(result))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
flag = True
N, M = map(int, input().split())
for i in range(N, M + 1):
    if M % i == 0:
        print(M // i)
        flag = False
        break

if flag:
    print(1)


Fixed submission:
import numpy as np
flag = True
N, M = map(int, input().split())
ans = 0
for i in range(1, int(np.sqrt(M)) + 2):
    if M % i == 0:
        if min(M // i, i) >= N:
            ans = max(ans, max(M // i, i))
        elif max(M // i, i) >= N:
            ans = max(ans, min(M // i, i))

print(ans)
Buggy python submission (verdict: Runtime Error):
import fraction

N, X = map(int, input().split())

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

dist_list = [abs(X - e) for e in x]
ans = dist_list[0]
for e in dist_list:
    ans = fraction.gcd(e, ans)


print(ans)


Fixed submission:
def gcd(x, y):
    while y != 0:
        temp = y
        y = x % y
        x = temp
    return x


N, X = map(int, input().split())

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

dist_list = [abs(X - e) for e in x]

ans = dist_list[0]
for e in dist_list:
    ans = gcd(ans, e)


print(ans)

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


N, X = map(int, input().split())

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

dist_list = [abs(X - e) for e in x]
ans = dist_list[0]
for e in dist_list:
    ans = math.gcd(e, ans)


print(ans)


Fixed submission:
def gcd(x, y):
    while y != 0:
        temp = y
        y = x % y
        x = temp
    return x


N, X = map(int, input().split())

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

dist_list = [abs(X - e) for e in x]

ans = dist_list[0]
for e in dist_list:
    ans = gcd(ans, e)


print(ans)

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


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


N, X = map(int, input().split())

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

dist_list = [abs(X - e) for e in x]

print(gcd_list(dist_list))


Fixed submission:
def gcd(x, y):
    while y != 0:
        temp = y
        y = x % y
        x = temp
    return x


N, X = map(int, input().split())

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

dist_list = [abs(X - e) for e in x]

ans = dist_list[0]
for e in dist_list:
    ans = gcd(ans, e)


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

N, M, Q = map(int, input().split())
A = [[0] * N for _ in range(N)]
for _ in range(M):
    l, m = map(int, input().split())
    A[l - 1][m - 1] += 1

questions = []
for _ in range(Q):
    p, q = map(int, input().split())
    questions.append((p - 1, q - 1))


D = []
for l in range(N):
    s = 0
    d = []
    for r in range(N):
        s += A[l][r]
        d.append(s)
    D.append(d)

for question in questions:
    print(sum([D[i][question[1]]
               for i in range(question[0], question[1] + 1)]))


Fixed submission:
N, M, Q = map(int, input().split())
A = [[0] * N for _ in range(N)]
for _ in range(M):
    l, m = map(int, input().split())
    A[l - 1][m - 1] += 1

questions = []
for _ in range(Q):
    p, q = map(int, input().split())
    questions.append((p - 1, q - 1))


D = []
for l in range(N):
    s = 0
    d = []
    for r in range(N):
        s += A[l][r]
        d.append(s)
    D.append(d)

T = []
for r in range(N):
    s = 0
    t = [0]
    for l in range(N):
        s += D[l][r]
        t.append(s)
    T.append(t)

for question in questions:
    print(T[question[1]][N] - T[question[1]][question[0]])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
A = [[0] * N for _ in range(N)]
for _ in range(M):
    l, m = map(int, input().split())
    A[l - 1][m - 1] += 1

questions = []
for _ in range(Q):
    p, q = map(int, input().split())
    questions.append((p - 1, q - 1))


D = []
for l in range(N):
    s = 0
    d = []
    for r in range(N):
        s += A[l][r]
        d.append(s)
    D.append(d)

for question in questions:
    print(sum([D[i][question[1]] for i in range(question[0], N)]))


Fixed submission:
N, M, Q = map(int, input().split())
A = [[0] * N for _ in range(N)]
for _ in range(M):
    l, m = map(int, input().split())
    A[l - 1][m - 1] += 1

questions = []
for _ in range(Q):
    p, q = map(int, input().split())
    questions.append((p - 1, q - 1))


D = []
for l in range(N):
    s = 0
    d = []
    for r in range(N):
        s += A[l][r]
        d.append(s)
    D.append(d)

T = []
for r in range(N):
    s = 0
    t = [0]
    for l in range(N):
        s += D[l][r]
        t.append(s)
    T.append(t)

for question in questions:
    print(T[question[1]][N] - T[question[1]][question[0]])