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

Fixed submission:
import os

s = list(map(str,input()))
t = list(map(str,input()))

m = len(s)
n = len(t)
ans = 0

if m<n:
    print("UNRESTORABLE")
    exit()
for i in range(m-n+1):
    s2 = s.copy()
    s1 = s2[i:i+n]
    flag = True
    for j in range(n):
        if s1[j]!="?" and s1[j]!=t[j]:
            flag = False
            break
        else:
            s1[j] = t[j]
    if flag:
        s2[i:i+n] = s1
        s2 = "".join(s2)
        a = s2.replace("?","a")
        if ans==0:
            ans = a
        elif ans > a:
            ans = a
if ans==0:
    print("UNRESTORABLE")
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
s = list(map(str,input()))
t = list(map(str,input()))


m = len(s)
n = len(t)
ans = []

if m<n:
    print("UNRESROEABLE")
else:
    for i in range(m-n+2):
        s1 = s[i:i+n]
        s2 = s
        flag = True
        for j in range(n):
            if s1[j]!="?" and s1[j]!=t[j]:
                flag = False
                break

        if flag:
            s2[i:i+n] = t
            for k in range(m):
                if s2[k]=="?":
                    s2[k] = "a"
            ans.append(s2)
    if len(ans)==0:
        print("UNRESTORABLE")
    else:
        ans.sort()
        print("".join(ans[0]))

Buggy submission (verdict: Runtime Error):
import os

def qcount(s,t,count):
    if s=="?" or s==t:
        count += 1
        return count
    else:
        return 0

S = list(input())
T = list(input())
count = 0
i = 0
result =False

if len(S)>=len(T):
    while len(S)-i:
        count = qcount(S[i],T[count],count)
        if count == len(T):
            i = len(S)-1
            result = True
            for j in range(len(T)):
                S[i-count+j+1] = T[j]
            for k in range(len(S)):
                if S[k]=="?":
                    S[k] = "a"
    i += 1
if result:
    print("".join(S))
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
import os

def qcount(s,t,count):
    if s=="?" or s==t:
        count += 1
        return count
    else:
        return 0

S = list(input())
T = list(input())
count = 0
i = 0
result =False
if len(S)>=len(T):
    while len(S)-i:
        count = qcount(S[i],T[count],count)
        if count == len(T):
            i = len(S)-1
            result = True
            for j in range(len(T)):
                S[i-count+j+1] = T[j]
                for k in range(len(S)):
                    if S[k]=="?":
                        S[k] = "a"
    i += 1
if result:
    print("".join(S))
else:
    print("UNRESTORABLE")
Problem p03729 (python)

Fixed submission:
A,B,C = input().split()

