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

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

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
if x>y:
  print(">")
elif x<y:
  print("<")
else:
  print("=")
Problem p03569 (python)

Fixed submission:
s = input()
l = 0
r = len(s)-1
c = 0
if s.count("x") == len(s):
  print(0)
  exit()
while l < r:
  c_l = 0
  c_r = 0
  while s[l] == "x":
    c_l += 1
    l += 1
  while s[r] == "x":
    c_r += 1
    r -= 1
  if s[l] != s[r]:
    print(-1)
    exit()
  c += abs(c_l-c_r)
  l += 1
  r -= 1
print(c)

Buggy submission (verdict: Runtime Error):
s = input()
l = 0
r = len(s)-1
c = 0
while l < r:
  c_l = 0
  c_r = 0
  while s[l] == "x":
    c_l += 1
    l += 1
  while s[r] == "x":
    c_r += 1
    r -= 1
  if s[l] != s[r]:
    print(-1)
    exit()
  c += abs(c_l-c_r)
  l += 1
  r -= 1
print(c)
Problem p04012 (python)

Fixed submission:
w = input()
for i in w:
  if w.count(i) % 2:
    print('No')
    exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
w = input()
for i in w:
  if w.coount(i) % 2:
    print('No')
    exit()
print('Yes')
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K = int(input())
 
 
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
           
 
                ans += gcd(i+1,j+1,k+1)
            #1-Kまで
print(ans)

Buggy submission (verdict: Runtime Error):
K = int(input())
import math
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += gcd(i+1,j+1,k+1)
            #1-Kまで
print(ans)
Problem p02909 (python)

Fixed submission:
from sys import stdin

a = stdin.readline().rstrip()
if a == "Sunny":
  print("Cloudy")
elif a== "Cloudy":
   print("Rainy")
else:
   print("Sunny")

Buggy submission (verdict: Runtime Error):
#キューを使っている。ところどころマイナスにしているのはキューの性質のため。実行時間が全然違うのはソートが早いから
n,m = map(int,input().split())
a = list(map(lambda x: -int(x) ,input().split()))
print(a)
import heapq
heapq.heapify(a)
for _ in range(m):
  tmp = -heapq.heappop(a)
  tmp //= 2
  heapq.heappush(a,-tmp)
print(-sum(a))

Buggy submission (verdict: Runtime Error):
l = stdin.readline().rstrip().split()
print(l)
Problem p02683 (python)

Fixed submission:
import numpy as np  # NumPyモジュールをインポートする
import itertools

val = input()
val = val.split(" ")
val = [int(i) for i in val]  # 全部intに変換

I = np.zeros((val[0], val[1]+1))

for i in range(val[0]):
    val2 = input()
    val2 = val2.split(" ")
    val2 = [int(i) for i in val2]  # 全部intに変換
    I[i] = val2

seq = [i for i in range(val[0])]  # 組み合わせを考える
# print(seq)

ans = []

for i in range(val[0]):
    Comb = list(itertools.combinations(seq, i+1))
    # print(Comb)
    for j in Comb:
        Com_list = list(j)
        # print(Com_list)
        I_sum = [[I[k][l+1] for k in Com_list] for l in range(val[1])]
        # print(I_sum)
        I_sum_over_x = [sum(m) for m in I_sum if sum(m) >= val[2]]
        # print('I_sum_over_x=', I_sum_over_x)
        if(len(I_sum_over_x) == val[1]):
            # print("xxx=", j)
            I_sum2 = [I[n][0] for n in list(j)]
            # print(I_sum2)
            # print(sum(I_sum2))
            ans.append(sum(I_sum2))

# print(ans)
if(len(ans) == 0):
    print('-1')
else:
    print(int(min(ans)))

Buggy submission (verdict: Runtime Error):
import numpy as np  # NumPyモジュールをインポートする
import itertools

val = input()
val = val.split(" ")
val = [int(i) for i in val]  # 全部intに変換

I = np.zeros((val[0], val[1]+1))

for i in range(val[0]):
    val2 = input()
    val2 = val2.split(" ")
    val2 = [int(i) for i in val2]  # 全部intに変換
    I[i] = val2

