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

Fixed submission:
N = 3
c = []
i = 0

for i in range(N):
	c.append(input().strip())

out = ""

for i in range(N):
    out = out + c[i][i]
    
print(out)

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().strip().split(' '))
a_rev = ""
i = 0
j = 0
cnt = 0

#chk = []

for i in range(b - a):
    a+=1
    
    for j in range(len(str(a))):
        a_rev = a_rev + str(a)[len(str(a)) - 1 - j]   

    if str(a_rev) == str(a):
        cnt+=1
        #chk.append(a_rev)   #test
    else:
        pass
    
    a_rev =""
    
print(cnt)
#print(chk)

Buggy submission (verdict: Runtime Error):
N = 3
c = []
i = 0


for i in range(N):
	c.append(list(map(str, input().strip().split(' '))))	#[A][B]

print(c[0][0] + c[1][1] + c[2][2])
Problem p03455 (python)

Fixed submission:
X,Y = map(int, input().split())

if (X*Y % 2 == 0):  print("Even")
else:               print("Odd")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())

out = "Even"	#Even奇数,Odd偶数


if ((a * b) % 2 == 0):
	out = "Odd"

print(out)
Problem p03469 (python)

Fixed submission:
s = input()

if s[:4] == "2017":
    s = s.replace(s[:4],"2018")
    
print(s)

Buggy submission (verdict: Runtime Error):
n,y = map(int,input().split())
 
y /= 1000
 
y10 = 0
y5 = 0
y1 = 0
 
i = 0
#i,j,k = 10000,5000,1000
while 1:
    y1 = i
    y5 = (10*n-y-9*y1)//5
    y10 = n-y5-y1
    if (10*n-y-9*y1)%5 == 0 and y10>=0 and y5>=0 and y1>=0:
        print(int(y10),int(y5),int(y1))
        break
    i += 1
    if i>n:
        print(-1,-1,-1)
        break
Problem p03624 (python)

Fixed submission:
s = input()
s_set = list(set(s))    #重複削除

s_set.sort()

chk = list("abcdefghijklmnopqrstuvwxyz")

i = 0

while 1:
    if s_set[i] != chk[i]:
        print(chk[i])
        break
    i += 1
    
    if i >= (len(s_set)):
        print(chk[i])
        break
    if i >= 25:
        print("None")
        break

Buggy submission (verdict: Runtime Error):
s = input()
s_set = list(set(s))    #重複削除

s_set.sort()

chk = list("abcdefghijklmnopqrstuvwxyz")

i = 0

while 1:
    if s_set[i] != chk[i]:
        print(chk[i])
        break
    i += 1
    if i >= 26 or i>=len(s):
        print("None")
        break

Buggy submission (verdict: Runtime Error):
s = input()
s_set = list(set(s))    #重複削除

s_set.sort()

chk = list("abcdefghijklmnopqrstuvwxyz")

i = 0

while 1:
    if s_set[i] != chk[i]:
        print(chk[i])
        break
    i +=1
    if i >= 26:
        print("None")
        break
Problem p03732 (python)

Fixed submission:
from itertools import accumulate

def chk(samp):
    for i in samp:
        print(samp)

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

w = [0 for i in range(N)]
v = [0 for i in range(N)]

for i in range(N):
    w[i],v[i]=map(int,input().split())



#価値毎に置き換える
wl = [[] for i in range(4)]

#価値ごとのりすとに入れていく
for i in range(N):
    wl[w[i]-w[0]].append(v[i])


#ソートして最初に0を追加する。0は選択しない場合
for i in range(4):
    wl[i].sort(reverse = 1)
    wl[i].insert(0,0)
    

#累積和を作る
for i in range(4):
    wl[i] = list(accumulate(wl[i]))
    
#出力用変数
out = 0


for i,wl0 in enumerate(wl[0]):
   for j,wl1 in enumerate(wl[1]):
       for k,wl2 in enumerate(wl[2]):
           for l,wl3 in enumerate(wl[3]):
               if i*(w[0])+j*(w[0]+1)+k*(w[0]+2)+l*(w[0]+3) > W:
                   pass
               else:
                   out = max(out,wl0+wl1+wl2+wl3)
                   
print(out)

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