if A[len(A)-1]==B[0] and B[len(B)-1]==C[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
A,B,C = input().split()

if A[len(A)-1]==B[0] and B[len(B)-1]==C[0]:
  print("YES)
else:
  print("NO")
Problem p03777 (python)

Fixed submission:
a,b = (str(x) for x in input().split())

if a=="H":
    print(b)
else:
    if b=="H":
        print("D")
    else:
        print("H")

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

if a=="H":
    print(b)
else:
    if b=="H":
        print("D")
    else:
        print("H")
Problem p03844 (python)

Fixed submission:
a,op,b = input().split()
A = int(a)
B = int(b)

if op == "+":
    print(A+B)
elif op == "-":
    print(A-B)

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

list.sort()
if list[0]+list[1] == list[2]:
    print("Yes")
else:
    print("No")
Problem p04029 (python)

Fixed submission:
N = int(input())
print(N*(N+1)//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(N*(N+1)//2
Problem p02584 (python)

Fixed submission:
X, K, D = map(int, input().split())
if (abs(X) - K * D) >= 0:
  print(abs(X) - K * D)
else:
  if (X // D - K) %2 == 0:
  	print(X%D)
  else:
    print(abs(X%D - D))

Buggy submission (verdict: Runtime Error):
X, K, D = map(int, input().split())
if (abs(X) - K * D) >= 0:
  print(abs(X) - K * D)
else:
  print(min(X%D, abs(X%D - D))

Buggy submission (verdict: Runtime Error):
X, K, D = map(int, input.split())
if (abs(X) - K * D) > = 0:
  print(abs(X) - K * D)
else:
  print(min(X%D, D-X%D))
Problem p02585 (python)

Fixed submission:
from collections import defaultdict
def f(s):
  return int(s) - 1

N, K = map(int, input().split())
P = list(map(f, input().split()))
C = list(map(int, input().split()))

loop = []

first = -1
x = -1
loop_mem = []
cnt = 0
score = 0

rem = set(range(N))

while len(rem) > 0:
  if first < 0:
    first = rem.pop()
    x = first
  loop_mem.append(x)
  if x != first:
    rem.remove(x)
  cnt += 1
  score += C[x]
  if first != P[x]:
    x = P[x]
  else:
    loop.append((loop_mem, cnt, score))
    first = -1
    loop_mem = []
    cnt = 0
    score = 0

ans = -1e10
for loop_mem, cnt, score in loop:
  imax = [-1e10 for _ in range(cnt)]
  imax[0] = 0
  for x in loop_mem:
    tmp = 0
    for j in range(1, cnt):
      tmp += C[x]
      imax[j] = max(imax[j], tmp)
      x = P[x]
  for j in range(2, cnt):
    imax[j] = max(imax[j-1], imax[j])
  if score <= 0:
    ans = max(ans, imax[-1])
  else:
    M = K // cnt
    m = K % cnt
    if M >= 1:
      tmp = max(score * M + max(imax[m], 0), score * (M-1) + imax[-1])
    else:
      tmp = imax[m]
    ans = max(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def f(s):
  return int(s) - 1

N, K = map(int, input().split())
P = list(map(f, input().split()))
C = list(map(int, input().split()))

loop = []

first = -1
x = -1
loop_mem = []
cnt = 0
score = 0

rem = set(range(N))

while len(rem) > 0:
  if first < 0:
    first = rem.pop()
    x = first
  loop_mem.append(x)
  if x != first:
    rem.remove(x)
  if first != P[x]:
    cnt += 1
    score += C[x]
    x = P[x]
  else:
    cnt += 1
    score += C[x]
    loop.append((loop_mem, cnt, score))
    first = -1
    loop_mem = []
    cnt = 0
    score = 0

ans = -1e10
for loop_mem, cnt, score in loop:
  imax = [-1e10 for _ in range(cnt-1)]
  for x in loop_mem:
    tmp = 0
    for j in range(cnt - 1):
      tmp += C[x]
      imax[j] = max(imax[j], tmp)
      x = P[x]
  for j in range(1, cnt-1):
    imax[j] = max(imax[j-1], imax[j])
  if score <= 0:
    ans = max(ans, imax[-1])
  else:
    M = K // cnt
    m = K % cnt
    if M >= 1:
      tmp = max(score * M + max(imax[m-1], 0), score * (M-1) + imax[-1])
    else:
      tmp = imax[m-1]
  	ans = max(ans, tmp)

print(ans)
Problem p02886 (python)

Fixed submission:
N = int(input())
d = list(map(int, input().split()))
ans = 0

from itertools import combinations
for i,j in combinations(range(N),2):
  ans += d[i-1]*d[j-1]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = list(map(int, input().split()))
ans = 0

from itertools import combinations
for i,j in combinations(d,2):
  ans += d[i-1]*d[j-1]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = list(map(int, input().split()))
ans = 0

from itertools import combinations
for i,j in combinations(N,2):
  ans += d[i]*d[j]
print(ans)
Problem p02939 (python)

Fixed submission:
S = input()
ans = 0
p = ''
i = 0

while i < len(S):
  ans+=1
  if p==S[i]:
    if i==len(S)-1:
      ans-=1
    i+=2
    p=''
  else:
    p=S[i]
    i+=1
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0
p = ''
i = 0

while i < len(S):
  ans+=1
  if p==S[i]:
    i+=2
    p=''
  else:
    i+=1
    p=S[i]
    
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0
p = ''
i = 0

while i < N:
  ans+=1
  if p==S[i]:
    i+=2
    p=''
  else:
    i+=1
    p=S[i]
    
print(ans)
Problem p02972 (python)

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

b = [0 for i in range(N+1)]
M = 0

for i in range(N):
    ind = N-i
    val = 0
    j=2
    while ind*j<=N:
        val += b[ind*j]
        j+=1
    if val%2 != a[ind]:
        M+=1
        b[ind]=1
print(M)
if M!=0:
    for i in range(1,N+1):
        if b[i]==1:
            if M!=1:
                print(i,end=' ')
            else:
                print(i)

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

b = []

for i in range(N):
    ind = N-i
    val = 0
    j=2
    while ind*j<=N:
        val += b[ind*j-1]
        j+=1
    if val%2 != a[ind-1]:
        b.append(ind)
print(len(b))
if len(b)!=0:
    print(' '.join([str(b[len(b)-i-1]) for i in range(len(b))]))

Buggy submission (verdict: Runtime Error):
#include <iostream>

using namespace std;

int main(){
    int i,j,N;
    int a[N+1],b[N+1];
    cin >> N;

    for(i=1;i<=N;i++){
        cin >> a[i];
        b[i]=0;
    }

    int M = 0;
    int k = 0;
    for(i=N;i>0;i--){
        int val = 0;
        for(j=2;i*j<=N;j++){
            val+=b[i*j];
        }
        if(val%2!=a[i]){
            b[i]=1;
            M++;
            k=max(k,i);
        }            
    }
    cout << M << endl;
    for(i=1;i<=N;i++){
        if(b[i]==1){
            cout<<i<<" ";
        }
    }
    if(M!=0)
        cout<<endl;
}
Problem p03032 (python)

Fixed submission:
from itertools import combinations
from bisect import bisect_left
N, K = map(int,input().split())
A = list(map(int,input().split()))

ans=0

for i,j in combinations(range(N+2),2):
  l = sorted(A[0:i]+A[j-1:N])
  if len(l)<=K:
    m = bisect_left(l,0)
    ans = max(ans,sum(l[min(K-len(l),m):]))
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
from bisect import bisect_left
N, K = map(int,input().split())
A = list(map(int,input().split()))

ans=0

for i,j in combinations(range(N+2),2):
  l = sorted(A[0:i]+A[j-1:N])
  if len(l)<=K:
    m = bisect_left(l,0)
  	ans = max(ans,sum(l[min(K-len(l),m):]))
print(ans)
Problem p03061 (python)

Fixed submission:
def gcd(a,b):
  if a>b:
    a,b = b,a
  if b%a == 0:
    return a
  else:
    return gcd(b%a,a)

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

from collections import defaultdict

L = defaultdict(lambda :1)
R = defaultdict(lambda :1)
L[1] = A[0]
R[1] = A[N-1]

for i in range(2,N):
  L[i] = gcd(L[i-1],A[i-1])
  R[i] = gcd(R[i-1],A[N-i])

ans = max(L[N-1],R[N-1])
for i in range(1,N-1):
  ans = max(ans,gcd(L[i],R[N-1-i]))

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  if a>b:
    a,b = b,a
  if a==1:
    return a
  else:
    return gcd(b%a,a)

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

ans = A[1]
g = A[0]

for i in range(N):
  g = gcd(g,A[i])
  ans = max(ans,g)
print(ans)
Problem p03076 (python)

Fixed submission:
l=[int(input()) for i in range(5)]
m=[c%10 for c in l if c%10>0]

def f(c):
    if c%10>0:
        return c+10-c%10
    else:
        return c

t=[f(c) for c in l]

ans=sum(t)
if len(m)>0:
  ans-=10-min(m)
print(ans)

Buggy submission (verdict: Runtime Error):
l=[int(input()) for i in range(5)]
m=[c%10 for c in l if c%10>0]

def f(c):
    if c%10>0:
        return c+10-c%10
    else:
        return c

t=[f(c) for c in l]

ans=sum(t)
if len(l)>0:
  ans-=10-min(m)
print(ans)
Problem p03152 (python)

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

l=[[0,0] for i in range(N*M+1)]

for a in A:
    if l[a][0]==1:
        print(0)
        exit()
    l[a][0]+=1
for b in B:
    if l[b][1]==1:
        print(0)
        exit()
    l[b][1]+=1

A=0
B=0
ans=1

for i in range(N*M):
    n=N*M-i
    if l[n]==[1,1]:
        A+=1
        B+=1
    elif l[n]==[1,0]:
        A+=1
        ans*=B
    elif l[n]==[0,1]:
        B+=1
        ans*=A
    else:
        ans*=A*B-(N*M-n)

    ans%=10**9+7

print(ans)

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

A=sorted(A)
B=sorted(B)

from bisect import bisect_left

ans=1

for i in range(N*M):
    n=N*M-i
    ai=bisect_left(A,n)
    bi=bisect_left(B,n)
    if n==A[ai] and n!=B[bi]:
        ans*=(M-bi)
    if n==B[bi] and n!=A[ai]:
        ans*=(N-ai)
    if n!=A[ai] and n!=B[bi]:
        ans*=(N-ai)*(M-bi)-(N*M-n)

print(ans%(10**9+7))
Problem p03160 (python)

Fixed submission:
def memoize(f):
    cache={}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper

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

import sys
sys.setrecursionlimit(1000000)

@memoize
def f(n):
    if n==1:
        return 0
    elif n==2:
        return abs(h[1]-h[0])
    elif n==3:
        return abs(h[2]-h[0])
    else:
        return min(f(n-1)+abs(h[n-1]-h[n-2]),f(n-2)+abs(h[n-1]-h[n-3]))

print(f(N))

Buggy submission (verdict: Runtime Error):
def memoize(f):
    cache={}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper

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

def f(n):
    if n<=1:
        return 0
    elif n==2:
        return abs(h[1]-h[0])
    elif n==3:
        return abs(h[2]-h[0])
    else:
        return min(f(n-1)+abs(h[n-1]-h[n-2]),f(n-2)+abs(h[n-1]-h[n-3]))

print(f(N))

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

def f(n):
    if n==1:
        return 0
    elif n==2:
        return abs(h[1]-h[0])
    elif n==3:
        return abs(h[2]-h[0])
    else:
        return min(f(n-1)+abs(h[n-1]-h[n-2]),f(n-2)+abs(h[n-1]-h[n-3]))

print(f(N))

Buggy submission (verdict: Runtime Error):
def memoize(f):
    cache={}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper

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

@memoize
def f(n):
    if n==1:
        return 0
    elif n==2:
        return abs(h[1]-h[0])
    elif n==3:
        return abs(h[2]-h[0])
    else:
        a = f(n-1)+abs(h[n-1]-h[n-2])
        b = f(n-2)+abs(h[n-1]-h[n-3])
        return min(a,b)

print(f(N))

Buggy submission (verdict: Runtime Error):
def memoize(f):
    cache={}
    def helper(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return helper

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

@memoize
def f(n):
    if n==1:
        return 0
    elif n==2:
        return abs(h[1]-h[0])
    elif n==3:
        return abs(h[2]-h[0])
    else:
        return min(f(n-1)+abs(h[n-1]-h[n-2]),f(n-2)+abs(h[n-1]-h[n-3]))

print(f(N))
Problem p03196 (python)

Fixed submission:
from math import sqrt

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

if N==1:
    print(P)
else:
    dic={}
    p=2
    while p<=sqrt(P):
        cnt=0
        while P%p==0:
            P=int(P/p)
            cnt+=1
        if cnt>0:
            dic[p]=cnt
        p+=1

    ans=1
    for p in dic.keys():
        ans *= p**int(dic[p]/N)
    print(ans)

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

p=0
q=0

for _ in range(N):
    a=int(input())
    if a>=p:
        q=p
        p=a

if p==1:
    print('first')
elif (p-q)%2==0:
    print('second')
else:
    print('first')
Problem p03212 (python)

Fixed submission:
from itertools import product

def f(n):
    return 3**n - 3*(1 + 2**n - 2)

s = input()
n = int(s)
m = len(s)

ans=0

if m>=4:
    for i in range(3,m):
        ans+=f(i)

for s in product(['7','5','3'],repeat=m):
    if len(set(s))==3 and int(''.join(s))<=n:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product
N = int(input())
ans = 0
for p in product(['0','3','5','7'],repeat=9):
  s = ''.join(p)
  if '3' in s and '5' in s and 7 in 's' and int(s) <= N:
    ans += 1
print(ans)
Problem p03260 (python)

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

if a*b%2==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())

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

num=0

for i in range(H):
    for j in range(W):
        if i%2==0:
            n=j
        else:
            n=W-1-j
        if A[i][n]%2==1:
            A[i][n]-=1
            if i!=H-1 and (i%2==0 and n==W-1) or (i%2==1 and n==0):
                num+=1
                A[i+1][n]+=1
                print(i+1,n+1,i+2,n+1)
            if (i%2==0 and n!=W-1) or (i%2==1 and n!=0):
                num+=1
                A[i][n+(-1)**(i%2)]+=1
                print(i+1,n+1,i+1,n+1+(-1)**(i%2))
Problem p03262 (python)

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

c = list(map(int,input().split()))
c.append(x)

def gcd(a,b):
    n = max(a,b)
    m = min(a,b)
    if n%m==0:
        return m
    else:
        return gcd(m,n%m)


c.sort()
ans = c[1]-c[0]

for i in range(n-1):
    ans = gcd(ans,c[i+2]-c[i+1])

print(ans)

Buggy submission (verdict: Runtime Error):
c.sort()
ans = c[1]-c[0]

for i in range(n-1):
    ans = gcd(ans,c[i+2]-c[i+1])

print(ans)

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

c = list(map(int,input().split()))
c.append(x)

from math import gcd

c.sort()
ans = c[1]-c[0]

for i in range(n-1):
    ans = gcd(ans,c[i+2]-c[i+1])

print(ans)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())

l=0

while s[l] == '1':
    l+=1
    if l >= len(s):
        l -= 1
        break

n = int(s[l])

if k<=l:
    print(1)
else:
    print(n)

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

l=0

while s[l] == '1':
    l+=1

n = int(s[l])

if k<=l:
    print(1)
else:
    print(n)
Problem p03330 (python)

Fixed submission:
N,C = map(int,input().split())
 
D = []
c = []
 
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split()))) 
 
c1 = []
c2 = []
c3 = []
 
from itertools import product
 
for i,j in product(range(N),repeat=2):
    if (i+j)%3 == 0:
        c1.append(c[i][j])
    elif (i+j)%3 == 1:
        c2.append(c[i][j])
    else:
        c3.append(c[i][j])
val=[]
cnt=[[],[],[]]
 
 
for j in range(C):
    cnt[0].append(c1.count(j+1))
    cnt[1].append(c2.count(j+1))
    cnt[2].append(c3.count(j+1))
 
for i in product(range(C),repeat=3):
    dif = 0
    if i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        for j in range(C):
            dif += D[j][i[0]] * cnt[0][j]
            dif += D[j][i[1]] * cnt[1][j]
            dif += D[j][i[2]] * cnt[2][j]
        val.append(dif)
 
print(min(val))

Buggy submission (verdict: Runtime Error):
4 3
0 12 71
81 0 53
14 92 0
1 1 2 1
2 1 1 2
2 2 1 3
1 1 2 2
428
k-mbp:ABC99 kaibe$ cat D.py 
N,C = map(int,input().split())

D = []
c = []

for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split()))) 

