Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,A=map(int,open(0).read().split());l=[0]*4
for a in A:l[a&3]+=1
print("YNeos"[d[1]+d[3]>1+d[0]::2])

Fixed submission:
N,*A=map(int,open(0).read().split());l=[0]*4
for a in A:l[a&3]+=1
o=l[1]+l[3];print("YNeos"[o>1+l[0]or o-1==l[0]and l[2]>0::2])
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split());print("YNeos"[all(A%3,B%3,(A+B)%3)::2])

Fixed submission:
A,B=map(int,input().split());print("PIomspsoisbslieb l e"[all([A%3,B%3,(A+B)%3])::2])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
alist = list(map(int, input().split()))

blist = []
for i in range(n) :
    bi = alist.pop(0)
    if (n^i)&1 == 1 :
        blist.insert(0, bi)
    else :
        blist.append(bi)

for b in blist :
    print(b, end=" ")

Fixed submission:
from collections import deque
n = int(input())
alist = deque(map(int, input().split()))

blist = deque([])
for i in range(n) :
    bi = alist.popleft()
    if (n^i)&1 == 1 :
        blist.appendleft(bi)
    else :
        blist.append(bi)

for b in blist :
    print(b, end=" ")

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

b = []
for i in range(n) :
    ai = alist[i]
    b.append(ai)
    b.reverse()

for bi in b :
    print(bi, end=" ")

Fixed submission:
from collections import deque
n = int(input())
alist = deque(map(int, input().split()))

blist = deque([])
for i in range(n) :
    bi = alist.popleft()
    if (n^i)&1 == 1 :
        blist.appendleft(bi)
    else :
        blist.append(bi)

for b in blist :
    print(b, end=" ")
Buggy python submission (verdict: Runtime Error):
*A,=map(int,open(0));i=1;t=[0]*A[0]
while i-2and t[i]==0:t[i]=1;i=A[i]
print(-1if i-2else sum(t))

Fixed submission:
*A,=map(int,open(0));i=1;t=[0]*A[0]+[0]
while i-2and t[i]==0:t[i]=1;i=A[i]
print(-1if i-2else sum(t))

Buggy python submission (verdict: Runtime Error):
*A,=map(int,open(0));i=1;t=[0]*A[0]
while i-2or t[i]:t[i]=1;i=A[i]
print(-1if i-2else sum(t))

Fixed submission:
*A,=map(int,open(0));i=1;t=[0]*A[0]+[0]
while i-2and t[i]==0:t[i]=1;i=A[i]
print(-1if i-2else sum(t))

Buggy python submission (verdict: Runtime Error):
*A,=map(int,open(0));i=1;t=[0]*A[0]
while i-2or i in t:t[i]=1;i=A[i]
print(-1if i-2else sum(t))

Fixed submission:
*A,=map(int,open(0));i=1;t=[0]*A[0]+[0]
while i-2and t[i]==0:t[i]=1;i=A[i]
print(-1if i-2else sum(t))

Buggy python submission (verdict: Time Limit Exceeded):
import sys;sys.setrecursionlimit(9**9);*A,=map(int,open(0))
def f(i,t):
 if i==2:return len(t)
 if i in t:return -1
 return f(A[i],t+[i])
print(f(1,[]))

Fixed submission:
*A,=map(int,open(0));i=1;t=[0]*A[0]+[0]
while i-2and t[i]==0:t[i]=1;i=A[i]
print(-1if i-2else sum(t))
Buggy python submission (verdict: Runtime Error):
s = input()
se = s[::2]
so = s[1::2]
ans = "-1 -1"
for i in range(len(s)-1) :
    if s[i] == s[i+1] :
        ans = str(i+1)+" "+str(i+2)
for i in range(len(se)-1) :
    if se[i] == se[i+1] :
        ans = str(2*i+1)+" "+str(2*i+3)
for i in range(len(se)-1) :
    if so[i] == so[i+1] :
        ans = str(2*i+2)+" "+str(2*i+4)
print(ans)

