Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())

c=False
for (i in range(25)):
        for(j in range(7)):
            if(i*4+7*j==N):
                c=True
                break
if(c):
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
K=4
D=7
c=False
for i in range(25):
        for j in range(7):
            if(i*K+D*j==N):
                c=True
                break
if(c):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s = raw_input().split(' ')
n, m = int(s[0]), int(s[1])
nums = []
for _ in range(n):
    num = input()
    nums.append(num)
if n == 0:
    print('0')
    exit()
total = [0 for _ in range(n)]
total[0] = nums[0]
for i in range(1, n):
    total[i] = total[i-1] + nums[i]
cnt = 0
for i in range(0, n):
    for j in range(i+1, n):
        if (total[j]-total[i]) % m == 0:
            cnt += 1
print cnt

Fixed submission:
s = raw_input().split(' ')
n, k = int(s[0]), int(s[1])
if n % k == 0:
    print('0')
else:
    print('1')

Buggy python submission (verdict: Runtime Error):
s = raw_input().split(' ')
n, k = int(s[0]), int(s[1])
div, mo = n / k, n % d
if mo == 0:
    print mo
else:
    print div-mo

Fixed submission:
s = raw_input().split(' ')
n, k = int(s[0]), int(s[1])
if n % k == 0:
    print('0')
else:
    print('1')
Buggy python submission (verdict: Runtime Error):
s1 = raw_input().split(' ')
n, m = int(s1[0]), int(s1[1])
i2il = {}
for _ in range(m):
    s = raw_input().split(' ')
    if s[0] in i2il:
        i2il[s[0]].append(s[1])
    else:
        i2il[s[0]] = [s[1]]
    if s[1] in i2il:
        i2il[s[1]].append(s[0])
    else:
        i2il[s[1]] = [s[0]]
if '1' not in i2il or s1[1] not in i2il:
    print 'IMPOSSIBLE'
else:
    mid = i2il[1]
    bhit = False
    for m in mid:
        if s1[1] in m:
            print 'POSSIBLE'
            bhit = True
            break
    if not bhit:
        print 'IMPOSSIBLE'
            


Fixed submission:
s1 = raw_input().split(' ')
n, m = int(s1[0]), int(s1[1])
i2il = {}
for _ in range(m):
    s = raw_input().split(' ')
    if s[0] in i2il:
        i2il[s[0]].append(s[1])
    else:
        i2il[s[0]] = [s[1]]
    if s[1] in i2il:
        i2il[s[1]].append(s[0])
    else:
        i2il[s[1]] = [s[0]]
if '1' not in i2il or s1[0] not in i2il:
    print 'IMPOSSIBLE'
else:
    mid = i2il['1']
    bhit = False
    for m in mid:
        if s1[0] in i2il[m]:
            print 'POSSIBLE'
            bhit = True
            break
    if not bhit:
        print 'IMPOSSIBLE'
Buggy python submission (verdict: Runtime Error):
S = input()

a = S.find('A')

s1 = S[2:-1]
s_count = s1.count('C')

if a != 0:
  return False

if s_count != 1:
  return False

c = s1.find('C')

y = S[1:c-1]
z = S[c+1:]


if y.islower() and z.islower:
  print('AC')
else:
  print('WA')


Fixed submission:
S = input()
     
a = S.find('A')
c = S.find('C')
     
s1 = S[2:-1]
s_count = s1.count('C')
   
y = S[1:c-1]
z = S[c+1:]

if c == 2:
	y = S[1]   

if a != 0:
	print('WA')

elif s_count != 1:
	print('WA')
     
else:
	if y.islower() and z.islower():
			print('AC')
	else:
		print('WA')
Buggy python submission (verdict: Runtime Error):
n = int(input())
while True:
    if i % 2 == 0 and i % n == 0:
      	print(i)
        break
    i += 1


Fixed submission:
n = int(input())
if n % 2 == 0:
    print(n)
else:
    print(n * 2)

Buggy python submission (verdict: Runtime Error):
n = int(input())

