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

Fixed submission:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    
    h, w = map(int, input().split())
    s = [list(input()) for i in range(h)]
    start = []
    for i in range(h):
        for j in range(w):
            if s[i][j] == "#": 
                start.append([i,j])

    ans = [0,0]
    vis = [[-1 for i in range(w)] for j in range(h)]
    def f(x, y, pre):
        vis[x][y] = 1
        if s[x][y] == "#":
            ans[0] += 1
        else:
            ans[1] +=1
        for i, j in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
            nx = i + x
            ny = j + y
            if nx >= 0 and ny >= 0 and nx < h and ny < w and vis[nx][ny] == -1:
                if pre == "B" and s[nx][ny] == ".":
                    f(nx,ny,"W")
                elif pre == "W" and s[nx][ny] == "#":
                    f(nx, ny, "B")
                
    
    ret = 0
    for i, j in start:
        if vis[i][j] == -1:
            f(i, j, "B")
        ret += ans[0] * ans[1]
        ans[0] = ans[1] = 0
    print(ret)
        

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline
def main():
    h, w = map(int, input().split())
    s = [list(input()) for i in range(h)]

    white, black = [], []
    for i in range(h):
        for j in range(w):
            if s[i][j] == "#":
                black.append([i, j])
            else:
                white.append([i, j])

    ans = 0
    for bx, by in black:
        for wx, wy in white:

            queue = [[bx, by]]
            visited = [[False for i in range(w + 1)] for j in range(h+1)]
            while len(queue) != 0:
                p = queue.pop(0)
                visited[p[0]][p[1]] = True
                if p[0] == wx and p[1] == wy:
                    ans += 1
                    break
                for x, y in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
                    nx = p[0] + x
                    ny = p[1] + y
                    if nx < 0 or ny < 0 or nx >= h or ny >= w or visited[nx][ny] == True:
                        continue
                    #print(nx, ny, s)
                    if (((nx+ny) % 2) == ((bx+by) % 2) and s[nx][ny] == ".") or (((nx+ny) % 2) != ((bx+by) % 2) and s[nx][ny] == "#"):
                        continue
                    queue.append([nx, ny])

    print(ans)


if __name__ == '__main__':
    main()
Problem p03244 (python)

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

a = [ v[i] for i in range(0,n,2)]
b = [ v[i] for i in range(1,n,2)]
A = [0] * 100010
B = [0] * 100010

for i in range(int(n/2)):
    A[a[i]] += 1
    B[b[i]] += 1

if A.index(max(A)) == B.index(max(B)):
    BB = sorted(B)
    cc1 = len(b) - BB[-2] + len(a) - max(A)
    AA = sorted(A)
    cc2 = len(a) - AA[-2] + len(b) - max(B)
    if cc1 > cc2:
        print(cc2)
    else:
        print(cc1)
else:
    print(n - max(A) - max(B))

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))

a = [0] * 100000
for i in v:
    a[i] += 1

A = sorted(a)
if A[-2] == 0:
    print(int(n/2))
else:
    print(len(v) - A[-1] - A[-2])
Problem p03262 (python)

Fixed submission:
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
 
ans = 0
for i in range(N):
    ans = fractions.gcd(ans,abs(x[i]-X))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))

ans = 0
for i in range(N):
    ans = math.gcd(ans,abs(x[i]-X))
print(ans)
Problem p03274 (python)

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

ans = 10**18
for i in range(N - K + 1):
    p1 = x[i]
    p2 = x[i+K-1]
    lr = abs(p1) + abs(p2 - p1)
    rl = abs(p2) + abs(p1 - p2)
    if lr < rl:
        ans = min(ans,lr)
    else:
        ans = min(ans,rl)
print(ans)

Buggy submission (verdict: Runtime Error):

N,K = map(int,input().split())
a = list(map(int,input().split()))
x = []
flg = True
for i in range(N):
    if a[i] > 0 and flg == True:
        x.append(0)
        flg = False
    x.append(a[i])