Fixed submission:
s = input()
se = s[::2]
so = s[1::2]
ans = "-1 -1"
for i in range(len(s)-1) :
    if s[i] == s[i+1] :
        ans = str(i+1)+" "+str(i+2)
for i in range(len(se)-1) :
    if se[i] == se[i+1] :
        ans = str(2*i+1)+" "+str(2*i+3)
for i in range(len(so)-1) :
    if so[i] == so[i+1] :
        ans = str(2*i+2)+" "+str(2*i+4)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
temp = math.gcd(a, b)
ans = a * b // temp
print(ans

Fixed submission:
import math
a,b = map(int,input().split())
temp = math.gcd(a, b)
ans = a * b // temp
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
if 1 <= n <= 10 ** 9:
    for i in range(n - 1):
        count += i + 1
    print(count)
else:
    print('hoge!')

Fixed submission:
n = int(input())
if n == 0:
    print(0)
else:
    ans = n*(n-1)//2
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
cnt=0
s=[sorted(input()) for _ in range(n)]
for i in range(1,n):
    for j in range(i):
        if s[j] == s[i]:
            cnt+=1
print(cnt)

Fixed submission:
import collections as co
n=int(input())
cnt=0
s=[''.join(sorted(input())) for _ in range(n)]
m=co.Counter(s)
for item in m:
    cnt += m[item]*(m[item]-1)/2
print(int(cnt))
'''
for i in range(1,n):
    for j in range(i):
        if s[j] == s[i]:
            cnt+=1
print(cnt)
'''
Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
ans=2018
for i in range(l,r):
	for j in range(i+1,r+1):
    	if i*j%2019<ans:
        	ans=i*j%2019
        elif i*j%2019==ans:
        	print(ans)
            exit()
print(ans)

Fixed submission:
l,r=map(int,input().split())
if l==0:
    print(0)
elif r*(r-1)<2019:
    print(l*(l+1))
else:
    ans=2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            if i*j%2019<ans:
                ans=i*j%2019
            elif i*j%2019==ans:
                print(ans)
                exit()
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
if l==0:
    print(0)
elif r*(r-1)<2019:
    print(l*(l+1))
else:
    print(min(i*j%2019 for i in range(l,r) for j in range(i+1,r+1)))

Fixed submission:
l,r=map(int,input().split())
if l==0:
    print(0)
elif r*(r-1)<2019:
    print(l*(l+1))
else:
    ans=2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            if i*j%2019<ans:
                ans=i*j%2019
            elif i*j%2019==ans:
                print(ans)
                exit()
    print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
a=[]
for _ in range(n)
    a.append(int(input()))
c = collections.Counter(a)
ans=0
for k,v in c.items():
    if v % 2 != 0:
        ans += 1
print(ans)

Fixed submission:
import collections
n=int(input())
a=[int(input()) for _ in range(n)]
c = collections.Counter(a)
ans=0
for k,v in c.items():
    if v % 2 != 0:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
c=[]
for _ in range(n):
    a=int(input())
    c.append(a)
cb=set(c)
ca=[]
for item in cb:
    if c.count(item) % 2 == 1:
        ca.append(item)
print(len(ca))

Fixed submission:
import collections
n=int(input())
a=[int(input()) for _ in range(n)]
c = collections.Counter(a)
ans=0
for k,v in c.items():
    if v % 2 != 0:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
cnt=[]
for _ in range(n):
    a=int(input())
    if a in cnt:
        cnt.remove(a)
    else:
        cnt.append(a)
print(len(cnt))

Fixed submission:
import collections
n=int(input())
a=[int(input()) for _ in range(n)]
c = collections.Counter(a)
ans=0
for k,v in c.items():
    if v % 2 != 0:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import bisect

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

colors = [A[0]]
for a in A[1:]:
    i = bisect.bisect_left(colors, a)
    if i != 0:
        del colors[i - 1]
    bisect.insort_left(colors, a)

print(len(colors))


Fixed submission:
from collections import deque
import bisect

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

colors = deque([A[0]])
for a in A[1:]:
    i = bisect.bisect_left(colors, a)
    if i != 0:
        colors[i - 1] = a
    else:
        colors.appendleft(a)

print(len(colors))

Buggy python submission (verdict: Runtime Error):
from collections import deque
import bisect

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

colors = deque([A[0]])
for a in A[1:]:
    i = bisect.bisect_left(colors, a)
    if i == 0:
        colors.appendleft(a)
    else:
        del colors[i - 1]
        bisect.insort_left(colors, a)

print(len(colors))


Fixed submission:
from collections import deque
import bisect

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

colors = deque([A[0]])
for a in A[1:]:
    i = bisect.bisect_left(colors, a)
    if i != 0:
        colors[i - 1] = a
    else:
        colors.appendleft(a)

print(len(colors))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
MOD = 10 ** 9 + 7
memo = {}


def c(a, b):
    if (a, b) not in memo:
        ans = 1
        for i in range(b):
            ans *= a - i
        for i in range(1, 1 + b):
            ans //= i
        memo[(a, b)] = ans
    return memo[(a, b)]


for i in range(1, 1 + K):
    ans_i = c(N - K + 1, i) * c(K - 1, i - 1)
    ans_i %= MOD
    print(ans_i)


Fixed submission:
N, K = map(int, input().split())
MOD = 10 ** 9 + 7


nk1Ci = [1]
k1Ci1 = [1]
temp1 = 1
temp2 = 1
for i in range(K):
    temp1 = temp1 * (N - K + 1 - i) // (i + 1)
    temp2 = temp2 * (K - 1 - i) // (i + 1)
    nk1Ci.append(temp1)
    k1Ci1.append(temp2)


for i in range(1, 1 + K):
    ans_i = nk1Ci[i] * k1Ci1[i - 1]
    ans_i %= MOD
    print(ans_i)
Buggy python submission (verdict: Runtime Error):
import std.stdio;

void main() {
  int X, A;
  readf("%d %d", &X, &A);
  writeln(X < A ? 0 : 10);
}

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

if X < A:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Time Limit Exceeded):
Q = 1000000007
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
dp = {
    0: 1,
    1: 0 if 1 in a else 1
}