for i in range(n, 1e9+1):
    if i % n == 0 && i % 2 == 0:
        print(i)
        break

Fixed submission:
n = int(input())
if n % 2 == 0:
    print(n)
else:
    print(n * 2)
Buggy python submission (verdict: Runtime Error):
print("Yes" if sorted(input()).join("") == "abc" else "No")

Fixed submission:
print("Yes" if "".join(sorted(input())) == "abc" else "No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

x=0
y=0
a.sort()
i=len(a)
while (i>1):
  if a[i-1]==a[i]:
    x=y
    y=a[i]
    i-=2
  else:
    i+=1
  if y>0:
    break

print(x*y)

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

x=0
y=0
a.sort()
i=1
while (i<len(a)):
  if a[i-1]==a[i]:
    x=y
    y=a[i]
    i+=2
  else:
    i+=1

print(x*y)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))

result = abs(a[0]-sum(a[1:]))
for i in range(1,N):
    result = min(result, abs(sum(a[:i]) - sum(a[i:])))

print(result)

Fixed submission:
N = int(input())

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

sum = 0
for a_i in a:
    sum+=a_i

min = abs(a[0]-(sum-a[0]))
x=a[0]
for a_i in a[1:-1]:
    x +=a_i
    if (min>abs(x-(sum-x))):
        min=abs(x-(sum-x))

print(min)
Buggy python submission (verdict: Runtime Error):
def solution():

    n, m, d = map(int, input().split())


    if d == 0:
        guess = n
        return (m-1)/n

    else:

        guess = 2 * (n - d)
        return (guess*(m-1)/n**2)

print(solution())

Fixed submission:
a, b = map(int, input().split())
if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")


Fixed submission:
a, b = map(int, input().split())
if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")
Buggy python submission (verdict: Time Limit Exceeded):
n, m, d = map(int, input().split())

if d == 0:
    guess = n
else:

    guess = 2 * (n - d)
total = n ** m
print((guess*(n)**(m-2)*(m-1) / total))


Fixed submission:
def solution():

    n, m, d = map(int, input().split())


    if d == 0:
        guess = n
        return (m-1)/n

    else:

        guess = 2 * (n - d)
        return (guess*(m-1)/n**2)

print(solution())
Buggy python submission (verdict: Runtime Error):
    inp = list(map(int, input().split()))
    n = inp[0]
    k = inp[1]
    print(str(abs(n%k)))

Fixed submission:
inp = list(map(int, input().split()))
n = inp[0]
k = inp[1]
if n % k == 0:
  print('0')
else:
  print('1')
Buggy python submission (verdict: Runtime Error):
num_list = list(map(int, input().split()))
count = 0

for i in range(3):
  count += num_list[i]

print(count)


Fixed submission:
s = input()
print(s.count("1"))
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    inputList = input().split()

    A = int(inputList[0])
    B = int(inputList[1])
    C = int(inputList[2])
    K = int(inputList[3])
    limit = pow(10, 18)

    for num in range(K):
        _A = B + C
        _B = A + C
        _C = A + B

        A = _A
        B = _B
        C = _C

        if A - B > limit:
            break

    result = A - B

    if result > limit:
        result = "Unfair"

    print(result)


Fixed submission:
if __name__ == '__main__':
    inputList = input().split()

    A = int(inputList[0])
    B = int(inputList[1])
    C = int(inputList[2])
    K = int(inputList[3])
    limit = pow(10, 18)

    if K % 2 == 0:
        result = A - B
    else:
        result = B - A

    if result > limit:
        result = "Unfair"

    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    inputList = input().split()

    A = int(inputList[0])
    B = int(inputList[1])
    C = int(inputList[2])
    K = int(inputList[3])

    for num in range(K):
        _A = B + C
        _B = A + C
        _C = A + B
        A = _A
        B = _B
        C = _C
    result = A - B
    if result > pow(10, 18):
        result = "Unfair"
    print(result)