w = [-1 for i in range(N)]
v = [-1 for i in range(N)]

for i in range(N):
    w[i],v[i] = map(int,input().split())
    
dp = [[0 for i in range(W+1)] for j in range(N)]

#荷物を1つだけ入れた状態で、各許容重量の最大値を初期値として持たせる
for i in range(N):
    dp[i][w[i]] = v[i]

for i in range(1,N):
    for j in range(W+1):
        if j < w[i]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1],dp[i-1][j-w[i]]+v[i])
'''
for i in range(N):
    print(dp[i])
'''

print(dp[N-1][W])

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

w = [-1 for i in range(N)]
v = [-1 for i in range(N)]

for i in range(N):
    w[i],v[i] = map(int,input().split())
    
dp = [[0 for i in range(W+1)] for j in range(N)]

#荷物を1つだけ入れた状態で、各許容重量の最大値を初期値として持たせる
for i in range(w[0],W+1):
    dp[0][i] = v[0]

for i in range(1,N):
    for k in range(1,w[i]+1):
        dp[i][k] = dp[i-1][k]
        for j in range(w[i],W+1):
            dp[i][j] = max(dp[i][j-1],dp[i-1][j],dp[i-1][j-w[i]]+v[i])
'''
for i in range(N):
    print(dp[i])
'''

print(dp[N-1][W])
Problem p03943 (python)

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

if a+b==c or a+c==b or c+b==a:
    print("Yes")
else:
    print("No")

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

if sum(a,b) == c or sum(a,c) == b or sum(c,b) == a:
    print("Yes")
else:
    print("No")
Problem p04046 (python)

Fixed submission:
h,w,a,b =map(int,input().split())
mod = 10**9+7

#階乗を求める
fact_l = [1 for i in range(h+w+1)]
for i in range(1,len(fact_l)):
    fact_l[i] *= (fact_l[i-1]*i)%mod

#逆元
factinv_l = [1 for i in range(h+w+1)]
for i in range(1,len(fact_l)):
    factinv_l[i] = pow(fact_l[i],mod-2,mod)
    
#必ず通るポイントまでの組み合わせ
point1 = [1 for i in range(w-b)]
for i in  range(len(point1)):
    yoko = b+i 
    tate = h-a-1
    n = yoko+tate
    r = yoko
    point1[i] = fact_l[n]*factinv_l[r]*factinv_l[n-r]%mod

#point1からの経路
out = 0
for i in range(len(point1)):
    yoko = w-b-i-1
    tate = a-1
    n = yoko+tate
    r = yoko
    case = fact_l[n]*factinv_l[r]*factinv_l[n-r]%mod
    out += (point1[i]*case)%mod
print(out%mod)

Buggy submission (verdict: Runtime Error):
h,w,a,b =map(int,input().split())
mod = 10**9+7

nfact_l = [1 for i in range(h+w+1)]
def nfact_mod(n0,mod0):
    for i in range(1,len(nfact_l)):
        nfact_l[i] *= (nfact_l[i-1]*i)%mod
nfact_mod(h+w+1,mod)

#二分累乗法 あとで使う
def powfunc_mod(n0,r0,mod0):
    ans0 = 1
    r0 = bin(r0)[:1:-1]
    for i in r0:
        if i == "1":
            ans0 *= (n0 % mod0)
        n0 *= (n0 % mod0)
        ans0 %= mod0
    return ans0

nfact_inv_l = [1 for i in range(h+w+1)]
for i in range(len(nfact_inv_l)):
    nfact_inv_l[i] = powfunc_mod(nfact_l[i],mod-2,mod)

point1 = [0 for i in range(w-b)]
for i in range(len(point1)):
    #  ... = n!*r!^(p-2)*(n-r)!^(p-2) [mod]
    yoko = b+i
    tate = h-a-1
    n = yoko+tate
    r = tate
    point1[i] = (nfact_l[n]*nfact_inv_l[r]*nfact_inv_l[n-r])%mod

#point1から目的まで行く経路数
out = 0
for i in range(len(point1)):
    yoko = w-b-1+i
    tate = a-1
    n = yoko+tate
    r = tate
    out += ((((point1[i]*nfact_l[n])%mod)*nfact_inv_l[r]%mod)*nfact_inv_l[n-r])%mod

