Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    K, S = map(int, input().split())
    print(
        len(
            [
                (x, y, z)
                for x in range(K + 1)
                for y in range(K + 1)
                for z in range(K + 1)
                if x + y + z == S and max(x, y, z) <= K
            ]
        )
    )


if __name__ == "__main__":
    resolve()

Fixed submission:
def resolve():
    K, S = map(int, input().split())
    count = 0
    for x in range(K + 1):
        for y in range(K + 1):
            if S - K <= x + y <= S and max(x, y) <= K:
                count += 1
    print(count)


if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Runtime Error):
# 解説を見て解いた。解説PDFの「B≦i≦Wを満たす全てのiについて」のWはW-1の間違い。
def make_table(h, w):

    for i in range(1, h + w - 1):
        fac_table.append(fac_table[-1] * i % mod)  # i! mod 10**9+7
        inv_table.append(pow(fac_table[-1], mod - 2, mod))  # (i!)^(-1) mod 10**9+7.


def comb(n, r):
    return fac_table[n] * inv_table[n - r] * inv_table[r] % mod


def resolve():
    H, W, A, B = map(int, input().split())
    make_table(H, W)
    _sum = 0
    print(
        sum(
            [
                comb(H - A - 1 + i, i) * comb(A - 1 + W - i - 1, A - 1) % mod
                for i in range(B, W)
            ]
        )
        % mod
    )


if __name__ == "__main__":
    resolve()

Fixed submission:
mod = 10 ** 9 + 7
fac_table = [1 for i in range(200001)]
inv_table = [1 for i in range(200001)]


def make_table(h, w):

    for i in range(1, h + w - 1):
        fac_table[i] = fac_table[i - 1] * i % mod
        inv_table[i] = pow(fac_table[i], mod - 2, mod)


def comb(n, r):
    return fac_table[n] * inv_table[n - r] % mod * inv_table[r] % mod


def resolve():
    H, W, A, B = map(int, input().split())
    make_table(H, W)
    print(
        sum(
            [
                comb(H - A - 1 + i, i) * comb(A - 1 + W - i - 1, A - 1) % mod
                for i in range(B, W)
            ]
        )
        % mod
    )

if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
 
 
def main():
    n = int(input())
    s = list(input())[:n]
 
    # memory = [[0 for j in range(n)] for i in range(n)]
    # for i in range(n):
    #     for j in range(i, n):
    #         memory[i][j] = s[i] == s[j]
    #         memory[j][i] = s[i] == s[j]
    # print(memory)
 
    result = 0
    for i in range(n):
        for j in range(i, n):
            for k in range(j, n):
                if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
                    continue
                if j - i == k - j:
                    continue
                result += 1
    print(result)
 
 
if __name__ == '__main__':
    main()

Fixed submission:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = input()

    ans = s.count('R') * s.count('G') * s.count('B')
    # print(ans)
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            k = (j - i) + j
            if k >= n:
                # print(i, j, k)
                break

            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = list(input())[:n]

    # memory = [[0 for j in range(n)] for i in range(n)]
    # for i in range(n):
    #     for j in range(i, n):
    #         memory[i][j] = s[i] == s[j]
    #         memory[j][i] = s[i] == s[j]
    # print(memory)

    result = 0
    for i in range(n):
        for j in range(i, n):
            for k in range(j, n):
                if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
                    continue
                if j - i == k - j:
                    continue
                result += 1
    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = input()

    ans = s.count('R') * s.count('G') * s.count('B')
    # print(ans)
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            k = (j - i) + j
            if k >= n:
                # print(i, j, k)
                break

            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import math
from decimal import Decimal
from scipy.special import comb
input = sys.stdin.readline


