Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections

S = input()

list1 = []
result = 0

for i in range(len(S)):
    list1.append(int(S[-i:])%2019)
    
a = collections.Counter(list1)

result += a[0]

val = list(a.values())
for j in range(len(a.values())):
    result += val[j]*(val[j]-1)/2
    
print(int(result))
        
  

Fixed submission:
s = input()[::-1]
counts = [0] * 2019
counts[0] = 1
num, d = 0, 1
result = 0

for i in s:
    num += int(i) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1
    
for cnt in counts:
    result += cnt*(cnt-1)//2
    
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import collections

S = input()

list1 = []
list2 = []
result = 0

for i in range(len(S)):
    if int(S[-i:])%2019==0:
        result += 1
    list1.append(int(S[-i:])%2019)
a = collections.Counter(list1)
val = list(a.values())
for j in range(len(a.values())):
    result += val[j]*(val[j]-1)/2
print(int(result))
        



Fixed submission:
s = input()[::-1]
counts = [0] * 2019
counts[0] = 1
num, d = 0, 1
result = 0

for i in s:
    num += int(i) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1
    
for cnt in counts:
    result += cnt*(cnt-1)//2
    
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
S = input()
list1 = []

for i in range(len(S)+1):
    for j in range(len(S)+1):
        if i<j:
            list1.append(int(S[i:j]))
arr = np.array(list1)%2019
print(np.sum(arr==0))     
  

Fixed submission:
s = input()[::-1]
counts = [0] * 2019
counts[0] = 1
num, d = 0, 1
result = 0

for i in s:
    num += int(i) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1
    
for cnt in counts:
    result += cnt*(cnt-1)//2
    
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
list1 = []

for i in range(len(S)+1):
    for j in range(len(S)+1):
        if i<j and int(S[i:j])%2019==0:
            list1.append(1)
print(sum(list1))
  

Fixed submission:
s = input()[::-1]
counts = [0] * 2019
counts[0] = 1
num, d = 0, 1
result = 0

for i in s:
    num += int(i) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1
    
for cnt in counts:
    result += cnt*(cnt-1)//2
    
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

AB = dict()

for _ in range(M):
    a, b = map(int, input().split())
    AB.setdefault(a, [])
    AB[a].append(b)

    AB.setdefault(b, [])
    AB[b].append(a)

a = [-1 for _ in range(N + 1)]

a[1] = 0
current = 1
pos = [1]

while True:
    next_pos = []

    for p in pos:
        for n in AB[p]:
            if a[n] == -1:
                a[n] = p
            next_pos.append(n)

    pos = next_pos

    if not next_pos or -1 not in a[2:]:
        break

if -1 in a[2:]:
    print('No')
else:
    print('Yes')
    for i in a[2:]:
        print(i)


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

AB = dict()

for _ in range(M):
    a, b = map(int, input().split())
    AB.setdefault(a, [])
    AB[a].append(b)

    AB.setdefault(b, [])
    AB[b].append(a)

a = [-1 for _ in range(N + 1)]

a[1] = 0
current = 1
pos = [1]

while True:
    next_pos = []

    for p in pos:
        for n in AB[p]:
            if a[n] == -1:
                a[n] = p
                next_pos.append(n)

    pos = next_pos
    if not pos:
        break

if -1 in a[2:]:
    print('No')
else:
    print('Yes')
    for i in a[2:]:
        print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())

sub = [0 for i in range(N)]

for a in A:
    sub[a - 1] += 1

for s in sub:
    print(s)
j

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

sub = [0 for i in range(N)]

for a in A:
    sub[a - 1] += 1

for s in sub:
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc162/tasks/abc162_d

N = int(input())
S = input()

ans = 0
for i in range(N):
    for j in range(i, N):
        for k in range(j, N):
            if j - i == k - j:
                continue

            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ans += 1

print(ans)