print(out)
Problem p03282 (python)

Fixed submission:
S=input();
K=input();
i = 0;
for i in range(len(S)) :
    if int(S[i]) > 1 :
        print(S[i]);
        break;
    elif i + 1 >= int(K) :
        print(1);
        break;

Buggy submission (verdict: Runtime Error):
S=input();
K=input();
i = 0;
for i in range(len(S)) :
    if int(S[i]) > 1 :
        print(S[i]);
        break;
    elif i + 1 >= K :
        print(1);

Buggy submission (verdict: Runtime Error):
S=input();
K=input();
i = 0;
for i in range(len(S)) :
    if int(S[i]) > 1 :
        print(S[i]);
        break;
    elif i + 1 >= K :
        print(1);

Buggy submission (verdict: Runtime Error):
import math;
S=input();
K=input();
i = 0;
for i in range(len(S)) :
    if int(S[i]) > 1 :
        print(S[i]);
        break;
    elif i >= K :
        print(1);
Problem p03733 (python)

Fixed submission:
N,T = map(int,input().split());
t = [int(x) for x in input().split()];

end = 0;
ans = 0;
for i in range(N) :
    if end > t[i] :
        ans += t[i] + T - end;
    else :
        ans += T;
    end = t[i] + T;
    #print(ans,end);

print(ans);

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split());
t = [int(x) for x in input().split()];

end = 0;
ans = 0;
for i in range(N) :
    if end > t[i] :
        ans += t[i] + T - end;
        else :
        ans += T;
    end += t[i] + T;
    #print(ans,end);

print(ans);
Problem p02657 (python)

Fixed submission:
x = list(map(int,input().split()))
result = x[0]*x[1]
print(result)

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

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

for i in range(lenght-1):
  x[i+1] = x[i] * x[i+1]
if x[-1] > 1e18:
  x[-1] = -1
print(x[-1])

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

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

でf

first_val = x[0]
for i in range(lenght-1):
  first_val *= x[i+1]

if first_val > 1e18:
  first_val = -1

print(first_val)
Problem p02909 (python)

Fixed submission:
S = input()
check = ["Sunny", "Cloudy", "Rainy"]
if "Sunny" == S:
  print("Cloudy")
elif "Cloudy" == S:
  print("Rainy")
else:
  print("Sunny")

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K,Q = [int(i) for i in input().split()]
mem_point = np.array([K for i in range(N)])
_points = np.array([-1 for i in range(N)])
for rounds in range(Q):
  anser = int(input())
  temp = _points.copy()
  temp[anser-1] = 0
  mem_point += temp
for point in mem_point:
  if 0 < point:
    print("Yes")
  else:
    print("No")
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int,input().split()))
cnt = 1
dis = 0
for i in range(n):
  dis += l[i]
  if dis > x:
    break
  cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int,iput().split()))
cnt = 1
dis = 0
for i in range(n):
  dis += l[i]
  if dis > x:
    break
  cnt += 1
print(cnt)
Problem p03027 (python)