#x.append(0)
#x.sort()

c = []
for i in range(N - K + 2):
    if (0 not in x[i:i+K+1]) or (len(x[i:i+K+1]) != K+1):
        continue
    p = x[i:i+K+1]
    if min(p) < 0 and max(p) > 0:
        if p[-1] + p[-1] - p[0] < abs(p[0]) + p[-1] -p[0]:
            c.append(p[-1] + (p[-1] - p[0]))
        else:
            c.append(abs(p[0]) + p[-1] - p[0])
    elif min(p) >= 0:
        c.append(p[-1])
    elif max(p) <= 0:
        c.append(abs(p[0]))

print(min(c))
Problem p03280 (python)

Fixed submission:
a,b = map(int,input().split())
print(a*b -(a+b-1))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print(a*b -(a+b-1))
Problem p03353 (python)

Fixed submission:
s = input()
K = int(input())

L = []
for i in range(len(s)):
    for j in range(1,K+1):
        L.append(s[i:i+j])
print(sorted(set(L))[K-1])

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())

L = []
L.append(s)

for i in range(len(s),0,-1):
    for j in range(len(s)):
        if i + j >= len(s):
            break
        L.append(s[j:i+j])
    L = sorted(set(L))
#    if len(L) >= K:
print(L[K-1])
Problem p03377 (python)

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

if A > X:
  print("NO")
elif A+B < X:
  print("NO")
else:
  print("YES")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())

if A > X:
  print("NO")
elif A+B < X:
  print("NO")
else:
  print("YES")
Problem p03399 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min(a,b) + min(c,d))

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
print(min(a,b) + min(c,d))
Problem p03425 (python)

Fixed submission:
N = int(input())
d = {}
for i in range(N):
    s = input()[0]
    if s not in d.keys():
        d[s] = 0
    d[s] += 1
march = ["M","A","R","C","H"]
lis = []
for a in d.keys():
    if a in march:
        lis.append(a)
import itertools
ans = 0
for l in list(itertools.combinations(lis,3)):
    ans += d[l[0]]*d[l[1]]*d[l[2]]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
Sdic = {}
L = ["M","A","R","C","H"]
for i in L:
    Sdic[i] = []

tN = N
for i in range(N):
    s = input()
    if s[0] in L:
        Sdic[s[0]].append(s)
    else:
        tN -= 1


zen = tN*(tN-1)*(tN-2) / 6

one = 0
for i in ["M","A","R","C","H"]:
    c = len(Sdic[i])
    if c >= 3:
        one += c * (c-1) * (c-2)  / 6


lis = []
for i in range(N):
    for j in range(N):
        if i < j:
            lis.append(len(Sdic[L[i]]) + len(Sdic[L[j]]))

two = 0
for c in lis:
    if c >= 3:
        two += c * (c-1) * (c-2)  / 6

print(int(zen - one - two))
Problem p03427 (python)

Fixed submission:
def main():
    n = input()
    if len(n) == 1:
        print(n)
        exit()
    else:
        ans = (len(n) - 1) * 9
        t = 0
        for i in range(len(n)):
            t += int(n[i])
        ans = max(ans, t)
        k = int(n)
        for i in range(len(n)-1):
            nn = str(k)
            m = int(nn[len(n) - i - 1:]) + 1
            k -= m
            t = 0
            for j in range(len(str(k))):
                t += int(str(k)[j])
            ans = max(ans, t)
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = input()
    if len(n) == 1:
        print(n)
    else:
        ans = (len(n) - 1) * 9
        t = 0
        for i in range(len(n)):
            t += int(n[i])
        ans = max(ans, t)
        k = int(n)
        for i in range(len(n)-1):
            nn = str(k)
            m = int(nn[len(n) - i - 1:]) + 1
            #print(m)
            k -= m
            t = 0
            for j in range(len(str(k))):
                t += int(str(k)[j])
            ans = max(ans, t)
    print(ans)


if __name__ == '__main__':
    main()