Fixed submission:
if __name__ == '__main__':
    inputList = input().split()

    A = int(inputList[0])
    B = int(inputList[1])
    C = int(inputList[2])
    K = int(inputList[3])
    limit = pow(10, 18)

    if K % 2 == 0:
        result = A - B
    else:
        result = B - A

    if result > limit:
        result = "Unfair"

    print(result)
Buggy python submission (verdict: Time Limit Exceeded):
def calculate_money(array):
    return [i * j for (i, j) in zip(array, money_list)]


if __name__ == '__main__':
    input_list = input().split()
    N = int(input_list[0])
    Y = int(input_list[1])
    money_list = [10000, 5000, 1000]
    num_list = []

    for x_num in range(0, N + 1):
        for y_num in range(0, N + 1 - x_num):
            num_list.append([x_num, y_num, N - x_num - y_num])

    cal_list = list(map(calculate_money, num_list))

    result = []

    for num, cal in enumerate(cal_list):
        if sum(cal) == Y:
            result = num_list[num]

    if len(result) == 0:
        print("-1 -1 -1")
    else:
        print(" ".join(map(str, result)))


Fixed submission:
def calculate_money():
    input_list = input().split()
    N = int(input_list[0])
    Y = int(input_list[1])

    for x_num in range(0, N + 1):
        for y_num in range(0, N + 1 - x_num):
            z_num = N - x_num - y_num
            if 10000 * x_num + 5000 * y_num + 1000 * z_num == Y:
                print(x_num, " ", y_num, " ", z_num)
                return
    print("-1 -1 -1")


if __name__ == '__main__':
    calculate_money()
Buggy python submission (verdict: Runtime Error):
n = input()
if n >= 20 or n % 7==0 or n%4==0 or n == 19 or n == 18 or n == 15 or n == 11:
    print("Yes")
else:
    print("No")

Fixed submission:
n = input()
n = int(n)
if n >= 20 or n % 7==0 or n%4==0 or n == 19 or n == 18 or n == 15 or n == 11:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n = map(int, input())
if n >= 20 or n % 7==0 or n%4==0 or n == 19 or n == 18 or n == 15 or n == 11 or n == 1:
    print("Yes")
else:
    print("No")

Fixed submission:
n = input()
n = int(n)
if n >= 20 or n % 7==0 or n%4==0 or n == 19 or n == 18 or n == 15 or n == 11:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s = list(map(int, input().split()))
K = int(input())
s = sorted()
for i in range(K):
    s[2] *= 2
print(sum(s))

Fixed submission:
s = list(map(int, input().split()))
K = int(input())
s = sorted(s)
for i in range(K):
    s[2] *= 2
print(sum(s))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
X = [int(i) for i in input().split()]
for i in range(N):
    t = X.pop(i)
    print(int(np.median(X)))
    X.insert(i, t)

Fixed submission:
N = int(input())
X = [int(i) for i in input().split()]
Y = X[:]
Y.sort()