for k in range(2, n + 1):
    dp[k] = (0 if k in a else dp[k - 1] + dp[k - 2]) % Q


print(dp[n])


Fixed submission:
Q = 1000000007
n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
dp = {
    0: 1,
    1: 0 if 1 in a else 1
}

for k in range(2, n + 1):
    dp[k] = (0 if k in a else dp[k - 1] + dp[k - 2]) % Q


print(dp[n])
Buggy python submission (verdict: Runtime Error):
print(“Christmas” + “ “.join([“Eve”] * int(input())))

Fixed submission:
print("Christmas" + (" Eve" * (25 - int(input()))))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
print(a + b / 2)

Fixed submission:
a, b = map(int, input().split())
print(a + b // 2)
Buggy python submission (verdict: Runtime Error):
print("Hello World" if print() == "1" else (int(input()) + int(input())))

Fixed submission:
print("Hello World" if input() == "1" else (int(input()) + int(input())))
Buggy python submission (verdict: Runtime Error):
from math import fractions


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

x.append(X)
x.sort()

last = x[0]
ans = abs(x[0] - x[1])
for i in x[1:]:
    ans = gcd(ans, abs(last - i))
    last = i

print(ans)


Fixed submission:
from fractions import gcd


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

x.append(X)
x.sort()

last = x[0]
ans = abs(x[0] - x[1])
for i in x[1:]:
    ans = gcd(ans, abs(last - i))
    last = i

print(ans)

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


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

x.append(X)
x.sort()

last = x[0]
ans = abs(x[0] - x[1])
for i in x[1:]:
    ans = gcd(ans, abs(last - i))
    last = i

print(ans)


Fixed submission:
from fractions import gcd


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

x.append(X)
x.sort()

last = x[0]
ans = abs(x[0] - x[1])
for i in x[1:]:
    ans = gcd(ans, abs(last - i))
    last = i

print(ans)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())

a = [None]
for i in range(H):
    a.append([None] + list(map(int, input().split())))


def is_odd(i, j):
    return a[i][j] % 2 == 1


