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

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

from bisect import bisect_right as bs
n,m,k = ip()
a = ip()
b = ip()
x = [0]*(n+1)
for i in range(n):
    x[i+1] = x[i]+a[i]
y = [0]*(m+1)
for i in range(m):
    y[i+1] = y[i]+b[i]
ans = 0
for i in range(n+1):
    if x[i] <= k:
        ans = max(ans,i+bs(y,k-x[i])-1)
    else:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
string s,t;
ll a[200500], b[200500], pa[200500], pbb[200500];

int main() {
	//freopen("input.txt","r",stdin);
 	//freopen("output.txt","w",stdout);
    int n,m,x,i;
	ll tests=1;
	while (tests--)
	{
		cin >> n >> m >> x;
		for (i = 0; i < n; i++)
		{
			cin >> a[i];
			pa[i+1] = pa[i] + a[i];
		}
		for (i = 0; i < m; i++)
		{
			cin >> b[i];
			pbb[i+1] = pbb[i] + b[i];
		}
		int ans = 0;
		for (i = 0; i <= n; i++)
		{
			if (pa[i] <= x)
			   ans = max(ans, i+(int)(upper_bound(pbb, pbb+m+1, x-pa[i])-pbb-1));
			else
				break;
		}
		cout << ans << endl;
	}
    return 0;
}
Problem p02659 (python)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