c1 = []
c2 = []
c3 = []

from itertools import product

for i,j in product(range(N),repeat=2):
    if (i+j)%3 == 0:
        c1.append(c[i][j])
    elif (i+j)%3 == 1:
        c2.append(c[i][j])
    else:
        c3.append(c[i][j])
val=[]
cnt=[[],[],[]]


for j in range(C):
    cnt[0].append(c1.count(j+1))
    cnt[1].append(c2.count(j+1))
    cnt[2].append(c3.count(j+1))

for i in product(range(C),repeat=3):
    dif = 0
    if i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        for j in range(C):
            dif += D[j][i[0]] * cnt[0][j]
            dif += D[j][i[1]] * cnt[1][j]
            dif += D[j][i[2]] * cnt[2][j]
        val.append(dif)

print(min(val))

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

D = []
c = []

for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split()))) 

c1 = []
c2 = []
c3 = []

from itertools import product

for i,j in product(range(N),repeat=2):
    if (i+j)%3 == 0:
        c1.append(c[i][j])
    elif (i+j)%3 == 1:
        c2.append(c[i][j])
    else:
        c3.append(c[i][j])

val=[]

for i in product(set(c1),set(c2),set(c3)):
    dif = 0
    if i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]:
        for j,k in product(range(N),repeat=2):
            dif += D[c[j][k]-1][i[(j+k)%3]-1]
        val.append(dif)