def main():
    n, r = map(int, input().split())
    if n <= 10:
        # r = x - (100 * (10 - n))
        print(r + 100 * (10 - n))

    else:
        print(r)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n, r = map(int, input().split())
    if n <= 10:
        # r = x - (100 * (10 - n))
        print(r + 100 * (10 - n))

    else:
        print(r)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    result = []
    for i in range(1, n + 1):
        result.append(a.index(i) + 1)
    print(*result, sep=' ')


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = np.argsort(np.array(a))+1
    # print(a)
    # result = []
    # for i in range(1, n + 1):
    #     result.append(a.where(lambda x: x == i))
    print(*a, sep=' ')


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-


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

    result = []
    for i in range(1, n + 1):
        result.append(a.index(i) + 1)
    print(*result, sep=' ')


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = np.argsort(np.array(a))+1
    # print(a)
    # result = []
    # for i in range(1, n + 1):
    #     result.append(a.where(lambda x: x == i))
    print(*a, sep=' ')


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_sorted = sorted(a)

    result = []
    for i in range(1, n + 1):
        result.append(a.index(i) + 1)
    print(*result, sep=' ')


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = np.argsort(np.array(a))+1
    # print(a)
    # result = []
    # for i in range(1, n + 1):
    #     result.append(a.where(lambda x: x == i))
    print(*a, sep=' ')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    n = int(input())
    h = list(map(int, input().split()))

    result = []
    count = 0
    for i in range(n - 1):
        if h[i] < h[i + 1]:
            result.append(count)
            count = 0
            continue

        count += 1
        if i == n - 2:
            result.append(count)

    print(max(result))


if __name__ == "__main__":
    main()


Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    n = int(input())
    h = list(map(int, input().split()))

    if n == 1:
        print(0)
        return

    result = []
    count = 0
    for i in range(n - 1):
        if h[i] < h[i + 1]:
            result.append(count)
            count = 0
            continue

        count += 1
        if i == n - 2:
            result.append(count)

    print(max(result))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        ans += i - 1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
from decimal import Decimal


def main():
    n = int(input())

    if n == 1:
        print(0)
        return

    # print(int(n ** 2 - n))
    # print((n ** 2 - n) / 2)
    # print(n * (n - 1))
    # print(n * (n - 1) / 2)
    ans = int(Decimal(n * (n - 1)) / 2)
    print(ans)
    # print(ans * 2)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

a.insert(0, 0)

for i in range(n):
    print(a.count(i+1))

Fixed submission:
import collections

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

c = collections.Counter(a)

a.insert(0, 0)

for i in range(n):
    print(c[i+1])

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

a.insert(0, 0)

#cnt = 0
#for i in range(n):
#    for j in range(n):
#        if i + 1 == a[j]:
#            cnt = cnt + 1

#    print(cnt)
#    cnt = 0

for i in range(n):
    print(a.count(i+1))

Fixed submission:
import collections

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

c = collections.Counter(a)

a.insert(0, 0)

for i in range(n):
    print(c[i+1])

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

a.insert(0, 0)

cnt = 0
for i in range(n):
    for j in range(n):
        if i + 1 == a[j]:
            cnt = cnt + 1

    print(cnt)
    cnt = 0


Fixed submission:
import collections

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

c = collections.Counter(a)

a.insert(0, 0)