a,b = input().split()
a = int(a)
b = list(b.split("."))
b = ''.join(b)
b = int(b)
print(a*b//100)

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

a,b = ip()
print(int(a*b//1))

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
ele = 10**18
prod = 1
if 0 in x:
    print(0)
    exit()
for i in x:
    prod *= i
    if prod > ele:
        print(-1)
        exit()
print(prod)
Problem p02676 (python)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

k = inp()
s = input()
if len(s) <= k:
    print(s)
else:
    print(s[:k]+"...")

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

k = inp()
s = input()
lf len(s) <= k:
    print(s)
else:
    print(s[:k]+"...")
Problem p02701 (python)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [input() for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

n = inp()
x = ipnl(n)
print(len(set(x)))

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [input() for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

n = input()
x = ipnl(n)
print(len(set(x)))

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [input() for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

n = input()
x = inpl(n)
print(len(set(x)))
Problem p02546 (python)

Fixed submission:
S = input()
if S[-1] == 's':
	print(S + 'es')
else:
 	print(S + 's')

Buggy submission (verdict: Runtime Error):
S = input()
if S[-1] == s
	print(S + 'es')
else:
 	print(S + 's')
Problem p02547 (python)

Fixed submission:
ans = 0
s = []
for i in range(int(input())):
  a,b = map(int,input().split())
  if a==b:
    ans += 1
    s.append(ans)
  else:
    ans = 0
if len(s)!=0 and max(s)>=3:
  print('Yes')
elif len(s)==0:
  print('No')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
ans = 0
s = []
for i in range(int(input())):
  a,b = map(int,input().split())
  if a==b:
    ans += 1
    s.append(ans)
  else:
    ans = 0
if max(s)>=3:
  print('Yes')
else:
  print('No')
Problem p02549 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
mod = 998244353
dp = [0]*(N+1)
dp[1] = 1

Ks = [list(mapint()) for _ in range(K)]
Ks.sort()

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sums(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

bit = Bit(N)
bit.add(1, 1)

for i in range(2, N+1):
    for l, r in Ks:
        if i-l<0:
            break
        dp[i] += bit.sums(i-l) - bit.sums(max(0, i-r-1))
        dp[i] %= mod
    bit.add(i, dp[i])

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
dp = [0]*(N*2+1)
dp[1] = 1
dp[2] = -1
mod = 998244353
LR = [list(mapint()) for _ in range(K)]
for i in range(1, N+1):
    dp[i] = (dp[i]+dp[i-1])%mod
    for l, r in LR:
        dp[i+l] = (dp[i+l]+dp[i])%mod
        dp[i+r+1] = (dp[i+r+1]-dp[i])%mod

print(dp[N])
Problem p02597 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Cs = list(input())
from collections import deque
Q = deque()
for i, c in enumerate(Cs):
    if c=='R':
        Q.append(i)

ans = 0
for i in range(N):
    c = Cs[i]
    if c=='W':
        if not Q:
            break
        r = Q.pop()
        if r>i:
            ans += 1
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Cs = list(input())
from collections import deque
Q = deque()
for i, c in enumerate(Cs):
    if c=='R':
        Q.append(i)

ans = 0
for i in range(N):
    c = Cs[i]
    if c=='W':
        r = Q.pop()
        if r>i:
            ans += 1
        else:
            break
print(ans)
Problem p02891 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
K = int(input())
leng = len(S)
if len(set(S))==1:
    print(K*leng//2)
    exit()
if S[0]!=S[-1] or K==1:
    last = S[0]
    cnt = 0
    for s in S[1:]:
        if s==last:
            cnt += 1
            last = '.'
        else:
            last = s
    print(cnt*K)
else:
    S += ['.']
    cnt = 1
    lis = []
    last = S[0]
    for s in S[1:]:
        if s==last:
            cnt += 1
        else:
            lis.append(cnt)
            last = s
            cnt = 1
    first = lis.pop(0)
    end = lis.pop()
    others = sum([i//2 for i in lis])
    ans = first//2 + others*K + (first+end)//2*(K-1)+end//2
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
K = int(input())
leng = len(S)
if len(set(S))==1:
    print(S*K//2)
    exit()
if S[0]!=S[-1] or K==1:
    last = S[0]
    cnt = 0
    for s in S[1:]:
        if s==last:
            cnt += 1
            last = '.'
        else:
            last = s
    print(cnt*K)
else:
    S += ['.']
    cnt = 1
    lis = []
    last = S[0]
    for s in S[1:]:
        if s==last:
            cnt += 1
        else:
            lis.append(cnt)
            last = s
            cnt = 1
    first = lis.pop(0)
    end = lis.pop()
    others = sum([i//2 for i in lis])
    ans = first//2 + others*K + (first+end)//2*(K-1)+end//2
    print(ans)
Problem p02964 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
As = list(mapint())
double_As = As*2
idx_dic = {}
idx_lis = [N+1]*(2*N)
for i in range(N*2-1, -1, -1):
    a = double_As[i]
    if a in idx_dic:
        idx_lis[i] = idx_dic[a]+1
    idx_dic[a] = i
doubling = [[0]*N for _ in range(60)]
accum = [[0]*N for _ in range(60)]
doubling[0] = [i%N for i in idx_lis[:N]]
accum[0] = [a-i for i, a in enumerate(idx_lis[:N])]
for i in range(1, 60):
    for j in range(N):
        doubling[i][j] = doubling[i-1][doubling[i-1][j]]
        accum[i][j] = accum[i-1][j] + accum[i-1][doubling[i-1][j]]
now = 0
cum = 0
cnt = 0
for i in range(59, -1, -1):
    if cum + accum[i][now]>N*K:
        continue
    else:
        cum += accum[i][now]
        now = doubling[i][now]
ans = []
while cum<N*K:
    if cum+accum[0][now]<=N*K:
        cum += accum[0][now]
        now = doubling[0][now]
    else:
        ans.append(As[now])
        now += 1
        cum += 1
print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
As = list(input().split())

SET = set()
ans = []
for i in range(1, K+1):
    lis = []
    s = set()
    for j in range(i):
        for a in As:
            if a in s:
                lis = lis[:lis.index(a)]
                s = set(lis)
            else:
                s.add(a)
                lis.append(a)
    string = ' '.join(lis)
    if string in SET:
        break
    SET.add(string)
    ans.append(string)

print(ans[K%(i-1)-1])
Problem p03107 (python)

Fixed submission:
S = list(input())
L = len(S)
from collections import Counter
c = Counter(S)
one = c['1']
zero = c['0']

print(L-abs(one-zero))

Buggy submission (verdict: Runtime Error):
S = list(input())
from collections import deque
S = deque(S)
f = S.popleft()
stocked = f
ans = 0
while S:
    n = S.popleft()
    if f!=n:
        ans += 1
        if not S:
            break
        f = S.popleft()
    else:
        stocked = f
        f = n
if stocked!=n:
    ans += 1
print(ans*2)
Problem p03253 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
mod = 10**9+7

pos = {}
neg = {}
n = 1
pos[0] = 1
neg[0] = 1
for i in range(1, 500000):
    n *= i
    n %= mod
    pos[i] = n
    neg[i] = pow(n, mod-2, mod)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
primes = prime_factorize(M)
c = Counter(primes)
primes = list(set(primes))
leng = len(primes)
ans = 1
for i in range(leng):
    p = primes[i]
    n = c[p]
    ans *= pos[N+n-1]*neg[n]*neg[N-1]
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
mod = 10**9+7

pos = {}
neg = {}
n = 1
for i in range(1, 500000):
    n *= i
    n %= mod
    pos[i] = n
    neg[i] = pow(n, mod-2, mod)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
primes = prime_factorize(M)
c = Counter(primes)
primes = list(set(primes))
leng = len(primes)
ans = 1
for i in range(leng):
    p = primes[i]
    n = c[p]
    ans *= pos[N+n-1]*neg[n]*neg[N-1]
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
mod = 10**9+7

pos = {}
neg = {}
n = 1
for i in range(1, 200000):
    n *= i
    n %= mod
    pos[i] = n
    neg[i] = pow(n, mod-2, mod)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
primes = prime_factorize(M)
c = Counter(primes)
primes = list(set(primes))
leng = len(primes)
ans = 1
for i in range(leng):
    p = primes[i]
    n = c[p]
    ans *= pos[N+n-1]*neg[n]*neg[N-1]
    ans %= mod

print(ans)
Problem p03634 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
query = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = mapint()
    query[a-1].append((b-1, c))
    query[b-1].append((a-1, c))

Q, K = mapint()
from collections import deque
stack = deque([(K-1, 0, -1)])
dist = [0]*N
while stack:
    now, cnt, per = stack.pop()
    lis = query[now]
    dist[now] = cnt
    for nx, c in lis:
        if nx==per:
            continue
        if c!=0:
            stack.append((nx, cnt+c, now))

for _ in range(Q):
    x, y = mapint()
    print(dist[x-1]+dist[y-1])

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
query = [[0]*N for _ in range(N)]
for _ in range(N-1):
    a, b, c = mapint()
    query[a-1][b-1] = c
    query[b-1][a-1] = c

Q, K = mapint()
from collections import deque
stack = deque([(K-1, 0, -1)])
dist = [0]*N
while stack:
    now, cnt, per = stack.pop()
    lis = query[now]
    dist[now] = cnt
    for nx, c in enumerate(lis):
        if nx==per:
            continue
        if c!=0:
            stack.append((nx, cnt+c, now))

for _ in range(Q):
    x, y = mapint()
    print(dist[x-1]+dist[y-1])
Problem p03776 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
Vs = list(mapint())
Vs.sort(reverse=True)
from collections import defaultdict, Counter
from math import factorial, gcd

count = defaultdict(int)
c = Counter(Vs)
ans = 0
ans_2 = (0, 0)
for i in range(A, B+1):
    val = sum(Vs[:i])
    if val/i>=ans-0.000000000000001:
        ans = val/i
        lowest_cnt = 0
        lowest = Vs[i-1]
        for j in range(i):
            if Vs[j]==lowest:
                lowest_cnt += 1
        val, i = val//gcd(val, i), i//gcd(val, i)
        count[(val, i)] += factorial(c[lowest])/factorial(lowest_cnt)/factorial(c[lowest]-lowest_cnt)
        ans_2 = (val, i)

print(ans)
print(round(count[ans_2]))

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, A, B = mapint()
Vs = list(mapint())
Vs.sort(reverse=True)
from collections import defaultdict, Counter
from scipy.special import comb

count = defaultdict(int)
c = Counter(Vs)
ans = 0
for i in range(A, B+1):
    val = sum(Vs[:i])/i
    if val>=ans:
        ans = val
        lowest_cnt = 0
        lowest = Vs[i-1]
        for j in range(i):
            if Vs[j]==lowest:
                lowest_cnt += 1
        count[int(ans*2)] += comb(c[lowest], lowest_cnt)

print(ans)
print(count[int(ans*2)])
Problem p02577 (python)

Fixed submission:
n = input()
def sumN(n):
    sum = 0
    for i in range(len(n)):
        sum += int(n[i])
    return sum
sum = sumN(n)
if sum % 9 == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = input()
sum = 0
def sumN(n):
    sum = 0
    for i in range(len(n)):
        sum += int(n[i])
    return sum
sum = sumN(n)
while sum > 10000:
    sum = sumN(sum)
if sum % 9 == 0:
    print('Yes')
else:
    print('No')
Problem p02627 (python)

Fixed submission:
n = str(input())
dai = ["Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M"]
syou = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"]
if n in dai:
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
n = str(input())
dai = [Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M]
syou = [q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m]
if n in dai:
  print('A')
else:
  print('a')
Problem p03041 (python)

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

S[K - 1] = S[K - 1].lower()

print(''.join(S))

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

S[K] = S[K].lower()

print(''.join(S))

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

S[K] = S[K].lower()

print(S)
Problem p02659 (python)

Fixed submission:
raw = input().split(' ')
a = int(raw[0])
b = int(raw[1].replace('.', ""))

print(a * b // 100)

Buggy submission (verdict: Runtime Error):
fn main(){
    let raw = input();
    let x: Vec<&str> = raw.split(' ').collect();
    
    let a: f64 = x[0].parse::<f64>().unwrap();
    let b: f64 = x[1].parse::<f64>().unwrap() * 100.0;
    
    println!("{}", (a * b / 100.0) as i32);
}

fn input() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_string()
}

Buggy submission (verdict: Runtime Error):
fn main(){
    let raw = input();
    let x: Vec<&str> = raw.split(' ').collect();
    
    println!("{:?}", x);
    
    let a: f64 = x[0].parse::<f64>().unwrap();
    let b: f64 = x[1].parse::<f64>().unwrap() * 100.0;
    
    println!("{}", (a * b / 100.0) as i32);
}

fn input() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_string()
}
Problem p02790 (python)

Fixed submission:
n = [int(e) for e in input().split(" ")]
if(n[0] == n[1]):
    print(str(n[0]) * n[0])
elif(n[0] < n[1]):
    print(str(n[0]) * n[1])
else:
    print(str(n[1]) * n[0])

Buggy submission (verdict: Runtime Error):
n = [int(e) for e in input().split(" ")]
if(n[0] == n[1]):
    print(f"{n[0]}" * n[0])
elif(n[0] < n[1]):
    print(f"{n[0]}" * n[1])
else:
    print(f"{n[1]}" * n[0])

Buggy submission (verdict: Runtime Error):
n = [int(e) for e in input().split(" ")]
if(n[0] == n[1]):
    print(f"{n[0]}" * n[0])
elif(n[0] < n[1]):
    print(f"{n[0]}" * n[1])
else:
    print(f"{n[1]}" * n[0])
Problem p02847 (python)

Fixed submission:
s = input()
v = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
i = 7
for w in v:
  if s != w:
    i -= 1
  else:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
s = input()
v = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
i = 7
for w in v:
  if s != v[i]:
    i -= 1
  else:
    print(i)
    break
Problem p02580 (python)

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

r_n = [0] * h
c_n = [0] * w
bomb_table = set()
for i in range(k):
    hi, wi = map(int, input().split())
    hi -= 1
    wi -= 1
    r_n[hi] += 1
    c_n[wi] += 1
    bomb_table.add((hi, wi))

max_x = max(c_n)
max_y = max(r_n)
ans = max_x + max_y

max_x_table = set()
max_y_table = set()

for i in range(h):
    if r_n[i] == max_y:
        max_y_table.add(i)

for i in range(w):
    if c_n[i] == max_x:
        max_x_table.add(i)

for i in max_y_table:
    for j in max_x_table:
        if (i, j) not in bomb_table:
            print(ans)
            exit(0)
print(ans - 1)

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

r_n = [0]*h
c_n = [0]*w
bomb_table = set()
for i in range(m):
	hi, wi = map(int, input().split())
	hi-=1
	wi-=1
	r_n[hi] += 1
	c_n[wi] += 1
	bomb_table.add((hi, wi))

max_x = max(c_n)
max_y = max(r_n)
ans = max_x + max_y

for i in range(h):
	if r_n[i] != max_y:
		continue
	for j in range(w):
		if c_n[j] != max_x:
			continue
		if (i,j) not in bomb_table:
			print(ans)
			exit()
			
print(ans - 1)
Problem p02623 (python)

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

a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_a = [0]
sum_b = [0]

for i in range(n):
    sum_a.append(sum_a[-1] + a[i])

for i in range(m):
    sum_b.append(sum_b[-1] + b[i])

ans = 0
j = m
for i in range(n + 1):
    while sum_a[i] + sum_b[j] > k and j >= 0:
        j -= 1

    if j < 0:
        break

    if sum_a[i] + sum_b[j] <= k:
        ans = max(ans, i + j)

print(ans)

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

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

a = list(map(int, input().split()))
b = list(map(int, input().split()))

a = deque(a)
b = deque(b)

ans = 0

while n > 0 and m > 0 and k > 0:
    if a[0] == b[0]:
        i = 0
        while i + 1 < m and i + 1 < n and a[i + 1] != b[i + 1]:
            i += 1
        if a[i] >= b[i]:
            k -= b[0]
            if k >= 0:
                ans += 1
            b.popleft()
            n -= 1
        else:
            k -= a[0]
            if k >= 0:
                ans += 1
            a.popleft()
            m -= 1
    elif a[0] > b[0]:
        k -= b[0]
        if k >= 0:
            ans += 1
        b.popleft()
        m -= 1
    else:
        k -= a[0]
        if k >= 0:
            ans += 1
        a.popleft()
        n -= 1

if n <= 0:
    while k > 0 and m > 0:
        k -= b[0]
        if k >= 0:
            ans += 1
        b.popleft()
elif m <= 0:
    while k > 0 and n > 0:
        k -= a[0]
        if k >= 0:
            ans += 1
        a.popleft()

print(ans)
Problem p02912 (python)

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

items = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(items)
             
for i in range(m):
    pop = heapq.heappop(items)*(-1)//2
    heapq.heappush(items, pop*(-1))

print(-1*sum(items))

Buggy submission (verdict: Runtime Error):
import heapq as hq

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

items = [-1*map(int, input().split()] 

hq.heapify(items)
             
for i in range(m):
	pop = hq.heapqpop(items)
    hq.heapqpush(items, pop//2)
              
return -1*sum(hq)