print(min(val))
Problem p03353 (python)

Fixed submission:
s = input()
K = int(input())

t = sorted(set(s))[0:K]

l = sorted(set(s))[0:K]

for i in range(min(K,len(t))):
    w = t[i]
    for j in range(len(s)):
        if s[j]==w:
            for k in range(2,6):
                l.append(s[j:j+k])

l = sorted(set(l))

print(l[K-1])

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

t = sorted(set(s))[0:K]

l = t.copy()

for i in range(min(K,len(t))):
    w = t[i]
    for j in range(len(s)):
        for k in range(i+2,K+1):
            if s[j]==w:
                l.append(s[j:j+k])

l = sorted(set(l))

print(l[K-1])
Problem p03379 (python)

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

x_sorted = sorted(x)

med = (x_sorted[int(n/2)-1] + x_sorted[int(n/2)])/2

for i in range(n):
    if x[i]<med:
        print(x_sorted[int(n/2)])
    else:
        print(x_sorted[int(n/2)-1])

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

x_sorted = sorted(x)

for i in range(n):
    l = x_sorted.copy()
    l.remove(x[i])
    print(l[int(n/2)-1])
Problem p03433 (python)

Fixed submission:
N=int(input())
A=int(input())
if N%500<=A:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
white=0
S=[]
for _ in range(H):
    s=list(input())
    white+=s.count('.')
    S.append(s)

