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

Fixed submission:
import itertools
import math
N=int(input())
a=[]
kyori_list=[]
for i in range(N):
    x,y=map(int,input().split())
    a.append((x,y))
for j in itertools.permutations(a):
    k=list(j)
    
    cnt=0
    sum=0
    while cnt<N-1:
        kryoi=0
        kyori=((k[cnt+1][0]-k[cnt][0])**2+(k[cnt+1][1]-k[cnt][1])**2)**(1/2)
        cnt+=1
        
        sum+=kyori
    kyori_list.append(sum)
c=0

for i in kyori_list:
    c+=i
    
    
print(c/math.factorial(N))

Buggy submission (verdict: Runtime Error):
mport itertools
import math
N=int(input())
a=[]
kyori_list=[]
for i in range(N):
    x,y=map(int,input().split())
    a.append((x,y))
for j in itertools.permutations(a):
    k=list(j)
    
    cnt=0
    sum=0
    while cnt<N-1:
        kryoi=0
        kyori=((k[cnt+1][0]-k[cnt][0])**2+(k[cnt+1][1]-k[cnt][1])**2)**(1/2)
        cnt+=1
        
        sum+=kyori
    kyori_list.append(sum)
c=0

for i in kyori_list:
    c+=i
    
    
print(c/math.factorial(N))
Problem p02923 (python)

Fixed submission:
N=int(input())
h=list(map(int,input().split()))
idou=[]
i=0
cnt=0
if N==1:
    print(0)
elif N==2:
    if h[1]-h[0]<=0:
        print(1)
    else:
        print(0)
else:
    while i<=N-2:
        if h[i]>=h[i+1]:
            cnt+=1
            if i==N-2:
                idou.append(cnt)
        else:
            idou.append(cnt)
            cnt=0
        i+=1

    print(max(idou))

Buggy submission (verdict: Runtime Error):
N=int(input())
h=list(map(int,input().split()))
idou=[]
i=0
cnt=0
if N==1:
    print(0)
elif N==2:
    if h[1]-h[0]>=0:
        print(1)
    else:
        print(0)
else:
    while i<=N-2:
        if h[i]>=h[i+1]:
            cnt+=1
            if i==N-2:
                idou.append(cnt)
        else:
            idou.append(cnt)
            cnt=0
        i+=1

print(max(idou))

Buggy submission (verdict: Runtime Error):
N=int(input())
h=list(map(int,input().split()))
idou=[]
i=0
cnt=0
while i<=N-2:
    if h[i]>=h[i+1]:
        cnt+=1
        if i==N-2:
            idou.append(cnt)
    else:
        idou.append(cnt)
        cnt=0
    i+=1

print(max(idou))
Problem p03000 (python)

Fixed submission:
N,X=map(int,input().split())
l=list(map(int,input().split()))
d=0
cnt=1
while True:
    
    d+=l[cnt-1]
    if d>X:
        print(cnt)
        break
    cnt+=1
    if cnt==N+1:
        print(N+1)
        break
else:
    
    print(cnt)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
l=list(map(int,input().split()))
d=0
cnt=1
while True:
    
    d+=l[cnt-1]
    if d>X:
        print(cnt)
        break
    cnt+=1
    
else:
    
    print(cnt)
Problem p03030 (python)

Fixed submission:
N=int(input())
rest=[]
for i in range(1,N+1):
    s,p=input().split()
    p=int(p)
    rest.append((s,-p,i))

x=sorted(rest)


for i in range(N):
    print(x[i][2])

Buggy submission (verdict: Runtime Error):
N=int(input())
rest=[]
for i in range(1,N+1):
    s,p=input().split()
    p=int(p)
    rest.append((s,-p,i))



for i in range(N):
    print(x[i][2])

Buggy submission (verdict: Runtime Error):
N=int(input())
rest=[]
for i in range(1,N+1):
    s,p=input().split()
    p=int(p)
    rest.append((s,-p,i))


print(x)
for i in range(N):
    print(x[i][2])
Problem p03071 (python)

Fixed submission:
a=list(map(int,input().split()))
if a[0]==a[1]:
    print(2*a[0])
else:
    print(2*max(a)-1)

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
if a[0]==a[1]:
  　print(2*a[0])
else:
　　print(2max(a)-1)
Problem p03076 (python)

