TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). A nonnegative integer A_{i,j} is written for each square (i,j).  You choose some of the squares so that each row and column contains at most K chosen squares. Under this constraint, calculate the maximum value of the sum of the integers written on the chosen squares. Additionally, calculate a way to choose squares that acheives the maximum.

Incorrect submission (verdict: Wrong Answer):
import networkx as nx

N,K=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
maxA = max([max(A[i]) for i in range(N)])

G = nx.DiGraph()
G.add_node('source',demand=-K*N)
G.add_node('sink',demand=K*N)
for i in range(N):
  for j in range(N):
    G.add_edge(i,N+j,weight=maxA-A[i][j],capacity=1)
    
for i in range(N):
  G.add_edge('source',i,weight=0,capacity=K)
  G.add_edge(N+i,'sink',weight=0,capacity=K)
  
flowCost,flowDict = nx.network_simplex(G)
ans=[['.']*N for _ in range(N)]
for i in flowDict.keys():
  if i in ('source','sink'):continue
  for j in flowDict[i].keys():
    if j in ('source','sink'):continue
    if flowDict[i][j]:
      ans[i][j-N] = 'x'

print(maxA*K*N-flowCost)
for i in range(N):
  print(''.join(ans[i]))

Fixed, accepted submission:
import networkx as nx

N,K=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
maxA = max([max(A[i]) for i in range(N)])

G = nx.DiGraph()
G.add_node('source',demand=-K*N)
G.add_node('sink',demand=K*N)
G.add_edge('source','sink',weight=maxA, capacity=K*N)
for i in range(N):
  for j in range(N):
    G.add_edge(i,N+j,weight=maxA-A[i][j],capacity=1)
    
for i in range(N):
  G.add_edge('source',i,weight=0,capacity=K)
  G.add_edge(N+i,'sink',weight=0,capacity=K)
  
flowCost,flowDict = nx.network_simplex(G)
ans=[['.']*N for _ in range(N)]
for i in flowDict.keys():
  if i in ('source','sink'):continue
  for j in flowDict[i].keys():
    if j in ('source','sink'):continue
    if flowDict[i][j]:
      ans[i][j-N] = 'X'

print(maxA*K*N-flowCost)
for i in range(N):
  print(''.join(ans[i]))
Problem:
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode:                 BubbleSort(A) 1 for i = 0 to A.length-1 2     for j = A.length-1 downto i+1 3         if A[j] < A[j-1] 4             swap A[j] and A[j-1]   Note that, indices for array elements are based on 0-origin.  Your program should also print the number of swap operations defined in line 4 of the pseudocode.

Incorrect submission (verdict: Wrong Answer):
N=int(input())

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

count=0
i=N-1

while i>=0:
	j=0
	while j<=i:
		if A[N-1-j]<A[N-2-j]:
			(A[N-1-j],A[N-2-j])=(A[N-2-j],A[N-1-j])
			count+=1
		j+=1
	i-=1


print(' '.join(map(str,A)))
print(count)

Fixed, accepted submission:
N=int(input())

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

count=0
i=N-1

while i>0:
	j=0
	while j<i:
		if A[N-1-j]<A[N-2-j]:
			(A[N-1-j],A[N-2-j])=(A[N-2-j],A[N-1-j])
			count+=1
			#print(' '.join(map(str,A)))
		j+=1
	i-=1


print(' '.join(map(str,A)))
print(count)
Problem:
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows:    * Rating 1-399 : gray   * Rating 400-799 : brown   * Rating 800-1199 : green   * Rating 1200-1599 : cyan   * Rating 1600-1999 : blue   * Rating 2000-2399 : yellow   * Rating 2400-2799 : orange   * Rating 2800-3199 : red  Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.   Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.   Find the minimum and maximum possible numbers of different colors of the users.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
color = [0] * 9
for i in range(n):
  if a[i] < 400:
    color[0] = 1
  elif a[i] < 800:
    color[1] = 1
  elif a[i] < 1200:
    color[2] = 1
  elif a[i] < 1600:
    color[3] = 1
  elif a[i] < 2000:
    color[4] = 1
  elif a[i] < 2400:
    color[5] = 1
  elif a[i] < 2800:
    color[6] = 1
  elif a[i] < 3200:
    color[7] = 1
  else:
    color[8] = color[8] + 1
if color[8] >= 1:
  while int(0) in color and color[8] != 0:
    color.remove(0)
    color.insert(0,1)
    color[8]  = color[8] - 1
  print(color.count(1))
else:
  print(color.count(1))