for i in range(N):
    print(Y[int(N/2)] if Y[int(N/2)] > X[i] else Y[int(N/2)-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
X = [int(i) for i in input().split()]

for i in range(N):
    Y = X[:]
    Y.pop(i)
    print(int(np.median(Y)))

Fixed submission:
N = int(input())
X = [int(i) for i in input().split()]
Y = X[:]
Y.sort()

for i in range(N):
    print(Y[int(N/2)] if Y[int(N/2)] > X[i] else Y[int(N/2)-1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = [int(i) for i in input().split()]

for i in range(N):
    Y = X[:]
    Y.pop(i)
    Y.sort()
    print(Y[int((N-1)/2)])

Fixed submission:
N = int(input())
X = [int(i) for i in input().split()]
Y = X[:]
Y.sort()

for i in range(N):
    print(Y[int(N/2)] if Y[int(N/2)] > X[i] else Y[int(N/2)-1])
Buggy python submission (verdict: Runtime Error):
def comb(a, b):
    ans, x, y = 0, a, b
    for i in range(1, b):
        x *= a-i
        y *= b-i
    ans = int(x/y)
    return ans
    
n= int(input())
a = [int(i) for i in input().split()]
m = max(a)

t = 0
t2 = 0
b = a[:]
b.remove(m)
for j in b:
    if j == 0:
        continue
    t3 = comb(m, j)
    if t < t3:
        t = t3
        t2 = j
print(str(m)+" "+str(t2))

Fixed submission:
n= int(input())
a = [int(i) for i in input().split()]
ai = max(a)
b = [abs(int(i-ai/2)) if i != ai else 10E9 for i in a]
aj = a[b.index(min(b))]
print(str(ai)+" "+str(aj))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
B = [0]+A[:]+[0]
C = A[:]+[0]+[0]
D = [abs(i-j) for i, j in zip(B, C)]

for i in range(N):
    if B[i] < B[i+1] and B[i+1] <B[i+2]:
        print(sum(D))
    else:
        t = abs(B[i+1]-B[i])+abs(B[i+2]-B[i+1])-abs(B[i+2]-B[i])
        print(sum(D)-t)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
B = [0]+A[:]+[0]
s = 0
for i in range(N+1):
    s += abs(B[i]-B[i+1])

for i in range(N):
    if B[i] < B[i+1] and B[i+1] <B[i+2]:
        print(s)
    else:
        t = abs(B[i+1]-B[i])+abs(B[i+2]-B[i+1])-abs(B[i+2]-B[i])
        print(s-t)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) == sum(b):
    if a == b:
        print("Yes")
    else:
        print("No")
elif sum(a) > sum(b):
    print("No")
else:
    for i in range(sum(b)-sum(a)):
        flg1 = 0
        flg2 = 0
        for j in range(N):
            if flg1 == 1 and flg2 ==1:
                break
            if a[j] < b[j] and flg1 == 0:
                a[j] += 2
                flg1 = 1
                if (abs(a[j]-b[j]))%2 == 1:
                    b[j] += 1
                    flg2 = 1
            if flg2 == 0:
                if b[j] < a[j]:
                    b[j] += 1
                    flg2 = 1
        if flg2 == 0:
            b[0] += 1
    if a == b:
        print("Yes")
    else:
        print("No")

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a == b:
    print("Yes")
elif sum(a) >= sum(b):
    print("No")
else:
    aa = 0
    bb = 0
    for i in range(N):
        if a[i]-b[i] > 0:
            bb += a[i]-b[i]
        elif b[i]-a[i] > 0:
            aa += (b[i]-a[i])//2
    if aa >= bb:
        print("Yes")
    else: 
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) == sum(b):
    if a == b:
        print("Yes")
    else:
        print("No")
elif sum(a) > sum(b):
    print("No")
else:
    for i in range(sum(b)-sum(a)):
        for j in range(N):
            if a[j] < b[j]:
                a[j] += 2
                break
        if (abs(a[j]-b[j]))%2 == 1:
            b[j] += 1
        else:
            for k in range(N):
                flg = 0
                if b[k] < a[k]:
                    b[k] += 1
                    flg = 1
                    break
            if flg == 0:
                b[0] += 1
    if a == b:
        print("Yes")
    else:
        print("No")

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a == b:
    print("Yes")
elif sum(a) >= sum(b):
    print("No")
else:
    aa = 0
    bb = 0
    for i in range(N):
        if a[i]-b[i] > 0:
            bb += a[i]-b[i]
        elif b[i]-a[i] > 0:
            aa += (b[i]-a[i])//2
    if aa >= bb:
        print("Yes")
    else: 
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(i) for i in input().split()]
s = list(set(a))
cnt = 0
for i in s:
    if a.count(i) == i:
        continue
    elif a.count(i) < i:
        cnt += a.count(i)
    else:
        cnt += a.count(i)-i
print(cnt)

Fixed submission:
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]
s = set(a)
c = Counter(a)

cnt = 0
for i in s:
    if c[i] < i:
        cnt += c[i]
    else:
        cnt += c[i]-i
print(cnt)
Buggy python submission (verdict: Runtime Error):
if s[0]=='A':
    if s[2:-2].count('C')==1:
        if (s[1]+s[2:-2].replace('C', '')+s[-1]).islower() :
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')
 