Fixed submission:
a=[]
b=[]
for _ in range(5):
    a.append(int(input()))
for i in  a:
    if i%10!=0:
        b.append(10-i%10)
if b:
             
    b.remove(max(b))
c=sum(b)
print(sum(a)+c)

Buggy submission (verdict: Runtime Error):
a=[]
b=[]
for _ in range(5):
    a.append(int(input()))
for i in  a:
    if i%10!=0:
        b.append(10-i%10)
if b:
             
    b.remove(max(b))
c=sum(b)
print(sum(a)+c)
print(sum(l))

Buggy submission (verdict: Runtime Error):
a=[]
b=[]
for _ in range(5):
    a.append(int(input()))
for i in  a:
    if i%10!=0:
        b.append(10-i%10)
b.remove(max(b))
c=sum(b)
print(sum(a)+c)
Problem p03086 (python)

Fixed submission:
S=input()
b=["A","T","G","C"]
cntl=[]
cnt=0
for i in S:
    if i in b:
        cnt+=1
    else:
        cntl.append(cnt)
        cnt=0
else:
    cntl.append(cnt)
print(max(cntl))

Buggy submission (verdict: Runtime Error):
S=input()
b=["A","T","G","C"]
cntl=[]
cnt=0
for i in S:
    if i in b:
        cnt+=1
    else:
        cntl.append(cnt)
        cnt=0
print(max(cntl))
Problem p03103 (python)

Fixed submission:
N,M=map(int,input().split())
shop=[]
for _ in range(N):
    a=list(map(int,input().split()))
    shop.append(a)
shop.sort(key=lambda x: x[0])
cnt=0
p=0
i=0

while cnt<M:
    a=shop[i][0]
    b=shop[i][1]
    cnt+=b
    p+=a*b
    i+=1
su=cnt-M

a = shop[i-1][0]
p-=a*su
print(p)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
shop=[]
for _ in range(N):
    a=list(map(int,input().split()))
    shop.append(a)
shop.sort(key=lambda x: x[0])
cnt=0
p=0
i=0

while cnt<=M:
    a=shop[i][0]
    b=shop[i][1]
    cnt+=b
    p+=a*b
    i+=1
su=cnt-M

a = shop[i-1][0]
p-=a*su
print(p)
Problem p02772 (python)

Fixed submission:
import numpy as np
import sys

n = int(input())
a = list(map(int, input().split()))
a = np.array(a)
a = a[a%2==0]

for i, j  in enumerate(a):
    if j%3 != 0 and j%5 != 0:
        print("DENIED")
        sys.exit()

print("APPROVED")

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.array(a)
a = a[a%2==0]

for i in range(n):
    if a[i]%3 != 0 and a[i]%5 != 0:
        return print("APPROVED")

return print("DENIED")
Problem p02780 (python)

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

#期待値L
L = [0 for _ in range(N)]
for i in range(N):
    L[i] = (1+P[i])/2

#累積和S
S = [0 for i in range(N)]
S[0] = L[0]
for i in range(1, N):
    S[i] = S[i-1] + L[i]

total = S[K-1]
for i in range(N-K):
    tmp = S[i+K]-S[i]
    if total < tmp:
        total = tmp

print(total)

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

#そのサイコロの期待値の合計
e_list = []
for i in range(N):
    e_list.append((1+p_list[i])/2.0)

#累積和
s_list = []
for i in range(N):
    s_list.append(sum(e_list[:i+1]))

#隣接するk個の和
for i in range(N-K+1):
    s_sum = s_list[i+K-1] - s_list[i]
    if dst < s_sum:
        dst = s_sum
print(dst)

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

dst = 0

for i in range(N-K+1):
    print("i : {}".format(i))
    p_sum = 0
    for j in range(K):
        p = p_list[i+j]
        print("p : {}".format(p))
        p_sum += ( p/2 * (1+p)) / p
    if p_sum > dst:
        dst = p_sum
    
print(dst)

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

dst = 0

for i in range(N-K+1):
  p_sum = 0
  for j in range(K):
    p = p[j]
    p_sum += p/2 * (1+p)
  if p_sum > dst:
    dst = p_sum
    
print(dst)
Problem p02786 (python)

Fixed submission:
h = int(input())
a = 0
while h > 0:
    h = h//2
    a += 1
  
print(2**a-1)

