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

Fixed submission:
N,M=map(int,input().split())
PY=[list(map(int,input().split()))+[i] for i in range(M)] #定義終了

PY.sort(key= lambda x:x[1])
num=[0]*N
w=[""]*M

for p,y,i in PY:
	num[p-1]+=1
	w[i]=str(p).zfill(6)+str(num[p-1]).zfill(6)

for i in range(M):
  	print(w[i])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
PY=[list(map(int,input().split()))+[i] for i in range(M)] #定義終了

PY.sort(key= lambda x:x[1])
num=[0]*N
w=[""]*M

for p,y,i in PY:
	num[p-1]+=1
	w[i]=str(p).zfill(6)+str(num[p-1]).zfill(6)

for a in range(M):
	print(w)
Problem p03291 (python)

Fixed submission:
# def C(n, r ,mod=10**9+7):
#     if n-r<r: r=n-r
#     if r == 0: return 1
#     if r == 1: return n
# 
#     numerator = [n - r + k + 1 for k in range(r)]
#     denominator = [k + 1 for k in range(r)]
# 
#     for p in range(2,r+1):
#         pivot = denominator[p - 1]
#         if pivot > 1:
#             offset = (n - r) % p
#             for k in range(p-1,r,p):
#                 numerator[k - offset] /= pivot
#                 denominator[k] /= pivot
# 
#     result = 1
#     for k in range(r):
#         if numerator[k] > 1:
#             result *= int(numerator[k]) %mod
# 
#     return result % mod

A=list(input())
n=len(A)
mod=10**9+7
ans=0
numa= A[0]=="A" 
numa_= A[0]=="?"
numc=A[2:].count("C")
numc_= A[2:].count("?")

for i in range(1,n-1):
    #print(numa,numa_,numc,numc_)
    apro=cpro=0
    if A[i]=="B" or A[i]=="?":
        # for k in range(numa_+1):
        #     apro+= (((C(numa_,k)*pow(2,numa_-k,mod))%mod)*(numa+k))%mod
        # for k in range(numc_+1):
        #     cpro+= (((C(numc_,k)*pow(2,numc_-k,mod))%mod)*(numc+k))%mod
        #print(apro,cpro)
        apro= ((3*numa+numa_)*pow(3,(numa_-1),mod))%mod
        cpro= ((3*numc+numc_)*pow(3,(numc_-1),mod))%mod
        ans+= (apro*cpro)%mod
        ans%=mod
    if A[i] == "A":
        numa+=1
    if A[i]=="?":
        numa_+=1
    if A[i+1] =="C":
        numc-=1
    if A[i+1]=="?":
        numc_-=1
print(ans)

Buggy submission (verdict: Runtime Error):
# def C(n, r ,mod=10**9+7):
#     if n-r<r: r=n-r
#     if r == 0: return 1
#     if r == 1: return n
# 
#     numerator = [n - r + k + 1 for k in range(r)]
#     denominator = [k + 1 for k in range(r)]
# 
#     for p in range(2,r+1):
#         pivot = denominator[p - 1]
#         if pivot > 1:
#             offset = (n - r) % p
#             for k in range(p-1,r,p):
#                 numerator[k - offset] /= pivot
#                 denominator[k] /= pivot
# 
#     result = 1
#     for k in range(r):
#         if numerator[k] > 1:
#             result *= int(numerator[k]) %mod
# 
#     return result % mod

A=list(input())
n=len(A)
mod=10**9+7
ans=0
numa= A[0]=="A" 
numa_= A[0]=="?"
numc=A[2:].count("C")
numc_= A[2:].count("?")

for i in range(1,n-1):
    #print(numa,numa_,numc,numc_)
    apro=cpro=0
    if A[i]=="B" or A[i]=="?":
        # for k in range(numa_+1):
        #     apro+= (((C(numa_,k)*pow(2,numa_-k,mod))%mod)*(numa+k))%mod
        # for k in range(numc_+1):
        #     cpro+= (((C(numc_,k)*pow(2,numc_-k,mod))%mod)*(numc+k))%mod
        #print(apro,cpro)
        apro= (3*numa+numa_)*3**(numa_-1)
        cpro= (3*numc+numc_)*3**(numc_-1)
        ans+= (apro*cpro)%mod
        ans%=mod
    if A[i] == "A":
        numa+=1
    if A[i]=="?":
        numa_+=1
    if A[i+1] =="C":
        numc-=1
    if A[i+1]=="?":
        numc_-=1
