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

Fixed submission:
import math

n = int(input())
small = [1]
large = [n]
for i in range(2,int(n**0.5)+1):
    if not (n%i):
        small.append(i)
        large.append(n//i)
print(int(math.log10(large[-1]))+1)

Buggy submission (verdict: Runtime Error):
import bisect
n = int(input())
ls = list(range(n+1))

ans = 10**9
for a in range(1,n):
    b = bisect.bisect_left(ls, n/a)
    ans = min(ans,int(max(len(str(a)),len(str(ls[b])))))
print(ans)
Problem p02729 (python)

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

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N, M = map(int, input().split())
goukei = comb(N, 2, exact=True) + comb(M, 2, exact=True)
print(goukei)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N, M = map(int, input().split())
goukei = comb(N, 2, exact=True) + comb(M, 2, exact=True)
print(goukei)
Problem p02557 (python)

Fixed submission:
from collections import Counter
import numpy as np


def main():
    n = int(input())
    a = np.array([int(i) for i in input().split()])
    b = np.array([int(i) for i in input().split()])
    ca = Counter(a)
    cb = Counter(b)
    for k in cb.keys():
        if cb[k] > n - ca[k]:
            print("No")
            return
    while any(a == b):
        s = max(ca[k] for k in cb.keys())
        b = np.roll(b, s)
    print("Yes")
    print(*b)


if __name__ == '__main__':
    main()

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


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    ca = Counter(a)
    cb = Counter(b)
    for k in cb.keys():
        if cb[k] > n - ca[k]:
            raise Exception
    print("No")


if __name__ == '__main__':
    main()

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


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    ca = Counter(a)
    cb = Counter(b)
    for k in cb.keys():
        if cb[k] > n - ca[k]:
            print("No")
            return
    raise Exception


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

Fixed submission:
import sys


def read():
    return sys.stdin.readline().rstrip()


def main():
    h, w, m = map(int, read().split())
    target = set()
    row = [0] * h
    col = [0] * w
    for _ in range(m):
        hi, wi = [int(i) - 1 for i in input().split()]
        target.add((hi, wi))
        row[hi] += 1
        col[wi] += 1
    row_max = max(row)
    r = [i for i in range(h) if row[i] == row_max]
    col_max = max(col)
    c = [i for i in range(w) if col[i] == col_max]
    for ri in r:
        for ci in c:
            if (ri, ci) not in target:
                print(row_max + col_max)
                return
    print(row_max + col_max - 1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys


def read():
    return sys.stdin.readline().rstrip()


def main():
    h, w, m = map(int, read().split())
    bitboard = 0
    for _ in range(m):
        hi, wi = map(int, read().split())
        bitboard += 1 << (w * (hi - 1) + (wi - 1))
    ans = 0
    for hi in range(h):
        for wi in range(w):
            b = bitboard & (((2**w - 1) << hi * w) | (sum(1 << (w * i) for i in range(h)) << wi))
            ans = max(bin(b).count("1"), ans)
    print(ans)


if __name__ == '__main__':
    main()

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


def read():
    return sys.stdin.readline().rstrip()


def main():
    h, w, m = map(int, read().split())
    target = [(0, 0) for _ in range(m)]
    row = np.zeros(h, dtype=int)
    col = np.zeros(w, dtype=int)
    for i in range(m):
        hi, wi = [int(i) - 1 for i in input().split()]
        target[i] = (hi, wi)
        row[hi] += 1
        col[wi] += 1
    r = row.max()
    ri = [i for i in range(h) if row[i] == r]
    c = 0
    for rii in ri:
        ci = col.copy()
        for y, x in target:
            if y == rii:
                ci[x] -= 1
        c = max(ci.max(), c)
    ans = r + c
    c = col.max()
    ci = [i for i in range(w) if col[i] == c]
    r = 0
    for cii in ci:
        ri = row.copy()
        for y, x in target:
            if x == cii:
                ri[y] -= 1
        r = max(ri.max(), r)
    ans = max(r + c, ans)
    print(ans)


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

Fixed submission:
n = int(input())
ans = 0
for i in range(1, n + 1):
  for j in range(i, n + 1, i):
    ans += j
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in arnge(1, n + 1):
  for j in range(1, n + 1, i):
    ans += j
print(ans)
Problem p02862 (python)

Fixed submission:
from functools import reduce

def modpow(a, m):
    ret = 1
    while m > 0:
        if m & 1:
            ret = ret * a % mod
        a = a * a % mod
        m = m >> 1
    return ret

def modinv(a):
    return modpow(a, mod - 2)

def cmb(n, r):
    r = min(r, n - r)
    if r == 0:
        return 1
    over = reduce(lambda a, b: a * b % mod, range(n, n - r, -1))
    under = reduce(lambda a, b: a * b % mod, range(1, r + 1))
    return over * modinv(under) % mod

x, y = [int(i) for i in input().split()]
if (x + y) % 3 or x > 2 * y or y > 2 * x:
    print(0)
else:
    mod = 10**9 + 7
    print(cmb((x + y) // 3, (2 * x - y) // 3))

Buggy submission (verdict: Runtime Error):
from functools import reduce

def modpow(a, m):
    ret = 1
    while m > 0:
        if m & 1:
            ret = ret * a % mod
        a = a * a % mod
        m = m >> 1
    return ret

def modinv(a):
    return modpow(a, mod - 2)

def cmb(n, r):
    r = min(r, n - r)
    if r == 0:
        return 1
    over = reduce(lambda a, b: a * b % mod, range(n, n - r, -1))
    under = reduce(lambda a, b: a * b % mod, range(1, r + 1))
    return over * modinv(under) % mod

x, y = [int(i) for i in input().split()]
if (x + y) % 3:
    print(0)
else:
    mod = 10**9 + 7
    print(cmb((x + y) // 3, (2 * x - y) // 3))

Buggy submission (verdict: Runtime Error):
# from operator import mul
from functools import reduce


def com_init():
    for i in range(2, n):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod


def com():
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


def modpow(a, m):
    ret = 1
    while m > 0:
        if m & 1:
            ret = ret * a % mod
        a = a * a % mod
        m = m >> 1
    return ret


def modinv(a):
    return modpow(a, mod - 2)


def cmb(n, r):
    r = min(r, n - r)
    if r == 0:
        return 1
    over = reduce(lambda a, b: a * b % mod, range(n, n - r, -1))
    under = reduce(lambda a, b: a * b % mod, range(1, r + 1))
    return over * modinv(under) % mod


x, y = [int(i) for i in input().split()]
if (x + y) % 3:
    print(0)
else:
    # n = (x + y) // 3
    # r = min((2 * x - y) // 3, (2 * y - x) // 3)
    mod = 10**9 + 7
    # fac, finv, inv = [1] * (n + 1), [1] * (n + 1), [1] * (n + 1)
    # com_init()
    # print(com())
    # print(factorial(n) // factorial(r) // factorial(n - r))
    print(cmb((x + y) // 3, (2 * x - y) // 3))
Problem p02912 (python)

Fixed submission:
import heapq
n, m = map(int, input().split())
a = [-int(i) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    mx = -heapq.heappop(a)
    heapq.heappush(a, -(mx // 2))
print(-sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in range(m):
    a[-1] //= 2
    if a[-1] < a[-2]:
        a.sort()
print(sum(a))
Problem p03012 (python)

Fixed submission:
n = int(input())
w = [int(i) for i in input().split()]
s = sum(w)
for t in range(1, n):
  s = min(s, abs(sum(w[:t]) - sum(w[t:])))
print(s)

Buggy submission (verdict: Runtime Error):
4
1 3 1 1
Problem p03013 (python)

Fixed submission:
import sys
def input():
  return sys.stdin.readline().rstrip()
mod = 10**9 + 7
n, m = [int(i) for i in input().split()]
a = [int(input()) for _ in range(m)]
notin = [1] * n
for i in a:
  notin[i] = 0
dp = [0] * n
dp[n - 1] = 1
if n > 1:
	dp[n - 2] = 1 + notin[n - 1]
for i in range(n - 3, -1, -1):
  dp[i] += dp[i + 1] * notin[i + 1] % mod
  dp[i] += dp[i + 2] * notin[i + 2] % mod
  dp[i] %= mod
print(dp[0])

Buggy submission (verdict: Runtime Error):
import sys


def read():
    return sys.stdin.readline().rstrip()


def main():
    n, m = map(int, read().split())
    a = {int(read()) - 1 for _ in range(m)}
    mod = 10**9 + 7
    dp = [0] * n
    if 0 not in a:
        dp[0] = 1
    if 1 not in a:
        dp[1] = 1 + dp[0]
    for i in range(2, n):
        if i in a:
            continue
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
    print(dp[-1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
import sys
def input() -> str:
    return sys.stdin.readline().rstrip()
mod = 10**9 + 7
@lru_cache(maxsize=None)
def dp(i):
    if i == n - 1:
        return 1
    if i == n - 2:
        return 2 - int(n - 1 in a)
    return dp(i + 1) * int(i + 1 not in a) % mod + dp(i + 2) * int(i + 2 not in a) % mod
n, m = [int(i) for i in input().split()]
a = [int(input()) for _ in range(m)]
print(dp(0))
Problem p03104 (python)

Fixed submission:
from math import log2

def main():
    a, b = map(int, input().split())
    if a == b:
        print(a)
        return
    if b == 0:
        print(0)
        return
    d = b - a + 1
    x = (d // 2 + (d % 2) * (a % 2)) % 2
    for i in range(1, int(log2(b)) + 1):
        k = 0
        p = 2**i
        q = 2 * p
        pa, qa = a % p, a % q
        pb, qb = b % p, b % q
        if a % q >= p:
            k += q - qa
        if b % q >= p:
            k += qb - p + 1
        x += (k % 2) * p
    print(x)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from math import log2

def main():
    a, b = map(int, input().split())
    x = (b - a + 1) // 2 % 2
    for i in range(1, int(log2(b)) + 1):
        k = 0
        p = 2**i
        q = 2 * p
        pa, qa = a % p, a % q
        pb, qb = b % p, b % q
        if a % q >= p:
            k += q - qa
        if b % q >= p:
            k += qb - p + 1
        x += (k % 2) * p
    print(x)

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

Fixed submission:
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
#import numpy

s =input()
l = len(s)
if s[l-1] == 's':
    print(s + 'es')
else:
    print(s + 's')

Buggy submission (verdict: Runtime Error):
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
#import numpy
#import sympy
import math
def divisors(n):
    num = 0
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            num += 1
            if n != i**2:
                num += 1
    
    return num
n = N()
cnt = 0
for i in range(1,n):
    ab = n-i
    cnt += divisors(ab)
print(cnt)
Problem p02624 (python)

Fixed submission:
def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        #print(range(i,n+1,i),sum(range(i,n+1,i)))
        ans += sum(range(i,n+1,i))

    print(ans)
main()

Buggy submission (verdict: Runtime Error):
import numpy as np
def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        #print(np.arange(i,n+1,i),np.arange(i,n,i).sum())
        ans += np.arange(i,n+1,i).sum()

    print(ans)
main()

Buggy submission (verdict: Runtime Error):
def main():
    import sympy
    n = int(input())
    s = 0
    
    for i in range(1,n+1):
        s += i * len(sympy.divisors(i))
    print(s)

main()

Buggy submission (verdict: Runtime Error):
def main():
    import sympy
    n = int(input())
    s = 0
    
    for i in range(1,n+1):
        s += i * len(sympy.divisors(i))
    print(s)

main()
Problem p02594 (python)

Fixed submission:
x=int(input())
if x >=30:
  print("Yes")
else:
  print('No')

Buggy submission (verdict: Runtime Error):
x=int(input)
if x >=30:
  print("Yes")
else:
  print('No')
Problem p02622 (python)

Fixed submission:
s=input()
t=input()

sum = 0

for i in range (len(t)):
  if s[i] != t[i] :
    sum = sum + 1 
print(sum)

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

sum = 0

for i in range (len(t)):
  if s(i) != t(i):
    sum = sum + 1 
print(sum)
Problem p02659 (python)

Fixed submission:
import math
from decimal import Decimal
a,b=map(Decimal,input().split())

print(math.floor(a*b))

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

int(a*b)
Problem p02682 (python)

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

if k<=a:
  print(k)
elif a<k and k<=a+b:
  print(a)
else:
  print(2*a+b-k)

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

if k<=a:
  print(a)
elif a<k and k<=a+b:
  print(a)
else:
  print(2a+b-k)
Problem p02693 (python)

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

i=0

while True:
  if (a+i)%k==0:
    print('OK')
    break
  
  if  a+i==b:
    print('NG')
    break
  
  i+=1

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

if b-a>=k-1:
  print('OK')
else:
  print('NG')
Problem p02771 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a==b and a!=c:
  print("Yes")
elif b==c and b!=a:
  print("Yes")
elif c==a and c!=b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int(input().split()))
if a==b and a!=c:
  print("Yes")
elif b==c and b!=a:
  print("Yes")
elif c==a and c!=b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=int(input().split())
if a==b and a!=c:
  print("Yes")
elif b==c and b!=a:
  print("Yes")
elif c==a and c!=b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=int(input())
if a==b and a!=c:
  print("Yes")
elif b==c and b!=a:
  print("Yes")
elif c==a and c!=b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A,B,C=int(input())
if A==B and A!=C:
  print("Yes")
elif B==C and B!=A:
  print("Yes")
elif C==A and C!=B:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A,B,C=int(input())
if A=B and A!=C:
  print("Yes")
elif B=C and B!=A:
  print("Yes")
elif C=A and C!=B:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A,B,C=int(input())
if A==B,A!=C: 
   print("Yes")
  elif B==C,B!=A:
      print("Yes")
  elif C==A,C!=B:
    print("Yes")
  else:
    print("No")
Problem p02951 (python)

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

if c > a-b:
  print(b+c-a)
else:
  print(0)

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

if c > a-b:
  print(b+c-q)
else:
  print(0)
Problem p03075 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

v=e-a

if v <=k:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a=int(inout())
b=int(inout())
c=int(inout())
d=int(inout())
e=int(inout())
k=int(inout())

v=b-a
w=c-b
x=d-c
y=e-d

z=max(max(v,w),max(x,y))

if z >k:
  print(':')
else:
  print('Yay!')

Buggy submission (verdict: Runtime Error):
a=int(inout())
b=int(inout())
c=int(inout())
d=int(inout())
e=int(inout())
k=int(inout())

v=b-a
w=c-b
x=d-c
y=e-d

z=max(max(v,w),max(x,y))

if z >k:
  print(':')
else:
  print('Yay!)
Problem p02570 (python)

Fixed submission:
d,t,s = map(int, input().split())
if d <= t*s:
  print('Yes')
else:
  print('No')

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

par = [i-1 for i in range(1, n+1)]

def find (x):
  if par[x] == x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]

def same(x,y):
  return find(x) == find(y)

def unite(x,y):
  x = find(x)
  y = find(y)
  if x == y:
    return 0
  par[x] = y

for i in range(m):
  a,b = map(int, input().split())
  unite(a-1, b-1)

ans = max(par)
print(ans)
Problem p02773 (python)

Fixed submission:
n = int(input())

d = {}

for i in range(n):
  a = input()
  if a not in d:
    d[a] = 1
  else:
    d[a] += 1

dsorted = sorted(d.items(), key=lambda x:x[1], reverse=True)

name = []
cnt = dsorted[0][1]

for i in dsorted:
  if i[1] == cnt:
    name.append(i[0])
  else:
    break

name.sort()

for i in name:
  print(i)

Buggy submission (verdict: Runtime Error):

n = int(input())

d = {}

for i in range(n):
  a = input()
  if a not in d:
    d[a] = 1
  else:
    d[a] += 1

dsorted = sorted(d, key=lambda x:x[1])

cnt = 0
for i in dsorted:
  print(i)
  cnt += 1
  if cnt == 2:
    break
Problem p02819 (python)

Fixed submission:
x = int(input())

def isprime(s):
  if s>2 and s%2==0:
    return False
  else:
    flg = True
    for i in range(3, s//2+1, 2):
      if s%i == 0:
        flg = False
        break
    return flg

for i in range(x, 10**6):
  if isprime(i) == True:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
pip install sympy
from sympy import isprime

x = int(input())
if x % 2 == 0:
  x += 1

flag = True

while flag == True:
  if isprime(x) == True:
    flag = False

print(x)

Buggy submission (verdict: Runtime Error):
from sympy import isprime

x = int(input())
if x % 2 == 0:
  x += 1

flag = True

while flag == True:
  if isprime(x) == True:
    flag = False

print(x)
Problem p02970 (python)

Fixed submission:
import math

n,d = map(int, input().split())
print(math.ceil(n / (2*d + 1)))

Buggy submission (verdict: Runtime Error):
n,d = map(int, input().split())
print(n // (2d + 1) + 1)
Problem p02990 (python)

Fixed submission:
import math
 
n,k = map(int, input().split())
 
def main(i):
  blue = math.factorial(k-1) // (math.factorial(i-1) * math.factorial(k-i))
  red = math.factorial(n-k+1) // (math.factorial(n-k+1-i) * math.factorial(i))
  print((blue*red) % (10**9 + 7))
 
for i in range(1, k+1):
  if i > n-k+1:
    print('0')
  else:
   main(i)

Buggy submission (verdict: Runtime Error):
import math

n,k = map(int, input().split())

def main(i):
  blue = int(math.factorial(k-1) / (math.factorial(i-1) * math.factorial(k-i)))
  red = int(math.factorial(n-k+1) / (math.factorial(n-k+1-i) * math.factorial(i)))
  print((blue*red) % (10**9 + 7))

for i in range(1, k+1):
  if i > n-k+1:
    print('0')
  else:
   main(i)

Buggy submission (verdict: Runtime Error):
import math

n,k = map(int, input().split())

def main(i):
  blue = int(math.factorial(k-1) / (math.factorial(i-1) * math.factorial(k-i)))
  red = int(math.factorial(n-k+1) / (math.factorial(n-k+1-i) * math.factorial(i)))
  print((blue*red) % (10**9 + 7))

for i in range(1, k+1)):
  if i > min(k+1, n-k+2):
    print('0')
  else:
   main(i)

Buggy submission (verdict: Runtime Error):
import math

n,k = map(int, input().split())

def main(i):
  blue = int(math.factorial(k-1) / (math.factorial(i-1) * math.factorial(k-i)))
  red = int(math.factorial(n-k+1) / (math.factorial(n-k+1-i) * math.factorial(i)))
  print((blue*red) % (10**9 + 7))

for i in range(1, min(k+1, n-k+2)):
  main(i)

Buggy submission (verdict: Runtime Error):
import math

n,k = map(int, input().split())

def main(i):
  blue = int(math.factorial(k-1) / (math.factorial(i-1) * math.factorial(k-i)))
  red = int(math.factorial(n-k+1) / (math.factorial(n-k+1-i) * math.factorial(i)))
  print((blue*red) % (10**9 + 7))

for i in range(1, min(k, n-k+2)):
  main(i)

Buggy submission (verdict: Runtime Error):
import math

n,k = map(int, input().split())

def main(i):
  blue = int(math.factorial(k-1) / (math.factorial(i-1) * math.factorial(k-i)))
  red = int(math.factorial(n-k+1) / (math.factorial(n-k+1-i) * math.factorial(i)))
  print((blue*red) % (10**9 + 7))

for i in range(1, k+1):
  main(i)
Problem p03011 (python)

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

print(sum(h)-max(h))

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

def nCr(n, r):
  num = 1
  for i in range(r+1, n+1):
    num *= i
  return num


P = 1
for i in range(m):
  if a[i] + 1 == a[i+1]:
    print(0)
    exit()

for i in range(1, m+2):
  step = a[i] - a[i-1] - 1
  pattern = 1
  for j in range(1, int(step/2+1)):
    pattern += nCr(step-j, j)
  P *= pattern 

print(P%1000000007)
Problem p03038 (python)

Fixed submission:
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1])
bc.reverse()

flg = 0
cnt = 0

for i in range(n):
  if bc[flg][1] >a[i] and flg < m:
    a[i] = bc[flg][1]
    cnt +=1
    if cnt == bc[flg][0]:
      flg += 1
      cnt = 0
      if flg == m:
        break
  else:
      break

print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1])
bc.reverse()

flg = 0
cnt = 0

for i in range(n):
  if bc[flg][1] >a[i] and flg < m:
    a[i] = bc[flg][1]
    cnt +=1
    if cnt == bc[flg][0]:
      flg += 1
      cnt = 0
  else:
      break

print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1])

t = True
cnt = 0

while t == True and cnt < len(bc):
  cnt += 1
  num = bc[cnt-1][0]
  large = bc[cnt-1][1]
  if large > min(a):
    for i in a:
      if i < large and a.index(i)+1 <= num:
        a[a.index(i)] = large
        print(a)
      else:
        break
    a.sort()
  else:
     t = False

print(sum(a))
Problem p03072 (python)

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

c = 0

for i in range(n):
  t = True
  for j in range(i):
    if h[j] > h[i]:
      t = False
      break
  if t == True:
    c += 1
  t = True
print(c)

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

c = 0

for i in h:
  t = True
  for j in range(i):
    if h[j] >= h[i]:
      t = False
      break
   c += 1
Problem p03073 (python)

Fixed submission:
s = list(map(int,input()))

n = int(len(s)/2)

a = [0]*len(s)
b = [0]*len(s)

for i in range(n):
  a[2*i] = 0
  a[2*i+1] = 1
  b[2*i] = 1
  b[2*i+1] = 0

if len(s)%2 ==1:
  a[len(s)-1] = 0
  b[len(s)-1] = 1 


an = 0
bn = 0

for j in range(len(s)):
  if a[j] != s[j]:
    an += 1
  if b[j] != s[j]:
    bn += 1

print(min(an, bn))

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

n = int(len(s)/2)
c = 0

if s[1] == s[0]:
  c +=1
  if s[0] == 0:
    s[1] = 1
  elif s[0] == 1:
    s[1] = 0

for i in range(n):
  if s[0] != s[2*i]:
    c += 1
  if s[1] != s[2*i+1]:
    c += 1

print(c)
Problem p03307 (python)

Fixed submission:

N = int(input())

if(N % 2 == 0):
    print(N)
else:
    print(2 * N)

Buggy submission (verdict: Runtime Error):

N = input()

i = N + 1
while True:
    if(i % 2 == 0 and i % N == 0):
        break
    i = i + 1

print(i)
Problem p02689 (python)

Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
ans = [1]*n
for i in range(m):
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        ans[ab[i][0]-1] = 0
        ans[ab[i][1]-1] = 0
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        ans[ab[i][1]-1] = 0
    else:
        ans[ab[i][0]-1] = 0
print(sum(ans))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
ans = [1]*n
for i in range(m):
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        ans[ab[i][0]-1] = 0
        ans[ab[i][1]-1] = 0
    elif h[ab[i][0]-1] > h[ab[i][1]]:
        ans[ab[i][1]-1] = 0
    else:
        ans[ab[i][0]-1] = 0
print(sum(ans))