Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02981 (python)

Fixed submission:
n,a ,b = map(int, input().split())
s = a * n
print(min(s,b))

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())
# 2019 = 3 * 673

rr = min(r, l + 2020)

res = 1000000
for i in range(l, rr+1):
    for j in range(l + 1, rr + 1):
        #print("{0}, {1}".format(i, j))
        if i >= j:
            #print("skip")
            continue

        if res > i*j % 2019:
            #print("{0}, {1}".format(i, j))
            res = i*j % 2019
print(res)
Problem p02993 (python)

Fixed submission:
s = input()
l = ""
res = True
for i in range(4):
    if s[i] == l:
        res = False
    l = s[i]
print("Good" if res else "Bad")

Buggy submission (verdict: Runtime Error):
def nCr(n, r):
    import math
    return math.factorial(n) // ((math.factorial(n - r) * math.factorial(r)))
MOD = 1000000007

n, k = map(int, input().split())
b, r = k, n-k
for i in range(0, k):
    x = nCr(b - 1,  i) # 青いブロックの分け方
    y = nCr(r + 1 , r- i)

    print(x * y % MOD)
Problem p02996 (python)

Fixed submission:
n = int(input())
tasks = []
for i in range(n):
    a,b = map(int, input().split())
    tasks.append((a,b))

tasks.sort(key=lambda x:x[1])
#print(tasks)

cur = 0
c = True
for i in range(n):
    cur += tasks[i][0]
    if cur > tasks[i][1]:
        c = False

print("Yes" if c else "No")

Buggy submission (verdict: Runtime Error):
    n = int(input())
    tasks = []
    for i in range(n):
        a,b = map(int, input().split())
        tasks.append((a,b))

    tasks.sort(key=lambda x:x[1])
    #print(tasks)

    cur = 0
    c = True
    for i in range(n):
        cur += tasks[i][0]
        if cur > tasks[i][1]:
            c = False

    print("Yes" if c else "No")
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
dat_l = list(map(int, input().split()))
cur = 0
c = 0
for i in range(n):
    cur += dat_l[i]
    if cur > x:
        break
    c += 1
print(c+1)

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(int, input().split())

# 横
men1 = w * y
men2 = w * (h-y)

# 縦
men3 = x * h
men4 = (w-x) * h


#print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))
out1 = max(min(men1, men2), min(men3, men4))
if min(men1, men2) == min(men3, men4):
    out2 = 1
elif x != 0 and y != 0 and (h / w) == (y / x):
    out1 = w * h / 2
    out2 = 1
else:
    out2 = 0

print("{0} {1}".format(out1, out2))
Problem p03001 (python)

Fixed submission:
w,h,x,y = map(int, input().split())
out1 = w * h / 2
out2 = 1 if x == w/2 and y == h/2 else 0
print("{0} {1}".format(str(out1), str(out2)))

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(int, input().split())

#print("{0} {1} {2} {3}".format(str(w), str(h), str(x), str(y)))

if x > w/2:
    x = w - x
if y > h/2:
    y = h - y

# 横
men1 = w * y
men2 = w * (h-y)

# 縦
men3 = x * h
men4 = (w-x) * h

#print("{0} {1} {2} {3}".format(str(w), str(h), str(x), str(y)))
#print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))

out2 = 0

if min(men1, men2) == 0:
    out1 = min(men3, men4)
elif min(men3, men4) == 0:
    out1 = min(men1, men2)
else:
    out1 = max(min(men1, men2), min(men3, men4))

if min(men1, men2) == min(men3, men4):
    out2 = 1
if men1 == men2 or men3 == men4):
    out2 = 1

if x == 0 and y ==0:
    out1 = x*y /2
    out2 = 0

print("{0} {1}".format(out1, out2))