seq = [i for i in range(val[0])]  # 組み合わせを考える
print(seq)

for i in range(val[0]):
    Comb = list(itertools.combinations(seq, i+1))
    # print(Comb)
    for j in Comb:
        Com_list = list(j)
        # print(Com_list)
        I_sum = [[I[k][l+1] for k in Com_list] for l in range(val[1])]
        print(I_sum)
        ans = [sum(i) for m in I_sum]
        print('ans=', ans)
        # if (ans >= 10):
        #     print(I[Com_list])
Problem p02742 (python)

Fixed submission:
s=input().rstrip().split()
h=int(s[0])
w=int(s[1])
res =0
if h == 1 or w == 1:
  res = 1
elif h%2==0:
    res = (h/2) * w
else:
    if w%2==0:
        res = int(h/2) * w +  w/2  
    else:
        res = int(h/2) * w + int(w/2) + 1
print(int(res))

Buggy submission (verdict: Runtime Error):
H=int(s[0])
W=int(s[1])
res =0
if H%2==0:
    res = int(H/2) * W
else:
    if W%2==0:
        #res = (int(H/2) + 1)* int(W/2) + (int(H/2))* int(W/2)  
        res = int(H/2) * W +  int(W/2)  
    else:
        res = int(H/2) * W + int(W/2)+1
print(res)
Problem p02743 (python)

Fixed submission:
from decimal import Decimal
s = input().split()
a = Decimal(s[0])
b = Decimal(s[1])
c = Decimal(s[2])
if  4 * a * b < (c - a -b) **2 and c - a - b > 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
s = input().split()
a=s[0]
b=s[1]
c=s[2]
if  np.sqrt(a) + np.sqrt(b) < np.sqrt(c):
    print('Yes')
else:
    print('No')
Problem p02675 (python)

Fixed submission:
a = input()[-1]
if a == '3':
  print('bon')
elif a == '0' or a=='1' or a=='6' or a=='8':
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
a = input()[-1
if a == '3':
  print('bon')
elif a == '0' or a=='1' or a=='6' or a=='8':
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
a = input()[-1]
if a == 3:
  print('bon;)
elif a == 0 or a==1 or a==6 or a==8:
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
a = input()[0]
if a == 3:
  print('bon;)
elif a == 0 or a==1 or a==6 or a==8:
  print('pon')
else:
  print('hon')
Problem p02687 (python)

Fixed submission:
s = str(input())

if s == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
from sys import stdin

n, m = list(map(int, input().split()))
h_n = list(map(int, input().split()))
a_b_m = stdin.readlines()

res = 0
omit_s = []
for i in range(1, n+1):
    count_omit = 0
    for k in range(len(omit_s)):
        if omit_s[k] == i:
            count_omit = 1
            break
    if count_omit == 0:
        count = 0
        count_higher = 0
        for j in range(m):
            a, b = [int(x) for x in a_b_m[j].rstrip().split()]
            if a == i:
                count = 1
                if h_n[b-1] >= h_n[a-1]:
                    count_higher = 1
                elif h_n[a-1] > h_n[b-1]:
                    ommit_s.append(b-1)
                    break
            elif b == i:
                count = 1
                if h_n[a-1] >= h_n[b-1]:
                    count_higher = 1
                    break
        if count == 1 and count_higher == 0:
            res += 1
        elif count == 0:
            res += 1
print(res)
Problem p02755 (python)

Fixed submission:
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

min_eight_ex_tax = float(A / 0.08)
max_eight_ex_tax = float((A + 1) / 0.08)
min_ten_ex_tax = int(B / 0.1)
max_ten_ex_tax = int((B + 1) / 0.1)

res = float(-1)
for x in range(min_ten_ex_tax, max_ten_ex_tax, 1):
    if min_eight_ex_tax <= x < max_eight_ex_tax:
        res = float(x)
        break
#print(min_eight_ex_tax, max_eight_ex_tax, min_ten_ex_tax, max_ten_ex_tax)
print(int(res))

Buggy submission (verdict: Runtime Error):
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

min_eight_ex_tax = float(A / 0.08)
max_eight_ex_tax = float((A + 1) / 0.08)
min_ten_ex_tax = float(B / 0.1)
max_ten_ex_tax = float((B + 1) / 0.1)

res = float(-1)
for x in range(min_ten_ex_tax, max_ten_ex_tax, 1):
    if min_eight_ex_tax <= x < max_eight_ex_tax:
        res = float(x)
        break
#print(min_eight_ex_tax, max_eight_ex_tax, min_ten_ex_tax, max_ten_ex_tax)
print(int(res))
Problem p02812 (python)

Fixed submission:
from sys import stdin

lines = stdin.readlines()

n = int(lines[0].rstrip())
s = str(lines[1].rstrip())

counter = 0
for i in range(n-2):
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                counter += 1
print(counter)

Buggy submission (verdict: Runtime Error):
from sys import stdin

lines = stdin.readlines()

n = int(lines[0].rstrip())
s = str(lines[1].rstrip())

counter = 0
for i in range(n-2):
if s[i] == 'A':
    if s[i+1] == 'B':
        if [i+2] == 'C':
            counter += 1
print(counter)
Problem p02866 (python)

Fixed submission:
import collections
 
N=int(input())
D=list(map(int,input().split()))
 
c=collections.Counter(D)
 
max_D=max(D)
ans=1
previous_leaf=1
 
if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]
 
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
 
N=int(input())
D=list(map(int,input().split()))
 
c=collections.Counter(D)
 
max_D=max(D)
ans=1
previous_leaf=1
 
if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]
 
print(ans)
import collections

N=int(input())
D=list(map(int,input().split()))

c=collections.Counter(D)

max_D=max(D)
ans=1
previous_leaf=1

if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]