Buggy submission (verdict: Runtime Error):
h = int(input())
a = 0
while h > 0:
    h = h//2
    a += 1

f[0] = h
  
print(2**a-1)
Problem p02838 (python)

Fixed submission:
import numpy as np

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

mod = 10 ** 9 + 7
s = 0

for i in range(60):# Aは2の6乗より小さい
    c = np.count_nonzero(A & 1) # 最下位のbitで0じゃないものの個数
    s += 2 ** i * c * (N - c) # https://qiita.com/ZhangChaoran/items/0d59eb5c95cd9414801d
    A >>= 1 #　1bitずつ右にずらす。これを繰り返し続ける
print(s % mod)

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

ans = 0

for i in range(N-1):
  for j in range(i+1, N):
    ans += (A[i]^A[j])
    
print(ans%(10**9+7))

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

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

xor_sum = 0
for i in range(N-1):
  for j in range(i+1, N):
    xor_sum += (A[i]^A[j])

dst = xor_sum % (10**9+7)
print(dst)

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


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

xor_sum = 0
for i in range(N-1):
  for j in range(i+1, N):
    xor_sum += (A[i]^A[j])

dst = xor_sum % (10**9+7)
print(dst)

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


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

sum = 0
for i in range((N-1)-1):
  for j in range(i+1, (N-1)):
    sum += (A[i]^A[j])

dst = sum % (10**9+7)
print(dst)

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


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

sum = 0
for i in range(N-1):
  for j in range(i+1, N):
    sum += (A[i]^A[j])

dst = sum % (10**9+7)
print(dst)

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


N = input()
A = input().split()

sum = 0
for i in range(N-1):
  for j in range(i+1, N):
    sum += (A[i]^A[j])

dst = sum % (10**9+7)
print(dst)

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


N = input()
A = [input().split() for i in range(N)]

sum = 0
for i in range(N-1):
  for j in range(i+1, N):
    sum += (A[i]^A[j])

dst = sum % (10**9+7)
print(dst)
Problem p02772 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
 
flag = True
for a in A:
  if a%2 == 0:
    if a%3 != 0 and a%5 != 0:
      flag = False
 
if flag:
  print('APPROVED')
else:
  print('DENIED')

Buggy submission (verdict: Runtime Error):
import numpy as np
 
stdin = open(0)
data = np.fromstring(stdin.read(), np.int32, sep=' ')
N = data[0]
A = data[1]

flag = True
for a in A:
  if a%2 == 0:
    if a%3 != 0 or a%5 != 0:
      flag = False

if flag:
  print('APPROVED')
else:
  print('DENIED')
Problem p02936 (python)

Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline
        
N,Q = (int(i) for i in input().split())
A = [[] for _ in range(N)]

for _ in range(N-1):
    a,b = (int(i) for i in input().split())
    A[a-1].append(b-1)
    A[b-1].append(a-1)

cnt = [0]*N   
for q in range(Q):
   p,x = (int(i) for i in input().split())
   cnt[p-1] += x

st = deque([(0,-1)])
while st:
    n,par = st.popleft()
    val = cnt[n]   
    for node in A[n]:
        if node == par:
            continue
        else:
            cnt[node] += val
            st.append([node,n])

print(*cnt)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,Q = map(int, input().split())
chi = np.zeros((N,N))

for n in range(N-1):
    a,b = map(int, input().split())
    chi[a-1,b-1] = 1
    for i in range(N):
        if chi[i,a-1] > 0:
            chi[i] += chi[a-1] 
            
cnt = [0]*N   
for q in range(Q):
   p,x = map(int, input().split())
   cnt[p-1] += x
   for i in range(N):
       if chi[p-1,i] > 0:
           cnt[i] += x

for n in range(N):
    print(cnt[n], end=" ")

Buggy submission (verdict: Runtime Error):
import numpy as np
N,Q = map(int, input().split())
chi = np.zeros((N,N))

for n in range(N-1):
    a,b = map(int, input().split())
    chi[a-1,b-1] = 1
    for i in range(N):
        if chi[i,a-1] > 0:
            chi[i] += chi[a-1] 
            
cnt = [0]*N   
for q in range(Q):
   p,x = map(int, input().split())
   cnt[p-1] += x
   for i in range(N):
       if chi[p-1,i] > 0:
           cnt[i] += x