Buggy submission (verdict: Runtime Error):
    w,h,x,y = map(int, input().split())

    if x > w/2:
        x = w - x
    if y > h/2:
        y = h - y

    # 横
    men1 = w * y
    men2 = w * (h-y)

    # 縦
    men3 = x * h
    men4 = (w-x) * h

    if x == 0 and y ==0 :
        out1 = w * h
        out2 = 1
    else:
        #print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))

        if min(men1, men2) == 0:
            out1 = min(men3, men4)
        elif min(men3, men4) == 0:
            out1 = min(men1, men2)
        else:
            out1 = max(min(men1, men2), min(men3, men4))

        if x != 0 and y != 0 and (h / w) == (y / x):
            out1 = w * h / 2

        out2 = 0
        if min(men1, men2) == min(men3, men4):
            out2 = 1
        if x != 0 and y != 0 and (h / w) == (y / x):
            out2 = 1

    print("{0} {1}".format(out1, out2))

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(int, input().split())

if x > w/2:
    x = w - x
if y > h/2:
    y = h - y

# 横
men1 = w * y
men2 = w * (h-y)

# 縦
men3 = x * h
men4 = (w-x) * h

if x == 0 and y ==0:
    out1 = w * h
    out2 = 1
else:
    print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))

    if min(men1, men2) == 0:
        out1 = min(men3, men4))
    elif min(men3, men4) == 0:
        out1 = min(men1, men2))
    else:
        out1 = max(min(men1, men2), min(men3, men4))

    if x != 0 and y != 0 and (h / w) == (y / x):
        out1 = w * h / 2

    out2 = 0
    if min(men1, men2) == min(men3, men4):
        out2 = 1
    if x != 0 and y != 0 and (h / w) == (y / x):
        out2 = 1

print("{0} {1}".format(out1, out2))

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(int, input().split())

# 横
men1 = w * y
men2 = w * (h-y)

# 縦
men3 = x * h
men4 = (w-x) * h


#print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))
out1 = max(min(men1, men2), min(men3, men4))
if min(men1, men2) == min(men3, men4):
    out2 = 1
elif (h / w) == (y / x):
    out2 = 1
else:
    out2 = 0

print("{0} {1}".format(out1, out2))
Problem p03006 (python)

Fixed submission:
n = int(input())
dat = []
for i in range(n):
    a,b = map(int, input().split())
    dat.append([a,b])
dat2 = []
if n == 1:
    print(1)
else:
    for i in range(n):
        x1, y1 = dat[i]
        for j in range(n):
            if i == j:
                continue
            x2, y2 = dat[j]
            dat2.append( (x1-x2, y1-y2) )
    import collections
    c = collections.Counter(dat2)
    #print(c)
    ta, tb = c.most_common(1)[0][0]
    res = 0
    for i in range(n):
        canwarp = False
        x1, y1 = dat[i]
        for j in range(n):
            if i == j:
                continue
            x2, y2 = dat[j]
            if x1-x2 == ta and  y1-y2 == tb:
                canwarp = True
        if canwarp:
            continue
        else:
            res += 1
    print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
dat = []
for i in range(n):
    a,b = map(int, input().split())
    dat.append([a,b])
dat2 = []
for i in range(n):
    x1, y1 = dat[i]
    for j in range(i+1, n):
        x2, y2 = dat[j]
        dat2.append( (x1-x2, y1-y2) )
import collections
c = collections.Counter(dat2)
#print(c)
print(n - c.most_common(1)[0][1])
Problem p03047 (python)

Fixed submission:
n, k = map(int, input().split())
print(n - k  + 1)