Fixed, accepted submission:
n = int(input())
a = list(map(int, input().split()))
color = [0] * 8
tmp = 0
for i in range(n):
  if a[i] < 400:
    color[0] = 1
  elif a[i] < 800:
    color[1] = 1
  elif a[i] < 1200:
    color[2] = 1
  elif a[i] < 1600:
    color[3] = 1
  elif a[i] < 2000:
    color[4] = 1
  elif a[i] < 2400:
    color[5] = 1
  elif a[i] < 2800:
    color[6] = 1
  elif a[i] < 3200:
    color[7] = 1
  else:
    tmp = tmp + 1
l = color.count(1)
if l == 0:
  print("1 {}".format(tmp))
else:
  print("{} {}".format(l, l + tmp))
Problem:
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.

Incorrect submission (verdict: Wrong Answer):
a, b = input().split()
target = a + b

heihousuu = [i ** 2 for i in range(1000) if i ** 2 <= 100100]

for h in heihousuu:
    if target == h:
        print('Yes')
        break
else:
    print('No')

Fixed, accepted submission:
a, b = input().split()


ab = int(a + b)

if (ab ** 0.5).is_integer():
    print("Yes")
else:
    print("No")
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:00:46 2020

@author: saito
"""

# %% import phase



# %% input phase
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = input()

# %% process phase
C = [0]*4
rslt = ['AC', 'WA', 'TLE', 'RE']
for i in range(4):
    C[i] = S.count(rslt[i])

# %%output phase
for i in range(4):
    print(rslt[i]+' '+'×'+' '+str(C[i]))

Fixed, accepted submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:00:46 2020

@author: saito
"""

# %% import phase



# %% input phase
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = input()

# %% process phase
C = [0]*4
rslt = ['AC', 'WA', 'TLE', 'RE']
for i in range(4):
    C[i] = S.count(rslt[i])

# %%output phase
for i in range(4):
    print(rslt[i]+' '+'x'+' '+str(C[i]))
Problem:
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

Incorrect submission (verdict: Wrong Answer):

n = int(input())
s = list(input())
x = []
y = []
ans = []

for i in range(1,n):
    x = s[0:i]
    y = s[i:n]
    print(x)
    print(y)

    for j in range(len(x)):
        a = 0
        if y.count(x[j]) >= 1:
            a += 1
    ans.append(a)
    print(ans)

print(max(ans))


Fixed, accepted submission:
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    head = s[:i]
    tail = s[i:]
    cnt = 0
    for i in range(26):
        c = chr(ord('a') + i)
        if c in head and c in tail:
            cnt += 1

    ans = max(ans, cnt)

print(ans)
Problem:
How many multiples of d are there among the integers between L and R (inclusive)?

Incorrect submission (verdict: Wrong Answer):
L,R,d = map(int,input().split())

r = R//4
l = (L-1)//4

print(r-l)

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

r = R//d
l = (L-1)//d

print(r-l)
Problem:
There is a cave.  The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.  It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.  Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.    * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.  Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Incorrect submission (verdict: Wrong Answer):
from collections import deque


N, M = map(int, input().rstrip().split())
G = [[] for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().rstrip().split())
    G[A].append(B)
    G[B].append(A)


sign = [-1]*(N+1)
sign[1] = 0

queue = deque([1])

while queue:
    node = queue.popleft()
    for next in G[node]:
        if sign[next] > -1:
            continue
        sign[next] = node
        queue.append(next)

ans = "Yes"

print(sign)

for i in range(2, N+1):
    S = sign[i]
    while S > 0:
        S = sign[S]

    if not S == 0:
        ans = "No"

print(ans)
if ans == "Yes":
    for i in range(2, N+1):
        print(sign[i])


Fixed, accepted submission:
from collections import deque


N, M = map(int, input().rstrip().split())
G = [[] for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().rstrip().split())
    G[A].append(B)
    G[B].append(A)


sign = [-1]*(N+1)
sign[0] = None
sign[1] = 0

queue = deque([1])

while queue:
    node = queue.popleft()
    for next in G[node]:
        if sign[next] > -1:
            continue
        sign[next] = node
        queue.append(next)

if -1 in sign:
    print("No")
else:
    print("Yes")
    for i in range(2, N+1):
        print(sign[i])
Problem:
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647.  Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers.  If given integers or the sum have more than 80 digits, print "overflow".

Incorrect submission (verdict: Wrong Answer):
import sys
import itertools

dataset_num = int(input())

class Overflow(Exception):
    pass