Problem p03447 (python)

Fixed submission:
X = int(input())
a = int(input())
b = int(input())
X -= a
k = X//b
print(X - b*k)

Buggy submission (verdict: Runtime Error):
x = int(input())
a = int(input())
b = int(input())
X -= a
k = X//b
print(X - b*k)
Problem p03450 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)

def main():
    N,M = map(int,input().split())
    e = [[] for i in range(N)]
    t = 0
    a = []
    for i in range(M):
        r,l,d = map(int,input().split())
        e[r-1].append([l-1,d])
        e[l-1].append([r-1,-d])
        a.append(r-1)
        a.append(l-1)
        t = r-1

    col = [ float("inf") for i in range(N) ]
    def dfs(i,c):

        for node in e[i]:
            if col[node[0]] == float("inf"):
                col[node[0]] = c + node[1]
                dfs(node[0],c+node[1])
            elif col[node[0]] != c + node[1]:
                print("No")
                exit()


    dfs(t,0)
    a = list(set(a))
    for i in a:
        if col[i] == float("inf"):
            dfs(i,0)


    print("Yes")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
e = [[] for i in range(N)]
t = 0
for i in range(M):
    r,l,d = map(int,input().split())
    e[r-1].append([l-1,d])
    e[l-1].append([r-1,-d])
    t = r-1

col = [ -1 for i in range(N) ]
def dfs(i,c):

    for node in e[i]:
        if col[node[0]] == -1:
            col[node[0]] = c + node[1]
            dfs(node[0],c+node[1])
        elif col[node[0]] != c + node[1]:
            print("No")
            exit()

dfs(t,0)

print("Yes")
Problem p03480 (python)

Fixed submission:
S = input()

ans = 0
if len(S) % 2 == 0:
    ans = len(S)//2
    c = ans
    t = S[ans]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
else:
    ans = len(S)//2+1
    c = ans
    t = S[ans-1]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break

    ans = max(len(S)//2,ans)

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()

ans = 0
if len(S) % 2 == 0:
    ans = len(S)//2
    c = ans
    t = S[ans]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
else:
    ans = len(S)//2
    c = ans+1
    t = S[ans+1]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
print(ans)
Problem p03502 (python)

Fixed submission:
N = int(input())

s = 0
sN = str(N)
for i in range(len(sN)):
  s += int(sN[i])

if N % s == 0:
  print("Yes")
else:
  print("No")

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

s = 0
sN = str(N)
for i in range(len(sN)):
  s += sN[i]

if N % s == 0:
  print("Yes")
else:
  print("No")
Problem p03547 (python)

Fixed submission:
x,y = input().split()
if x == y:
  print("=")
elif x > y:
  print(">")
elif x < y:
  print("<")

Buggy submission (verdict: Runtime Error):
X,Y = input().split()
if x == y:
  print("=")
elif x > y:
  print(">")
elif x < y:
  print("<")
Problem p03575 (python)

Fixed submission:

cnt = 0
def dfs(g , start,N):
    global cnt
    visited = [False for i in range(N)]
    stack =[]
    stack.append(start)

    while stack:
        v = stack.pop()
        visited[v] = True

        for i in range(N):
            if g[v][i] == 1 and visited[i] ==False:
                stack.append(i)

    for i in range(N):
        if visited[i] == False:
            cnt += 1
            break


N,M = map(int,input().split())
g = [ [0 for i in range(N)] for j in range(N)]
a,b = [0] * M,[0] * M

for i in range(M):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

for i in range(M):

    g[a[i]][b[i]] -= 1
    g[b[i]][a[i]] -= 1

    dfs(g,0,N)

    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
def dfs(g , start,N):
    global cnt
    visited = [False for i in range(N)]
    stack =[]
    stack.append(start)

    while stack:
        v = stack.pop()
        visited[v] = True


        for i in range(N):
            if g[v][i] == 1 and visited[i] ==False:
                stack.append(i)

    for i in range(N):
        if visited[i] == False:
            cnt += 1
            break


N,M = map(int,input().split())
g = [ [0 for i in range(N)] for j in range(N)]
a,b = [0] * N,[0] * N

for i in range(M):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

for i in range(M):

    g[a[i]][b[i]] -= 1
    g[b[i]][a[i]] -= 1

    dfs(g,0,N)

    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

print(cnt)
Problem p03612 (python)

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

ans = 0
for i in range(1,N+1):
    if i == p[i-1]:
        ans += 1

k = 0
for i in range(1,N):
    i += k
    if i >= N:
        break
    if i == p[i-1] and i+1 == p[i]:
        ans -= 1
        k += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int,input().split()))

