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

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

if(S[0] == "1"):
    s = []
else:
    s = [0]
cnt = 1
tmp = S[0]
for i in range(1, len(S)):
    if(tmp == S[i]):
        cnt += 1
    else:
        s.append(cnt)
        tmp = S[i]
        cnt = 1
s.append(cnt)
tmp1 = 0
if(len(s)//2 <= K):
    ans = sum(s)        
else:
    ans = sum(s[:(2*K+1)])
    tmp = ans
    cnt = 0
    for i in range(2*K+1, len(s)-1, 2):
        if(ans < tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]):
            ans = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        else:
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        cnt += 2
    ss = s[::-1]
    if(S[-1] == "0"):
        tmp1 = sum(ss[:(2*K)])
    else:
        tmp1 = sum(ss[:(2*K+1)])
print(max(ans, tmp1))

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

if(S[0] == "1"):
    s = []
else:
    s = [0]
cnt = 1
tmp = S[0]
for i in range(1, len(S)):
    if(tmp == S[i]):
        cnt += 1
    else:
        s.append(cnt)
        tmp = S[i]
        cnt = 1
s.append(cnt)
if(len(s)//2 <= K):
    ans = sum(s)        
else:
    ans = sum(s[:(2*K+1)])
    tmp = ans
    cnt = 0
    for i in range(2*K+1, len(s)-1, 2):
        if(ans < tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]):
            ans = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        else:
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        cnt += 2
    ss = s[::-1]
    if(S[-1] == "0"):
        tmp1 = sum(ss[:(2*K)])
    else:
        tmp1 = sum(ss[:(2*K+1)])
print(max(ans, tmp1))
Problem p03161 (python)

Fixed submission:
def main():

    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    DP = [0]*N
    DP[1] = abs(h[1]-h[0])

    for i in range(2, N):
        DP[i] = min(abs(h[i]-h[j]) + DP[j] for j in range(max(0, i-K), i))
    print(DP[-1])
    
main()

Buggy submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    DP = [10**10 for _ in range(N)]
    DP[0] = 0
    DP[1] = abs(h[0]-h[1])
    
    for i in range(2, N):
        DP[i] = min([DP[k]+abs(h[i]-h[k]) for k in range(max(0, i-k), i)])    
    print(DP[N-1])
main()
Problem p03164 (python)

Fixed submission:
import numpy as np

N, W = map(int, input().split())
knap = []
for i in range(N):
    knap.append(tuple(map(int, input().split())))

s_val = sum([v for w, v in knap])
    
INF = float("inf")
dp = np.full(s_val+1, INF)
dp[0] = 0

for i, (w, v) in enumerate(knap):
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
    
print(max([i for i in range(s_val+1) if dp[i] <= W]))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, W = map(int, input().split())
knap = []
for i in range(N):
    knap.append(tuple(map(int, input().split())))

s_val = sum([v for w, v in knap])
    
INF = float("inf")
dp = np.full(s_val+1, INF)

for i, (w, v) in enumerate(knap):
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
    
print(max([i for i in range(s_val+1) if dp[i] <= W]))
Problem p03219 (python)

Fixed submission:
x,y = map(int,input().split())