def next_cell(i, j):
    if i % 2 == 1:
        if j < W:
            return i, j + 1
    else:
        if 0 < j:
            return i, j - 1
    if i < H:
        return i + 1, j
    return None, None


def move(i, j):
    ni, nj = next_cell(i, j)
    if ni is None:
        return None
    a[i][j] -= 1
    a[ni][nj] += 1
    return "{} {} {} {}".format(i, j, ni, nj)


ans = []
for j in range(1, W + 1):
    for i in range(1, H + 1):
        if is_odd(i, j):
            res = move(i, j)
            if res is not None:
                ans.append(res)


print(len(ans))
for line in ans:
    print(line)


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

a = [None]
for i in range(H):
    a.append([None] + list(map(int, input().split())))


def is_odd(i, j):
    return a[i][j] % 2 == 1


def next_cell(i, j):
    if i % 2 == 1:
        if j < W:
            return i, j + 1
    else:
        if 1 < j:
            return i, j - 1
    if i < H:
        return i + 1, j
    return None, None


def move(i, j):
    ni, nj = next_cell(i, j)
    if ni is None:
        return None
    a[i][j] -= 1
    a[ni][nj] += 1
    return "{} {} {} {}".format(i, j, ni, nj)


ans = []
i, j = 1, 1
while True:
    if is_odd(i, j):
        res = move(i, j)
        if res is not None:
            ans.append(res)
    i, j = next_cell(i, j)
    if i is None:
        break

print(len(ans))
for line in ans:
    print(line)
Buggy python submission (verdict: Time Limit Exceeded):

def section_sum(a, b):
    return acc[b] - acc[a]


def minimize(s2):
    lsum = float("inf")
    for s1 in range(1, s2):
        if abs(section_sum(0, s1) - section_sum(s1, s2)) < lsum:
            q = section_sum(0, s1)
            r = section_sum(s1, s2)
            lsum = abs(q - r)
        else:
            break

    rsum = float("inf")
    for s3 in range(s2, len(a)):
        if abs(section_sum(s2, s3) - section_sum(s3, len(a))) < rsum:
            s = section_sum(s2, s3)
            t = section_sum(s3, len(a))
            rsum = abs(s - t)
        else:
            break

    cut = [q, r, s, t]
    return abs(min(cut) - max(cut))


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

acc = [0]
for x in a:
    acc.append(acc[-1] + x)


ans = float("inf")
for s2 in range(2, len(a) - 1):
    ans = min(ans, minimize(s2))

print(ans)


Fixed submission:

def section_sum(a, b):
    return acc[b] - acc[a]


def minimize(s1, s2, s3):
    lsum = float("inf")
    for i in range(s1, s2):
        if abs(section_sum(0, i) - section_sum(i, s2)) < lsum:
            q = section_sum(0, i)
            r = section_sum(i, s2)
            s1 = i
            lsum = abs(q - r)
        else:
            break

    rsum = float("inf")
    for i in range(s3, len(a)):
        if abs(section_sum(s2, i) - section_sum(i, len(a))) < rsum:
            s = section_sum(s2, i)
            t = section_sum(i, len(a))
            s3 = i
            rsum = abs(s - t)
        else:
            break

    cut = [q, r, s, t]
    return abs(min(cut) - max(cut)), s1, s2, s3


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

acc = [0]
for x in a:
    acc.append(acc[-1] + x)

s1, s2, s3 = 1, 2, 3
ans = float("inf")
for s2 in range(2, len(a) - 1):
    x, s1, s2, s3 = minimize(s1, s2, s3)
    ans = min(ans, x)

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


def is_symmetric(board):
    for i in range(N):
        for j in range(i, N):
            if board(j, i) != board(i, j):
                return False
    return True


def translate(board, a, b):
    def get(i, j):
        return board[(i + a) % N][(j + b) % N]
    
    return get


def solve(board):
    ans = 0
    for a in range(N):
        if is_symmetric(translate(board, a, 0)):
            ans += N - a
    for b in range(N):
        if b == 0:
            continue
        if is_symmetric(translate(board, 0, b)):
            ans += N - b
    return ans