f=[[0 for i in range(W)] for j in range(H)]

def path(i,j):
    s=S[i][j]
    q=[]
    for k in [1,-1]:
        if 0<=i+k<H and f[i+k][j]==0 and S[i+k][j]==s:
            q.append((i+k,j))
        if 0<=j+k<W and f[i][j+k]==0 and S[i][j+k]==s:
            q.append((i,j+k))
    return q

flag=False
if S[0][0]=='.' and S[-1][-1]=='.':
    que = path(0,0)
else:
    que = []
f[0][0]=1

l=1
while len(que)>0 and flag==False:
    l+=1
    tmp=[]
    for q in que:
        tmp+=path(*q)
        f[q[0]][q[1]]=1
        if q==(H-1,W-1):
            flag=True
    que=tmp

if flag:
    print(white-l)
else:
    print(-1)
Problem p03472 (python)

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

d=[]
for _ in range(N):
    d.append(list(map(int,input().split())))

d.sort(key=lambda x:x[0],reverse=True)
a = d[0][0]

d.sort(key=lambda x:x[1],reverse=True)

i=0
dam=0
b_damage=[]

while d[i][1]>a:
    dam+=d[i][1]
    b_damage.append(dam)
    i+=1
    if i==N:
        break

r = H//a + 1
l = 0