print(ans)
Problem p03295 (python)

Fixed submission:
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
n,m=map(int,input().split())
query=[]
for i in range(m):
    a,b=map(int,input().split())
    query.append([a,b])
query.sort(key=lambda x:x[1])

tekyo=-1
kazu=0
for i in range(m):
    a,b=query[i][0],query[i][1]
    if tekyo<a: #キレてない
        tekyo=b-1
        kazu+=1
print(kazu)

Buggy submission (verdict: Runtime Error):
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
n,k=map(int,input().split())
A=list(map(int,input().split()))
#n,k=5,3
#A=[-30,-10,10,20,40]
ans=inf
for i in range(n-k+1):
    ans=min(ans, abs(A[i])+abs(A[i]-A[i+k-1]), abs(A[i+k-1])+abs(A[i+k-1]-A[i]) )
print(ans)
Problem p03307 (python)

Fixed submission:
n=int(input())
if n%2==0:
  print(n)
else:
  print(n*2)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
q=0
Z=[]
for b in range(max(A)-min(A)):
  q=0
  for j in range(n):
    q+=abs(A[j]-b-min[A]-j-1)
  Z.append(q)
print(min(Z))
Problem p03617 (python)

Fixed submission:
q,h,s,d=map(int,input().split())
n=int(input())
n*=4
j=4*(2*q<h)+2*(2*h<s)+(4*q<s)
if j%4==0:
  if 2*s<d:
    print(s*(n//4))
  else:
    print(d*(n//8)+s*((n%8)//4))
  
if j==2 or j==3:
  if 4*h<d:
    print(h*(n//2))
  else:
    print(d*(n//8)+h*((n%8)//2))

if j==5 or j==7:
  if q*8<d:
    print(q*n)
  else:
    print(d*(n//8)+q*(n%8))

Buggy submission (verdict: Runtime Error):
q,h,s,d=map(int,input().split())
n=int(input())
n*=4
if q*2<h:
    if h*2<s:
        if q*8<d:
            print(n*q);exit()
        else:
            print(q*(n%8)+d*(n//8));exit()
    elif 2*s<d:
      if q*4<s:
        print(n*q)
      else:
        print(s*(n//4));exit()
    else:
      if q*4<s:
        print(d*(n//8)+q*(n%8))
      else:
        print(d*(n//8)+s*((n%8)//4);exit()
else:
    if 2*h<s:
        if 2*s>d:
            print(d*(n//8)+h*((n%8)//2));exit()
        else:
            print(h*(n//2));exit()
    else:
        if 2*s<d:
            print(s*(n//4))
        else:
            print(d*(n//8)+s*((n%8)//4))
Problem p03986 (python)

Fixed submission:
s=input() ; n=len(s)
ss=n//2; tt=n//2
ans=0
for i in range(n):
    if s[i]=="S":
        ans=max(ans, ss-tt)
        ss-=1
    else:
        tt-=1
print(ans*2)

Buggy submission (verdict: Runtime Error):
s=input() ; n=len(s)
for i in range(10000):
    s=s.replace("ST","")
    if a==s:
      print(len(s));exit()
    a=s
print(len(s))
Problem p02549 (python)

Fixed submission:
mod = 998244353
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(k)]
for i in range(k):
    lr[i][1] += 1
dp = [0] * n
dp[0] = 1
for i in range(1, n):
    dp[i] += dp[i - 1]
    if i == 1:
        dp[1] = 0
    for l, r in lr:
        if i - l >= 0:
            dp[i] += dp[i - l]
        if i - r >= 0:
            dp[i] -= dp[i - r]
    dp[i] %= mod
print(dp[n - 1])

Buggy submission (verdict: Runtime Error):
mod = 998244353
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(k)]
dp = [0 for i in range(n + 1)]
dp[0] = 1
cum = [0, 1]
cur = [0 for i in range(k)]
for i in range(1, n + 1):
    cnt = 0
    for j in range(k):
        r = (i - (lr[j][1] - lr[j][0] + 1))
        l = r - (lr[j][1] - lr[j][0])
        print(l, r, cum)
        if l <= 0:
            continue
        cnt += cum[r] - cum[l - 1]
    dp[i] = dp[i - 1] + cnt
    cum.append(cnt + cum[-1])
print(dp[n])
Problem p02627 (python)

Fixed submission:
a = input()
print("A" if a.isupper() else "a")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=""
while n>0:n-=1;s+=chr(97+n%26);n//=26
print(s[::-1])
Problem p02754 (python)

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

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
print(a * (n // (a + b)) + min(a, n % (a + b))
Problem p02759 (python)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(int(N / 2))
else:
  print(int(N / 2 + 1))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
l = []
l2 = []
l3 = [0 for i in range(n)]
cnt = 0
if (m == 0 and n == 1) or (n == 1 and m == 1 and sc[0] == [1, 0]):
    print(0)
    exit()
for i in sc:
    if i[0] == 1 and i[1] == 0:
        print(-1)
        exit()
    elif i[0] in l and l2[l.index(i[0])] != i[1]:
        print(-1)
        exit()
    else:
        l.append(i[0])
        l2.append(i[1])
        l3[i[0] - 1] = i[1]
        cnt += 1
if l3[0] == 0:
    l3[0] = 1
print(*l3, sep="")
Problem p02766 (python)

Fixed submission:
from math import log
n, k = map(int, input().split())
print(int(log(n, k)) + 1)

Buggy submission (verdict: Runtime Error):
def conv(x, n):
    nchar = '0123456789ABCDEF'
    digit = 0
 
    result = ''
 
    while x > 0:
        result = nchar[x % n] + result
        x = x / n
 
    return result
n, k = map(int, input().split())
print(conv(n, k))
Problem p02777 (python)

Fixed submission:
input1 = input().split()
input2 = list(map(int,input().split()))
U = input()
S = input1[0]
T = input1[1]
A = input2[0]
B = input2[1]
if U == S:
  A -= 1
else:
  B -= 1
print(str(A) + " " + str(B))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * (n + 1)
ans = []
for i in range(n):
    l[i + 1] = l[i] + (p[i] + 1) / 2
for i in range(n - k + 1):
    ans.append(l[i + k] - l[i])
print(max(ans))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * n
ans = []
l[0] = (p[0] + 1) / 2
for i in range(1, n):
    l[i] = l[i - 1] + (p[i] + 1) / 2
for i in range(n - k):
    ans.append(l[i + k] - l[i])
print(max(ans))
Problem p02785 (python)

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
h.reverse()
if k >= n:
    print(0)
else:
    del h[:k]
    print(sum(h))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
for i in range(k):
    h.remove(max(h))
print(sum(h))
Problem p02790 (python)

Fixed submission:
input_numbers = list(map(int,input().split()))
a = input_numbers[0]
b = input_numbers[1]
A = a
B = b
x = 0
y = 0
while A > 0:
  x += 10 ** (A-1) * b
  A -= 1
while B > 0:
  y += 10 ** (B-1) * a
  B -= 1
if x > y:
  print(x)
else:
  print(y)

Buggy submission (verdict: Runtime Error):
input_numbers = list(map(int,input().split()))
a = input_numbers[0]
b = input_numbers[1]
A = a
B = b
x = 0
y = 0
while A >= 0:
  x += 10 ** A * b
  A -= 1
while B >= 0:
  y += 10 ** B * a
  B -= 1
if x > y:
  ptint(x)
else:
  print(y)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
from math import sqrt
n = int(input())
cnt = 0
for i in range(1, n):
    for i in range(2, int(sqrt(n)) + 1):
        if i % j == 0:
            continue
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
from math import sqrt
n = int(input())
cnt = 0
for i in range(1, n):
    for i in range(2, int(sqrt(n)) + 1):
        if i % j == 0:
            continue
    cnt += 1
print(cnt)
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb
n, k = map(int, input().split())
for i in range(1, k + 1):
    print(int(comb(n - k + 1, i, exact=True)) * comb(k - 1, i - 1, exact=True) % (pow(10, 9) + 7))

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb
n, k = map(int, input().split())
for i in range(1, k + 1):
    print(int(comb(n- k + 1, i) * comb(k - 1, i - 1) % (10 ** 9 + 7)))
Problem p02998 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
n = int(input())
edges = [[] for i in range(200000)]
for i in range(n):
    x, y = map(int, input().split())
    edges[x - 1].append(y + 99999)
    edges[y + 99999].append(x - 1)
ans = 0
visited = [0] * (200000)
cntx, cnty = 0, 0
def dfs(u):
    global cntx, cnty
    visited[u] = 1
    if u // 100000 >= 1:
        cnty += 1
    else:
        cntx += 1
    for i in edges[u]:
        if visited[i] == 0:
            dfs(i)
ans = -1 * n
for i in range(100000):
    if visited[i] == 0:
        cntx, cnty = 0, 0
        dfs(i)
        ans += cntx * cnty
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
edges = [[] for i in range(200000)]
for i in range(n):
    x, y = map(int, input().split())
    edges[x - 1].append(y + 99999)
    edges[y + 99999].append(x - 1)
ans = 0
visited = [0] * (200000)
cntx, cnty = 0, 0
def dfs(u):
    global cntx, cnty
    visited[u] = 1
    if u // 100000 >= 1:
        cnty += 1
    else:
        cntx += 1
    for i in edges[u]:
        if visited[i] == 0:
            dfs(i)
ans = -1 * n
for i in range(100000):
    if visited[i] == 0:
        cntx, cnty = 0, 0
        dfs(i)
        ans += cntx * cnty
print(ans)
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
bc = sorted([list(map(int, input().split())) for i in range(m)], key=lambda x:x[1], reverse=True)
ans = 0
x, y = 0, 0
for i in range(n):
    if y == m or a[x] > bc[y][1]:
        ans += a[x]
        x += 1
    else:
        ans += bc[y][1]
        bc[y][0] -= 1
        if bc[y][0] == 0:
            y += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
bc = sorted([list(map(int, input().split())) for i in range(m)], key=lambda x:x[1], reverse=True)
ans = 0
x, y = 0, 0
for i in range(n):
    if a[x] > bc[y][1] or y == m:
        ans += a[x]
        x += 1
    else:
        ans += bc[y][1]
        bc[y][0] -= 1
        if bc[y][0] == 0:
            y += 1
print(ans)
Problem p03332 (python)

Fixed submission:
mod = 998244353
n, a, b, k = map(int, input().split())
ans = 0
def comb(n, r):
    if n < r:return 0
    if n < 0 or r < 0:return 0
    return fa[n] * fi[r] % mod * fi[n - r] % mod
fa = [1] * (n + 1)
fi = [1] * (n + 1)
for i in range(1, n + 1):
    fa[i] = fa[i - 1] * i % mod
    fi[i] = pow(fa[i], mod - 2, mod)
for i in range(n + 1):
    x = k - a * i
    if x >= 0 and x % b == 0:
        j = x // b
        if j <= n:
            ans += comb(n, i) * comb(n, j)
            ans %= mod
print(ans % mod)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n,a,b,k=map(int,input().split())
A=0
m=998244353
for i in range(n+1):
 if (k-i*a)%b==0:A+=comb(n,i,exact=True)*comb(n,(k-i*a)//b,exact=True)%m
print(A%m)
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
d = [-1 for i in range(n)]
e = [[] for i in range(n)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    e[a - 1].append([b - 1, c])
    e[b - 1].append([a - 1, c])
q, k = map(int, input().split())
def dfs(cur, par, di):
    d[cur] = di
    for i in e[cur]:
        if d[i[0]] == -1:
            if i == par:
                continue
            dfs(i[0], cur, di + i[1])
dfs(k - 1, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    print(d[x - 1] + d[y - 1])

Buggy submission (verdict: Runtime Error):
n = int(input())
d = [-1 for i in range(n)]
e = [[] for i in range(n)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    e[a - 1].append([b - 1, c])
    e[b - 1].append([a - 1, c])
q, k = map(int, input().split())
def dfs(cur, par, di):
    d[cur] = di
    for i in e[cur]:
        if d[i[0]] == -1:
            if i == par:
                continue
            dfs(i[0], cur, di + i[1])
dfs(k - 1, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    print(d[x - 1] + d[y - 1])
Problem p03986 (python)

Fixed submission:
x=input()
s,a=0,0
for i in x:
 if i=="S":
  s+=1
 elif s==0:
  a+=1
 else:
  s-=1
print(a+s)

Buggy submission (verdict: Runtime Error):
x=input()
s,a=0,0
for i in x:
 if i=="S":
  s+=1
 elif s==0:
  ans+=1
 else:
  s-=1
print(ans+s)
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])


ans, j = 0, M
anss = []
for i in range(1+N):
    if a[i] > K:
        break
    while 1:
        if a[i] + b[j] <= K:
            break
        j -= 1
    
    ans = max(ans, i+j)
    
            
print(ans)

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


a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])


ans, j = 0, M
anss = []
for i in range(1, 1+N):
    if a[i] > K:
        break
    ans = 0
    for j in range(M, -1, -1):
        if a[i] + b[j] <= K:
            ans = j
            break
    ans += i
    anss.append(ans)
    
            
print(max(anss))
Problem p02629 (python)

Fixed submission:
N = int(input())
final = ""
chars = "abcdefghijklmnopqrstuvwxyz"
dic = {i: chars[i] for i in range(0, 26)}
pw_26 = [26**i for i in range(13)]
cum = 0
digit = 0
for i in range(13):
    cum += pw_26[i]
    if N < cum:
        digit = i
        break
start_from = cum - pw_26[digit]
temp = N - start_from
digits = []
counter = 0
while counter < digit:
    res = temp % 26
    temp //= 26
    digits.append(res)
    counter += 1

for j in range(len(digits)):
    char = dic[digits[j]]
    final = char + final
print(final)

Buggy submission (verdict: Runtime Error):
N = int(input())
final = ""
digits = []
temp = N

while temp > 0:
    res = temp%26
    temp //= 26
    digits.append(res)
    
chars = "abcdefghijklmnopqrstuvwxyz"
dic = {i: chars[i] for i in range(26)}
for j in range(len(digits)):
    char = dic[digits[j] - 1]
    final = char + final
print(final)
Problem p02753 (python)

Fixed submission:
s = input()

if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')

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

if s = 'AAA' or 'BBB':
    print('No')
else:
    print('Yes')
Problem p02831 (python)

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

from fractions import gcd

lcm = a * b // gcd(a, b)

print(lcm)

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

from math import gcd


lcm = a * b // gcd(a, b)

print(lcm)

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

from math import gcd

lcm = a * b // gcd(a, b)

print(lcm)

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

from math import gcd

lcm = a * b // gcd(a, b)

print(lcm)
Problem p02832 (python)

Fixed submission:
N = int(input())
a = [0] + list(map(int, input().split()))

if 1 not in a:
    ans = -1
    print(ans)
else:
    broken = []
    survived = []
    latest = 1
    for i in range(1,N+1):
        if a[i] != latest:
            broken.append(a[i])
        else:
            latest += 1
            survived.append(a[i])
    print(len(broken))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
idx = [0]
k = 0

if n == 1:
    if a[0] == 1:
        print(0)
    else:
        print(-1)
else:
    for i in range(1, n):
        if i not in a:
            break

        a = a[idx[i-1]: n]
        idx.append(a.index(i))

        k += 1

    if k == 0:
        print(-1)
    else:
        print(n - k)
Problem p02629 (python)

Fixed submission:
N,a=int(input()),''
while 0<N:N-=1;a+=chr(ord('a')+N%26);N//=26
print(a[::-1])

Buggy submission (verdict: Runtime Error):
N=int(input());N-=1
a=list('abcdefghijklmnopqrstuvwxyz')
n=[]
def nn(n,x):
    m=n;r=[]
    while 0<m:
        r.insert(0,m%x)
        m=m//x
    r[-1]+=1
    return r
for i in nn(N,26):
    n.append(a[i-1])
print(''.join(n))
Problem p02689 (python)

Fixed submission:
N,M=map(int,input().split())
H=list(map(int,input().split()))
l=[1]*N
for i in range(M):
    A,B=map(int,input().split())
    A-=1
    B-=1
    if H[A] <= H[B]:
        l[A] = 0
    if H[A] >= H[B]:
        l[B] = 0
print(l.count(1))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
H=list(map(int,input().split()))
l=[0]*N
nice=0
for i in range(M):
    A,B=map(int,input().split())
    A-=1
    B-=1
    if l[A] == 0:
        l[A] = B
        nice += 1
    elif H[l[A]] < H[B]:
        l[A] = B
    if l[B]==0:
        l[B] = 0.5
print(nice+l.count(0))
Problem p02729 (python)

Fixed submission:
N,M=map(int,input().split())
print(int(N*(N-1)/2+M*(M-1)/2))

Buggy submission (verdict: Runtime Error):
import math
N,M=map(int,input().split())
def kumiawase(n):
    a=math.factorial(n)
    r=math.factorial(2)
    return a / (r*math.factorial(n-2))
print(int(kumiawase(M)+kumiawase(N)))
Problem p02779 (python)

Fixed submission:
N,A=int(input()),list(map(int,input().split()))
A=sorted(A,key=int)
l=set([])
for i in A:
    if i in l:
        print("NO")
        exit()
    else:
        l.add(i)
print("YES")

Buggy submission (verdict: Runtime Error):
N,A=int(input()),list(map(int,input().split()))
A=sorted(A,key=int)
l=[0]*(A[-1]+1)
for i in A:
    if l[i]==1:
        print("NO")
        exit()
    else:
        l[i]=1
print("YES")
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()

b1,b2="",""

if N%2==1:
    print("No")
    exit()
else:
    for i in range(int(N/2)):
        b1=b1+S[i]
        b2=S[(len(S)-1)-i]+b2
if b1==b2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,S=int(input()),input()
a,b='',''
if N%2==0:
    for i in range(int(N/2)):
        a = a+S[i]
        b = S[len(S)-(i+1)]+b
    print('Yes' if a==b else: 'No')
else:
    print(No)

Buggy submission (verdict: Runtime Error):
N,S=int(input()),input()
a,b='',''
if N%2==0:
    for i in range(int(N/2)):
        a = a+S[i]
        b = S[len(S)-1]+b
    print('Yes' if a==b else: 'No')
else:
    print(No)
Problem p03075 (python)

Fixed submission:
l=[]
for i in range(5):l.append(int(input()))
k=int(input())
c=0
for i in l:
    for j in l:
        if abs(i-j)>k:c+=1
print('Yay!' if c==0 else ':(')

Buggy submission (verdict: Runtime Error):
for i in range(5):l.append(int(input()))
k=int(input())
c=0
for i in l:
    for j in l:
        if abs(i-j)>k:c+=1
print('Yay!' if c==0 else ':(')
Problem p02552 (python)

Fixed submission:
print(int(input())^1)

Buggy submission (verdict: Runtime Error):
print(int(input)^1)
Problem p02577 (python)

Fixed submission:
N = int(input())
print("Yes" if N % 9 == 0 else "No")

Buggy submission (verdict: Runtime Error):
N = Int(input())
print("Yes" if N % 9 == 0 else "No")
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
s = 0
for i, a in enumerate(A):
    if s + a > K:
        break
    s += a
else:
    i += 1
for j, b in enumerate(B):
    if s + b > K:
        break
    s += b
else:
    j += 1

ans = i + j
while i:
    i -= 1
    s -= A[i]
    while j < M and s + B[j] <= K:
        s += B[j]
        j += 1
    ans = max(ans, i + j)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
s = 0
for i, a in enumerate(A):
    if s + a > K:
        break
    s += a
else:
    i += 1
for j, b in enumerate(B):
    if s + b > K:
        break
    s += b
else:
    j += 1

ans = i + j
while i:
    i -= 1
    s -= A[i]
    while j < M and s + B[j] <= K:
        j += 1
        s += B[j]
    ans = max(ans, i + j)

print(ans)