for n in range(N):
    print(cnt[n], end=" ")
Problem p03031 (python)

Fixed submission:
N,M = map(int, input().split())
ks = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()] 

ans = 0

for i in range(1 << N):
    cnt_on = [0]*M
    for j in range(N):
        if ((i >> j) & 1) == 1:
            for m in range(M):
                cnt_on[m] += ks[m][1:].count(j+1)

    c = 0
    for m in range(M):
        if cnt_on[m]%2 == p[m]:
            c += 1
    
    if c == M:
        ans += 1


print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
ks = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()] 

l = max(max(ks))

lis_swi = s = [[] for i in range(l)]

for m in range(M):
    for s in ks[m][1:]:
        lis_swi[s-1].append(m)


ans = 0

for i in range(1 << l):
    cnt_on = [0]*M
    for j in range(l):
        if ((i >> j) & 1) == 1:
            for m in lis_swi[j]:
                cnt_on[m] +=1

    f = True
    for m in range(M):
        if cnt_on[m]%2 != p[m]:
            f = False
            break
    
    if f:
        ans += 1


print(ans)
Problem p03039 (python)

Fixed submission:
N,M,K = map(int, input().split())
mod = 10**9+7
nm = N*M
n2 = (N**2)%mod
m2 = (M**2)%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

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, 10**6 +1):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for x in range(1,M):
    ans += x*(M-x)*n2*cmb(nm-2,K-2,mod)
    ans %= mod

for y in range(1,N):
    ans += y*(N-y)*m2*cmb(nm-2,K-2,mod)
    ans %= mod

print(int(ans))

Buggy submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
mod = 10**9+7
nm = N*M
n2 = (N**2)%mod
m2 = (M**2)%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

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, 10**4 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for x in range(1,M):
    ans += x*(M-x)*n2*cmb(nm-2,K-2,mod)
    ans %= mod

for y in range(1,N):
    ans += y*(N-y)*m2*cmb(nm-2,K-2,mod)
    ans %= mod

print(int(ans))
Problem p03070 (python)

Fixed submission:
N = int(input())
a = [int(input()) for _ in range(N)]

s = sum(a)
mod = 998244353

dp1 = [0] * (s+1)
dp2 = [0] * (s+1)
dp1[0] = 1
dp2[0] = 1
sum_ = 0


ans = 0
for n in range(N):
    for i in reversed(range(sum_+1)):
        dp1[i] %= mod
        dp2[i] %= mod
        dp1[i+a[n]] += dp1[i]
        dp1[i] <<= 1
        dp2[i+a[n]] += dp2[i]
    #print(dp1,dp2)
    sum_ += a[n]

ans = (3 ** N)%mod
for i in range(s+1):
    if i*2 >= s:
        ans -= dp1[i]*3 + mod*3
        ans %= mod
    if i*2 == s:
        ans += dp2[i]*3
        ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for _ in range(N)]

s = sum(a)
mod = 998244353

dp1 = [0] * (s+1)
dp2 = [0] * (s+1)
dp1[0] = 1
dp2[0] = 1
sum_ = 0


ans = 0
for n in range(N):
    for i in reversed(range(sum_+1)):
        dp1[i] %= mod
        dp2[i] %= mod
        dp1[i+a[n]] += dp1[i]
        dp1[i] <<= 1
        dp2[i+a[n]] += dp2[i]
    print(dp1,dp2)
    sum_ += a[n]

ans = (3 ** N)%mod
for i in range(s+1):
    if i*2 >= s:
        ans -= dp1[i]*3 + mod*3
        ans %= mod
    if i*2 == s:
        ans += dp2[i]*3
        ans %= mod

print(ans)
Problem p03081 (python)

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

t = [0]*Q
d = [0]*Q
for q in range(Q):
    t[q],d[q] = map(str, input().split())


s1 = 0
sN = N-1

for q in reversed(range(Q)):
    if t[q] == S[s1] and d[q] == 'L':
        s1 += 1
    elif s1 > 0:
        if d[q] == 'R' and S[s1-1] == t[q]:
            s1 -= 1
    if t[q] == S[sN] and d[q] == 'R':
        sN -= 1
    elif sN < N-1:
        if d[q] == 'L' and S[sN+1] == t[q]:
            sN += 1
    if s1 > sN:
        break
    #print(s1,sN)


print(sN-s1+1)

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