Fixed submission:
mod = 10**6+3
max = 10**6+2
g1 = [1, 1]
for i in range( 2, max + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
def rev(a):
    return pow(a,mod-2,mod)
def f(x,d,n):
    if d==0:
        return pow(x,n,mod)
    else:
        d_r = rev(d)
        xdr = d_r * x % mod
        if xdr==0:
            return 0
        elif (xdr+n-1)>=mod:
            return 0
        else:
            return (g1[xdr+n-1]*rev(g1[xdr-1]%mod)*pow(d,n,mod))%mod
ans = []
q = int(input())
for _ in range(q):
    x,d,n = map(int,input().split())
    ans.append(f(x,d,n))
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
import numpy as np
q = int(input())
ans = []
for _ in range(q):
    x,d,n = map(int,input().split())
    a = np.arange(x,x+n*d,d)
    ans.append(np.prod(a)%1000003)
for i in ans:
    print(i)
Problem p03039 (python)

Fixed submission:
n,m,k = map(int,input().split())
ans = 0
mod = 10**9+7
max = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, max + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
C = cmb(m*n-2,k-2,mod)
for i in range(1,n):
    ans += (i*(n-i)*(m**2))*C
for i in range(1,m):
    ans += (i*(m-i)*(n**2))*C
print(ans%mod)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
ans = 0
MOD = 10**9+7
from scipy.special import comb
C = comb(m*n-2,k-2,exact=True)%MOD
for i in range(1,n):
    ans += (i*(n-i)*(m**2))*C
for i in range(1,m):
    ans += (i*(m-i)*(n**2))*C
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
ans = 0
MOD = 10**9+7
import  numpy as np
x = np.array([i for i in range(1,n+1)]*m)
y = np.array([i for i in range(1,m+1)]*n)
npabs = np.frompyfunc(abs,1,1)
for i in range(len(x)-1):
    x_ = x[i:]-x[i]
    x_ = np.sum(npabs(x_))
    y_ = y[i:]-y[i]
    y_ = np.sum(npabs(y_))
    ans += x_+y_
from scipy.special import comb
print((ans*comb(m*n-2,k-2,exact=True))%MOD)
Problem p03044 (python)

Fixed submission:
n = int(input())
v = [list(map(int,input().split())) for _ in range(n-1)]
g = {}
for a,b,w in v:
    if a not in g:
        g[a] = []
    if b not in g:
        g[b] = []
    g[a].append([b,w])
    g[b].append([a,w])
from collections import deque
queue = deque([[1,0]])
b = [-1]*n
b[0] = 0
while queue:
    q,d = queue.popleft()
    if d%2==1:
        b[q-1] = 0
    else:
        b[q-1] = 1
    for new_q in g[q]:
        v_,d_ = new_q
        if b[v_-1]==-1:
            queue.appendleft([v_,d+d_])
for i in b:
    print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = [list(map(int,input().split())) for _ in range(n-1)]
g = {}
for a,b,w in v:
    if a not in g:
        g[a] = []
    g[a].append([b,w])
from collections import deque
queue = deque([[1,0]])
b = deque()
done = set([])
while queue:
    q,d = queue.popleft()
    if d%2==1:
        b.appendleft(q)
    done |= set([q])
    for new_q in g[q]:
        v_,d_ = new_q
        if v_ not in done:
            queue.appendleft([v_,d+d_])
for i in range(1,n+1):
    if i in b:
        print(1)
    else:
        print(0)
Problem p03050 (python)

Fixed submission:
n = int(input())
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
div = make_divisors(n)
for i in div[1:]:
    if n//(i-1)==n%(i-1):
        ans += i-1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(int(n**0.5)-1,n):
    if n%i==n//i:
        ans +=1

print(ans)
Problem p03096 (python)

Fixed submission:
n = int(input())
c = [0] + [int(input()) for _ in range(n)]
dp = [0] * (200001)
num = 1
for i in range(n):
    if c[i]!=c[i+1]:
        num += dp[c[i+1]]
        dp[c[i+1]] = num
print(num%(10**9+7))

Buggy submission (verdict: Runtime Error):
n = int(input())
c = [0] + [int(input()) for _ in range(200001)]
dp = [0] * (n+1)
num = 1
for i in range(n):
    if c[i]!=c[i+1]:
        num += dp[c[i+1]]
        dp[c[i+1]] = num
print(num%(10**9+7))

Buggy submission (verdict: Runtime Error):
n = int(input())
c = [0] + [int(input()) for _ in range(n)]
dp = [0] * (n+1)
num = 1
for i in range(n):
    if c[i]!=c[i+1]:
        num += dp[c[i+1]]
        dp[c[i+1]] = num
print(num)
Problem p03111 (python)

Fixed submission:
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 10**9
def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Buggy submission (verdict: Runtime Error):
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(n)]
INF = 10**9
def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret2 = dfs(cur+1,a+l[cur],b,c)+10
    ret3 = dfs(cur+1,a,b+l[cur],c)+10
    ret4 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))
Problem p03112 (python)

Fixed submission:
a,b,q = map(int,input().split())
s = [-float('inf')]+[int(input()) for i in range(a)]+[float('inf')]
t = [-float('inf')]+[int(input()) for i in range(b)]+[float('inf')]
x = [int(input()) for i in range(q)]
import bisect
for x_ in x:
    s_r = bisect.bisect_right(s,x_)
    t_r = bisect.bisect_right(t,x_)
    res = float('inf')
    for S in [s[s_r-1],s[s_r]]:
        for T in [t[t_r-1],t[t_r]]:
            d1 = abs(S-x_)+abs(T-S)
            d2 = abs(T-x_)+abs(S-T)
            res = min(res,d1,d2)
    print(res)