Fixed submission:
r=int(input())
if r<1200:
  print('ABC')
elif 1200<=r and r<2800:
  print('ARC')
else:
  print('AGC')

Buggy python submission (verdict: Runtime Error):
s=input()
if s[0]=='A':
  if s[2:-2].count('C')==1:
    if (s[1]+s[2:-2].replace('C', '')+s[-1]).islower() :
  		print('AC')
    else:
    	print('WA')
  else:
  	print('WA')
else:
  print('WA')

Fixed submission:
r=int(input())
if r<1200:
  print('ABC')
elif 1200<=r and r<2800:
  print('ARC')
else:
  print('AGC')

Buggy python submission (verdict: Runtime Error):
r=input()
if r<1200:
  print('ABC')
elif 1200<=r and r<2800:
  print('ARC')
else:
  print('AGC')

Fixed submission:
r=int(input())
if r<1200:
  print('ABC')
elif 1200<=r and r<2800:
  print('ARC')
else:
  print('AGC')

Buggy python submission (verdict: Runtime Error):
r=input()
if r<1200:
  print('ABC')
elif 1200<=r<2800:
  print('ARC')
else:
  print('AGC')

Fixed submission:
r=int(input())
if r<1200:
  print('ABC')
elif 1200<=r and r<2800:
  print('ARC')
else:
  print('AGC')
Buggy python submission (verdict: Runtime Error):
s=input()
if s[0]=='A':
  if s[2:-2].count('C')==1:
    if (s[1]+s[2:-2].replace('C', '')+s[-1]).islower() :
  		print('AC')
    else:
      print('WA')
  else:
    print('WA')
else:
  print('WA')



Fixed submission:
s=input()
if s[0]=='A':
    if s[2:-1].count('C')==1:
        if (s[1]+s[2:-1].replace('C', '')+s[-1]).islower() :
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
min = 30000000
for i in range(1,n-1):
    be = s[:i]
    af = s[i+1:n]
    cont = 0
    for j in range(len(be)):
        if be[j] == 'W':
            cont += 1
    for k in range(len(af)):
        if af[k] == 'E':
            cont += 1
    if cont < min:
        min = cont

a = s[1:n]
cont = 0
for w1 in range(n-1):
    if a[w1] == 'E':
        cont += 1
if cont < min:
    min = cont

a = s[:n-1]
cont = 0
for w2 in range(n-1):
    if a[w2] == 'W':
        cont += 1
if cont < min:
    min = cont

print(min)

Fixed submission:
n = int(input())
s = input()
min = 0
for i in range(1,n):
    if s[i] == 'E':
        min += 1
cont = min
for j in range(1,n):
    if s[j-1] == 'W':
        cont += 1
    if s[j] == 'E':
        cont -= 1
    if cont < min:
        min = cont
print(min)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input()))

print(sum(A) - N)

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

print(sum(A) - N)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

A = sorted([a - i for a, i in enumerate(A)])

result = 0
while len(A) > 1:
  result += A[-1] - A[0]
  A = A[1:-1]

print(result)

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

A = sorted([a - i for a, i in enumerate(A)])