N = int(input())
board = []
for i in range(N):
    board.append(input())


print(solve(board))

Fixed submission:
from collections import Counter

def c2(a):
    if a <= 1:
        return 0
    return a * (a - 1) / 2

def solve(arr):
    cum = [0]
    s = 0
    for i in arr:
        s += i
        cum.append(s)

    return int(sum(c2(v) for k, v in Counter(cum).items()))

input()
print(solve([int(i) for i in input().split()]))
Buggy python submission (verdict: Time Limit Exceeded):
'''input
5
abcde
fghij
klmno
pqrst
uvwxy
'''


def is_symmetric(board):
    for i in range(N):
        for j in range(N):
            if board(j, i) != board(i, j):
                return False
    return True


def translate(board, a, b):
    def get(i, j):
        return board[(i + a) % N][(j + b) % N]
    
    return get


def solve(board):
    ans = 0
    for a in range(N):
        if is_symmetric(translate(board, a, 0)):
            ans += N - a
    for b in range(N):
        if b == 0:
            continue
        if is_symmetric(translate(board, 0, b)):
            ans += N - b
    return ans


N = int(input())
board = []
for i in range(N):
    board.append(input())


print(solve(board))

Fixed submission:


def is_symmetric(board):
    for i in range(N):
        for j in range(i, N):
            if board(j, i) != board(i, j):
                return False
    return True


def translate(board, a, b):
    def get(i, j):
        return board[(i + a) % N][(j + b) % N]
    
    return get


def solve(board):
    ans = 0
    for a in range(N):
        if is_symmetric(translate(board, a, 0)):
            ans += N - a
    for b in range(N):
        if b == 0:
            continue
        if is_symmetric(translate(board, 0, b)):
            ans += N - b
    return ans


N = int(input())
board = []
for i in range(N):
    board.append(input())


print(solve(board))

Buggy python submission (verdict: Time Limit Exceeded):
def is_symmetric(N, board):
    for i in range(N):
        for j in range(N):
            if board[i][j] != board[j][i]:
                return False
    return True


def generate_board(N, board, a, b):
    new = []
    for i in range(N):
        new.append([None for i in range(N)])

    for i in range(N):
        for j in range(N):
            new[(i + a) % N][(j + b) % N] = board[i][j]

    return new


def solve(N, board):
    ans = 0
    for i in range(2*N - 1):
        if i < N:
            if is_symmetric(N, generate_board(N, board, 0, i)):
                ans += i + 1
        else:
            if is_symmetric(N, generate_board(N, board, 0, i)):
                ans += 2*N - 1 - i
    return ans


N = int(input())
board = []
for i in range(N):
    board.append([j for j in input()])


print(int(solve(N, board)))

Fixed submission:


def is_symmetric(board):
    for i in range(N):
        for j in range(i, N):
            if board(j, i) != board(i, j):
                return False
    return True


def translate(board, a, b):
    def get(i, j):
        return board[(i + a) % N][(j + b) % N]
    
    return get


def solve(board):
    ans = 0
    for a in range(N):
        if is_symmetric(translate(board, a, 0)):
            ans += N - a
    for b in range(N):
        if b == 0:
            continue
        if is_symmetric(translate(board, 0, b)):
            ans += N - b
    return ans


N = int(input())
board = []
for i in range(N):
    board.append(input())


print(solve(board))
Buggy python submission (verdict: Runtime Error):
import sys
#import bisect
#from collections import deque
import math

def input():
    return sys.stdin.readline().rstrip('\n')


X,Y = list(map(int, input().split()))

if (2*X-Y) % 3:
    print(0)
    sys.exit()

if (2*Y-X) % 3:
    print(0)
    sys.exit()