def damage(k):
    if k<len(b_damage)+1:
        return b_damage[k-1]
    elif len(b_damage)==0:
        return a*k
    else:
        l=k-len(b_damage)
        return b_damage[-1]+a*l


while r-l!=1:
    mid=(r+l)//2
    dam = damage(mid)
    if dam >= H:
        r=mid
    else:
        l=mid
print(r)

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

d=[]
for _ in range(N):
    d.append(list(map(int,input().split())))

d.sort(key=lambda x:x[0],reverse=True)
a = d[0][0]

d.sort(key=lambda x:x[1],reverse=True)

i=0
dam=0
b_damage=[]

while d[i][1]>a:
    dam+=d[i][1]
    b_damage.append(dam)
    i+=1
    if i==N:
        break

r = H//a + 1
l = 0

def damage(k):
    if k<len(b_damage)+1:
        return b_damage[k-1]
    else:
        l=k-len(b_damage)
        return b_damage[-1]+a*l


while r-l!=1:
    mid=(r+l)//2
    dam = damage(mid)
    if dam >= H:
        r=mid
    else:
        l=mid
print(r)
Problem p03478 (python)

Fixed submission:
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  s=0
  for j in str(i):
    s+=int(j)
  if a<=s<=b :
    ans+=i
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
for i in range(1,N+1):
  s=0
  for j in str(i):
    s+=int(j)
  if a<=s<=b:
    ans+=1
print(ans)
Problem p03494 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
l=[]

for a in A:
    b=0
    while a%2==0:
        a//=2
        b+=1
    l.append(b)
print(min(l))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
l=[]
for a in A:
  b=0
  while a%2==0:
    a//=2
    b+=1
  l.append(b)
print(min(b))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
l=[]
for a in A:
  b=0
  while a%2==0:
    a//=2
  	b+=1
  l.append(b)
print(min(l))