ans = 0
for i in range(1,N+1):
    if i == p[i-1]:
        ans += 1

k = 0
for i in range(1,N):
    i += k
    if i == p[i-1] and i+1 == p[i]:
        ans -= 1
        k += 1
print(ans)
Problem p03626 (python)

Fixed submission:
N = int(input())
S1 = input()
S2 = input()

i = 1
if S1[0] == S2[0]:
    ans = 3
    state = 0
else:
    i+= 1
    ans = 6
    state = 1
mod  = 10**9 + 7
while N > i:
    if S1[i] != S2[i] and state == 0:
        ans *= 2
        i+=2
        state = 1
    elif S1[i] != S2[i] and state == 1:
        ans *= 3
        i+=2
    elif S1[i] == S2[i] and state == 0:
        ans *= 2
        i+= 1
    elif S1[i] == S2[i] and state == 1:
        ans *= 1
        i+=1
        state = 0

    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S1 = input()
S2 = input()

i = 1
if S1[0] == S2[0]:
    ans = 3
    state = 0
else:
    i+= 1
    ans = 6
    state = 1
mod  = 10**9 + 7
while N > i:
    if S1[i] != S2[i] and state == 0:
        ans *= 2
        i+=2
        state = 1
    elif S1[i] != S2[i] and state == 1:
        ans *= 3
        i+=2
    elif S1[i] == S2[i] and state == 0:
        ans *= 2
        i+= 1
    elif S1[i] == S2[i] and state == 1:
        ans *= 1
        i+=1
        state = 0

    ans %= mod
print(ans)
~
Problem p03633 (python)

Fixed submission:
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a


def lcm(a,b):
    return (a*b) // gcd(a,b)


N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

t = T[0]
for i in range(N - 1):
    t = lcm(t,T[i+1])
print(t)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def lcm(a,b):
    return (a*b)/int(gcd(a,b))

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

ans = T[0]
for i in range(1,N):
    ans = int(lcm(ans,T[i]))
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
def lcm(a,b):
    return (a*b)/int(ath.gcd(a,b))

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

ans = T[0]
for i in range(1,N):
    ans = int(lcm(ans,T[i]))
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
def lcm(a,b):
    return (a*b)/math.gcd(a,b)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

ans = T[0]
for i in range(1,N):
    ans = lcm(int(ans),int(T[i]))
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
def lcm(a,b):
    return a*b/math.gcd(a,b)

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

ans = T[0]
for i in range(1,N):
    ans = lcm(ans,T[i])
print(int(ans))
Problem p03648 (python)

Fixed submission:
from datetime import date
from math import factorial
import functools
from heapq import*
from collections import deque
import collections
import math
from collections import defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
inf = float("inf")