print(ans)
Problem p02882 (python)

Fixed submission:
a,b,x=map(int,input().split())
import math
rec=a*a*b/2
if x==a*a*b:
    print(0)
    exit()
if x<=rec:
    c=x*2/a/b

    print(math.degrees(math.atan(b/c)))
else:
    x=a*a*b-x
    c=x*2/a/a
    print(90-math.degrees(math.atan(a/c)))

Buggy submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
import math
rec=a*a*b/2
if x<=rec:
    c=x*2/a/b

    print(math.degrees(math.atan(b/c)))
else:
    x=a*a*b-x
    c=x*2/a/b
    print(90-math.degrees(math.atan(b/c)))
Problem p02995 (python)

Fixed submission:
def g(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
from decimal import Decimal
A,B,C,D=map(lambda x:Decimal(int(x)),input().split())



if A%C==0:
    x=B//C-A//C+1
else:
    x=B//C-A//C
if A%D==0:
    y=B//D-A//D+1
else:
    y=B//D-A//D
E=Decimal(C*D//g(C,D))
if A%E==0:
    z=B//E-A//E+1
else:
    z=B//E-A//E
print(B-A+1-(x+y-z))

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D=map(int,input().split())

if A%C==0:
    x=B//C-A//C+1
else:
    x=B//C-A//C
if A%D==0:
    y=B//D-A//D+1
else:
    y=B//D-A//D
E=C*D/math.gcd(C,D)
if A%E==0:
    z=B//E-A//E+1
else:
    z=B//E-A//E
print(round(B-A+1-(x+y-z)))
Problem p03037 (python)

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

s=[]
l= 0
r = n
for i in range(m):
    ln,rn=map(int,input().split())
    if ln>l:
        l=ln
    if rn<r:
        r=rn
if r-l+1>0:
    print(r-l+1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=[]
l= 0
r = n
for i in range(m):
    ln,rn=map(int,input().split())
    if ln>l:
        l=ln
    if rn<r:
        r=rn
print(rn-ln+1)
Problem p03471 (python)

Fixed submission:

N,Y=map(int,input().split())

for i in range(N+1):
    for j in range(N+1-i):
        if i*10000+j*5000+(N-i-j)*1000==Y:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):

N,Y=map(int,input().split())

for i in range(N+1):
    for j in range(N+1-j):
        if i*10000+j*5000+(N-i-j)*1000==Y:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1)
Problem p03565 (python)

Fixed submission:


S=input()
T=input()

def match(S,T):
    for i in range(len(T)):
        if S[i]==T[i] or S[i]=='?':
            continue
        else:
            return False
    return True

if len(T)>len(S):
    print('UNRESTORABLE')
    exit()

S=S[::-1]
T=T[::-1]   
p=len(S)-len(T)+1
for i in range(p):
    sub = S[i:i+len(T)]
    if match(sub,T):
        S1=S.replace(sub,T,1).replace('?','a')
        print(S1[::-1])
        exit()
print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
import sys
import os
f = open('/Users/murakiyusuke/coding/atcoder/input.txt','r')
sys.stdin = f

S=input()
T=input()

def match(S,T):
    for i in range(len(T)):
        if S[i]==T[i] or S[i]=='?':
            continue
        else:
            return False
    return True

if len(T)>len(S):
    print('UNRESTORABLE')
    exit()

S=S[::-1]
T=T[::-1]   
p=len(S)-len(T)+1
for i in range(p):
    sub = S[i:i+len(T)]
    if match(sub,T):
        S1=S.replace(sub,T,1).replace('?','a')
        print(S1[::-1])
        exit()
print('UNRESTORABLE')
Problem p03944 (python)

Fixed submission:
w,h,n= map(int,input().split())
s=[]
for i in range(n):
    s.append(list(map(int,input().split())))
l=0
d=0
for j in range(n):
    if s[j][2]==1 and s[j][0]>l:
        l=s[j][0]
    elif s[j][2]==2 and s[j][0]<w:
        w=s[j][0]
    elif s[j][2]==3 and s[j][1]>d:
        d=s[j][1]
    elif s[j][2]==4 and s[j][1]<h:
        h=s[j][1]

if h-d>0 and w-l>0:
    print((h-d)*(w-l))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
w,h,n= map(int,input().split())
s=[]
for i in range(n):
    s.append(list(int(input())))
l=0
d=0
for j in range(n):
    if s[j][2]==1 and s[j][0]>l:
        l=s[j][0]
    elif s[j][2]==2 and s[j][0]<w:
        w=s[j][0]
    elif s[j][2]==3 and s[j][1]>d:
        d=s[j][1]
    elif s[j][2]==4 and s[j][1]<h:
        h=s[j][1]

if h-d>0 and w-l>0:
    print((h-d)*(w-l))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
w,h,n= map(int,input().split())
s=[]
for i in range(n):
    s.append(int(input()))
l=0
d=0
for j in range(n):
    if s[j][2]==1 and s[j][0]>l:
        l=s[j][0]
    elif s[j][2]==2 and s[j][0]<w:
        w=s[j][0]
    elif s[j][2]==3 and s[j][1]>d:
        d=s[j][1]
    elif s[j][2]==4 and s[j][1]<h:
        h=s[j][1]

if h-d>0 and w-l>0:
    print((h-d)*(w-l))
else:
    print(0)
Problem p04013 (python)

Fixed submission:
from collections import defaultdict

N, A = map(int, input().split())
X = list(map(int, input().split()))
for i in range(N):
    X[i] -= A

dp = defaultdict(int)
dp[0] = 1

for x in X:
    
    for j, c in list(dp.items()):
        dp[j + x] += c

print(dp[0]-1)

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
X = list(map(int, input().split()))
for i in range(N):
    X[i] -= A

dp = defaultdict(int)
dp[0] = 1

for x in X:
    
    for j, c in list(dp.items()):
        dp[j + x] += c

print(dp[0]-1)
Problem p04030 (python)

Fixed submission:
s = input()
n= len(s)
a=[]

for i in range(n):
    if s[i]!='B':
        a.append(s[i])
    else:
        if a!=[]:
            del a[-1]
print(''.join(a))

Buggy submission (verdict: Runtime Error):
s = input()
n= len(s)
a=[]

for i in range(n):
    if s[i]!='B':
        a.append(s[i])
    else:
        del a[-1]
print(''.join(a))
Problem p02677 (python)

Fixed submission:
import math

A, B, H, M = map(int, input().split())

H_arg = H*30 + 0.5*M
M_arg = 6*M

if H_arg - M_arg>=180:
    H_M_arg = (360-H_arg) + M_arg
else:
    H_M_arg = abs(H_arg - M_arg)

# print(H_M_arg)

X = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(H_M_arg)))
print(X)