t = [0]*Q
d = [0]*Q
for q in range(Q):
    t[q],d[q] = input().split()


s1 = 0
sN = N-1

for q in reversed(range(Q)):
    if t[q] == S[s1] and d[q] == 'L':
        s1 += 1
    elif s1 > 0:
        if d[q] == 'R' and S[s1-1] == t[q]:
            s1 -= 1
    if t[q] == S[sN] and d[q] == 'R':
        sN -= 1
    elif sN < N-1:
        if d[q] == 'L' and S[sN+1] == t[q]:
            sN += 1
    #print(s1,sN)


print(sN-s1+1)

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

t = [0]*Q
d = [0]*Q
for q in range(Q):
    t[q],d[q] = map(str, input().split())


s1 = 0
sN = N-1

for q in reversed(range(Q)):
    if t[q] == S[s1] and d[q] == 'L':
        s1 += 1
    elif s1 > 0:
        if d[q] == 'R' and S[s1-1] == t[q]:
            s1 -= 1
    if t[q] == S[sN] and d[q] == 'R':
        sN -= 1
    elif sN < N-1:
        if d[q] == 'L' and S[sN+1] == t[q]:
            sN += 1
    #print(s1,sN)


print(sN-s1+1)

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

t = [0]*Q
d = [0]*Q
for q in range(Q):
    t[q],d[q] = map(str, input().split())


s1 = 0
sN = N-1

for q in reversed(range(Q)):
    if t[q] == S[s1] and d[q] == 'L':
        s1 += 1
    elif s1 > 0:
        if d[q] == 'R' and S[s1-1] == t[q]:
            s1 -= 1
    if t[q] == S[sN] and d[q] == 'R':
        sN -= 1
    elif sN < N-1:
        if d[q] == 'L' and S[sN+1] == t[q]:
            sN += 1
    #print(s1,sN)


print(sN-s1+1)

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

t = [0]*Q
d = [0]*Q
for q in range(Q):
    t[q],d[q] = map(str, input().split())


s1 = 0
sN = N-1

for q in reversed(range(Q)):
    if t[q] == S[s1]:
        if d[q] == 'L':
            s1 += 1
    if t[q] == S[sN]:
        if d[q] == 'R':
            sN -= 1
    #print(s1,sN)


print(sN-s1+1)
Problem p03095 (python)

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

alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
count = [1]*26

for n  in range(N):
    for a in range(26):
        if S[n] == alp[a]:
            count[a] += 1

ans = 1
for a in range(26):
    ans *= count[a]
    ans %= 10**9+7

ans -= 1

print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math

n, s = input().split()
N = int(n)
S = [str(i) for i in s] 

counter = [0] * 26
alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(26):
    counter[i] = S.count(alp[i])

syu = 0
for i in range(26):
    if counter[i] > 0:
        syu += 1

ans = 0
for k in range(1,syu+1):
    ans += math.factorial(N) // (math.factorial(N - k) * math.factorial(k))
    #print(ans)