M = max((2*X-Y)//3, (2*Y-X)//3)
N = min((2*X-Y)//3, (2*Y-X)//3)

from scipy.special import comb
#print(comb(M+N,N) % (pow(10,9) + 7))
print(comb(M+N,N, exact=True)% (pow(10,9) + 7))


Fixed submission:
import sys
#import bisect
#from collections import deque
import math

def input():
    return sys.stdin.readline().rstrip('\n')


X,Y = list(map(int, input().split()))

if (2*X-Y) % 3:
    print(0)
    sys.exit()

if (2*Y-X) % 3:
    print(0)
    sys.exit()

M = max((2*X-Y)//3, (2*Y-X)//3)
N = min((2*X-Y)//3, (2*Y-X)//3)

if M<0 or N<0:
    print(0)
    sys.exit()
    
mod = pow(10,9) + 7

#from scipy.special import comb
#print(comb(M+N,N) % (pow(10,9) + 7))
#print(comb(M+N,N, exact=True)% (pow(10,9) + 7))  causes "RE" at atcoder
#from math import factorial
#print((factorial(M+N)//factorial(M)//factorial(N)))

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def ohmycomb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

print(ohmycomb(M+N, N, mod))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().rstrip('\n')

##### main

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

A.sort()
F.sort(reverse=True)
AxF = [A[i]*F[i] for i in range(N)]
AxFmax = max(AxF)

def is_possible(x):
    _sum = 0
    for i in range(N):
        _sum += max(0, A[i] - x//F[i])
    #print(x,_sum,K)
    return _sum <= K

left = 0
right = AxFmax

while(left != right):
    x = (left+right)//2
    if is_possible(x):
        right = x
    else:
        left = x+1
    #print('main', left, right, x)
            
print(left)


Fixed submission:
import sys

def input():
    return sys.stdin.readline().rstrip('\n')

##### main

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

A.sort()
F.sort(reverse=True)
AxF = [A[i]*F[i] for i in range(N)]
AxFmax = max(AxF)

def is_possible(x):
    _sum = 0
    for i in range(N):
        _sum += max(0, A[i] - x//F[i])
    #print(x,_sum,K)
    return _sum <= K

left = 0
right = AxFmax

while(left != right):
    x = (left+right)//2
    if is_possible(x):
        right = x
    else:
        left = x+1
    #print('main', left, right, x)
            
print(left)
Buggy python submission (verdict: Runtime Error):
from collections import deque

def input():
    return sys.stdin.readline().rstrip('\n')

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

D = deque(D)
sum0 = D.pop()
hp = 0

for _ in range(N-1):
    d = D.pop()
    hp += d * sum0
    sum0 += d

print(hp)


Fixed submission:
import sys
#import bisect
from collections import deque

def input():
    return sys.stdin.readline().rstrip('\n')

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

D = deque(D)
sum0 = D.pop()
hp = 0

for _ in range(N-1):
    d = D.pop()
    hp += d * sum0
    sum0 += d

print(hp)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

count = 0
for i in range(N):
    count += i
    
print(count)


Fixed submission:
N = int(input())

count = 0

#for i in range(N):
#    count += i

count = N*(N-1)//2

print(count)
Buggy python submission (verdict: Runtime Error):
from array import array

N = int(input())

S = []

for i in range(N):
    s = input()
    slist = list(s)
    slist.sort()
    s = ''.join(slist)
    S.append(s)

FAC = array('l', [0]*(N+1))
FAC[1] = 1

for i in range(2,N+1):
    FAC[i] = FAC[i-1]*i
    
count = 0


for s in set(S):
    s_counts  = S.count(s)
    if s_counts > 1:
        #fac = math.factorial(s_counts)
        #count += fac//2
        count += FAC[s_counts]//2

print(count)


Fixed submission:
from collections import defaultdict
import sys
from scipy.misc import comb

N = int(input())

dd=defaultdict(int)

Sread = sys.stdin.read()


for s in Sread.split('\n'):
    slist = list(s)
    slist.sort()
    s = ''.join(slist)
    #print('-', s)
    dd[s]+=1

#FAC = {}
#FAC[1] = 1
#
#for i in range(2,N+1):
#    FAC[i] = FAC[i-1]*i
    
count = 0

for k in dd:
    s_counts = dd[k]
    if s_counts > 1:
        #count += FAC[s_counts]//2
        count += comb(s_counts, 2, exact=True)

print(count)