Buggy submission (verdict: Runtime Error):
import math

A B H M = map(int, input().split())

H_arg = H*30 + 0.5*M
M_arg = 6*M

if H_arg - M_arg>=180:
    H_M_arg = (360-H_arg) + M_arg
else:
    H_M_arg = abs(H_arg - M_arg)

X = math.sqrt(A**2+B**2-2*A*B*cos(H_M_arg))
print(X)
Problem p02813 (python)

Fixed submission:
import math
import itertools

N = int(input())
P = input()
Q = input()

p_list = [int(i) for i in P.split(" ")]
q_list = [int(i) for i in Q.split(" ")]

n = []
for i in range(N):
    n.append(i+1)

p_num = 1
q_num = 1
for i in itertools.permutations(n):
    if list(i)==p_list:
        a = p_num
    if list(i)==q_list:
        b = q_num
    p_num += 1
    q_num += 1

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import math
import itertools

N = int(input())
P = input()
Q = input()

p_list = [int(i) for i in P.split(" ")]
q_list = [int(i) for i in Q.split(" ")]

n = []
for i in range(N):
    n.append(i+1)

p_num = 1
q_num = 1
for i in itertools.permutations(n):
    if list(i)==p_list:
        a = p_num
    elif list(i)==q_list:
        b = q_num
    p_num += 1
    q_num += 1