Fixed submission:
# https://atcoder.jp/contests/abc162/tasks/abc162_d

N = int(input())
S = input()


def colors(target, a, b):
    for i in range(N):
        for j in range(i + 1, N):
            if S[i] == a and S[j] == b:
                target[i] += 1


rg = [0 for _ in range(N)]
colors(rg, 'R', 'G')
gr = [0 for _ in range(N)]
colors(gr, 'G', 'R')

gb = [0 for _ in range(N)]
colors(gb, 'G', 'B')
bg = [0 for _ in range(N)]
colors(bg, 'B', 'G')

rb = [0 for _ in range(N)]
colors(rb, 'R', 'B')
br = [0 for _ in range(N)]
colors(br, 'B', 'R')

ans = 0
for i in range(N):
    if S[i] == 'B':
        for j in range(i + 1, N):
            ans += rg[j]
            ans += gr[j]

            k = j + j - i
            if k >= N:
                continue
            if S[i] == 'B' and S[j] == 'R' and S[k] == 'G':
                ans -= 1
            if S[i] == 'B' and S[j] == 'G' and S[k] == 'R':
                ans -= 1

    if S[i] == 'R':
        for j in range(i + 1, N):
            ans += gb[j]
            ans += bg[j]

            k = j + j - i
            if k >= N:
                continue
            if S[i] == 'R' and S[j] == 'G' and S[k] == 'B':
                ans -= 1
            if S[i] == 'R' and S[j] == 'B' and S[k] == 'G':
                ans -= 1

    if S[i] == 'G':
        for j in range(i + 1, N):
            ans += rb[j]
            ans += br[j]

            k = j + j - i
            if k >= N:
                continue
            if S[i] == 'G' and S[j] == 'R' and S[k] == 'B':
                ans -= 1
            if S[i] == 'G' and S[j] == 'B' and S[k] == 'R':
                ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc158/tasks/abc158_d

S = input()
Q = int(input())

elements = [None for _ in range(Q * 2 + len(S) * 2)]

head = Q + len(S)
last = len(S)
for i, s in enumerate(S):
    elements[head + i] = s

for _ in range(Q):
    query = input()
    if query[0] == '1':
        elements[head:head + last] = elements[head + last - 1:head - 1:-1]
    else:
        if query[2] == '1':
            head -= 1
            elements[head] = query[4]
        else:
            elements[head + last] = query[4]

        last += 1

elements = filter(lambda a: a is not None, elements)
print(''.join(elements))


Fixed submission:
# https://atcoder.jp/contests/abc158/tasks/abc158_d
from collections import deque

S = input()
Q = int(input())

is_reverse = False
text = deque(S)
for _ in range(Q):
    query = input()
    if query[0] == '1':
        is_reverse = not is_reverse
    else:
        if query[2] == '1':
            if is_reverse:
                text.append(query[4])
            else:
                text.appendleft(query[4])
        else:
            if is_reverse:
                text.appendleft(query[4])
            else:
                text.append(query[4])

if is_reverse:
    print(''.join(text)[::-1])
else:
    print(''.join(text))

Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/abc158/tasks/abc158_d

S = input()
Q = int(input())

for _ in range(Q):
    query = input()
    if query[0] == '1':
        S = S[::-1]
    else:
        if query[2] == '1':
            S = query[4] + S
        else:
            S = S + query[4]

print(S)


Fixed submission:
# https://atcoder.jp/contests/abc158/tasks/abc158_d
from collections import deque

S = input()
Q = int(input())

is_reverse = False
text = deque(S)
for _ in range(Q):
    query = input()
    if query[0] == '1':
        is_reverse = not is_reverse
    else:
        if query[2] == '1':
            if is_reverse:
                text.append(query[4])
            else:
                text.appendleft(query[4])
        else:
            if is_reverse:
                text.appendleft(query[4])
            else:
                text.append(query[4])

if is_reverse:
    print(''.join(text)[::-1])