Buggy submission (verdict: Runtime Error):
a,b,q = map(int,input().split())
s = [-float('inf')]+[int(input()) for i in range(a)]+[float('inf')]
t = [-float('inf')]+[int(input()) for i in range(b)]+[float('inf')]
x = [int(input()) for i in range(q)]
import bisect
for x_ in x:
    s_r = bisect.bisect_right(s,x_)
    t_r = bisect.bisect_right(s,x_)
    res = float('inf')
    for S in [s[s_r-1],s[s_r]]:
        for T in [t[t_r-1],t[t_r]]:
            d1 = abs(S-x_)+abs(T-S)
            d2 = abs(T-x_)+abs(S-T)
            res = min(res,d1,d2)
    print(res)

Buggy submission (verdict: Runtime Error):
a,b,q = map(int,input().split())
s = [-float('inf')]+[int(input()) for i in range(a)]+[float('inf')]
t = [-float('inf')]+[int(input()) for i in range(b)]+[float('inf')]
x = [int(input()) for i in range(q)]
import bisect
for x_ in x:
    s_r = bisect.bisect_right(s,x_)
    t_r = bisect.bisect_right(s,x_)
    res = INF
    for S in [s[s_r-1],s[s_r]]:
        for T in [t[t_r-1],t[t_r]]:
            d1 = abs(S-x_)+abs(T-S)
            d2 = abs(T-x_)+abs(S-T)
            res = min(res,d1,d2)
    print(res)

for ans_ in ans:
    print(ans_)
Problem p03240 (python)

Fixed submission:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh = sorted(xyh, key = lambda x: -x[2])
tx, ty, th = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = th + abs(tx - Cx) + abs(ty - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        H = l[0][2]+abs(i-l[0][0])+abs(j-l[0][1])
        for k in range(1,n):
            if not h==max(H-abs(i-l[k][0])-abs(j-l[k][1]), 0):
                break
            if k==n-1 and h>0:
                print(i,j,h)
                import sys
                sys.exit()
Problem p03244 (python)

Fixed submission:
n = int(input())
v = list(map(int,input().split()))
l1 = []
l2 = []
for i,v_ in enumerate(v):
    if i%2==0:
        l1.append(v_)
    else:
        l2.append(v_)

from collections import Counter
if len(set(v))==1:
    print(n//2)
else:
    c1 = Counter(l1).most_common(2)
    c2 = Counter(l2).most_common(2)
    if c1[0][0]==c2[0][0]:
        print(n-max(c1[0][1]+c2[1][1], c1[1][1]+c2[0][1]))
    else:
        print(n-c1[0][1]-c2[0][1])

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))
l1 = []
l2 = []
for i,v_ in enumerate(v):
    if i%2==0:
        l1.append(v_)
    else:
        l2.append(v_)