print(abs(a-b))
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
if (a*b) % 2:
  print("Odd")
else:
  print("Even")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = a*b
 
 
if c % 2==0:
  print("even")
elif c % 2==1:
  print("odd")

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


if c % 2==0:
  print("even")
elif c % 2==1:
  print("odd")
Problem p02761 (python)

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

l = [list(x) for x in zip(*l)]

flag = True
num = [-1] * n
for i in range(m):
    if num[l[0][i]-1] == -1:
        num[l[0][i]-1] = l[1][i]
    elif num[l[0][i]-1] != l[1][i]:
        flag = False

if n != 1:
    if num[0] == 0:
        flag = False
    elif num[0] == -1:
        num[0] = 1

ans = ""
if flag:
    for i in range(n):
        ans += str(max(0, num[i]))

print(ans) if flag else print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]
l = [list(x) for x in zip(*l)]

flag = True
ans = [-1] * n
for i in range(m):
    if ans[l[0][i]-1] == -1:
        ans[l[0][i]-1] = l[1][i]
    elif ans[l[0][i]-1] != l[1][i]:
        flag = False

if n != 1:
    if ans[0] == 0:
        flag = False

if flag:
    ans[0] = max(0, ans[0])
    ans[1] = max(0, ans[1])
    ans[2] = max(0, ans[2])
    ans = str(ans[0]) + str(ans[1]) + str(ans[2])

print(ans) if flag else print(-1)
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
l = [int(i) for i in input().split()]

i = 0
for i in range(n):
    if x - l[i] < 0:
        break
    x -= l[i]
    i += 1

print(i+1)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = [int(i) for i in input().split()]

i = 0
while True:
    if x - l[i] < 0:
        break
    x -= l[i]
    i += 1

print(i+1)
Problem p03001 (python)

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

pattern = 0
if w/2 == x and h/2 == y:
    pattern = 1

print("{} {}".format(w*h/2, pattern))

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

pattern = 1
if w/2 == x and h/2 == y:
    pettern = 1
elif w/2 == x or h/2 == y:
    pettern = 0

print("{} {}".format(w*h/2, pettern))
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if (a*b)%2 == 1:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = map(int, raw_input().split())
if a % 2 and b % 2:
	print "Odd"
else:
	print "Even"
Problem p03698 (python)

Fixed submission:
import collections
s = input()
alph = "abcdefghijklmnopqrstuvwxyz"
col = dict(collections.Counter(s))

flag = True
for i in range(26):
    if col.get(alph[i], 0) > 1:
        print("no")
        flag = False
        break