print(sum(abs(x-y) for x,y in zip(A, A[::-1]))//2)
Buggy python submission (verdict: Runtime Error):
X = int(input())

import math
def is_beki(n):
  for i in range(2, int(math.sqrt(n)//1)+1):
    beki = i
    while beki <= n:
      if beki == n:
        return True
      beki = beki * i
  return False

for i in range(X, 1, -1):
  if is_beki(i):
    break
print(i)

Fixed submission:
X = int(input())

import math
def is_beki(n):
  for i in range(2, int(math.sqrt(n)//1)+1):
    beki = i
    while beki <= n:
      if beki == n:
        return True
      beki = beki * i
  return False

if X == 1:
  print(1)
else:
  for i in range(X, 1, -1):
    if is_beki(i):
      break
  print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))

sorted_X = sorted(X)
m1, m2 = sorted[N//2-1: N//2]

if m1 == m2:
  for i in range(N):
    print(m1)
else:
  for i in range(N):
    if X[i] <= m1:
      print(m2)
    else:
      print(m1)

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

sorted_X = sorted(X)
m1, m2 = sorted_X[N//2-1: N//2+1]

if m1 == m2:
  for i in range(N):
    print(m1)
else:
  for i in range(N):
    if X[i] <= m1:
      print(m2)
    else:
      print(m1)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

for i in range(A, B+1):
  if i < A + K or i > B - K:
    print(i)


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

l = B - A + 1

if l == 1:
  print(A)
elif l == 2:
  print(A)
  print(B)
else:
  if (l+1)//2 <= K:
    for i in range(A, B+1):
      print(i)
  else:
    for i in range(A, A+K):
      print(i)
    for i in range(B-K+1, B+1):
      print(i)

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

for i in range(A, B+1):
  if i < A + K or i > B - K:
    print(i)


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

l = B - A + 1

if l == 1:
  print(A)
elif l == 2:
  print(A)
  print(B)
else:
  if (l+1)//2 <= K:
    for i in range(A, B+1):
      print(i)
  else:
    for i in range(A, A+K):
      print(i)
    for i in range(B-K+1, B+1):
      print(i)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    if S - (x + y) <= K:
      z = S - (x + y)
      if z >= 0 and z <= K:
        counter += 1

print(counter)

Fixed submission:
K, S = map(int, input().split())

counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    z = S - (x + y)
    if z >= 0 and z <= K:
      counter += 1

print(counter)

Buggy python submission (verdict: Runtime Error):
counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    if S - (x + y) <= K:
      z = S - (x + y)
      if z >= 0 and z <= K:
        counter += 1

print(counter)

Fixed submission:
K, S = map(int, input().split())

counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    z = S - (x + y)
    if z >= 0 and z <= K:
      counter += 1

print(counter)

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

counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    for z in range(K + 1):
      total = x + y + z
      if total == S:
        counter += 1

print(counter)

Fixed submission:
K, S = map(int, input().split())

counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    z = S - (x + y)
    if z >= 0 and z <= K:
      counter += 1

print(counter)

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

counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    for z in range(K + 1):
      total = x + y + z
      if total == S:
        counter += 1

print(counter)

Fixed submission:
K, S = map(int, input().split())

counter = 0
for x in range(K + 1):
  for y in range(K + 1):
    z = S - (x + y)
    if z >= 0 and z <= K:
      counter += 1

print(counter)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split(" "))
def check(x):
    sum=0
    while x>0: 
        sum = sum + x % 10 
        x=int(x/10); 
    return sum
 
total=0
for i in range(n+1): #1-10 1,2,10
    sum=check(i)
    if sum<=b and sum>=a:
        #print(i)
        total=total+i
 
print(total)
n,a,b=map(int,input().split(" "))
def check(x):
    sum=0
    while x>0: 
        sum = sum + x % 10 
        x=int(x/10); 
    return sum

total=0
for i in range(n+1): #1-10 1,2,10
    sum=check(i)
    if sum<=b and sum>=a:
        #print(i)
        total=total+i

print(total)
提出情報

Fixed submission:
n,a,b=map(int,input().split(" "))
def check(x):
    sum=0
    while x>0: 
        sum = sum + x % 10 
        x=int(x/10); 
    return sum

total=0
for i in range(n+1): #1-10 1,2,10
    sum=check(i)
    if sum<=b and sum>=a:
        #print(i)
        total=total+i

print(total)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
data = input().split(" ")

N = int(data[0])
A = int(data[1])
B = int(data[2])

total_sum = 0

for i in range(N+1):
    sum = 0
    tmp = i
    while tmp > 0:
        sum += tmp % 10;
        tmp = int(tmp/10)
    if sum >= A and sum <= B:
        total_sum += i

print(total_sum)
    

Fixed submission:
# coding: utf-8
N = int(input())
X = N
f = 0
while N > 0:
    f += N % 10;
    N = int(N / 10)

if X%f == 0:
    print("Yes")
else:
    print("No")