Buggy submission (verdict: Runtime Error):
r, g, b, n = map(int,input().split())
res = 0
for i in range(n // r + 1):
    for j in range((n-r*i) // g + 1):
        if (n - (i * r) - (g * j) ) % b == 0:
            #print("{0}, {1}, {2}".format(i, j, (n - (i * r) - (g * j) ) % g))
            res += 1

print(res)
Problem p03049 (python)

Fixed submission:
n = int(input())
res = 0
numa = numb = numboth = 0
for _ in range(n):
    s = input()
    res += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        numboth += 1
    elif s[0] == "B":
        numb += 1
    elif s[-1] == "A":
        numa += 1

#print(numboth, numa, numb)
#print(res)

if numboth == 0:
    res += min(numa, numb)
else:
    if numa == 0 and numb == 0:
        res += numboth - 1
    else:
        res += numboth
        res += min(numa, numb)
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
res = 0
sboth = 0
sa = 0
sb = 0
for i in range(n):
    s = input()
    res += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        sboth += 1
        continue
    if s[0] == "B":
        sb += 1
        continue
    if s[-1] == "A":
        sa += 1
        continue

num = min(sboth)
res += num
sboth -= num

num = min(sboth, sb)
res += num
sboth -= num

num = min(sa, sb)
res += num
sa -= num
sb -= num

num = min(sboth)
res += num
sboth -= num

num = min(sboth, sb)
res += num
sboth -= num

num = min(sa, sb)
res += num
sa -= num
sb -= num


if sboth > 0:
    sboth = 1
    res += sboth - 1

print(res)
Problem p03087 (python)

Fixed submission:
n, q = map(int, input().split())
s = input()
dat_q = []
for i in range(q):
    l, r = map(int, input().split())
    dat_q.append((l, r))

c = [0] * n
for i in range(1, n):
    if s[i-1:i+1] == "AC":
        c[i] = c[i-1] + 1
    else:
        c[i] = c[i-1]
for i in range(q):
    l, r = dat_q[i][0], dat_q[i][1]
    print(c[r - 1] - c[l - 1])

Buggy submission (verdict: Runtime Error):
    n, q = map(int, input().split())
    s = input()
    dat_q = []
    for i in range(q):
        l, r = map(int, input().split())
        dat_q.append((l, r))

    c = [0] * n
    for i in range(1, n):
        if s[i-1:i+1] == "AC":
            c[i] = c[i-1] + 1
        else:
            c[i] = c[i-1]
    for i in range(q):
        l, r = dat_q[i][0], dat_q[i][1]
        print(c[r - 1] - c[l - 1])
Problem p03102 (python)

Fixed submission:
n,m,c = map(int,input().split())
b = map(int,input().split())
b = list(b)
count = 0
for i in range(n):
    sum = 0
    a = map(int, input().split())
    a = list(a)
    for j in range(m):
        sum += a[j] * b[j]
    sum += c
    if sum > 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n,m,c = int(map,input().split())
b = int(map,input().split())
count = 0
for i in range(n):
    sum = 0
    a = int(map, input().split())
    for j in range(m):
        sum += a[j] * b[j]
    sum += c
    if sum > 0:
        count += 1
print(count)
Problem p03161 (python)

Fixed submission:
n, k = map(int, input().split())
dat_h = list(map(int, input().split()))
dp = [100000000000] * (n + 1)
dp[0] = 0
for i in range(1, n):
    #print("i:{0}", i)
    for j in range(1, k + 1):
        #print("j:{0}", j)
        if (i - j) >= 0:
            dp[i] = min(dp[i], dp[i-j] + abs(dat_h[i] - dat_h[i-j]))
#print(dp)
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())
dat_h = list(map(int, input().split()))
dp = [math.inf] * (n + 1)
dp[0] = 0
for i in range(1, n):
    #print("i:{0}", i)
    for j in range(1, k + 1):
        #print("j:{0}", j)
        if (i - j) >= 0:
            dp[i] = min(dp[i], dp[i-j] + abs(dat_h[i] - dat_h[i-j]))
#print(dp)
print(dp[n-1])
Problem p03289 (python)

Fixed submission:
s  = input()
f = True
if s[0] != "A":
    f = False
c = 0
for i in range(2, len(s) - 1):
    if s[i] == "C":
        c += 1
if c != 1:
    f=False
ss = s[1:].replace("C", "")
for i in range(len(ss)):
    if ss[i] < "a" or ss[i] > "z":
        f = False
if f:
    print("AC")
else:
    print("WA")

Buggy submission (verdict: Runtime Error):
def resolve():
s = input()

f = True

if s[0] != "A":
    f = False

ss = s[1:2] + s[3:-2] + s[-1:]
for i in range(len(ss)):
    if ss[i] < "a" or ss[i] > "z":
        f = False

if (s[2] == "C" and s[-2] == "C"):
    f = False
if (s[2] != "C" and s[-2] != "C"):
    f = False

if f:
    print("AC")
else:
    print("WA")
Problem p03309 (python)

Fixed submission:
n = int(input())
dat = list(map(int, input().split()))
dat_d = []

total = 0
for i in range( n):
    total += (dat[i] - (i+1))
    dat_d.append(dat[i] - (i+1))

#print(dat)
#print(dat_d)
#print(total)
#f = (total // n)
#print(f)

dat_d.sort()
#print(dat_d)
f = dat_d[n//2]

total = 0
for i in range( n):
    total += abs(dat_d[i] - f)

print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
dat = list(map(int, input().split()))
dat_d = []

total = 0
for i in range( n):
    total += (dat[i] - (i+1))
    dat_d.append(dat[i] - (i+1))

#print(dat)
#print(dat_d)
#print(total)
#f = (total // n)
#print(f)

f = (dat_d[n//2])
dat_d = list(map(lambda x: x - f, dat_d))
total = 0
for i in range(n):
    total += abs(dat_d[i])

f = (dat_d[n//2 + 1])
dat_d = list(map(lambda x: x - f, dat_d))
total2 = 0
for i in range(n):
    total2 += abs(dat_d[i])

total = min(total, total2)

print(total)
Problem p03386 (python)

Fixed submission:
a,b,k = map(int, input().split())
n = a
c = 1
while n <= b:
    print(n)
    n += 1
    c += 1
    if c > k:
        break
if n <= (b - k):
    n = b - k + 1

c = 1
while n <= b:
    print(n)
    n += 1
    c += 1
    if c > k:
        break

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
for i in range(k):
    print(a + i)



for j in range(k - 1, -1, -1):
    print(b-j)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
for i in list(range(k)):
    print(a + i)



for j in list(range(k - 1, -1, -1)):
    print(b-j)
Problem p03400 (python)

Fixed submission:
n = int(input())
d,x = map(int, input().split())
sum = 0
for i in range(n):
    a = int(input())
    for j in range(100):
        day = 1 + j*a
        if day <= d:
            sum += 1
        else:
            break
print(x + sum)

Buggy submission (verdict: Runtime Error):
    n = int(input())
    d,x = map(int, input().split())
    sum = 0
    for i in range(n):
        a = int(input())
        for j in range(100):
            day = 1 + j*a
            if day <= d:
                sum += 1
            else:
                break
    print(x + sum)

Buggy submission (verdict: Runtime Error):
    n = int(input())
    d,x = map(int, input().split())
    sum = 0
    for i in range(n):
        a = int(input())
        for j in range(100):
            day = 1 + j*a
            if day <= d:
                sum += 1
            else:
                break
    print(x + sum)
Problem p03449 (python)

Fixed submission:
n = int(input())
dat1 = list(map(int, input().split()))
dat2 = list(map(int, input().split()))
s1 = sum(dat1)
s2 = sum(dat2)
dp1 = [0]*200
dp2 = [0]*200
for i in range(n):
    dp1[i+1] = dp1[i] + dat1[i]
    dp2[i+1] = max(dp1[i+1] + dat2[i], dp2[i] + dat2[i])

print(dp2[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
dat1 = list(map(int, input().split()))
dat2 = list(map(int, input().split()))
s1 = sum(dat1)
s2 = sum(dat2)
dp1 = [0]*20
dp2 = [0]*20
for i in range(n):
    dp1[i+1] = dp1[i] + dat1[i]
    dp2[i+1] = max(dp1[i+1] + dat2[i], dp2[i] + dat2[i])

print(dp2[n])
Problem p03493 (python)

Fixed submission:
s=input()
count = 0
if s[0] == "1":
    count = count + 1
if s[1] == "1":
    count = count + 1
if s[2] == "1":
    count = count + 1
print(count)

Buggy submission (verdict: Runtime Error):
s = input()
res = 0
for i in len(s):
  if s[i] == "1":
    res+= 1
print(res)
Problem p03563 (python)

Fixed submission:
r = int(input())
g = int(input())
x = (2*g) - r
print(x)

Buggy submission (verdict: Runtime Error):
    r = int(input())
    g = int(input())
    x = (2*g) - r
    print(x)

Buggy submission (verdict: Runtime Error):
    r = int(input())
    g = int(input())
    x = (2*g) - r
    print(x)
Problem p03565 (python)

Fixed submission:
import pprint
s = input()
t = input()
candidate = []
for i in range(len(s) - len(t) + 1):
    can = True
    for j in range(len(t)):
        if s[i + j] == "?" or s[i + j] == t[j]:
            continue
        else:
            can = False
            break
    if can:
        res = []
        for j in range(i):
            if s[j] == "?":
                res.append("a")
            else:
                res.append(s[j])
        for j in range(len(t)):
            res.append(t[j])
        for j in range(len(s) - len(t) - i):
            if s[j + len(t) + i] == "?":
                res.append("a")
            else:
                res.append(s[j + len(t) + i])
        candidate.append("".join(res))

if len(candidate) != 0:
    candidate.sort()
    #pprint.pprint(candidate)
    print(candidate[0])

else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
for i in range(len(s) - len(t) + 1):
    can = True
    for j in range(len(t)):
        if s[i + j] == "?" or s[i + j] == t[j]:
            continue
        else:
            can = False
            break
    if can:
        break
if can:
    res = []
    for j in range(i):
        if s[j] == "?":
            res.append("a")
        else:
            res.append(s[j])
    for j in range(len(t)):
        res.append(t[j])
    for j in range(len(s) - len(t) - i):
        if s[j + len(t) + i] == "?":
            res.append("a")
        else:
            res.append(s[j + len(t) + i])
    print("".join(res))

else:
    print("UNRESTORABLE")
Problem p03644 (python)

Fixed submission:
import math
n = int(input())
curnum = 1
curmax = 0
for i in range(1, n + 1):
    c = int(math.log2(i))
    if c > curmax:
        curmax = c
        curnum = i
print(curnum)

Buggy submission (verdict: Runtime Error):
import math
math.log2(2)

Buggy submission (verdict: Runtime Error):
import math
math.log2("hoge")

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
curnum = 1
curmax = 0
for i in range(1, n + 1):
    c = int(math.log2(i))
    if c > curmax:
        curmax = c
        curnum = i
print(curnum)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
curnum = 1
curmax = 0
for i in range(1, n + 1):
    c = int(math.log2(i))
    if c > curmax:
        curmax = c
        curnum = i
print(curnum)
Problem p03645 (python)

Fixed submission:
n, m = map(int, input().split())
dat = []
dat_m = [[]] * (n+1)
dat_finish = [False] * (n+1)

for i in range(m):
    a,b = map(int, input().split())
    dat.append( (a,b) )

#print(dat)
for i in range(m):
    a,b = dat[i]
    if b == n:
        dat_finish[a] = True
#print(dat_finish)

c = False
for i in range(m):
    a,b = dat[i]
    if a == 1:
        if dat_finish[b]:
            c = True

print("POSSIBLE" if c else "IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
from collections import deque
n, m = map(int, input().split())
dat = deque([])
dat_finish = [False] * (n + 1)

for i in range(m):
    a, b = map(int, input().split())
    dat.append((a, b))

dat2 = dat.copy()

for i in range(m):
    a, b = dat.pop()
    if b == n:
        dat_finish[a] = True

c = False
for i in range(m):
    a, b = dat2.pop()
    if a == 1:
        if dat_finish[b]:
            c = True

print("POSSIBLE" if c else "IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
    from collections import deque
    n, m = map(int, input().split())
    dat_m = [deque([]) for x in range(n + 1)]

    for i in range(m):
        a, b = map(int, input().split())
        dat_m[a].append(b)

    c = False
    for i in dat_m[1]:
        if n in dat_m[i]:
            c = True

    print("POSSIBLE" if c else "IMPOSSIBLE")
Problem p03826 (python)

Fixed submission:
a,b,c,d = map(int, input().split())
if a*b > c*d:
    print(a*b)
else:
    print(c*d)

Buggy submission (verdict: Runtime Error):
mod = 1000000000 + 7
 
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr
 
n = int(input())
dat = [0] * 2000 # 約数として求められたある数の合計
 
# N! の各要素の素因数分解をする
res = 1
for i in range(1, n + 1):
    d = factorization(i)
    for j in range(len(d)):
        dat[d[j][0]] += d[j][1]
 
for i in range(2, n + 1):
    res *= (dat[i] + 1)
    res %= mod
 
print(res)
Problem p03844 (python)

Fixed submission:
a,o,b = input().split()
a = int(a)
b = int(b)
if o == "+":
    print(a+b)
else:
    print(a-b)

Buggy submission (verdict: Runtime Error):
import math
math.log2(2)
Problem p03937 (python)

Fixed submission:
maze = []
h, w = map(int,input().split())
for _ in range(h):
    maze.append(list(input()))
#print(maze)
x,y = 0,0
while True:
    maze[y][x] = "."
    if x == w-1 and  y == h-1:
        break
    if x != w-1 and maze[y][x+1]== "#":
        x += 1
        continue
    if y != h-1 and maze[y+1][x]=="#":
        y += 1
        continue
    break
from pprint import pprint
#pprint(maze)
f= True
for i in range(h):
    if maze[i].count("#") != 0:
        f = False
print("Impossible" if not f else "Possible")

Buggy submission (verdict: Runtime Error):
    maze = []
    h, w = map(int,input().split())
    for _ in range(h):
        maze.append(list(input()))
    #print(maze)
    x,y = 0,0
    while True:
        maze[y][x] = "."
        if x == w-1 and  y == h-1:
            break
        if x != w-1 and maze[y][x+1]== "#":
            x += 1
            continue
        if y != h-1 and maze[y+1][x]=="#":
            y += 1
            continue
        break
    from pprint import pprint
    #pprint(maze)
    f= True
    for i in range(h):
        if maze[i].count("#") != 0:
            f = False
    print("Impossible" if not f else "Possible")
Problem p02555 (python)

Fixed submission:
N=int(input())
DP=[0]*(N+1)
tmp=0
mod=10**9+7
if N<3:
   print(0)
   exit()
DP[3]=1
for i in range(4,N+1):
   DP[i]=(DP[i-1]+DP[i-3])%mod
print(DP[N]%mod)

Buggy submission (verdict: Runtime Error):
N=int(input())
DP=[0]*(N+1)
DP[3]=1
tmp=0
mod=10**9+7
for i in range(4,N+1):
   DP[i]=(DP[i-1]+DP[i-3])%mod
print(DP[N]%mod)
Problem p02702 (python)

Fixed submission:
import sys
tmp=sys.stdin.readline().rstrip()
def main():
   ans=0
   cnt=[0]*2019
   cnt[0]+=1
   t=0
   d=1
   for i in reversed(tmp):
      t=(t+int(i)*d)%2019
      cnt[t]+=1
      d=d*10%2019
   for i in cnt:
      ans+=i*(i-1)//2
   print(ans)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import collections
tmp=sys.stdin.readline()
def main():
   cnt=[0]*2019
   cnt[0]+=1
   for i in reversed(range(len(tmp))):
      cnt[int(tmp[i:])%2019] += 1
   cnt=collections.Counter(cnt).items()
   ans=0
   for i,j in cnt:
      if i > 1:
         ans+=i*(i-1)//2*j
   print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
tmp=sys.stdin.readline()
def main():
   cnt=[0]*2019
   cnt[0]+=1
   for i in reversed(range(len(tmp))):
      cnt[int(tmp[i:])%2019] += 1
   import collections
   cnt=collections.Counter(cnt).items()
   ans=0
   for i,j in cnt:
      if i > 1:
         ans+=i*(i-1)//2*j
   print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
tmp=sys.stdin.readline()
def main():
   cnt=[0]*2019
   cnt[0]+=1
   for i in reversed(range(len(tmp))):
      cnt[int(tmp[i:])%2019] += 1
   import collections
   cnt=collections.Counter(cnt).items()
   ans=0
   for i,j in cnt:
      if i > 1:
         ans+=i*(i-1)//2*j
   print(ans)

if __name__ == "__main__":
    main()
Problem p02756 (python)

Fixed submission:
A = input()
B = int(input())
C = ""
for i in range(B):
    D = input().split()
    if D[0] == "1":
        C,A = A,C
    else:
        if D[1] == "1":
            C += D[2]
        else:
            A += D[2]
C = C[::-1]
print(C+A)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
A = deque(input())
B = int(input())
for i in range(B):
    C = sys.stdin.readline().split()
    if C[0] == "1":
        A.reverse()
    else:
		X = C[2]
        if C[1] == "1":
            A.appendleft(X)
        else:
            A.append(X)
print("".join(A))