def main():
    k = int(input())
    if k == 0:
        print(3)
        print("2 2 2")
        exit()
    elif k == 1:
        print(3)
        print("1 0 3")
        exit()
    a = min(k, 50)
    b = k % a
    ans = [i + k//a for i in range(a)]
    for i in range(b):
        ans.sort()
        for j in range(1, a):
            ans[j] -= 1
        ans[0] += a

    print(a)
    print(*ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    k = int(input())
    a = min(k, 50)
    b = k % a
    ans = [i + k//a for i in range(a)]
    for i in range(b):
        ans.sort()
        for j in range(1, a):
            ans[j] -= 1
        ans[0] += a

    print(a)
    print(*ans)


if __name__ == '__main__':
    main()
Problem p03695 (python)

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

baclet = [False] * 9
baclet[8] = 0

for val in a:
    if val < 400:
        baclet[0] = True
    elif val >= 400 and val < 800: 
        baclet[1] = True
    elif val >= 800 and val < 1200: 
        baclet[2] = True
    elif val >= 1200 and val < 1600: 
        baclet[3] = True
    elif val >= 1600 and val < 2000: 
        baclet[4] = True
    elif val >= 2000 and val < 2400: 
        baclet[5] = True
    elif val >= 2400 and val < 2800: 
        baclet[6] = True
    elif val >= 2800 and val < 3200: 
        baclet[7] = True
    elif val >= 3200: 
        baclet[8] += 1

if baclet[:-1].count(True) > 0:
    print(baclet[:-1].count(True),end=" ")
elif baclet[8] > 0:
    print(1,end=" ")

print(baclet[:-1].count(True) + baclet[8])

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))

baclet = [False] * 9
baclet[8] = 0

for val in a:
    if val < 400:
        baclet[0] = True
    elif val >= 400 and val < 800: 
        baclet[1] = True
    elif val >= 800 and val < 1200: 
        baclet[2] = True
    elif val >= 1200 and val < 1600: 
        baclet[3] = True
    elif val >= 1600 and val < 2000: 
        baclet[4] = True
    elif val >= 2000 and val < 2400: 
        baclet[5] = True
    elif val >= 2400 and val < 2800: 
        baclet[6] = True
    elif val >= 2800 and val < 3200: 
        baclet[7] = True
    elif val >= 3200: 
        baclet[8] += 1

if baclet[:-1].count(True) > 0:
    print(baclet[:-1].count(True),end=" ")
elif backet[8] > 0:
    print(1,end=" ")

if baclet[8] >= 8:
    print(8)
elif 8 - baclet[:-1].count(True) <= baclet[8]:
    print(8)
else:
    print(baclet[:-1].count(True) + baclet[8])
Problem p03722 (python)

Fixed submission:
def BellmanFord(edges,num_v,source):
  dist=[float("inf") for i in range(num_v)]
  dist[source]=0
  
  for i in range(num_v):
    for edge in edges:
      if edge[0] != float("inf") and dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        if i==num_v-1 and edge[1] == N - 1:
            return -1
  
  return dist

N,M = map(int,input().split())
edges = []
for i in range(M):
    a,b,c = map(int,input().split())
    edges.append([a-1,b-1,-c])

d  = BellmanFord(edges,N,0)
if d==-1:
    print("inf")
    exit()

print(-d[N-1])

Buggy submission (verdict: Runtime Error):
def BellmanFord(edges,num_v,source):
  dist=[float("inf") for i in range(num_v)]
  dist[source]=0
  
  for i in range(num_v):
    for edge in edges:
      if edge[0] != float("inf") and dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        if i==num_v-1: return -1
  
  return dist

N,M = map(int,input().split())
edges = []
edges2 = []
for i in range(M):
    a,b,c = map(int,input().split())
    edges.append([a-1,b-1,-c])
    edges2.append([a-1,b-1,c])

d  = BellmanFord(edges,N,0)
d2  = BellmanFord(edges2,N,0)
if d==-1:
    print("inf")
    exit()

for i in range(N):
    if d[i] == float("inf"):
        print("inf")
        exit()

print(max(-d[N-1],d2[N-1]))
Problem p03997 (python)

Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
h=int(input())
print((a+b)＊h/2)
Problem p04013 (python)

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

dp = [ [ [ 0 for j in range(N+1)] for i in range(2501) ] for k in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for j in range(2501):
        for k in range(N):
            if j - x[i] >=0:
                dp[i+1][j][k+1] = dp[i][j-x[i]][k]
            dp[i+1][j][k] += dp[i][j][k]

ans = 0
for k in range(1,N+1):
    ans += dp[N][A*k][k]
print(ans)

Buggy submission (verdict: Runtime Error):
N,A = map(int,input().split())
x = list(map(int,input().split()))
xsum =sum(x)

dp = [ [ [ 0 for j in range(N+1)] for i in range(xsum+1) ] for k in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for j in range(xsum+1):
        for k in range(N):
            if j - x[i] >=0:
                dp[i+1][j][k+1] = dp[i][j-x[i]][k]
            dp[i+1][j][k] += dp[i][j][k]

ans = 0
for k in range(1,N+1):
    ans += dp[N][A*k][k]
print(ans)
Problem p04032 (python)

Fixed submission:
s = input()
l = []
t = s[0]
m = 1
for i in range(1,len(s)):
    if s[i] == t:
        m += 1
    else:
        t = s[i]
        l.append(m)
        m = 1
l.append(m)

if len(l) == 1:
    print(1,l[0])
    exit()
if l[0] > 1:
    print(1,l[0]+l[1])
    exit()

for i in range(len(s)-2):
    if s[i] == s[i+2] and s[i] != s[i+1]:
        print(i+1,i+3)
        exit()
if max(l) == 1:
    print(-1,-1)
    exit()

ruiseki = [l[0]]
for i in range(1,len(l)):
    ruiseki.append(ruiseki[i-1] + l[i])

for i in range(len(ruiseki)-1):
    if ruiseki[i+1] - ruiseki[i] > 1:
        print(ruiseki[i],ruiseki[i+1])
        exit()

Buggy submission (verdict: Runtime Error):
s = input()
l = []
t = s[0]
m = 1
for i in range(1,len(s)):
    if s[i] == t:
        m += 1
    else:
        t = s[i]
        l.append(m)
        m = 1
l.append(m)

if max(l) == 1:
    print(-1,-1)
    exit()
if len(l) == 1:
    print(1,l[0])
if l[0] > 1:
    print(1,l[0]+l[1])
    exit()

ruiseki = [l[0]]
for i in range(1,len(l)):
    ruiseki.append(ruiseki[i-1] + l[i])

for i in range(len(ruiseki)-1):
    if ruiseki[i+1] - ruiseki[i] > 1 and i != len(ruiseki) - 2:
        print(ruiseki[i],ruiseki[i+1])
        exit()
    if ruiseki[i+1] - ruiseki[i] > 1 and i == len(ruiseki) - 2:
        print(ruiseki[i],ruiseki[i+1])
        exit()
Problem p02717 (python)

Fixed submission:
X, Y, Z = map(int, input().split())
print(Z, X, Y)

Buggy submission (verdict: Runtime Error):
X, Y, Z = map(int, input().split())
print(f"{Z} {X} {Y}")

Buggy submission (verdict: Runtime Error):
X, Y, Z = map(int, input().split())
print(f"{Z} {X} {Y}")
Problem p02853 (python)

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

prize_list = [300000, 200000, 100000]

ans = 0
if X <= 3:
    ans += prize_list[X-1]
if Y <= 3:
    ans += prize_list[Y-1]
if X == 1 and Y == 1:
    ans += 400000
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

prize_list = [100000, 200000, 300000]

ans = prize_list[3-X] + prize_list[3-Y]
if X == 1 and Y == 1:
    ans += 400000
print(ans)
Problem p02981 (python)

Fixed submission:
N, A, B = map(int, input().split())
if N*A > B:
    print(B)
else:
    print(N*A)

Buggy submission (verdict: Runtime Error):
import itertools
L, R = map(int, input().split())

if R - L + 1 > 2019:
    remainder_list = [N%2019 for N in range(L, L+2019)]
else:
    remainder_list = [N%2019 for N in range(L, R+1)]  
remainder_list = list(set(remainder_list))
all_list = [(i*j)%2019 for i, j in list(itertools.combinations(remainder_list, 2))]
print(min(all_list))