Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N, A = map(int, readline().rstrip().split())
    X = list(map(int, readline().rstrip().split()))
    X = [x-A for x in X]
    ans = 0
    X1 = X[:N//2]
    X2 = X[N//2:]
    X1_sum = [0]
    for i in range(1, 2**len(X1)):
        b = bin(i)[2:].zfill(len(X1))
        su = sum([X1[i] for i, e in enumerate(b) if e == '1'])
        X1_sum.append(su)
    X2_sum = [0]
    for i in range(1, 2**len(X2)):
        b = bin(i)[2:].zfill(len(X2))
        su = sum([X2[i] for i, e in enumerate(b) if e == '1'])
        X2_sum.append(su)
    c = Counter(X2_sum)
    c_keys = c.keys()
    for x1 in X1_sum:
        if -x1 in c_keys:
            ans += c[-x1]

    print(ans - 1)

    
if __name__ == '__main__':
    main()

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

def main():
    N, A = map(int, readline().rstrip().split())
    X = list(map(int, readline().rstrip().split()))
    lim = max(X) * N
    X = [x-A for x in X]
    dp = [[0]*(2*lim) for _ in range(N+1)]
    dp[0][lim] = 1
    for i in range(1, N+1):
        x = X[i-1]
        for j in range(2*lim):
            if 0 <= j - x < 2 * lim:
                dp[i][j] = dp[i-1][j] + dp[i-1][j-x]
            else:
                dp[i][j] = dp[i-1][j]
    
    print(dp[N][lim] - 1)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N, A = map(int, readline().rstrip().split())
    X = list(map(int, readline().rstrip().split()))
    X = [x-A for x in X]
    ans = 0
    X1 = X[:N//2]
    X2 = X[N//2:]
    X1_sum = [0]
    for i in range(1, 2**len(X1)):
        b = bin(i)[2:].zfill(len(X1))
        su = sum([X1[i] for i, e in enumerate(b) if e == '1'])
        X1_sum.append(su)
    X2_sum = [0]
    for i in range(1, 2**len(X2)):
        b = bin(i)[2:].zfill(len(X2))
        su = sum([X2[i] for i, e in enumerate(b) if e == '1'])
        X2_sum.append(su)
    c = Counter(X2_sum)
    c_keys = c.keys()
    for x1 in X1_sum:
        if -x1 in c_keys:
            ans += c[-x1]

    print(ans - 1)

    
if __name__ == '__main__':
    main()

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

def main():
    N, A = map(int, readline().rstrip().split())
    X = list(map(int, readline().rstrip().split()))
    lim = max(X) * N
    X = [x-A for x in X]
    dp = [[0]*(2*lim) for _ in range(N+1)]
    dp[0][lim] = 1
    for i in range(1, N+1):
        x = X[i-1]
        for j in range(2*lim):
            if 0 <= j - x < 2 * lim:
                dp[i][j] = dp[i-1][j] + dp[i-1][j-x]
            else:
                dp[i][j] = dp[i-1][j]
    
    print(dp[N][lim] - 1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def gcd_cnt(t):
    a = 0
    kosuu = n//t
    a=kosuu*(2*t + (kosuu-1)*t)//2
    return a

n = int(input())
sub = 0
#約数でそのままアクセス可能
kosuu_ls = [0]*(n+1)
for t in range(1,n+1):
    sub+=gcd_cnt(t)
print(sub)


Fixed submission:
def gcd_cnt(n):
    sub = 0
    for i in range(1, n+1):
        kosuu = n//i
        sub+=kosuu*(2*i + (kosuu-1)*i)//2
    return sub

n = int(input())
sub = gcd_cnt(n)
print(sub)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd_cnt(t):
    for i in range(t, n+1,t):
        kosuu_ls[i]+=i
    #print("defない", kosuu_ls)

n = int(input())
sub = 0
#約数でそのままアクセス可能
kosuu_ls = [0]*(n+1)
for t in range(1,n+1):
    gcd_cnt(t)
#最後に全部たす
for i in range(1,n+1):
    sub+=(kosuu_ls[i])
print(sub)
#print(kosuu_ls)


Fixed submission:
def gcd_cnt(n):
    sub = 0
    for i in range(1, n+1):
        kosuu = n//i
        sub+=kosuu*(2*i + (kosuu-1)*i)//2
    return sub

n = int(input())
sub = gcd_cnt(n)
print(sub)
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
b = int(b[0])*100 + int(b[1])*10 + int(b[3])
c = a*b
print(c//100)


Fixed submission:
a, b = input().split()
a = int(a)
b = int(b[0])*100 + int(b[2])*10 + int(b[3])
c = a*b
print(c//100)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(a*b//1)

Fixed submission:
a, b = input().split()
a = int(a)
b = int(b[0])*100 + int(b[2])*10 + int(b[3])
c = a*b
print(c//100)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
sub=0
flg_r = 0
flg_g = 0
flg_b = 0#0だと見つかってない
for a in range(n-2):
    rgb = ("R","G","B")
    #print(a)
    for b in range(a+1,n-1):
        #print(a,b)
        rgb_kake = list(rgb)
        rgb_kake.remove(s[a])
        if s[a] != s[b]:
            #print(s[a],s[b],rgb, rgb_kake)
            rgb_kake.remove(s[b])
            for c in range(b+1,n):
                if s[c] == rgb_kake[0]:
                    #print(a,b,c)
                    if b-a != c-b:
                        sub+=1
print(sub)


Fixed submission:
n = int(input())
s = input()
r_cnt = s.count("R")
g_cnt = s.count("G")
b_cnt = s.count("B")

sub = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i+d
        k = j+d
        if k >= n:
            break

        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            sub-=1
print(sub)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
vote_ls = []
vote_num = [0]*n
for i in range(n):
    aaa = input()
    if aaa in vote_ls:
        #print("a")
        vote_num[vote_ls.index(aaa)]+=1
    else:
        vote_ls.append(aaa)
        vote_num[vote_ls.index(aaa)]+=1
#print(vote_num)
sub_ls = []
max_vote = max(vote_num)
for i in range(n):
    if vote_num[i] == max_vote:
        sub_ls.append(vote_ls[i])
sub_ls.sort()
for i in range(len(sub_ls)):
    print(sub_ls[i])


Fixed submission:
n = int(input())
vote_ls = {}
#vote_num = [0]*n
for i in range(n):
    aaa = input()
    if aaa in vote_ls.keys():
        vote_ls[aaa]+=1
    else:
        vote_ls[aaa] = 1
#print(vote_ls)
sub_ls = []
'''
max_vote = max(vote_)
for i in range(n):
    if vote_num[i] == max_vote:
        sub_ls.append(vote_ls[i])
sub_ls.sort()
for i in range(len(sub_ls)):
    print(sub_ls[i])
'''
sorted = sorted(vote_ls.items(), key=lambda x:x[1])
sub_ls.append(sorted[-1])
for i in range(len(sorted)-2,-1,-1):
    if sorted[i][1] == sorted[-1][1]:
        sub_ls.append(sorted[i])
    else:
        break
#print(sub_ls)
sub_ls.sort()
for i in range(len(sub_ls)):
    print(sub_ls[i][0])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p_ls = list(map(int, input().split()))
ave_ls = []
'''
if n == 1:
    ave_ls.append(p_ls[0]*0.5+1)
elif n == 2:
    ave_ls.append((p_ls[0]+p_ls[1])*0.5+1)
else:
    for i in range(n-2):
        ave_ls.append((p_ls[i]+p_ls[i+1]+p_ls[i+2])*0.5+1)
'''
for i in range(n-k+1):
    now_ave = 0
    for j in range(k):
        now_ave+=p_ls[i+j]
    ave_ls.append(now_ave*0.5+0.5*k)
print(max(ave_ls))


Fixed submission:
n, k = map(int, input().split())
p_ls = list(map(int, input().split()))
ave_ls = []
'''
if n == 1:
    ave_ls.append(p_ls[0]*0.5+1)
elif n == 2:
    ave_ls.append((p_ls[0]+p_ls[1])*0.5+1)
else:
    for i in range(n-2):
        ave_ls.append((p_ls[i]+p_ls[i+1]+p_ls[i+2])*0.5+1)
'''
now_ave = 0
for i in range(k):
    now_ave +=p_ls[i]
ave_ls.append(now_ave*0.5+0.5*k)
for i in range(n-k):
    #print(now_ave)
    now_ave -=p_ls[i]
    now_ave+=p_ls[i+k]
    #print("p_ls[i]",p_ls[i],"p_ls[i+k-1]",p_ls[i+k-1])
    ave_ls.append(now_ave*0.5+0.5*k)
print(max(ave_ls))
Buggy python submission (verdict: Time Limit Exceeded):
def search(ind):
    for i in range(ind):
        if p_ls[i] < p_ls[ind]:
            return 0
    return 1

n = int(input())
p_ls = list(map(int, input().split()))
sub_cnt = 0
one = p_ls.index(1)+1
for i in range(one):
    sub_cnt += search(i)
print(sub_cnt)


Fixed submission:
n = int(input())
p_ls = list(map(int, input().split()))
mini = p_ls[0]
cnt = 0
for i in range(n):
    if mini >= p_ls[i]:
        cnt+=1
        mini= p_ls[i]
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
def search(ind):
    for i in range(ind):
        if p_ls[i] < p_ls[ind]:
            return 0
    return 1

n = int(input())
p_ls = list(map(int, input().split()))
sub_cnt = 0
for i in range(n):
    sub_cnt += search(i)
print(sub_cnt)


Fixed submission:
n = int(input())
p_ls = list(map(int, input().split()))
mini = p_ls[0]
cnt = 0
for i in range(n):
    if mini >= p_ls[i]:
        cnt+=1
        mini= p_ls[i]
print(cnt)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
sub_ls = []
for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)
    sub_ls.append([p,s])
ac_cnt = []
wa_cnt = []
for i in range(n):
    ac_cnt.append(0)
    wa_cnt.append(0)
#print(ac_cnt, wa_cnt)
for i in range(m):
    if ac_cnt[sub_ls[i][0]-1] == 0:
        #print(sub_ls[i][1], ac_cnt[i])
        if sub_ls[i][1] == "AC":
            ac_cnt[sub_ls[i][0]-1] = 1
        else:
            wa_cnt[i-1]+=1
ac_sum = 0
wa_sum = 0
for i in range(n):
    if ac_cnt[i] == 1:
        ac_sum+=1
    wa_sum+=wa_cnt[i]
print(ac_sum, wa_sum)


Fixed submission:
n, m = map(int, input().split())
sub_ls = []
for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)-1
    sub_ls.append([p,s])
ac_cnt = []
wa_cnt = []
for i in range(n):
    ac_cnt.append(0)
    wa_cnt.append(0)
#print(ac_cnt, wa_cnt)
for i in range(m):
    if ac_cnt[sub_ls[i][0]] == 0:
        #print(sub_ls[i][1], ac_cnt[i])
        if sub_ls[i][1] == "AC":
            ac_cnt[sub_ls[i][0]] = 1
        else:
            wa_cnt[sub_ls[i][0]]+=1
ac_sum = 0
wa_sum = 0
for i in range(n):
    #print(ac_cnt[i], wa_cnt[i])
    ac_sum+=ac_cnt[i]
    if ac_cnt[i] == 1:
        wa_sum+=wa_cnt[i]
print(ac_sum, wa_sum)
Buggy python submission (verdict: Runtime Error):
x = int(input())
flg = 0
_flg = 1
while flg == 0:
    mx  = int(x**0.5)
    for i in range(2, mx+1):
        if x % i == 0:
            _flg = 0
            break
    fig = _flg
    if flg == 0:
        x+=1
print(x)


Fixed submission:
s, t = map(str, input().split())
print(t+s)
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print( (a*b)//math.gcd(a, b) )


Fixed submission:
import fractions
a, b = map(int, input().split())
print( (a*b)//fractions.gcd(a, b) )
Buggy python submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
man = [0] * n
#合計正解数はq
for i in range(k):
    man[int(input()) - 1]+=1

for i in range(n):
    if k - (q - man[i]) >= 1:
        print("Yes")
    else:
        print("No")


Fixed submission:
n, k, q = map(int, input().split())
man = [0] * n
#合計正解数はq
for i in range(q):
    man[int(input()) - 1]+=1

for i in range(n):
    if k - (q - man[i]) >= 1:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
sub = 0
for i in range(a):
  sub+=i
print(sub)

Fixed submission:
a = int(input())
sub = a*(a-1)//2
print(sub)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
#10^9+7  で割った余り
k = k %(1000000000 + 7)
#その文字より前に大きな数字
before_cnt = 0
#その文字より後に大きな数字
after_cnt = 0
n_list = list(map(int, input().split()))
for i in range(n):
  for j in range(n):
    if n_list[i] > n_list[j]:
      #print("i",i,"j",j)
      if i < j:
        after_cnt+=1
      else:
        before_cnt+=1
kurikaesi = 0
for i in range(1, k+1):
  kurikaesi += i
#print("kurikaesi",kurikaesi)
#print(after_cnt, before_cnt)
print((before_cnt*(kurikaesi-k) + after_cnt*kurikaesi)%(1000000000+7))
      

Fixed submission:
n, k = map(int, input().split())
#10**9+7  で割った余り
#k = k %(10**9 + 7)
#その文字iより前に大きな数字
before_cnt = 0
#その文字より後に大きな数字
after_cnt = 0
n_list = list(map(int, input().split()))
for i in range(n-1):
  for j in range(i+1, n):
    if n_list[i] > n_list[j]:
      before_cnt+=1
    elif n_list[i] < n_list[j]:
      #print("i",i,"j",j)
      after_cnt+=1
      '''
      if i < j:
        after_cnt+=1
      else:
        before_cnt+=1
'''
kurikaesi = int((1 + k)*k//2)
#print("type",type(k),"kurikaesi",kurikaesi)
#print(after_cnt, before_cnt)
print(((after_cnt*(kurikaesi-k) + before_cnt*kurikaesi))%(10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
cnt = 0
pre_word = [""]
#print(s)
i = 1
while s:
  if pre_word[-1] != s[0:i]:
    pre_word.append(s[0:i])
    s = s[i:]
    i = 0
    cnt += 1
  if s == "":
    break
  i+=1
print(cnt)

Fixed submission:
s = input()
cnt = 0
pre_word = [""]
ra = len(s)
i = 0
while True:
  j = 1
  if i+j > ra:
    break
  while True:
    if i+j > ra:
      i+=j
      break
    if pre_word[-1] != s[i:i+j]:
      pre_word.append(s[i:i+j])
      i += j
      j = 0
      cnt += 1
    j+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = int(input())
pf=[]
for i in range(2,int(s**0.5)+1):
    while s%i==0:
        pf.append(i)
        s//=i
if s>1:pf.append(i)
a = 0
b = 0
for i in range(len(pf)):
  if(i%2==0):
    a+=pf[i]
  else:
    b+=pf[i]
if a==0:
  a = 1
if b==0:
  b = 1
print("0","0",a,"0","0",b)



Fixed submission:
import math
s = int(input())
root = math.ceil(s**0.5)
#print("root",root)
diff = abs(root**2 - s)
#print("diff",diff)
pf=[]
a = 0
b = 0
#print(int(diff**0.5))
if diff != 1:
  if diff == 2:
    a = 1
    b = 2
  elif diff == 3:
    a = 1
    b = 3
  else:
    test = int(diff**0.5)+1
    for i in range(2, test):
      #print("diffloop",diff)
#      if i == 1710:
#        print("1710diff",diff)
#      if i ==25322:
#        print("25322diff",diff%i)
      while diff%i==0:
        pf.append(i)
        diff//=i
#        print("i",i,"diff",diff)
    if diff>1:pf.append(diff)
    for i in range(len(pf)):
      if(i%2==0):
        if a ==0:
          a = 1
        a*=pf[i]
      else:
        if b ==0:
          b = 1
        b*=pf[i]
else:
  a = 1
  b = 1
if a != 0 and b == 0:
  b = 1
if b != 0 and a == 0:
  a = 0
if a > 10**9:
  a /= pf[0]
  b *= pf[0]
if b > 10**9:
  a *= pf[0]
  b /= pf[0]
#print("pf",pf)
if a >= 0 and b >= 0:
  print("0","0",a,root,root,b)
elif a >= 0 and b < 0:
  print("0",-b,a,root-b,root,0)
elif a < 0 and b >= 0:
  print(-a,"0","0",root,root-a,b)
else:
  print(-a,-b,"0",root-b,root-a,"0")
Buggy python submission (verdict: Runtime Error):
cnt = int(input())
in_str = [int(i) for i in input().split()]
in_str.sort()
print(in_str[cnt//2+1] - in_str[cnt // 2])

Fixed submission:
cnt = int(input())
in_str = [int(i) for i in input().split()]
in_str.sort()
#print("in_str[cnt // 2-1]",in_str[cnt // 2-1])
#print("in_str[cnt//2]",in_str[cnt//2])
print(in_str[cnt//2] - in_str[cnt // 2-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b, c = [0] * q, [0] * q
for i in range(q):
    b[i], c[i] = map(int, input().split())

sum = 0
kazu = [0] * (10**5)
for i in a:
    kazu[i] += 1
    sum += i
for i in range(q):
    cnt = kazu[b[i]]
    kazu[b[i]] = 0
    kazu[c[i]] += cnt
    sa = c[i] - b[i]
    sum += (sa * cnt)
    print(sum)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b, c = [0] * q, [0] * q
for i in range(q):
    b[i], c[i] = map(int, input().split())

sum = 0
kazu = [0] * (10**5+1) 
for i in a:
    kazu[i] += 1
    sum += i
for i in range(q):
    cnt = kazu[b[i]]
    kazu[b[i]] = 0
    kazu[c[i]] += cnt
    sa = c[i] - b[i]
    sum += (sa * cnt)
    print(sum)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))

p2 = [i for i in range(1, 101)]
p3 = list(set(p2) - set(p))

minv = 1000
for i in p3:
    if abs(i-x) < minv:
        minv = abs(i-x)
        ans = i

print(ans) 


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

if not x in p:
    print(x)
    exit()
up = x + 1
down = x - 1
while True:
    if not down in p:
        print(down)
        exit()
    elif not up in p:
        print(up)
        exit()
    up += 1
    down -= 1
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

ans = 1
for i in range(n):
    ans *= a[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
else:
    print(ans)

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

ans = 1
for i in range(n):
    ans *= a[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))

ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())

nokori = K - A - B

wa = 0
wa += A

if nokori == 0:
    a    
elif C >= nokori:
    wa -= nokori
else:
    wa -= C

print(wa)

Fixed submission:
A, B, C, K = map(int, input().split())

nokori = K - A - B

wa = 0
while True:
    if A >= K:
        wa += K
        break
    else:
        wa += A
    if C >= nokori:
        wa -= nokori
        break
    else:
        wa -= C
        break

print(wa)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int, input().split())

wa = 0
wa += A
nokori = K - A - B

while nokori != 0:
    if C != 0:
        wa -= 1
        C -= 1
        nokori -= 1
    else:
        break

print(wa)

Fixed submission:
A, B, C, K = map(int, input().split())

nokori = K - A - B

wa = 0
while True:
    if A >= K:
        wa += K
        break
    else:
        wa += A
    if C >= nokori:
        wa -= nokori
        break
    else:
        wa -= C
        break

print(wa)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
#a = input().rstrip() 文字の時rstrip()で改行削除

N = int(input())
S = input().rstrip()

min = float("inf")
for i in range(N):
    cnt = 0
    for j in range(i):
        if S[j] != "E":
            cnt += 1
    for j in range(i+1, N):
        if S[j] != "W":
            cnt += 1
    if cnt < min:
        min = cnt

print(min)


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

N = int(input())
S = input().rstrip()
W = [0] * N
E = [0] * N

cnt = 0
for i in range(1, N):
    if S[i-1] == "W":
        cnt += 1
        W[i] = cnt
    else:
        W[i] = cnt
cnt = 0
for i in reversed(range(N-1)):
    if S[i+1] == "E":
        cnt += 1
        E[i] = cnt
    else:
        E[i] = cnt

min = float("inf")
for i in range(N):
    if W[i] + E[i] < min:
        min = W[i] + E[i]
print(min)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
#a = input().rstrip() 文字の時rstrip()で改行削除

N = int(input())
S = input().rstrip()

min = float("inf")
for i in range(N):
    cnt = 0
    for j in range(i):
        if S[j] != "E":
            cnt += 1
    for j in range(i+1, N):
        if S[j] != "W":
            cnt += 1
    if cnt < min:
        min = cnt

print(min)


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

N = int(input())
S = input().rstrip()
W = [0] * N
E = [0] * N

cnt = 0
for i in range(1, N):
    if S[i-1] == "W":
        cnt += 1
        W[i] = cnt
    else:
        W[i] = cnt
cnt = 0
for i in reversed(range(N-1)):
    if S[i+1] == "E":
        cnt += 1
        E[i] = cnt
    else:
        E[i] = cnt

min = float("inf")
for i in range(N):
    if W[i] + E[i] < min:
        min = W[i] + E[i]
print(min)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k < 0 or k > K:
            continue
        if i+j+k == S:
            cnt += 1
print(cnt)

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

K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
if s==t(:-1):
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
t=input()
if s==t[:-1]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
m=min(n,b)
tmp=(a*//b)-(((m-1)//b)*a)    
print(tmp)

Fixed submission:
a,b,n=map(int,input().split())
m=min(n,b-1)
tmp=(a*m//b)-((m//b)*a)    
print(tmp)

Buggy python submission (verdict: Time Limit Exceeded):
def floor(x):
    return int(x)

a,b,n=map(int,input().split())
if b<n:
    m=floor((a*(b-1)/b))
    for i in range(b,n+1):
        tmp=floor(a*i/b)-(floor(i/b)*a)
        if tmp>m:
            m=tmp
    print(m)
else:
    m=0
    for i in range(1,n+1):
        tmp=floor(a*i/b)-(floor(i/b)*a)
        if tmp>m:
            m=tmp
    print(m)

Fixed submission:
a,b,n=map(int,input().split())
m=min(n,b-1)
tmp=(a*m//b)-((m//b)*a)    
print(tmp)

Buggy python submission (verdict: Time Limit Exceeded):
def floor(x):
    return int(x)

a,b,n=map(int,input().split())
m=0
for i in range(1,n+1):
    tmp=floor(a*i/b)-(floor(i/b)*a)
    if tmp>m:
        m=tmp
print(m)

Fixed submission:
a,b,n=map(int,input().split())
m=min(n,b-1)
tmp=(a*m//b)-((m//b)*a)    
print(tmp)
Buggy python submission (verdict: Runtime Error):
s,w=map(it,input().split())
if s<=w:
  print("unsafe")
else:
  print("safe")

Fixed submission:
s,w=map(int,input().split())
if s<=w:
  print("unsafe")
else:
  print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
dic=[]
for i in range(n):
    tmp=input()
    if tmp not in dic:
        dic.append(tmp)
print(len(dic))

Fixed submission:
n=int(input())
dic={}
for i in range(n):
    tmp=input()
    if tmp not in dic.keys():
        dic[tmp]=1
print(len(dic))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
dic=[]
for i in range(n):
    if s[i] not in dic:
        dic.append(s[i])
print(len(dic))

Fixed submission:
n=int(input())
dic={}
for i in range(n):
    tmp=input()
    if tmp not in dic.keys():
        dic[tmp]=1
print(len(dic))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n-1):
    b[a[i]-1]+=1
for i in range(n+1):
    print(b[i])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n-1):
    b[a[i]-1]+=1
for i in range(n):
    print(b[i])
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
k=int(input())
s=0
for i in range(1,k+1):
    for j in range(1, k+1):
        tmp=gcd(i,j)
        for h in range(1, k+1):
            s+=gcd(tmp,h)
print(s)

Fixed submission:
import math
k=int(input())
s=0
for i in range(1,k+1):
    for j in range(1, k+1):
        tmp=math.gcd(i,j)
        for h in range(1, k+1):
            s+=math.gcd(tmp,h)
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
t=0
for i in range(1,n-1):
    for j in range(i+1, n):
        for k in range(j+1,n+1):
            if j*2!=k+i:
                if s[i-1]!=s[j-1] and s[i-1]!=s[k-1] and s[k-1]!=s[j-1]:
                    t+=1
print(t)

Fixed submission:
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ct=r*g*b
for i in range(n-2):
    for j in range(i+1,n-1):
        k=2*j-i
        if k<=n-1:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                ct-=1
print(ct)
Buggy python submission (verdict: Time Limit Exceeded):
N,X,Y=map(int,input().split())
ans=[0]*(N-1)
for i in range(N-1):
  for j in range(i+1,N):
      ans[min(abs(j-i), abs(X-i-1) + 1 + abs(j+1-Y ), abs(Y-i-1) + 1 + abs(j+1-X))-1]+=1
for i in range(N-1):
    print(ans[i])

Fixed submission:
N,X,Y=map(int,input().split())
ans=[0]*(N-1)
for i in range(1,N):
  for j in range(i+1,N+1):
      ans[min(abs(j-i), abs(X-i) + 1 + abs(j-Y ), abs(Y-i) + 1 + abs(j-X))-1]+=1
for i in range(N-1):
    print(ans[i])