for i in range(n):
    print(c[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

cnt = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                cnt = cnt + 1

print(cnt)

Fixed submission:
k, s = map(int, input().split())

cnt = 0

for x in range(k+1):
    for y in range(k+1):
        z = s - (x + y)
        if z >= 0 and z <= k:
            cnt = cnt + 1
#        for z in range(k+1):
#            if x + y + z == s:
#                cnt = cnt + 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
c=0
if (b-a)>k+1:
  c=1
elif (a%k)-(b%k)>=0:
    c=1
else:
  c=0
if c==1:
  print('ok')
else:
  print('ng')

Fixed submission:
k=int(input())
suzi_list=input().split()
a=int(suzi_list[0])
b=int(suzi_list[1])
c=(b//k)*k
if a<=c:
  print('OK\n')
else:
  print('NG\n')

Buggy python submission (verdict: Runtime Error):
c=0
if (b-a)<+1:
  c=1
elif (a%k)-(b%k)>-1:
    c=1
else:
  c=0
if c==1:
  print('ok')
else:
  print('ng')

Fixed submission:
k=int(input())
suzi_list=input().split()
a=int(suzi_list[0])
b=int(suzi_list[1])
c=(b//k)*k
if a<=c:
  print('OK\n')
else:
  print('NG\n')

Buggy python submission (verdict: Runtime Error):
c=0
if (b-a)<k:
  c=1
elif (a%k)-(b%k)>0:
    c=1
else:
  c=0
if c=1:
  print(ok)
else:
  print(ng)

Fixed submission:
k=int(input())
suzi_list=input().split()
a=int(suzi_list[0])
b=int(suzi_list[1])
c=(b//k)*k
if a<=c:
  print('OK\n')
else:
  print('NG\n')

Buggy python submission (verdict: Runtime Error):
b=0
if (b-a)>k:
  print("ok")
else:
  for i in range(1,1001):
    if a<i*k<b:
      b=1
if b=0:
  print("ng")
else:
  print("ok")

Fixed submission:
k=int(input())
suzi_list=input().split()
a=int(suzi_list[0])
b=int(suzi_list[1])
c=(b//k)*k
if a<=c:
  print('OK\n')
else:
  print('NG\n')
Buggy python submission (verdict: Runtime Error):
print(int(input)/3)

Fixed submission:
a = int(input())/3
print(a*a*a)
Buggy python submission (verdict: Runtime Error):
x,a = [int(i) for i in input().split()]

if x < a:
    print(0)
else:
    

Fixed submission:
x,a = [int(i) for i in input().split()]

if x < a:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [[1,int(i)] for i in input().split()]
bc = [[int(i) for i in input().split()] for j in range(m)]
x = a+bc
x.sort(key=lambda y:y[1])
total = 0
ans = 0
for i in reversed(range(n+m)):
    if total >= n:
        break
    else:
        ans += x[1][i]*min(n-total,x[0][i])
        total += x[0][i]
print(ans)

Fixed submission:
n,m = map(int,input().split())
a = [[1,int(i)] for i in input().split()]
bc = [[int(i) for i in input().split()] for j in range(m)]
x = a+bc
x.sort(key=lambda y:y[1])
total = 0
ans = 0
for i in reversed(range(n+m)):
    if total >= n:
        break
    else:
        ans += x[i][1]*min(n-total,x[i][0])
        total += x[i][0]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
for i in range(m):
    b,c = map(int,input().split())
    a.extend([c]*b)
a.sort()
print(sum(a[len(a)-n:]))

Fixed submission:
n,m = map(int,input().split())
a = [[1,int(i)] for i in input().split()]
bc = [[int(i) for i in input().split()] for j in range(m)]
x = a+bc
x.sort(key=lambda y:y[1])
total = 0
ans = 0
for i in reversed(range(n+m)):
    if total >= n:
        break
    else:
        ans += x[i][1]*min(n-total,x[i][0])
        total += x[i][0]
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
possible_answers = []
possible_answer = 0
acgt = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    if s[i] in acgt:
        possible_answer += 1
    else:
        possible_answers.append(possible_answer)
        possible_answer = 0

print(max(possible_answers))

Fixed submission:
s = input()
possible_answers = [0]
possible_answer = 0
acgt = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    if s[i] in acgt:
        possible_answer += 1
    else:
        possible_answers.append(possible_answer)
        possible_answer = 0

possible_answers.append(possible_answer)
print(max(possible_answers))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
inf = 10**10
dp = [inf]*n
dp[0] = 0

for i in range(1,n):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(min(i,k)+1))

print(dp[n-1])

Fixed submission:
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
inf = 10**10
dp = [inf]*n
dp[0] = 0
 
for i in range(1,n):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(min(i,k)+1))
 
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
dp = [float('inf')]*n
dp[0] = 0

for i in range(1,n):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(min(i,k)+1))

print(dp[n-1])

Fixed submission:
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
inf = 10**10
dp = [inf]*n
dp[0] = 0
 
for i in range(1,n):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(min(i,k)+1))
 
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
dp = [float('inf')]*n
dp[0] = 0

for i in range(1,n):
    for j in range(1,k+1):
        if i >= j:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
        else:
            break

print(dp[n-1])

Fixed submission:
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
inf = 10**10
dp = [inf]*n
dp[0] = 0
 
for i in range(1,n):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(min(i,k)+1))
 
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
dp = [float('inf')]*n
dp[0] = 0
if n == 2:
    print(h[1]-h[0])
else:
    for i in range(1,n):
        for j in range(1,k+1):
            if i >= j:
                dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
    print(dp[n-1])

                

Fixed submission:
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
inf = 10**10
dp = [inf]*n
dp[0] = 0
 
for i in range(1,n):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(min(i,k)+1))
 
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
import fractions

