Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
def ncr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n=int(input())
slist=[''.join(sorted(input())) for i in range(n)]
res=0
for s in set(slist):
    cnt = slist.count(s)
    if cnt > 1:
        res += ncr(cnt,2)
print(res)

Fixed submission:
n=int(input())
sdict={}
cnt=0
for i in range(n):
    s=''.join(sorted(input()))
    if s in sdict:
        sdict[s] += 1
        cnt += sdict[s] - 1
    else:
        sdict[s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
slist=[]
for i in range(n):
    slist.append(''.join(sorted(input())))
dup = [s for s in set(slist) if slist.count(s) > 1]
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
res=0
for s in dup:
    res += combinations_count(slist.count(s),2)
print(res)

Fixed submission:
n=int(input())
sdict={}
cnt=0
for i in range(n):
    s=''.join(sorted(input()))
    if s in sdict:
        sdict[s] += 1
        cnt += sdict[s] - 1
    else:
        sdict[s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
slist=[]
for i in range(n):
    slist.append(''.join(sorted(input())))
dup = [s for s in set(slist) if slist.count(s) > 1]
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
res=0
for s in dup:
    res += combinations_count(slist.count(s),2)
print(res)

Fixed submission:
n=int(input())
sdict={}
cnt=0
for i in range(n):
    s=''.join(sorted(input()))
    if s in sdict:
        sdict[s] += 1
        cnt += sdict[s] - 1
    else:
        sdict[s] = 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n=int(input())
plist=list(map(int, input().split()))
k=0
for i in range(1,n+1):
    if i != plist[i]:
        k+=1
if k <= 2:
    print('YES')
else:
    print('NO')

Fixed submission:
n=int(input())
plist=list(map(int, input().split()))
k=0
for i in range(1,n+1):
    if i != plist[i-1]:
        k+=1
if k <= 2:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
n=int(input())
monsters=list(map(int, input().split()))
battle=list(map(int, input().split()))
remain=0
win=0
for i in range(n):
    if remain != 0:
        win += remai
        battle[i] -= remain
        remain = 0
    if monsters[i] < battle[i]:
        win += monsters[i]
        monsters[i+1] -= battle[i] - monsters[i]
    else:
        win += battle[i]
        remain = monsters[i] - battle[i]
print(win)

Fixed submission:
n=int(input())
monsters=list(map(int, input().split()))
battle=list(map(int, input().split()))
remain=0
win=0
for i in range(n):
    if monsters[i] < battle[i]:
        win += monsters[i]
        if monsters[i+1] >= battle[i] - monsters[i]:
            win += battle[i] - monsters[i]
            monsters[i+1] -= battle[i] - monsters[i]
        else:
            win += monsters[i+1]
            monsters[i+1] = 0
    else:
        win += battle[i]
print(win)
Buggy python submission (verdict: Runtime Error):
n=int(input())
alist=[int(input()) for i in range(n)]
b=alist.sort(reverse=True)
for a in alist:
    if a < b[0]:
        print(b[1])
    elif b[0] <= a:
        print(b[0])

Fixed submission:
n=int(input())
alist=[int(input()) for i in range(n)]
b=sorted(alist, reverse=True)
for a in alist:
    if a < b[0]:
        print(b[0])
    elif b[0] <= a:
        print(b[1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
alist=[int(input()) for i in range(n)]
for i in range(n):
    if i == 0:
        max_a = 0
    else:
        max_a = max(alist[0:i])
    if i == n-1:
        max_b = alist[-1]
    else:
        max_b = max(alist[i+1:])
    print(max([max_a, max_b]))

Fixed submission:
n=int(input())
alist=[int(input()) for i in range(n)]
b=sorted(alist, reverse=True)
for a in alist:
    if a < b[0]:
        print(b[0])
    elif b[0] <= a:
        print(b[1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
alist=[int(input()) for i in range(n)]
for i in range(n):
    if i == 0:
        max_a = 0
    else:
        max_a = max(alist[0:i])
    if i == n-1:
        max_b = alist[-1]
    else:
        max_b = max(alist[i+1:])
    print(max([max_a, max_b]))

Fixed submission:
n=int(input())
alist=[int(input()) for i in range(n)]
b=sorted(alist, reverse=True)
for a in alist:
    if a < b[0]:
        print(b[0])
    elif b[0] <= a:
        print(b[1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
alist=[int(input()) for in range(n)]
max = 0
for i,a in enumerate(alist):
    max_a = max(alist[0:i])
    max_b = max(alist[i+1:])
    print(max([max_a, max_b]))

Fixed submission:
n=int(input())
alist=[int(input()) for i in range(n)]
b=sorted(alist, reverse=True)
for a in alist:
    if a < b[0]:
        print(b[0])
    elif b[0] <= a:
        print(b[1])
Buggy python submission (verdict: Runtime Error):
L,R=map(int, input().split())
n=R-L
ans=[]
if L < 2019:
    for i in range(n+1):
        l=L+i
        ans.append(l % 2019)
    a=ans.sort()
    print(a[0]*a[1])
else:
    if R < 4038:
        for i in range(n+1):
            l=L+i
            ans.append(l % 2019)
        a=ans.sort()
        print(a[0]*a[1])
    else:
        print(0)



Fixed submission:
L,R=map(int, input().split())
n=R-L
ans=[]
if n == 1:
    print((L*R)%2019)
elif n < 2019:
    for i in range(n+1):
        for j in range(1,n+1):
            l=L+i
            r=l+j
            if r > R:
                break
            ans.append((l*r) % 2019)
    print(min(ans))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
L,R=map(int, input().split())
n=R-L
ans=[]

for i in range(n):
    l=L+i
    for j in range(i+1, n):
        r=l+j
        if r > R:
            break
        ans.append((l*r) % 2019)
print(min(ans))

Fixed submission:
L,R=map(int, input().split())
n=R-L
ans=[]
if n == 1:
    print((L*R)%2019)
elif n < 2019:
    for i in range(n+1):
        for j in range(1,n+1):
            l=L+i
            r=l+j
            if r > R:
                break
            ans.append((l*r) % 2019)
    print(min(ans))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
L,R=map(int, input().split())
n=R-L
x=[i+L for i in range(n)]
ans=[]

for i in range(n):
    l=L+i
    for j in range(i+1, n):
        r=l+j
        if r >= R:
            break
        ans.append((l*r) % 2019)
print(min(ans))

Fixed submission:
L,R=map(int, input().split())
n=R-L
ans=[]
if n == 1:
    print((L*R)%2019)
elif n < 2019:
    for i in range(n+1):
        for j in range(1,n+1):
            l=L+i
            r=l+j
            if r > R:
                break
            ans.append((l*r) % 2019)
    print(min(ans))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int, input().split()))
d=0
dlist=[]
dlist.append(0)
for i in range(2,n+2):
    d=d+l[i-1]
    if d <= x:
        dlist.append(d)
print(len(dlist))


Fixed submission:
n,x=map(int,input().split())
l=list(map(int, input().split()))
d=0
dlist=[]
dlist.append(0)
for i in range(1,n+1):
    d=d+l[i-1]
    if d <= x:
        dlist.append(d)
print(len(dlist))
Buggy python submission (verdict: Runtime Error):
a,b=map(int, sinput().split())
if a >= 13:
    print(b)
elif 6 <= a and a <= 12:
    print(b/2)
else:
    print(0)


Fixed submission:
a,b=map(int, input().split())
if a <= 5:
    print(0)
elif 6 <= a and a <= 12:
    print(int(b/2))
else:
    print(b)
Buggy python submission (verdict: Runtime Error):
N,M=map(int, input().split())
pass_id = range(1,N+1)

for i in range(M):
    L,R=map(int, input().split())
    for id in pass_id:
        if not id in range(L,R+1):
            pass_id.pop(pass_id.index(id))
print(len(pass_id))

Fixed submission:
N, M = map(int, input().split())
l, r = 1, N
for i in range(M):
    L, R = map(int, input().split())
    l = max(l, L)
    r = min(r, R)

print(max(0, r - l + 1))
Buggy python submission (verdict: Runtime Error):
s = input()
r_cnt = 0
b_cnt = 0
for color in s:
  if color == 'R':
    r_cnt += 1
    if r_cnt > (s.length/2):
      print('Yes')
      break
  else:
    b_cnt += 1
    if b_cnt > (s.length/2):
      print('No')
      break
else:
  if r_cnt > b_cnt:
    print('Yes')
  else:
    print('No')


Fixed submission:
n=input()
s = input()
r_cnt = 0
b_cnt = 0
for color in s:
  if color == 'R':
    r_cnt += 1
  else:
    b_cnt += 1
else:
  if r_cnt > b_cnt:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
r_cnt = 0
b_cnt = 0
for color in s:
  if color == 'R':
    r_cnt += 1
    if r_cnt > (s.length/2):
      print('Yes')
      break
  else:
    b_cnt += 1
    if b_cnt > (s.length/2):
      print('No')
      break



 

 

Fixed submission:
n=input()
s = input()
r_cnt = 0
b_cnt = 0
for color in s:
  if color == 'R':
    r_cnt += 1
  else:
    b_cnt += 1
else:
  if r_cnt > b_cnt:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
for color in s:


Fixed submission:
n=input()
s = input()
r_cnt = 0
b_cnt = 0
for color in s:
  if color == 'R':
    r_cnt += 1
  else:
    b_cnt += 1
else:
  if r_cnt > b_cnt:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int, input.split())
max=a*c
if b >= max:
    print(c)
else:
    print(b//a)


Fixed submission:
a,b,c=map(int, input().split())
if b >= a*c:
    print(c)
else:
    print(b//a)
Buggy python submission (verdict: Runtime Error):
from datetime import datetime
input_date = datetime.datetime.strptime(input(), "%Y%m%d")

heisei = datetime.datetime(2019,4,30)
if input_date < heisei:
    print('Heisei')
else:
    print('TBD')





Fixed submission:
import datetime
s=input()

input_date = datetime.datetime.strptime(s, "%Y/%m/%d")
heisei = datetime.datetime(2019,4,30)

if input_date <= heisei:
    print('Heisei')
else:
    print('TBD')

Buggy python submission (verdict: Runtime Error):
from datetime import datetime
input_date = datetime.datetime(input(), "%Y%m%d")

heisei = datetime.datetime(2019,4,30)
if input_date < heisei:
    print('Heisei')
else:
    print('TBD')

Fixed submission:
import datetime
s=input()

input_date = datetime.datetime.strptime(s, "%Y/%m/%d")
heisei = datetime.datetime(2019,4,30)

if input_date <= heisei:
    print('Heisei')
else:
    print('TBD')
Buggy python submission (verdict: Runtime Error):
n=int(input())
sum=0

for i in range(n):
    value,unit=map(int, input().split())
    if unit == 'BTC':
        sum += value * 380000
    else:
        sum+=value
print(sum)

Fixed submission:
n=int(input())
sum=0

for i in range(n):
    value,unit=map(str, input().split())
    if unit == 'BTC':
        sum += float(value) * 380000
    else:
        sum+=float(value)
print(sum)
Buggy python submission (verdict: Runtime Error):
n,m=map(int, input().split())
cnt = [0]*m
for i in range(n):
    like = list(map(int, input().split()))
    k = like.pop(0)
    for j in like:
        cnt[j] += 1

all_like=0
for _ in cnt:
    if _ == n:
        all_like += 1


Fixed submission:
n,m=map(int, input().split())
cnt = [0]*m
for i in range(n):
    like = list(map(int, input().split()))
    k = like.pop(0)
    for j in like:
        cnt[j-1] += 1

all_like=0
for _ in cnt:
    if _ == n:
        all_like += 1
print(all_like)
Buggy python submission (verdict: Runtime Error):
ab,bc,ca=map(int,input().spit())
print(ab*bc*0.5)

Fixed submission:
ab,bc,ca=map(int,input().split())
print(int(ab*bc*0.5))
Buggy python submission (verdict: Runtime Error):
s=int(input())
an=[0]*1000000
tmp=[False]*300
an[0] = s
for i in range(1, 1000000):
    if an[i-1] % 2 == 0:
        an[i] = int(an[i-1]/2)
    else:
        an[i] = 3*an[i-1] + 1
    if not tmp[an[i]]:
        tmp[an[i]] = True
    else:
        print(i+1)
        exit()


Fixed submission:
s = int(input())
def f(x):
  if x % 2 == 0:
    return x/2
  else:
    return 3 * x + 1

X = [s]
m = 1
next = s

while True:
  m += 1
  next = f(next)
  if next in X:
    break
  else:
    X.append(next)
    
print(m)

Buggy python submission (verdict: Runtime Error):
s=int(input())
an=[0]*1000000
tmp=[False]*300
an[0] = s
for i in range(1, 1000000):
    if an[i-1] % 2 == 0:
        an[i] = an[i-1]/2
    else:
        an[i] = 3*an[i-1] + 1
    if not tmp[an[i]]:
        tmp[an[i]] = True
    else:
        print(i)
        exit()
        

Fixed submission:
s = int(input())
def f(x):
  if x % 2 == 0:
    return x/2
  else:
    return 3 * x + 1

X = [s]
m = 1
next = s

while True:
  m += 1
  next = f(next)
  if next in X:
    break
  else:
    X.append(next)
    
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
N, K=map(int, input().split())
h=list(map(int, input().split()))
dp = [10**5] * N
dp[0] = 0
for i in range(1, N):
    x = max(0, i-K)
    dp[i] = min([dp[j]+abs(h[j]-h[i]) for j in range(x, i)])
print(dp[-1])

Fixed submission:
N, K=map(int, input().split())
h=list(map(int, input().split()))
dp = [10**5] * N
dp[0] = 0
for i in range(1, N):
    x = max(0, i-K)
    dp[i] = min([dp[j]+abs(h[j]-h[i]) for j in range(x, i)])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N, K=map(int, input().split())
h=list(map(int, input().split()))
dp = [10**5] * N
dp[0] = 0
for i in range(1, N):
    x = max(0, i-K)
    dp[i] = min([dp[j]+abs(h[j]-h[i]) for j in range(x, i)])
print(dp[-1])

Fixed submission:
N, K=map(int, input().split())
h=list(map(int, input().split()))
dp = [10**5] * N
dp[0] = 0
for i in range(1, N):
    x = max(0, i-K)
    dp[i] = min([dp[j]+abs(h[j]-h[i]) for j in range(x, i)])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N, K=map(int, input().split())
h=list(map(int, input().split()))
dp = [10**5] * (N+K)
dp[0] = 0
dp[1] = dp[0] + abs(h[0]-h[1])
for i in range(2, N):
    dp[i] = min([dp[i-k] + abs(h[i-k]-h[i]) for k in range(1, K+1)])
print(dp[N-1])

Fixed submission:
N, K=map(int, input().split())
h=list(map(int, input().split()))
dp = [10**5] * N
dp[0] = 0
for i in range(1, N):
    x = max(0, i-K)
    dp[i] = min([dp[j]+abs(h[j]-h[i]) for j in range(x, i)])
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
N, W=map(int, input().split())
WV=[list(map(int, input().split())) for i in range(N)]
dp = [-1] * (W+1)
dp[0] = 0
for w, v in WV:
    for i in range(W, w-1, -1):
        if dp[i-w] == -1:
            continue
        dp[i] = max(dp[i], dp[i-w] + v)
print(max(dp))


Fixed submission:
N, W=map(int, input().split())
WV=[list(map(int, input().split())) for i in range(N)]
dp = [-1] * (W+1)
dp[0] = 0
for w, v in WV:
    for i in range(W, w-1, -1):
        if dp[i-w] == -1:
            continue
        dp[i] = max(dp[i], dp[i-w] + v)
print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')
N, W=map(int, input().split())
WV=[list(map(int, input().split())) for i in range(N)]
dp = [-1] * (W+1)
dp[0] = 0
for w, v in WV:
    for i in range(W, w-1, -1):
        if dp[i-w] == -1:
            continue
        dp[i] = max(dp[i], dp[i-w] + v)
print(max(dp))


Fixed submission:
N, W=map(int, input().split())
WV=[list(map(int, input().split())) for i in range(N)]
dp = [-1] * (W+1)
dp[0] = 0
for w, v in WV:
    for i in range(W, w-1, -1):
        if dp[i-w] == -1:
            continue
        dp[i] = max(dp[i], dp[i-w] + v)
print(max(dp))
Buggy python submission (verdict: Runtime Error):
s=input()
import math
xlist=[math.abs(int(s[i:i+2])-753) for i in range(0,len(s)-3)]
print(min(xlist))

Fixed submission:
s=input()
xlist=[abs(int(s[i:i+3])-753) for i in range(len(s)-2)]
print(min(xlist))
Buggy python submission (verdict: Runtime Error):
num=list(map(int,input()))
num.sort(reverse=True)
print(num[0]*10+num[1]+num[2])

Fixed submission:
num=list(map(int,input().split()))
num.sort(reverse=True)
print(num[0]*10+num[1]+num[2])
Buggy python submission (verdict: Runtime Error):
S=input()
judge='AC'
cnt = 0

for i in len(S):
    if S[i].isupper():
        if i == 0 or i == len(S) - 2 or S[i] != 'C':
            judge = 'WA'
        cnt+=1

if cnt != 1:
    judge = 'WA'
print(judge)


Fixed submission:
S=input()

judge = "AC" if (S[0] == 'A' and S[2:-1].count('C') == 1 and S[1:].replace('C', '').islower()) else "WA"
print(judge)
Buggy python submission (verdict: Runtime Error):
N=input()
sn = 0
for n in N:
    sn += int(n)

if N % sn == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
N=input()
sn = 0
for n in N:
    sn += int(n)

if int(N) % sn == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
d,n=map(int,input().spilit())
if d==0:
  print('5')
else:
  a=100**d
  print(a*n)

Fixed submission:
d,n=map(int,input().split())
if n < 100:
  print(n*(100**d))
else:
  print((n+1)*100**d)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
print(max(len(set(S[:i]&set(S[i:])) for i in range(N))))

Fixed submission:
N=int(input())
S=input()
print(max(len(set(S[:i]) & set(S[i:])) for i in range(N)))
Buggy python submission (verdict: Runtime Error):
N,X=map(int, input().split())
M=list(map(int, input().split()))
X = X - sum(M)
cnt += N
cnt += X // min(M)
print(cnt)

Fixed submission:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N,X=map(int, input().split())
M=[int(input()) for i in range(N)]
Y = X - sum(M)

cnt = N
cnt += (Y // min(M))
print(cnt)
Buggy python submission (verdict: Runtime Error):
N,Y=map(int, input().split())
result = [-1,-1,-1]
for i in range(N):
    for j in range(N):
        k = N - i + j 
        sum = 10000*i + 5000* j + 1000*k
        if Y == sum:
            result = [i, j, k]
            break
print(result.join(" "))


Fixed submission:
N,Y=map(int, input().split())
result = ["-1","-1","-1"]
for i in range(N+1):
    for j in range(N-i+1):
        k = N - (i + j) 
        x = 10000 * i + 5000 * j + 1000 * k
        if Y == x:
            result = [str(i), str(j), str(k)]
            break
print(" ".join(result))

Buggy python submission (verdict: Runtime Error):
N,Y=map(int, input().split())
result = [-1,-1,-1]
for i in range(N):
    for j in range(N):
        k = N - i + j 
        sum = 10000*i + 5000* j + 1000*k
        if Y == sum:
            result = [i, j, k]
            break
print(" ".join(result))


Fixed submission:
N,Y=map(int, input().split())
result = ["-1","-1","-1"]
for i in range(N+1):
    for j in range(N-i+1):
        k = N - (i + j) 
        x = 10000 * i + 5000 * j + 1000 * k
        if Y == x:
            result = [str(i), str(j), str(k)]
            break
print(" ".join(result))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


Q=int(input())
fn=[99999 for i in range(10**5+100)]
for i in range(Q):
    
    L, R=map(int, input().split())
    for x in range(L, R+1):
        if fn[x] != 99999:
            continue
        if is_prime(x) and is_prime(int((x+1)/2)):
            fn[x] = 1
        else:
            fn[x] = 0
    print(sum(fn[L:R+1]))


Fixed submission:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left

import math
n = 10**5
e = [True]*(n+1)
e[0] = False
e[1] = False
for i in range(2, int(n**0.5)+1):
    if not e[i]:
        continue
    for j in range(i*2, n+1, i):
        e[j] = False

c = [0]*(n+2)
for i in range(3, n+1, 2):
    if e[i] and e[(i+1)//2]:
        c[i] += 1

for i in range(3, n+1):
    c[i] += c[i-1]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(c[r]-c[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from itertools import product, permutations, combinations
N=int(input())
A=sorted(list(map(int, input().split())), reverse=True)
B=sorted(list(map(int, input().split())), reverse=True)
C=sorted(list(map(int, input().split())), reverse=True)

ret = 0
for i in C:
    small_b = [b for b in B if b < i]
    for j in small_b:
        small_a = [a for a in A if a < j]
        ret += len(small_a)

print(ret)

Fixed submission:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
N=int(input())
A=sorted(list(map(int, input().split())))
B=sorted(list(map(int, input().split())))
C=sorted(list(map(int, input().split())))


ret = 0
for i in range(N):
    # 中段を決めた時、その値より小さくなる上段を探す
    new_A = bisect_left(A, B[i])
    # 中段を決めた時、その値より大きくなる下段を探す
    new_C = bisect_right(C, B[i])
    # 組み合わせ
    ret += new_A * (N - new_C)

print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
cnt=0
for z in range(0, k+1):
    for y in range(0, k+1):
        for x in range(0, k+1):
            if (x+y+z)==s:
                cnt+=1
print(cnt)

Fixed submission:
k,s = map(int,input().split())
cnt=0
for x in range(0, k+1):
    for y in range(0, k+1):
        z = s-x-y
        if 0 <= z and z <= k:
          cnt+=1
            
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
As = [int(x) for x in input().split()]
rs = list(range(1,N+1))
print(" ".join(map(str,[As.index(r)+1 for r in rs])))

Fixed submission:
N = int(input())
As = [int(x) for x in input().split()]
rs = list(range(1,N+1))
for i,A in enumerate(As):
    rs[A-1] =i+1

print(" ".join(map(str,rs)))
Buggy python submission (verdict: Runtime Error):
import collections
from math import factorial

N =int(input())
cnts = [frozenset(collections.Counter(list(input())).items()) for _ in range(N)]
xs = collections.Counter(cnts)
ans = 0
for _,v in xs.items():
    if v>=1:
        a = factorial(v) // (2*factorial(v - 2))
        ans +=a
print(ans)

Fixed submission:
import collections
from math import factorial

N =int(input())
cnts = [frozenset(collections.Counter(list(input())).items()) for _ in range(N)]
xs = collections.Counter(cnts)
ans = 0
for _,v in xs.items():
    if v>1:
        a = factorial(v) // (2*factorial(v - 2))
        ans +=a
print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
from scipy.special import comb
N =int(input())
cnts = [frozenset(collections.Counter(list(input())).items()) for _ in range(N)]
xs = collections.Counter(cnts)
ans = 0
for _,v in xs.items():
    if v>=1:
        a = comb(v, 2, exact=True)
        ans +=a
print(ans)

Fixed submission:
import collections
from math import factorial

N =int(input())
cnts = [frozenset(collections.Counter(list(input())).items()) for _ in range(N)]
xs = collections.Counter(cnts)
ans = 0
for _,v in xs.items():
    if v>1:
        a = factorial(v) // (2*factorial(v - 2))
        ans +=a
print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
from scipy.special import comb
N =int(input())
cnts = [frozenset(collections.Counter(list(input())).items()) for _ in range(N)]
xs = collections.Counter(cnts)
ans = 0
for _,v in xs.items():
    if v>=1:
        a = comb(v, 2, exact=True)
        ans +=a
print(ans)

Fixed submission:
import collections
from math import factorial

N =int(input())
cnts = [frozenset(collections.Counter(list(input())).items()) for _ in range(N)]
xs = collections.Counter(cnts)
ans = 0
for _,v in xs.items():
    if v>1:
        a = factorial(v) // (2*factorial(v - 2))
        ans +=a
print(ans)