from collections import Counter
if set(l1)==set(l2):
    print(n//2)
else:
    c1 = Counter(l1).most_common(2)
    c2 = Counter(l2).most_common(2)
    if c1[0][0]==c2[0][0]:
        print(n-max(v[0][1]+v[1][1], v[1][1]+v[0][1]))
    else:
        print(n-v[0][1]-v[0][1])
Problem p03316 (python)

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

Buggy submission (verdict: Runtime Error):
n = str(input())
sum = 0
for i in range(len(n)):
    sum += int(n[i])
if n%sum==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = str(input())
sum = 0
for i in range(len(n)):
    sum += int(n[i])
if n%sum=0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = str(input())
sum = 0
for i in n:
    sum += int(i)
if n%sum=0:
    print('Yes')
else:
    print('No')
Problem p03325 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
memo = {}
def f(i):
    if i in memo.keys():
        return memo[i]
    if i==0 or i%2==1:
        return 0
    else:
        memo[i] = 1+f(i//2)
        return memo[i]
ans = 0
for a_ in a:
    ans += f(a_)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
memo = [0 for i in range(1000001)]
def f(i):
    if memo[i]:
        return memo[i]
    if i==0 or i%2==1:
        return 0
    else:
        memo[i] = 1+f(i//2)
        return memo[i]
ans = 0
for a_ in a:
    ans += f(a_)
print(ans)
Problem p03338 (python)

Fixed submission:
n = int(input())
s = input()
l = []
if n==2:
    if s[0]==s[1]:
        print(1)
    else:
        print(0)
else:
    for i in range(1,len(s)-1):
        a = set(list(s[:i]))
        b = set(list(s[i:]))
        l.append(len(a & b))
    print(max(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
l = []
for i in range(1,len(s)-1):
    a = set(list(s[:i]))
    b = set(list(s[i:]))
    l.append(len(a & b))
print(max(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
l = []
for i in range(1,len(s)-1):
    a = set(list(s[:i]))
    b = set(list(s[i:]))
    l.append(len(a & b))
print(max(l))
Problem p03361 (python)

Fixed submission:
h,w = map(int,input().split())
s = ['.'*(w+2)]+['.'+input()+'.' for _ in range(h)]+['.'*(w+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=='#':
            if s[i-1][j]=='#' or s[i+1][j]=='#' or s[i][j-1]=='#' or s[i][j+1]=='#':
                continue
            else:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            if s[i-1][j]=='#' or s[i+1][j]=='#' or s[i][j-1]=='#' or s[i][j+1]=='#':
                continue
            else:
                print('No')
                exit()
print('Yes')
Problem p03378 (python)

Fixed submission:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
x_s = 0
x_l = 0
for i in range(m):
    if x>a[i]:
        x_l+=1
    else:
        x_s+=1
print(min(x_s,x_l))

Buggy submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
a = [int(input()) for i in range(m)]
x_s = 0
x_l = 0
for i in range(m):
    if x>a[i]:
        x_l+=1
    else:
        x_s+=1
print(min(x_s,x_l))
Problem p03379 (python)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
x_ = x.copy()
x_.sort()
l = x_[len(x)//2-1]
r = x_[len(x)//2]
for i in range(len(x)):
    if x[i]<=l:
        print(r)
    else:
        print(l)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
x_ = x.copy()
x_.sort()
l = x_[len(x)//2-1]
r = x_[len(x)//2+1]
for i in range(len(x)):
    if x[i]<=l:
        print(r)
    else:
        print(l)
Problem p03380 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a_ = sorted(a)
if len(a)==2:
    print(a_[1],a_[0])
    exit()
a = a_[::-1]
k = 10**9
for i in range(1,n):
    if k>abs(a[0]/2-a[i]):
        k=abs(a[0]/2-a[i])
        ans = [a[0],a[i]]
print(ans[0],ans[1])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a_ = sorted(a)
if len(a)==2:
    print(a_[1],a_[0])
    exit()
a = a_[::-1]
k = 10**5
for i in range(1,n):
    if k>abs(a[0]//2-a[i]):
        k=abs(a[0]//2-a[i])
        ans = [a[0],a[i]]
print(ans[0],ans[1])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a_ = sorted(a)
if len(a)==2:
    print(a_[1],a_[0])
    exit()
a = a_[::-1]
k = 10**5
for i in range(1,n):
    if k>abs(a[0]/2-a[i]):
        k=abs(a[0]/2-a[i])
        ans = [a[0],a[i]]
print(ans[0],ans[1])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a_ = sorted(a)
if len(a)==2:
    print(a_[1],a_[0])
    exit()
a = a_[::-1]
import bisect
import math
def combinations_count(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
ret = 0
for i in range(10):
    k = bisect.bisect_left(a_,a[i]//2)
    if a[i]//2-a_[k]>a_[k+1]-a[i]//2:
        k += 1
    cmb = combinations_count(a[i],a_[k])
    if ret<cmb:
        ans = [a[i],a_[k]]
        ret = cmb
print(ans[0],ans[1])
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
ans = []
for i in range(a,a+k):
    if i>b:
        break
    ans.append(i)
for i in range(b,b-k,-1):
    if i<a:
        break
    ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input()split())
ans = []
for i in range(a,a+k+1):
    if i>b:
        break
    ans.append(i)
for i in range(b,b-k-1,-1):
    if i<a:
        break
    ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
    print(ans)