for _ in range(dataset_num):
    try:
        k1 = input()
        k2 = input()
        k1_val = [0] * 80
        k2_val = [0] * 80

        if len(k1) >= 80 or len(k2) >= 80:
            raise Overflow()
        
        for i, x in enumerate(reversed(k1)):
            k1_val[i] = int(x)

        for i, x in enumerate(reversed(k2)):
            k2_val[i] = int(x)
        
        res = [0] * 80
        for i in range(0, 80):
            res[i] += k1_val[i] + k2_val[i]
            if res[i] >= 10:
                res[i+1] += 1
                res[i] -= 10
        sumstr = "".join([str(x) for x in itertools.dropwhile(lambda x: x == 0, reversed(res))])
        if len(sumstr) >= 80:
            raise Overflow()

        print(sumstr)
    except Overflow:
        print("overflow")

Fixed, accepted submission:
import sys
import itertools

dataset_num = int(input())

class Overflow(Exception):
    pass

for _ in range(dataset_num):
    try:
        k1 = input()
        k2 = input()
        k1_val = [0] * 100
        k2_val = [0] * 100

        if len(k1) > 80 or len(k2) > 80:
            raise Overflow()
        
        for i, x in enumerate(reversed(k1)):
            k1_val[i] = int(x)

        for i, x in enumerate(reversed(k2)):
            k2_val[i] = int(x)
        
        res = [0] * 100 
        for i in range(0, 100):
            res[i] += k1_val[i] + k2_val[i]
            if res[i] >= 10:
                res[i+1] += 1
                res[i] -= 10
        sumstr = "".join([str(x) for x in itertools.dropwhile(lambda x: x == 0, reversed(res))])
        if len(sumstr) > 80:
            raise Overflow()
        if len(sumstr) == 0:
            sumstr = "0"

        print(sumstr)
    except Overflow:
        print("overflow")
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 19:45:18 2020

@author: harsh
"""

#%%
import math
x=int(input())
rate=100
i=1
while(True):
    if(rate>=x):
        print(i)
        break
    else:
        rate=rate*1.01
        i+=1
#print((math.log(x/100))/(math.log(1.01)))


Fixed, accepted submission:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 19:45:18 2020

@author: harsh
"""

#%%
import math
x=int(input())
rate=100
i=1
while(True):
    if(rate>=x):
        print(i-1)
        break
    else:
        rate=int(rate*1.01)
        i+=1
#print((math.log(x/100))/(math.log(1.01)))
Problem:
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.

Incorrect submission (verdict: Wrong Answer):
s = input()
for i in s:
    if s.count(i) != 1:
        print('No')
        exit
print('Yes')

Fixed, accepted submission:
s = input()
for i in s:
    if s.count(i) != 1:
        print('no')
        exit()
print('yes')
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int,input().split())
print(("NO","YES")[a<=c<=b])

Fixed, accepted submission:
a,b,c=map(int,input().split())
print(("No","Yes")[a<=c<=b])
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())

s = sorted([a, b, c])
           
print('Yes' if s[0] ==5 and s[1] == 5 and s[2]== 7 else 'No')

Fixed, accepted submission:
a,b,c = sorted(map(int, input().split()))
print("YES" if a==b==5 and c ==7 else "NO")
Problem:
You are given two integers a and b. Determine if a+b=15 or a\times b=15 or neither holds.  Note that a+b=15 and a\times b=15 do not hold at the same time.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())

if(a + b == 15 or a * b == 15):
  print("*")
else:
  print("x")

Fixed, accepted submission:
a, b = map(int, input().split())

if(a + b == 15):
  print("+")
elif(a * b == 15):
  print("*")
else:
  print("x")
Problem:
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?

Incorrect submission (verdict: Wrong Answer):
n, m = map(int, input().split())
bridge = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    ans = 0
    for x, y in bridge:
        if x == i or y == i:
            ans += 1
    print(ans)

Fixed, accepted submission:
n, m = map(int, input().split())
bridge = [list(map(int, input().split())) for _ in range(m)]

for i in range(1, n+1):
    ans = 0
    for x, y in bridge:
        if x == i or y == i:
            ans += 1
    print(ans)
Problem:
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows:    * Rating 1-399 : gray   * Rating 400-799 : brown   * Rating 800-1199 : green   * Rating 1200-1599 : cyan   * Rating 1600-1999 : blue   * Rating 2000-2399 : yellow   * Rating 2400-2799 : orange   * Rating 2800-3199 : red  Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.   Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.   Find the minimum and maximum possible numbers of different colors of the users.

Incorrect submission (verdict: Wrong Answer):
N = input()
a = [int(i) for i in input().split()]
scores = [0,0,0,0,0,0,0,0]
score8 = 0
for i in a:
    checknum = int(i/400)
    if checknum > 7:
        score8 += 1
    else:
        scores[checknum] = 1
print(min([sum(scores) + score8,8]))