if flag:
    print("yes")

Buggy submission (verdict: Runtime Error):
s = input()
print("yes" if len(s) = len(set(s))) else "not")
Problem p02946 (python)

Fixed submission:
k, x = [int(x) for x in input().split()]
rl = max(-1000000, x - k + 1)
rr = min(+1000000, x + k - 1)
print(*(range(rl, rr + 1)))

Buggy submission (verdict: Runtime Error):
k, x = [int(x) for x in input().split()]
rl = max(-1000000, x - k + 1)
rr = min(+1000000, x + k - 1)
print(" ".join(range(rl, rr + 1)))
Problem p02958 (python)

Fixed submission:
input()
p = [int(x) for x in input().split()]
q = sorted(p)
d = [(pi, qi) for pi, qi in zip(p, q) if pi != qi]
print("YES" if len(d) == 0 or len(d) == 2 and d[0][0] == d[1][1] and d[1][0] == d[0][1] else "NO")

Buggy submission (verdict: Runtime Error):
input()
p = [int(x) for x in input()]
q = sorted(p)
d = [(pi, qi) for pi, qi in zip(p, q) if pi != qi]
print("YES" if len(d) == 0 or len(d) == 2 and d[0][0] == d[1][1] and d[1][0] == d[0][1] else "NO")
Problem p03000 (python)

Fixed submission:
n, x = [int(x) for x in input().split()]
k = 0
ans = 1
for li in input().split():
    k += int(li)
    ans += k <= x

print(ans)

Buggy submission (verdict: Runtime Error):
n, x = [int(x) for x in input().split()]
k = 0
ans = 1
for li in input().split():
    k += li
    ans += k <= x

print(ans)
Problem p03030 (python)

Fixed submission:
#!/usr/bin/env python3
n = int(input())
res = [[i] + input().split() for i in range(n)]

res.sort(key=lambda x: (x[1], -int(x[2])))

for r in res:
    print(r[0] + 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n = int(input())
res = [(i, *input().split()) for i in range(n)]

res.sort(key=lambda x: (x[1], -int(x[2])))

for r in res:
    print(r[0] + 1)
Problem p03071 (python)

Fixed submission:
a, b = [int(x) for x in input().split()]
print(max(a + a - 1, a + b, b + b - 1))

Buggy submission (verdict: Runtime Error):
a, b = [int(x) for x in input()]
print(max(a + a - 1, a + b, b + b - 1))
Problem p03128 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
try:
    from typing import Dict, List
except ImportError:
    pass


def solve(N: int, M: int, A: "List[int]"):
    mn = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    A.sort(reverse=True)
    dp = [-1] * (N + 1)
    dp[0] = 0
    for i in range(1, N + 1):
        m = -1
        for Ai in A:
            if i - mn[Ai] >= 0 and dp[i - mn[Ai]] >= 0:
                m = max(m, dp[i - mn[Ai]] + 1)
        if m >= 0:
            dp[i] = m
    assert dp[N] >= 0
    k = N
    res = []  # type: List[int]
    while dp[k]:
        for Ai in A:
            if k - mn[Ai] >= 0 and dp[k - mn[Ai]] == dp[k] - 1:
                res.append(Ai)
                k -= mn[Ai]
                break

    print("".join(str(d) for d in res))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
try:
    from typing import Dict, List
except ImportError:
    pass


def solve(N: int, M: int, A: "List[int]"):
    mn = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    A.sort(reverse=True)
    dp = [-1] * (N + 1)
    dp[0] = 0
    for i in range(1, N + 1):
        m = -1
        for Ai in A:
            if i - mn[Ai] >= 0 and dp[i - mn[Ai]] >= 0:
                m = max(m, dp[i - mn[Ai]] + 1)
        if m >= 0:
            dp[i] = m
    assert dp[N] >= 0
    k = N
    res = []  # type: List[int]
    while dp[k]:
        for Ai in A:
            if dp[k - mn[Ai]] == dp[k] - 1:
                res.append(Ai)
                k -= mn[Ai]
                break

    print("".join(str(d) for d in res))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()