print(x+y//2)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
print(x + y/c)

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

print(x+y//c)

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

print(x+y//c)
Problem p03220 (python)

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

h = list(map(int, (input().split())))
min = abs(a - (t - h[0]*0.006))
ans = 1

for i in range(1, n):
    if (min > abs(a - (t - h[i]*0.006))):
        min = abs(a - (t - h[i]*0.006))
        ans = i+1

print(ans)

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

h = list(map(int, (input().split())))
min = abs(a - (t - h[i]*0.006))

for i in range(1, n):
    if(min > abs(a - (t - h[i]*0.006))):
        min = a - (t - h[i]*0.006)
        ans = i+1

print(ans)
Problem p03231 (python)

Fixed submission:
import fractions
N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return (x*y)//(fractions.gcd(x, y))

L = lcm(N, M)
num = lcm(L//N, L//M)

n = (N-1)*(L//N)+1
m = (M-1)*(L//M)+1

if(max(n, m) < num):
    if(S[0] == T[0]):
        print(L)
    else:
        print(-1)
else:
    if(N > M):
        tmp = M//(L//N)
    else:
        tmp = N//(L//M)
    for i in range(tmp):
        if(S[i*L//M] != T[i*L//N]):
            print(-1)
            break
    else:
        print(L)

Buggy submission (verdict: Runtime Error):
import fractions
N, M = map(int, input().split())
S = input()
T = input()

def lcm(x, y):
    return (x*y)//(fractions.gcd(x, y))

len_x = lcm(N, M)
n = [""]*(len_x)    
m = [""]*(len_x)

for i in range(len(S)):
    n[(len_x//N)*i] = S[i]
    
for i in range(len(T)):    
    m[(len_x//M)*i] = T[i]
for i in range(len_x):
    if(n[i] == "" or m[i] == ""):
        continue     
    if(n[i] != m[i]):
        print(-1)
else:
    print(len_x)
Problem p03289 (python)

Fixed submission:
s = input()

if(s[0] == "A" and s.count("A") == 1):
    if(s[2:len(s)-1].count("C") == 1 and s.count("C") == 1):
        s = s.replace("C", "")
        s = s.replace("A", "")
        if(s.islower()):
            print("AC")
        else:
            print("WA")
    else: 
        print("WA")
else:
    print("WA")

Buggy submission (verdict: Runtime Error):
s = input()
flg = True
if(s[0] != "A"):
    flg = False
if(s[2:-1].count("C")!=1):
    flg = False
for i in range(1, len(s)):
    if(s[i] == "C" and i !=len(s)-1):
        continue
    if(s[i].isupper()):
        flg = False

print("AC" if Flg else "WA")
Problem p03330 (python)

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

D = []
for i in range(C):
    D.append(list(map(int, input().split())))

cc = [[0]*C for i in range(3)]
for i in range(N):
    color = list(map(int, input().split()))
    for j in range(len(color)):
        cc[(i+j)%3][color[j]-1] += 1
    
iwakan = [[[0, 0] for _ in range(C)] for _ in range(3)]

for i in range(3):
    for j in range(C):
        tmp = 0
        for k in range(len(cc[i])):
            tmp += cc[i][k]*D[k][j]
        iwakan[i][j][0] = tmp
        iwakan[i][j][1] = j

ans = 10**15
for i in range(len(iwakan)):
    iwakan[i] = sorted(iwakan[i], key=lambda x:x[0])
    
for i in range(3):
    for j in range(3):
        if(iwakan[0][i][1] == iwakan[1][j][1]):
            continue
        for k in range(3):
            if(iwakan[0][i][1] == iwakan[2][k][1]):
                continue
            if(iwakan[1][j][1] == iwakan[2][k][1]):
                continue
            ans = min(ans, iwakan[0][i][0]+iwakan[1][j][0]+iwakan[2][k][0])
            
print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    N, Ma, Mb = map(int, input().split())
    yakuhin = []
    sa = 0
    sb = 0
    for i in range(N):
        yakuhin.append(list(map(int, input().split())))
        sa += yakuhin[i][0]
        sb += yakuhin[i][1]
    
    INF = 10**15
    DP = [[[INF for _ in range(sb+1)] for _ in range(sa+1)] for _ in range(N+1)]
    
    for i in range(N):
        DP[i][0][0] = 0
    
    for i in range(N):
        for j in range(sa+1):
            for k in range(sb+1):
                if(j >= yakuhin[i][0] and k >= yakuhin[i][1]):
                    DP[i+1][j][k] = min(DP[i][j][k], DP[i][j-yakuhin[i][0]][k-yakuhin[i][1]]+yakuhin[i][2])
                else:
                    DP[i+1][j][k] = min(DP[i+1][j][k], DP[i][j][k])
        
    ans = INF
    for i in range(1, N):
        for j in range(1, sa+1):
            for k in range(1, sb+1):
                if(j*Mb == k*Ma):
                    ans = min(ans, DP[i][j][k])    
        
    print(ans if ans != INF else -1)
    
main()
Problem p03380 (python)

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

tmp = a[0]//2
s = 10**18
num = 0
for i in range(1, n):
    if(abs(tmp-a[i]) < s):
        s = abs(tmp-a[i])
        num = a[i]

print(a[0], num)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

tmp = 0
num = 0
for i in range(1, n):
    if(a[i] >= a[0]//2):
        aa = a[0]-a[i]
        if(aa >= tmp):
            tmp = aa
            num = a[i]
            
    else:
        if(a[i] >= tmp):
            tmp = aa
            num = a[i]

print(a[0], num)
Problem p03436 (python)

Fixed submission:
from collections import deque 

def main():
    H, W = map(int, input().split())
    s = []
    num = 0
    for i in range(H):
        s.append(list(input()))
        num += s[i].count("#")
    ans = -1    
    cnt = [[0 for _ in range(W)] for _ in range(H)]
    queue = deque()
    queue.append((0, 0))
    while queue:
        x, y = queue.popleft()
        if(s[x][y] == "#"):
            continue
        if(x == H-1 and y == W-1):
            ans = cnt[x][y]
        s[x][y] = "#"
        
        d = [(-1, 0), (1, 0), (0, 1), (0, -1)]
        for dx, dy in d:
            nx = x + dx
            ny = y + dy
            if(nx < 0 or nx >= H or ny < 0 or ny >= W):
                continue
            queue.append((nx, ny))
            if(s[nx][ny] != "#"):
                cnt[nx][ny] = cnt[x][y]+1
    if(ans == -1):
        print(-1)
    else:
        print(H*W-ans-num-1)
    
main()

Buggy submission (verdict: Runtime Error):
from collections import deque 

def main():
    H, W = map(int, input().split())
    s = []
    num = 0
    for i in range(H):
        s.append(list(input()))
        num += s[i].count("#")
        
    cnt = [[0 for _ in range(W)] for _ in range(H)]
    queue = deque()
    queue.append((0, 0))
    while queue:
        x, y = queue.popleft()
        if(s[x][y] == "#"):
            continue
        if(x == H-1 and y == W-1):
            ans = cnt[x][y]
        s[x][y] = "#"
        
        d = [(-1, 0), (1, 0), (0, 1), (0, -1)]
        for dx, dy in d:
            nx = x + dx
            ny = y + dy
            if(nx < 0 or nx >= H or ny < 0 or ny >= W):
                continue
            queue.append((nx, ny))
            if(s[nx][ny] != "#"):
                cnt[nx][ny] = cnt[x][y]+1
    
    print(H*W-ans-num-1)
    
main()
Problem p03503 (python)

Fixed submission:
N = int(input())
F= [list(map(int, input().split())) for _ in range(N)]
P= [list(map(int, input().split())) for _ in range(N)]

ans = -10000000000
for mask in range(1, 2**10):
    tmp = 0
    for j in range(N):
        cnt = 0
        for k in range(10):
            if((mask>>k)%2 == 1 and F[j][k] == 1):
                cnt += 1
        tmp += P[j][cnt]
    ans = max(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
F= [list(map(int, input().split())) for _ in range(N)]
P= [list(map(int, input().split())) for _ in range(N)]

tmp = 0
ans = 0
for i in range(1, 2**10+1):
    tmp = 0
    for j in range(N):
        cnt = 0
        for k in range(10):
            if((i>> k)%2 == 1 and F[j][k] == 1):
                cnt += 1
        tmp += P[j][cnt+1]
    ans = max(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
F= [list(map(int, input().split())) for _ in range(N)]
P= [list(map(int, input().split())) for _ in range(N)]

num = 0
store = []
second = []
pos = []
ans = 0
min_z = 10**7+1
n = 0
for i in range(N):
    num = F[i].count(1)
    if(max(P[i][:(num+1)]) != P[i][0]):
        ans += max(P[i][:(num+1)])
    else:
        store.append(P[i][0])
        second.append(max(P[i][1:(num+1)]))
        pos.append(i)
if ans:
    for j in pos:
        ans += store[j]
    print(ans)
else:
    for k in range(len(pos)):
        if(store[k]-second[k] < min_z):
            min_z = store[k]-second[k]
            n = k
    ans += second[n]
    for k in range(len(store)):
        if(k == n):
            continue
        ans += store[k]
    print(ans)
Problem p03544 (python)

Fixed submission:
n = int(input())
cnt = 0

def lucas(n, ans1, ans2):
    if(n >= 2):
        for _ in range(n-1):
            ans = ans1 + ans2
            ans1 = ans2
            ans2 = ans
        return ans
            
    elif(n == 0):
        return 2
    elif(n == 1):
        return 1

print(lucas(n, 2, 1))

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

def lucas(n, ans1, ans2):
    for _ in range(n-1):
        ans = ans1 + ans2
        ans1 = ans2
        ans2 = ans
    return ans

print(lucas(n, 2, 1))
Problem p03565 (python)

Fixed submission:
S = input()
T = input()
Flg = False

ans1 = "z"*len(S)
pos = ""
num = 0
for i in range(len(S)-len(T)+1):
    sl = ""
    sl = S[i:(i+len(T))]
    for j in range(len(T)):
        pos = ""
        if(sl[j] != "?" and sl[j] != T[j]):
            break
    else:
        pos += S[:i]+T+S[(i+len(T)):]
        if(ans1 > pos):
            ans1 = pos
            Flg = True
                
if(Flg == True):
    ans1 = ans1.replace("?", "a") 
    print(ans1)
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
S = input()[::-1]
T = input()[::-1]
Flg = False

ans1 = "z"*len(S)
pos = ""
num = 0
for i in range(len(S)-len(T)+1):
    sl = ""
    sl = S[i:(i+len(T))]
    for j in range(len(T)):
        pos = ""
        if(sl[j] == T[j]):
            if(sl.count("?") >= len(T)-1):
                pos += S[:i]+T+S[(i+len(T)):]
                Flg = True
                if(pos < ans1):
                    ans1 = pos
if(Flg == True):
    ans1 = ans1.replace("?", "a")   
    print(ans)
else:
    print("UNRESTORABLE")
Problem p03591 (python)

Fixed submission:
s=input()
if('YAKI' == s[0:4]):
    print('Yes')
else:
    print('No')

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

for i in range(N+1):
    for j in range(M+1):
        if(i*(M-j)+(N-i)*j == K):
            print("Yes")
            quit()
else:
    print("No")
Problem p03592 (python)

Fixed submission:
N, M, K = map(int, input().split())
Flg = "No"

for i in range(N+1):
    for j in range(M+1):
        if(i*(M-j)+(N-i)*j == K):
            Flg = "Yes"
            break
print(Flg)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
print("Yes" if (N+M)%K == 0 else "No")
Problem p03624 (python)

Fixed submission:
from string import * 
s = input()
a = ascii_lowercase

for i in a:
    if i not in s:
        print(i)
        break
    if i == "z":
        print("None")
        break

Buggy submission (verdict: Runtime Error):
s = input()
a = ascii_lowercase

for i in a:
    if i not in s:
        print(i)
        break
    if i == "z":
        print("None")
        break

Buggy submission (verdict: Runtime Error):
s = input()
a = ascii_lowercase

for i in range(len(a)):
    if a[i] not in s:
        print(a[i])
        break
    elif(i == 25):
        print("None")
Problem p03633 (python)

Fixed submission:
import fractions

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm(x, y):
    return (x*y)//fractions.gcd(x, y)

ans = T[0]

for i in range(N):
    ans = lcm(ans, T[i])

print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd 

def lcd(x, y):
    return (x*y)/gcd(x, y)

N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())

num = lcd(T[0], T[1])    
    
for i in range(2, N):
    num = lcd(num, T[i])
print(int(num))

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

def gcd(x, y):
    if(y == 0):
        return x
    else:
        return gcd(y, x%y)

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

ans = int(input())  
for _ in range(N-1):
    T = int(input())
    ans = lcm(ans, T)
print(int(ans))

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

def gcd(x, y):
    if(y == 0):
        return x
    else:
        return gcd(y, x%y)

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

ans = 1    
for _ in range(N):
    T = int(input())
    ans = lcm(ans, T)
print(int(ans))

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

for i in range(N-1):
    T = int(input())
    if(max(T, num)%min(T, num) == 0):
        div_T = max(T, num)
    else:
        for j in range(2, 10**18+1):
            if(max(T, num)*j % min(T, num) == 0):
                div_T = max(T, num)*j
                break
print(div_T)
Problem p03651 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
max_A = max(A)
A.sort()

if(max_A < K):
    print("IMPOSSIBLE")
else:
    num = 10**10
    for i in range(N-1):
        if(min(num, abs(A[i]-A[i+1]))):
            num = min(num, abs(A[i]-A[i+1]))

    for i in range(N):
        if(A[i] < K):
            continue
        if((K-A[i])%num == 0):
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
max_A = max(A)
A.sort()

if(max_A < K):
    print("IMPOSSIBLE")
else:
    num = 10**10
    for i in range(N-1):
        num = min(num, abs(A[i]-A[i+1]))

    for i in range(N):
        if(A[i] < K):
            continue
        if((K-A[i])%num == 0):
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")
Problem p03721 (python)

Fixed submission:
N, K = map(int, input().split())
d = [0]*(10**5+1)
sum_d = 0

for _ in range(N):
    a, b = map(int, input().split())
    d[a] += b

for i in range(1, 10**5+1):
    sum_d += d[i]
    if(sum_d >= K):
        print(i)
        break

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
L = []
for i in range(N):
    a, b = map(int, input().split())
    L.append(a)
    L.append(b)
    
L = sorted(L)
print(L[K+1])
Problem p03752 (python)

Fixed submission:
import copy

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

ans = []
for i in range(2**N):
    s = a.copy()
    cnt = 0
    tmp = 1
    henkou = [False for _ in range(N)]
    for j in range(N):
        if((i >> j)&1):
            henkou[j] = True
    bill = s[0]
    for k in range(1, N):
        if(henkou[k]):
            if(bill >= s[k]):
                cnt += bill-s[k]+1
                s[k] = bill+1
                bill = s[k]
                tmp += 1
            else:
                bill = s[k]
                tmp += 1
        else:
            if(bill < s[k]):
                bill = s[k]
                tmp += 1
    if(tmp >= K):
        ans.append(cnt)
print(min(ans), end='\n')

Buggy submission (verdict: Runtime Error):
import copy

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

ans = []
for i in range(2**N):
    s = a.copy()
    cnt = 0
    tmp = 0
    henkou = [False for _ in range(N)]
    for j in range(N):
        if((i >> j)&1):
            henkou[j] = True
    bill = s[0]
    for k in range(1, N):
        if(henkou[k]):
            if(bill >= s[k]):
                cnt += bill-s[k]+1
                s[k] = bill+1
                bill = s[k]
        else:
            if(bill >= s[k]):
                tmp += 1
            else:
                bill = s[k]
    if(N-tmp >= K):
        ans.append(cnt)
print(min(ans))
Problem p03799 (python)

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

if(2*N <= M):
    m = M-2*N
    print(N+m//4)
else:
    print(M//2)

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

if(2*N <= M):
    m = M-2*N
    print(N+m//4)
else:
    print(m//2)
Problem p03816 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

a = Counter(A)
l_a = len(a)
if(l_a%2 == 0):
     print(l_a-1)
else:
    print(l_a)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

#a = Counter(A)
l_a = len(a)
if(l_a%2 == 0):
     print(l_a-1)
else:
    print(l_a)
Problem p03919 (python)

Fixed submission:
from string import *
h,w=map(int,input().split())

s = [input().split() for _ in range(h)]

for i in range(h):
    for j in range(w):
        if(s[i][j]=='snuke'):
            idx1=ascii_lowercase[j].swapcase()
            idx2=str(i+1)
            print(idx1+idx2)
            exit()

Buggy submission (verdict: Runtime Error):
from string import *
h,w=map(int,input().split())

s =[None] * h
for i in range(h):
    s[i] = [None] * w
    for j in range(w):
        s[i][j] = input()

for i in range(h):
    for j in range(w):
        if(s[i][j]=='snuke'):
            idx1=ascii_lowercase[i].swapcase()
            idx2=str(j+1)
            print(idx1+idx2)
            break
Problem p03944 (python)

Fixed submission:
w, h, n=map(int,input().split())

mat = [list(map(int, input().split())) for _ in range(n)]

w1 = 0
w2 = w
h1 = 0
h2 = h

for i in range(n):
    if(mat[i][2] == 1 and w1 < mat[i][0]):
        w1 = mat[i][0]
    elif(mat[i][2] == 2 and w2 > mat[i][0]):
        w2 = mat[i][0]
    elif(mat[i][2] == 3 and h1 < mat[i][1]):
        h1 = mat[i][1]
    elif(mat[i][2] == 4 and h2 > mat[i][1]):
        h2 = mat[i][1]
        
print((w2-w1)*(h2-h1) if w2 >= w1 and h2 >= h1 else 0)

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

mat = [list(map(int, input().split())) for _ in range(n)]

w1 = 0
w2 = w
h1 = 0
h2 = h

for i in range(n):
    if(mat[i][2] == 1 and w1 < mat[i][0]):
        w1 = mat[i][0]
    elif(mat[i][2] == 2 and w2 > mat[i][0]):
        w2 = mat[i][0]
    elif(mat[i][2] == 3 and w3 < mat[i][1]):
        h1 = mat[i][1]
    elif(mat[i][2] == 4 and w4 > mat[i][1]):
        h2 = mat[i][1]
        
print((w2-w1)*(h2-h1) if w2 >= w1 and h2 >= h1 else 0)
Problem p03962 (python)

Fixed submission:
a = input().split()
num = 3

if a[0] == a[1]:
    num = num - 1
    if a[0] == a[2]:
        num = num - 1
elif a[0] == a[2]:
    num = num - 1
elif a[1] == a[2]:
    num = num - 1
    
print(num)

Buggy submission (verdict: Runtime Error):
a = input().split()
num = 3

if a[0] == a[1]:
    num = num - 1
    if a[0] == a[2]:
        num = num - 1:
elif a[0] == a[2]:
    num = num - 1
elif a[1] == a[2]:
    num = num - 1
    
print(num)

Buggy submission (verdict: Runtime Error):
a = input().split()
num = 3

if a[0] == a[1]:
    num = num - 1
    if a[1] == a[2]:
        num = num - 1:
elif a[0] == a[2]:
    num = num - 1
elif a[1] == a[2]:
    num = num - 1
    
print(num)

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

num = 3

if a == b:
    num = num - 1
    if b == c:
        num = num - 1
elif b == c:
    num = num - 1
    
print('num')

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

num = 3

if a == b:
    num = num - 1
    if b == c:
        num = num - 1
elif b == c:
    num = num - 1
    
print(num)
Problem p03998 (python)

Fixed submission:
S = {i:list(input()) for i in "abc"}
s = "a"
while S[s]:
    s = S[s].pop(0)
print(s.upper())

Buggy submission (verdict: Runtime Error):
dict = {ch: list(input()) for ch in "abc"}
ch = "a"

While (dict[ch]):
    ch = dict[ch].pop(0)

print(ch.upper())
Problem p04026 (python)

Fixed submission:
from collections import Counter

s = input()

flg = False
lst = []

for i in range(len(s)-2):
    if(s[i] == s[i+1]):
        flg = True
        lst.append(i+1)
        lst.append(i+2)
        break
    elif(s[i] == s[i+2]):
        flg = True
        lst.append(i+1)
        lst.append(i+3)
        break

if not(lst):     
    if(s[len(s)-1] == s[len(s)-2]):
        lst.append(len(s)-1)
        lst.append(len(s))
        flg = True

if(flg):
    print(*lst)
else:
    print(-1, -1)

Buggy submission (verdict: Runtime Error):
from collections import Counter

s = input()

flg = False
lst = []
for i in range(len(s)-2):
    if(s[i] == s[i+1]):
        flg = True
        lst.append(i+1)
        lst.append(i+2)
        break
    elif(s[i] == s[i+2]):
        flg = True
        lst.append(list(i+1, i+3))
        break
if(flg):
    print(*lst)
else:
    print(-1, -1)