else:
    print(''.join(text))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
vs = input().split()

vs1 = [vs[i] for i in range(0, len(vs), 2)]
vs2 = [vs[i] for i in range(1, len(vs), 2)]

m1 = 0
i1 = -1
m2 = 0
i2 = -1
ccc = 0
for value in vs1:
    ccc += 1
    count = vs1.count(value)
    if count > m1:
        i2 = i1
        m2 = m1
        i1 = value
        m1 = count

m3 = 0
i3 = -1
m4 = 0
i4 = -1
ccc2 = 0
for value in vs2:
    ccc2 += 1
    count = vs2.count(value)
    if count > m3:
        i4 = i3
        m4 = m3
        i3 = value
        m3 = count

if i1 != i3:
    print((ccc - m1) + (ccc2 - m3))
else:
    if m2 > m4:
        print((ccc - m2) + (ccc2 - m3))
    else:
        print((ccc - m1) + (ccc2 - m4))


Fixed submission:
from collections import Counter

n = int(input())
vs = input().split()

xs = [v for v in vs[::2]]
x = Counter(xs).most_common()

ys = [v for v in vs[1::2]]
y = Counter(ys).most_common()

if x[0][0] != y[0][0]:
    d = n - x[0][1] - y[0][1]
    print(d)
else:
    if len(x) == 1:
        print(n // 2)
    else:
        d1 = n - x[0][1] - y[1][1]
        d2 = n - x[1][1] - y[0][1]
        if d1 > d2:
            print(d2)
        else:
            print(d1)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
alist = list(map(int, input().split()))

ca = {0: 0}
for i, a in enumerate(alist):
    ca[i+1] = sum(alist[0:i+1]) % m

c = 0
for i in range(1, n+1):
    for j in range(i, n+1):
        s = ca[j] - ca[i-1]
        if s % m == 0:
            c += 1
print(c)


Fixed submission:
from collections import defaultdict

n, m = map(int, input().split())
alist = list(map(int, input().split()))

c = 0
cnt = defaultdict(int)
cnt[0] = 1
s = 0
for i in range(n):
    s += alist[i]
    c += cnt[s%m]
    cnt[s%m] += 1

print(c)

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

c = 0
for i in range(n):
    for j in range(i, n):
        s = sum(alist[i:(j+1)])
        if s % m == 0:
            c += 1

print(c)


Fixed submission:
from collections import defaultdict

n, m = map(int, input().split())
alist = list(map(int, input().split()))

c = 0
cnt = defaultdict(int)
cnt[0] = 1
s = 0
for i in range(n):
    s += alist[i]
    c += cnt[s%m]
    cnt[s%m] += 1

print(c)
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind:
    def __init__(self, elements):
        self.elements = {e: -1 for e in elements}

    def same(self, a, b):
        return self.find(a) == self.find(b)

    def find(self, a):
        parent = self.elements[a]
        if parent < 0:
            return a
        self.elements[a] = self.find(parent)
        return self.elements[a]

    def unite(self, a, b):
        a_parent = self.find(a)
        b_parent = self.find(b)

        # already same union
        if a_parent == b_parent:
            return

        self.elements[a_parent] += self.elements[b_parent]
        self.elements[b_parent] = a_parent


N, K, L = map(int, input().split())
roads = []
trains = []
for _ in range(K):
    roads.append(list(map(int, input().split())))
for _ in range(L):
    trains.append(list(map(int, input().split())))

road_union = UnionFind(i for i in range(1, N + 1))
for road in roads:
    road_union.unite(road[0], road[1])

train_union = UnionFind(i for i in range(1, N + 1))
for train in trains:
    train_union.unite(train[0], train[1])

ma = dict()
for i in range(N):
    p = (road_union.find(i + 1), train_union.find(i + 1))
    ma.setdefault(p, 0)
    ma[p] += 1

for i in range(N):
    p = (road_union.find(i + 1), train_union.find(i + 1))
    print(ma[p], end=' ')


Fixed submission:
class UnionFind:
    def __init__(self, elements):
        self.elements = {e: -1 for e in elements}

    def same(self, a, b):
        return self.find(a) == self.find(b)

    def find(self, a):
        parent = self.elements[a]
        if parent < 0:
            return a
        self.elements[a] = self.find(parent)
        return self.elements[a]

    def unite(self, a, b):
        a_parent = self.find(a)
        b_parent = self.find(b)

        # already same union
        if a_parent == b_parent:
            return

        self.elements[a_parent] += self.elements[b_parent]
        self.elements[b_parent] = a_parent


N, K, L = map(int, input().split())
road_union = UnionFind(i for i in range(1, N + 1))
for _ in range(K):
    a, b = map(int, input().split())
    road_union.unite(a, b)

train_union = UnionFind(i for i in range(1, N + 1))
for _ in range(L):
    a, b = map(int, input().split())
    train_union.unite(a, b)

ma = dict()
for i in range(N):
    p = (road_union.find(i + 1), train_union.find(i + 1))
    ma[p] = ma.get(p, 0) + 1

for i in range(N):
    p = (road_union.find(i + 1), train_union.find(i + 1))
    print(ma[p], end=' ')
Buggy python submission (verdict: Runtime Error):
N   =   int(input())
L   =   int(input())

s_list = [input() for _ in range(N)]
s_list.sort()

for ele in s_list: 
    print(ele, end = '')

Fixed submission:
n, l = map(int, input().strip().split())
s_list = [input() for _ in range(n)]
s_list.sort()
 
for s in s_list:
    print(s, end='')
print()

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

s_list = [input() for _ in range(N)]

for ele in sorted(s_list): 
    print(ele, end = '')

Fixed submission:
n, l = map(int, input().strip().split())
s_list = [input() for _ in range(n)]
s_list.sort()
 
for s in s_list:
    print(s, end='')
print()

Buggy python submission (verdict: Runtime Error):
N   =   int(input())
L   =   int(input())
a   =   []
for i in range(N):
    a.append(input())
for ele in sorted(a): 
    print(ele, end = '')

Fixed submission:
n, l = map(int, input().strip().split())
s_list = [input() for _ in range(n)]
s_list.sort()
 
for s in s_list:
    print(s, end='')
print()
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(input().split())
B = np.array(A,dtype='float64')
B = np.max(B)
if B>=2e18 :
    print("-1")
else:
    A=np.array(A,dtype='int64')
    ans=np.prod(A,dtype='int64')
    if ans >=np.int64(1e18) : flg = 1
    if ans<=np.int64(0)  : flg = 1
    if flg ==1:
        print(ans)
    else:
        print("-1")

Fixed submission:
import numpy as np
N = int(input())
A = list(input().split())

Af =  np.array(A,dtype='float64')
Afans = np.prod(Af,dtype='float64')

if Afans == 0.:
    print('0')
elif Afans >=2e18:
    print('-1')
else:
    Ai =  np.array(A,dtype='int64')
    Aians = np.prod(Ai,dtype='int64')
    if Aians <=np.int64(1e18) and Aians >=np.int64(0):
        print(Aians)
    else:
        print("-1")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A=list(map(int,input().split()))
x = 1
for i in range(len(A)):
    x = x*A[i]
if x <=1e18:
    print(x)
else:
    print("-1")

Fixed submission:
import numpy as np
N = int(input())
A = list(input().split())

Af =  np.array(A,dtype='float64')
Afans = np.prod(Af,dtype='float64')

if Afans == 0.:
    print('0')
elif Afans >=2e18:
    print('-1')
else:
    Ai =  np.array(A,dtype='int64')
    Aians = np.prod(Ai,dtype='int64')
    if Aians <=np.int64(1e18) and Aians >=np.int64(0):
        print(Aians)
    else:
        print("-1")
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
[A,B] = input().split()
c = 0
if '.' in B:
    c = int(B.find('.'))
c = len(B)-c-1
B = B.replace(".","")
A = np.int64(A)
B = np.int64(B)
C = A*B
if c == 0 or C <=100:
    print(math.floor(C/int(10**c)))
else c == 1:
    print(str(C)[:-c])

Fixed submission:
import numpy as np
import math
[A,B] = input().split()
# A = "1000000000000001"
# B = "9.09"
c = 0
if '.' in B:
    c = int(B.find('.'))
c = len(B)-c-1
B = B.replace(".","")
A = np.int64(A)
B = np.int64(B)
C = A*B
if c == 0 or C <=100:
    print(math.floor(C/int(10**c)))
elif c == 1:
    print(str(C)[:-1])
elif c == 2:
    print(str(C)[:-2])
# C = C/int(10**c)
# print(C)
# print(math.floor(C))
# print(9990000000000000)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
import copy 
N = input()
N = np.int64(N)
# print(np.sqrt(N))
l = []
x  = 2
while N>1:
    if N%x ==0:
        l.append(x)
        N = N/x
    else:
        x = x + 1
        if x > np.sqrt(N):
            l.append(int(N))
            break
# l = [2, 2, 2, 3, 3, 3, 5, 5, 5, 6079, 6079]
# l = [2, 2, 2, 3]
l2 = []
while l!=[]:
#     print(l)
    i = l[0]
    n = l.count(i)
    l = l[n:]
    l2.append(n)
    if l==[]:break
# print(l2)
# print('///')

i = 0
m = 0
l2 = np.array(l2)
# print(l2)
ans = 0
while True:
    i += 1
#     m = m + i
#     print(m)
    l2 = l2-i
    l2 = l2[l2>=0]
    ans = ans + len(l2)
#     print(l2)
    if len(l2)==0:break
print(ans)

Fixed submission:
import numpy as np
import math
import copy 
N = input()
N = np.int64(N)
# print(np.sqrt(N))
l = []
x  = 2
xen = np.sqrt(N)
while N>1:
    if N%x ==0:
        l.append(x)
        N = N/x
    else:
        x = x + 1
        if x > xen:
            l.append(int(N))
            break
# l = [2, 2, 2, 3, 3, 3, 5, 5, 5, 6079, 6079]
# l = [2, 2, 2, 3]
l2 = []
while l!=[]:
#     print(l)
    i = l[0]
    n = l.count(i)
    l = l[n:]
    l2.append(n)
    if l==[]:break
# print(l2)
# print('///')

i = 0
m = 0
l2 = np.array(l2)
# print(l2)
ans = 0
while True:
    i += 1
#     m = m + i
#     print(m)
    l2 = l2-i
    l2 = l2[l2>=0]
    ans = ans + len(l2)
#     print(l2)
    if len(l2)==0:break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=input()
a=np.arange(np.float(N))+1
for i in range(len(a)):
    if a[i]%3==0 and a[i]%5==0:
        a[i]=0
    elif a[i]%3==0:
        a[i]=0
    elif a[i]%5==0:
        a[i]=0
print(int(sum(a)))


Fixed submission:
import numpy as np
N=input()
a=np.arange(np.float(N))+1
a=np.where(a%3==0.,0,a)
a=np.where(a%5==0.,0,a)
print(int(sum(a)))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
K=int(input())
gcd=0.
for i in range(K):
    for j in range(K):
        for k in range(K):
            gcd+=reduce(math.gcd,[i+1,j+1,k+1])
print(int(gcd))

Fixed submission:
import math
from functools import reduce
from itertools import product
K=int(input())
gcd=0.
for i in range(K):
    for j in range(K):
        a=math.gcd(i+1,j+1)
        for k in range(K):
            gcd+=math.gcd(a,k+1)
print(int(gcd))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
A_i = {}
A_j = {}
for i, a in enumerate(A):
    A_i[i] = a + i
    A_j[i] = i - a

r = 0
for i in range(n):
    for j in range(i + 1, n):
        if A_i[i] == A_j[j]:
            r += 1

print(r)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
A_j = {}
for i, a in enumerate(A):
    if A_j.get(i - a):
        A_j[i - a] += 1
    else:
        A_j[i - a] = 1

r = 0
for i, a in enumerate(A):
    t = A_j.get(a + i)
    if t:
        r += t

print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
A_i = {}
A_j = {}
for i, a in enumerate(A):
    A_i[i] = a + i
    A_j[i] = i - a

r = 0
for i in range(n):
    for j in range(i + 1, n):
        if A_i[i] == A_j[j]:
            r += 1

print(r)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
A_j = {}
for i, a in enumerate(A):
    if A_j.get(i - a):
        A_j[i - a] += 1
    else:
        A_j[i - a] = 1

r = 0
for i, a in enumerate(A):
    t = A_j.get(a + i)
    if t:
        r += t

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
M = 2019
dp = [0] * M
dp[0] = 1
t = 0
for i, s in enumerate(S[::-1]):
    t = (t + int(s) * (10 ** i)) % M
    dp[t] += 1

r = 0
for d in dp:
    r += d * (d - 1) // 2

print(r)


Fixed submission:
S = input()
M = 2019
dp = [0] * M
dp[0] = 1
t = 0
for i, s in enumerate(S[::-1]):
    t = (t + int(s) * (pow(10, i, M))) % M
    dp[t] += 1

r = 0
for d in dp:
    r += d * (d - 1) // 2

print(r)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
r = 0
n = len(s)
for i in range(n):
    for k in range(i + 3, n + 1):
        if i + 3 <= n:
            if int(s[i:k]) % 2019 == 0:
                r += 1
print(r)


Fixed submission:
S = input()
M = 2019
dp = [0] * M
dp[0] = 1
t = 0
for i, s in enumerate(S[::-1]):
    t = (t + int(s) * (pow(10, i, M))) % M
    dp[t] += 1

r = 0
for d in dp:
    r += d * (d - 1) // 2

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
s = input()

c = collections.Counter(s)
r = c['R'] * c['G'] * c['B']

for i in range(n):
    for k in range(i, n):
        j = (i + k) // 2
        if (i + k) % 2 == 0 and 0 < 2 < n:
            if s[i] != s[k] and s[k] != s[j] and s[i] != s[j]:
                r -= 1

print(r)


Fixed submission:
import collections

n = int(input())
s = input()

c = collections.Counter(s)
r = c['R'] * c['G'] * c['B']

for i in range(n):
    for k in range(i, n):
        j = (i + k) // 2
        if (i + k) % 2 == 0 and 0 < 2 < n:
            if s[i] != s[k] and s[k] != s[j] and s[i] != s[j]:
                r -= 1

print(r)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

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

print(comb(n, 2, exact=True) + comb(m, 2, exact=True))


Fixed submission:
from math import factorial

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

if n > 2 and m > 2:
    print(
        factorial(n) // (factorial(n - 2) * factorial(2))
        + factorial(m) // (factorial(m - 2) * factorial(2))
    )
elif n < 2 and m < 2:
    print(0)
elif n < 2:
    print(factorial(m) // (factorial(m - 2) * factorial(2)))
elif m < 2:
    print(factorial(n) // (factorial(n - 2) * factorial(2)))
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
s = "a" * a + "b" * b
S = s * (int(n / (a + b)) + 1)
print(S[:n].count("a"))


Fixed submission:
n, a, b = map(int, input().split())
if a == 0:
    print(0)
elif n <= a:
    print(n)
else:
    r = int(n / (a + b))
    if n % (a + b) < a:
        print(n - r * b)
    else:
        print(a * (r + 1))