Fixed, accepted submission:
N = int(input())
A = [int(_) for _ in input().split()]
colors = [0] * 9
for a in A:
    c = a // 400
    if c < 8:
        colors[c] = 1
    else:
        colors[8] += 1
print(max(sum(colors[:8]), 1), sum(colors))
Problem:
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.  Given an integer N, determine whether it is a Harshad number.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
t = sum(map(int, list(str(n))))
if n // t == 0:
	print("Yes")
else:
	print("No")

Fixed, accepted submission:
n = int(input())
t = sum(map(int, list(str(n))))
if n % t == 0:
	print("Yes")
else:
	print("No")
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = int(input())

M = N % 500
if M < A:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
N = int(input())
A = int(input())

M = N % 500
if M <= A:
    print("Yes")
else:
    print("No")
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))

for i in range(1, n):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(A)


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

print(*A)
for i in range(1, n):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(*A)
Problem:
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.

Incorrect submission (verdict: Wrong Answer):
# B - Two Anagrams
s = list(input())
t = list(input())


s = sorted(s)
s = "".join(s)


t = sorted(t, reverse=True)
t = "".join(t)

print(s,t)


ans = ""
N = min(len(s),len(t))
for i in range(N):
    print(ord(s[i]), ord(t[i]))
    if ord(s[i]) == ord(t[i]):
        pass
    elif ord(s[i]) < ord(t[i]):
        ans = "Yes"
        break
    else:
        ans = "No"
        break
else: 
    if len(s) < len(t):
        ans = "Yes"
    else:
        ans = "No"


print(ans)


Fixed, accepted submission:
# B - Two Anagrams
s = list(input())
t = list(input())


s = sorted(s)
s = "".join(s)


t = sorted(t, reverse=True)
t = "".join(t)


ans = ""
N = min(len(s),len(t))
for i in range(N):
    if ord(s[i]) == ord(t[i]):
        pass
    elif ord(s[i]) < ord(t[i]):
        ans = "Yes"
        break
    else:
        ans = "No"
        break
else: 
    if len(s) < len(t):
        ans = "Yes"
    else:
        ans = "No"


print(ans)
Problem:
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?

Incorrect submission (verdict: Wrong Answer):
n,m = map(int ,input().split())
l=[list(map(int ,input().split())) for x in range(m)]
count=0
for i in range(1,m+1):
    for j in range(m):
        if i in l[j]:
            count+=1
    print(count)
    count=0 

Fixed, accepted submission:
n,m = map(int ,input().split())
l=[list(map(int ,input().split())) for x in range(m)]
count=0
for i in range(1,n+1):
    for j in range(m):
        if i in l[j]:
            count+=1
    print(count)
    count=0
Problem:
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647.  Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers.  If given integers or the sum have more than 80 digits, print "overflow".

Incorrect submission (verdict: Wrong Answer):
n=int(input())
for i in range(n):
    a=input()
    if a==1:
        break
    b=input()
    print(str(a)+str(b))

Fixed, accepted submission:
n = int(input())
 
for i in range(n):
    a = int(input())
    b = int(input())
 
    if (a + b) < (10 ** 80):
        print(a + b)
    else:
        print("overflow")
Problem:
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.   Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.   Here, both the x\- and y-coordinates before and after each movement must be integers.   He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).   Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).   Under this condition, find a shortest path for him.

Incorrect submission (verdict: Wrong Answer):
sx,sy,tx,ty=map(int,input().split())
string="U"*(ty-sy)+"R"*(tx-sx)+"L"*(tx-sx+1)+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
print(string)

Fixed, accepted submission:
sx,sy,tx,ty=map(int,input().split())
string="U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx+1)+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
print(string)
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Incorrect submission (verdict: Wrong Answer):
def DigitsSUM(Num):
    sumN = 0
    while Num > 0:
        sumN += Num % 10
        Num/=10
    return int(sumN)


N,A,B = input().split()
LowerLimit=int(A)
UpperLimit=int(B)
num = int(N)
sumary = []
counter = 0
for i in range(1,num+1):
    sumN = DigitsSUM(i)
    if LowerLimit <= sumN and sumN <= UpperLimit+1:
        print(i, sumN)
        counter+=int(i)
        
print(counter)




Fixed, accepted submission:
def DigitsSUM(Num):
    sumN = 0
    while Num > 0:
        sumN += int(Num) % 10
        Num /= 10
    return int(sumN)


N,A,B = input().split()
LowerLimit=int(A)
UpperLimit=int(B)
num = int(N)
sumary = []
counter = 0
for i in range(1,num+1):
    sumN = DigitsSUM(i)
    
    if LowerLimit <= sumN and sumN <= UpperLimit:
        counter+=int(i)
        
print(counter)