N,X = map(int,input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
y = [0]*N
for i in range(N):
    y[i] = x[i+1]-x[i]

answer = fractions.gcd(y[0],y[1])
for i in range(2,N):
    answer = fractions.gcd(answer,y[i])

print(answer)


Fixed submission:
import fractions

N,X = map(int,input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
y = [0]*N
for i in range(N):
    y[i] = x[i+1]-x[i]

if len(y) == 1:
    print(y[0])
else:
    answer = fractions.gcd(y[0],y[1])
    for i in range(2,N):
        answer = fractions.gcd(answer,y[i])
    print(answer)

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

N,X = map(int,input().split())
x = [int(input()) for i in range(N)]
x.append(X)
x.sort()
y = [0]*N
for i in range(N):
    y[i] = x[i+1]-x[i]

answer = fractions.gcd(y[0],y[1])
for i in range(2,N):
    answer = fractions.gcd(answer,y[i])

print(answer)


Fixed submission:
import fractions

N,X = map(int,input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
y = [0]*N
for i in range(N):
    y[i] = x[i+1]-x[i]

if len(y) == 1:
    print(y[0])
else:
    answer = fractions.gcd(y[0],y[1])
    for i in range(2,N):
        answer = fractions.gcd(answer,y[i])
    print(answer)
Buggy python submission (verdict: Runtime Error):
mport sys
input = sys.stdin.readline

a, b, c = list(map(int, input().split()))
x = a
a = b
b = x

x = a
a = c
c = x

print(a, b, c)

Fixed submission:
import sys
input = sys.stdin.readline

a, b, c = list(map(int, input().split()))
x = a
a = b
b = x

x = a
a = c
c = x

print(a, b, c)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
a = list(map(int, input().split()))
r = 0
x = 0.0
max = 0
for i in range(n-k+1):
  sum = 0
  for j in range(k):
    sum += a[i+j]
  if max < sum:
    max = sum
    r = i
for j in range(k):
  d = a[r+j]
  x += (((d+1)*d)/2)/d
print(x)

Fixed submission:
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = {}
r = s = m = 0
for i in range(k):
  s += a[i]
  if a[i] in b:
    pass
  else:
    d = a[i]
    b[d] = (d+1)/2.0
m = s
    
for i in range(n-k):
  s = s - a[i] + a[k+i]
  if a[k+i] in b:
    pass
  else:
    d = a[k+i]
    b[d] = (d+1)/2.0
  if m < s:
    m = s
    r = i+1
    
sp = 0.0
for i in range(k):
  sp += b[a[r+i]]
print(sp)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
a = list(map(int, input().split()))
max = 0.0
for i in range(n-k+1):
  sum = 0
  for j in range(k):
    d = a[i+j]
    sum += (((d+1)*d)/2)/d
  if max < sum:
    max = sum
print(max)

Fixed submission:
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = {}
r = s = m = 0
for i in range(k):
  s += a[i]
  if a[i] in b:
    pass
  else:
    d = a[i]
    b[d] = (d+1)/2.0
m = s
    
for i in range(n-k):
  s = s - a[i] + a[k+i]
  if a[k+i] in b:
    pass
  else:
    d = a[k+i]
    b[d] = (d+1)/2.0
  if m < s:
    m = s
    r = i+1
    
sp = 0.0
for i in range(k):
  sp += b[a[r+i]]
print(sp)
Buggy python submission (verdict: Runtime Error):

import math

def combain(X, Y):
    return int(math.factorial(X) / math.factorial(Y))

N = int(input())
S = []

ans = 0

for i in range(N):
    S.append(sorted(input()))

S.sort()

ans = 0

X = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        X += 1
    elif X > 1:
        C = combain(X, 2)
        X = 1
        ans += C

if X > 1:
    C = combain(X, 2)
    X = 1
    ans += C

print(ans)



Fixed submission:

def combain(X, Y):
    return int(( X * (X - 1)) / Y)

N = int(input())
S = []

ans = 0

for i in range(N):
    S.append(sorted(input()))

S.sort()

ans = 0

X = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        X += 1
    elif X > 1:
        C = combain(X, 2)
        X = 1
        ans += C

if X > 1:
    C = combain(X, 2)
    X = 1
    ans += C
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
S = []

ans = 0

for i in range(N):
    S.append(sorted(input()))

for i in range(N):
    s_i = S[i]

    for j in range(i+1, N):
        s_j = S[j]

        if s_i == s_j:
            ans += 1


print(ans)

Fixed submission:

def combain(X, Y):
    return int(( X * (X - 1)) / Y)

N = int(input())
S = []

ans = 0

for i in range(N):
    S.append(sorted(input()))

S.sort()

ans = 0

X = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        X += 1
    elif X > 1:
        C = combain(X, 2)
        X = 1
        ans += C

if X > 1:
    C = combain(X, 2)
    X = 1
    ans += C
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
S = []

ans = 0

for i in range(N):
    S.append(input())

for i in range(N):
    s_i = S[i]

    for j in range(i+1, N):
        s_j = S[j]

        if sorted(s_i) == sorted(s_j):
            ans += 1


print(ans)

Fixed submission:

def combain(X, Y):
    return int(( X * (X - 1)) / Y)

N = int(input())
S = []

ans = 0

for i in range(N):
    S.append(sorted(input()))

S.sort()

ans = 0

X = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        X += 1
    elif X > 1:
        C = combain(X, 2)
        X = 1
        ans += C

if X > 1:
    C = combain(X, 2)
    X = 1
    ans += C
    
print(ans)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split(" "))

ans = 2019
for i in range(L, min(R, (L + 2019 * 1000 )):
    ans = min(ans, (i * (i + 1)) % 2019)


print(ans)

Fixed submission:
L, R = map(int, input().split(" "))

ans = 2019
for i in range(L, min(R, L + 2019 * 10)):
    for j in range(i + 1, min(R+1, L + 2019 * 10)):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split(" "))
L = list(map(int, input().split(" ")))

ans=0

cur_X = 0
pos_N = 0
while cur_X <= X and pos_N <= N:
    cur_X += L[pos_N]
    pos_N += 1
    ans += 1

print(ans)


Fixed submission:

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

ans = 1
cur_X = 0
pos_N = 0

for i in range(N):
    ans += 1
    cur_X += L[i]

    if cur_X > X:
        ans -= 1
        break

print(ans)

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

ans=0

cur_X = 0
pos_N = 0
while cur_X <= X and pos_N <= N:
    cur_X += L[pos_N]
    pos_N += 1
    ans += 1

print(ans)

Fixed submission:

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

ans = 1
cur_X = 0
pos_N = 0

for i in range(N):
    ans += 1
    cur_X += L[i]

    if cur_X > X:
        ans -= 1
        break

print(ans)