for a in range(26):
    num = counter[a]
    mod = N - num 
    if num == 2:
        ans -= num - 1
        for k in range(3,syu+1):
            #print(k)
            ans -= math.factorial(mod) // (math.factorial(mod - k+num) * math.factorial(k-num))
    if num > 2:
        itr = math.factorial(num) // (math.factorial(num - 2) * math.factorial(2))
        ans -= (num - 1) * itr
        for k in range(3,syu+1):
            itr = math.factorial(num) // (math.factorial(num - k) * math.factorial(k))
            ans -= (math.factorial(mod) // (math.factorial(mod - k+num) * math.factorial(k-num)))*itr

print(ans)
Problem p03290 (python)

Fixed submission:
D, G = map(int, input().split())
p = [0]*D
c = [0]*D
for d in range(D):
    p[d], c[d] = map(int, input().split())

time_list = []
for i in range(1<<D):
    point = 0
    time = 0
    output = []
    #for j in range(D): 
        #print(i,j+1,bin(i>>j))
        #if ((i >> j) & 1) == 1: #ある数と1とのANDを取ることは，その数の右端のbitが0か1を調べることに等しい．iの右からj+1番目のbitが1かどうかを確認している．
            #output.append(A[j])
    #print(output)
    for d in range(D):
        if ((i>>d) & 1) == 1:
            point += 100*(d+1)* p[d] + c[d]
            time += p[d]
    if point < G:
        # iで一番左側にある0を探す。
        for d in range(D)[::-1]:
            if ((i>>d) & 1) == 0: # and論理積は1==1以外はすべてfalse
                for k in range(p[d]):
                    if point < G:
                        point += 100*(d+1) 
                        time += 1
                    else: break
                break
            else: continue
    if point >= G:
        time_list.append(time)
print(min(time_list))

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
p = [0]*D
c = [0]*D
for d in range(D):
    p[d], c[d] = map(int, input().split())

time_list = []
for i in range(1<<D):
    point = 0
    time = 0
    output = []
    for j in range(D): 
        #print(i,j+1,bin(i>>j))
        if ((i >> j) & 1) == 1: #ある数と1とのANDを取ることは，その数の右端のbitが0か1を調べることに等しい．iの右からj+1番目のbitが1かどうかを確認している．
            output.append(A[j])
    #print(output)
    for d in range(D):
        if ((i>>d) & 1) == 1:
            point += 100*(d+1)* p[d] + c[d]
            time += p[d]
    if point < G:
        # iで一番左側にある0を探す。
        for d in range(D)[::-1]:
            if ((i>>d) & 1) == 0: # and論理積は1==1以外はすべてfalse
                for k in range(p[d]):
                    if point < G:
                        point += 100*(d+1) 
                        time += 1
                    else: break
                break
            else: continue
    if point >= G:
        time_list.append(time)
print(min(time_list))
Problem p03339 (python)

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

E = [0]*(N+2)
W = [0]*(N+2)
for i in range(1,N+1):
    if S[i-1] == 'E':
        E[i] = E[i-1] + 1
        W[i] = W[i-1]
    else:
        W[i] = W[i-1] + 1
        E[i] = E[i-1]

ans = 300000
for L in range(1,N+1):
    num = E[N] - E[L] + W[L-1] -W[0]
    if ans > num:
        ans = num

print(ans)

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

E = [0]*(N+2)
W = [0]*(N+2)
for i in range(1,N+1):
    if S[i-1] == 'E':
        E[i] = E[i-1] + 1
        W[i] = W[i-1]
    else:
        W[i] = W[i-1] + 1
        E[i] = E[i-1]
#print(E)
#print(W)
ans = N
for l in range(1,N+2):
    num = E[N]-E[l+1]
    num += W[l-1]-W[0]
    if ans >= num:
        ans = num

print(ans)
Problem p02921 (python)

Fixed submission:
S = list(input())
T = list(input())
l = 0
for i in range(len(S)):
  if S[i] == T[i]:
    l += 1
print(l)

Buggy submission (verdict: Runtime Error):
S = list(input())
T = list(input())
l = 0
for i in range(len(s)):
  if S[i] == T[i]:
    l += 1
print(l)
Problem p03035 (python)

Fixed submission:
A,B = map(int,input().split())
print(B if A >= 13 else 0 if A  <= 5 else B//2)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
L1, R1 = map(int, input().split())
flag = 0
def find_key(L1,R1,L2,R2):
  if R1 < L2 or R2 < L1:
    return(False)
  else:
    a = [R1,L1,R2,L2]
    a.sort()
    return(a[1],a[2])

for i in range(M - 1):
  L,R = map(int, input().split())
  if find_key(L1,R1,L,R) != False:
    L1,R1 = find_key(L1,R1,L,R)
  else:
    flag = 1
    print(0)
    break
if flag = 0:
  print(R1-L1+1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
L1, R1 = map(int, input().split())
flag = 0
def find_key(L1,R1,L2,R2):
  if R1 < L2 or R2 < L1:
    print(0)
    flag = 1
    break
  else:
    a = [R1,L1,R2,L2]
    a.sort()
    return(a[1],a[2])

for i in range(M - 1):
  L,R = map(int, input().split())
  L1,R1 = find_key(L1,R1,L,R)
if flag == 1:
  print(L1,R1)

Buggy submission (verdict: Runtime Error):
year,original = input().split()
if int(year) >= 13:
  print(int(original)
elif 6<=int(year)<=12:
  print(int(original)/2)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
year = input()
original = input()
if int(year) >= 13:
  print(int(original)
elif 6<=int(year)<=12:
  print(int(original)/2)
else:
  print(0)