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

Fixed submission:
n=int(input())
print (3*n*n)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=[int(input()) for i in range(a)]
m=max(b) 
for  i in range(0,a,1):
    if b[i]==m:
        c=b.copy()
        c[i]=0
        print(max(c))
    else:
        print (m)

Buggy submission (verdict: Runtime Error):
n=int(input())
print (3*n*N)
Problem p02971 (python)

Fixed submission:
a=int(input())
b=[int(input()) for i in range(a)]
m=max(b) 

if b.count(m)>=2:
    for i in range(a):
        print (m)
else:
    c=b.copy()
    c.sort(reverse=True)
    m2=c[1]
    for i in range(a):
        if b[i]==m:
            print(m2)
        else:
            print (m)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=[int(input()) for i in range(a)]
m=max(b) 

if b.count(m)>=2:
    for i in range(a):
        print (m)
else:
    b.sort(reverce=True)
    m2=b[1]
    for i in range(a):
        if b[i]==m:
            print(m2)
        else:
            print (m)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=[int(input()) for i in range(a)]
m=max(b) 
for  i in range(0,a,1):
    if b[i]==m:
        c=b.copy()
        c[i]=0
        print(max(c))
    else:
        print (m)
Problem p02993 (python)

Fixed submission:
n=list(map(int,input()))
count=0
for i in (range(3)):
    if n[i]==n[i+1]:
        count+=1
if count>=1:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
n=list(map(int,input()))
for i in (range(3)):
    if n[i]==n[i+1]:
        count+=1
if count>=1:
    print("Bad")
else:
    print("Good")
Problem p02995 (python)

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
x1=b//c-(a-1)//c #ｃの割れるやつ
x2=b//d-(a-1)//d #ｄの割れるやつ
sks=c * d // fractions.gcd(c,d)#最小公倍数　普通ならmathメソッドにある
x3=b//sks-(a-1)//sks#ｃ＊ｄの割れるやつ
ans=b-a+1-(x1+x2-x3)
print (ans)

Buggy submission (verdict: Runtime Error):

import fractions
a,b,c,d=map(int,input().split())
x1=b//c-(a-1)//c #ｃの割れるやつ
x2=b//d-(a-1)//d　#ｄの割れるやつ
sks=c * d // fractions.gcd(c,d)#最小公倍数　普通ならmathメソッドにある
x3=b//sks-(a-1)//sks#ｃ＊ｄの割れるやつ
ans=b-a+1-(x1+x2-x3)
print (ans)

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

x1=b//c-a//c
x2=b//d-a//d
sks=c * d // math.gcd(c,d)
x3=b//sks-a//sks
ans=(x1+x2)-x3
print (ans)
Problem p03032 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
min_nk=min(n,k)
for i in range(min_nk+1):#左
    for j in range(n-min_nk+i,n+1):#右
        count=a[0:i]+a[j:n]
        count.sort()
       # print(count)
        ans=max(ans,sum(count))
        for x in range(1,k-len(count)+1):#消せれば消す
           # print(sum(count[x:]))
            ans=max(ans,sum(count[x:]))
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
min_nk=min(n,k)
for i in range(min_nk+1):#左
    for j in range(n-min_nk+i,n+1):#右
        count=a[0:i]+a[j:n]
        count.sort()
       # print(count)
       ans=max(sum(count))
        for x in range(1,min_nk-len(count)+1):#消せれば消す
           # print(sum(count[x:]))
            ans=max(ans,sum(count[x:]))
print(ans)
Problem p03035 (python)

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

if a<=5:
    print("0")
elif a>=13:
    print(b)
else:
    print(b//2)

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

if a<=5:
    print(0)
elif a>=12:
    print(b)
else:
    print(b//2)
Problem p03060 (python)

Fixed submission:
n=int(input())
a=[]
v=list(map(int,input().split()))
c=list(map(int,input().split()))

for i in range(n):
    if v[i]-c[i]>0:
        a.append(v[i]-c[i])
print(sum(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
v=list(map(int,input().split()))
c=list(map(int,input().split()))
if n==1:
    if v[0]-c[0]<=0:
        print("0")
    else:
        print(v[0]-c[0])
    exit()
for i in range(n):
    if v[i]-c[i]>0:
        a.append(v[i]-c[i])
a.sort()
print(a[-1]+a[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[0]*n
v=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n):
    a[i]=v[i]-c[i]
a.sort()
print(a[-1]+a[-2])
Problem p03061 (python)

Fixed submission:
import fractions
from functools import reduce
n=int(input())
a=list(map(int,input().split()))


l=[0]
r=[0]
for i in range(0,n):
    l.append(fractions.gcd(l[i],a[i]))
    r.append(fractions.gcd(r[i],a[n-i-1]))

#print(l,r)
r=r[::-1]
ans=[]
for i in range(n):
    ans.append(fractions.gcd(l[i],r[i+1]))
print(max(ans))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
n=int(input())
a=list(map(int,input().split()))


l=[0]
r=[0]
for i in range(0,n):
    l.append(math.gcd(l[i],a[i]))
    r.append(math.gcd(r[i],a[n-i-1]))

#print(l,r)
r=r[::-1]
ans=[]
for i in range(n):
    ans.append(math.gcd(l[i],r[i+1]))
print(max(ans))
Problem p03069 (python)

Fixed submission:
n=int(input())
c=str(input())
#c=c[::-1]
#print(c)
black=c.count('#')
white=n-black
left=0#左は黒を消す
right=white#右はしろを消す
#print(white,black)
ans=right
for i in range(n):
    if c[i]=='#':
        left+=1
    else:
        right-=1
    
    ans=min(ans,left+right)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
c=str(input())
c=c[::-1]
#print(c)
c_count=[]
count1=0
count2=0
for i in range(n):
    if c[i]=='.':
        start=i
        break
else:
    print(0)


for i in range(start,n):
    if c[i]=='.':
        if count2!=0:
            c_count.append(count2)
            count2=0
        count1+=1
    else:
        if count1!=0:
            c_count.append(count1)
            count1=0
        count2+=1
        
c_count.append(max(count1,count2))

#print(c_count)
ans=0
for i in range(0,len(c_count)-1,2):
    ans+=min(c_count[i],c_count[i+1])
print(ans)
Problem p03150 (python)

Fixed submission:
s = input()
for i in range(len(s)):
    for j in range(i, len(s)+1):
        if s[:i] + s[j:] == "keyence":
            print("YES")
            exit()
print("NO")

Buggy submission (verdict: Runtime Error):
s=input()
for i in range(len(s)):
    for j in range(i,len(s)+1):
        if s[:i]+s[j]=="keyence":
            print("YES")
            exit()
print("NO")
Problem p03160 (python)

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

dp=[-1]*n
dp[0]=0
dp[1]=abs(a[0]-a[1])

for i in range(2,n):
    dp[i]=min(
        dp[i-2]+abs(a[i]-a[i-2]),
        dp[i-1]+abs(a[i]-a[i-1])
    )
    
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
dp=[-1]*n
dp[0]=0
if n=<x:
    x=n-1
for i in range(1,x+1):
    dp[i]=abs(a[i]-a[0])

for i in range(x+1,n):
    min1=10**9
    for j in range(i-(x),i):  
        if min1>dp[j]+abs(a[j]-a[i]):               
            min1=dp[j]+abs(a[j]-a[i])
    dp[i]=min1
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
dp=[-1]*n
dp[0]=0
if n<x:
    x=n
for i in range(1,x+1):
    dp[i]=abs(a[i]-a[0])

for i in range(x+1,n):
    min1=10**9
    for j in range(i-(x),i):  
        if min1>dp[j]+abs(a[j]-a[i]):               
            min1=dp[j]+abs(a[j]-a[i])
    dp[i]=min1
print(dp[-1])
Problem p03231 (python)

Fixed submission:
import fractions
n,m=map(int,input().split())
s=list(str(input()))
t=list(str(input()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

l=lcm(n, m)
index=fractions.gcd(n,m)
#print(indexn,indexm)
for i in range(index):
    #print(i)
    if s[n//index*i]!=t[m//index*i]:
        print(-1)
        break
else:
    print(l)

Buggy submission (verdict: Runtime Error):
import fractions
n,m=map(int,input().split())
s=list(str(input()))
t=list(str(input()))

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l=lcm(n, m)
index=fractions.gcd(n,m)
#print(indexn,indexm)
for i in range(index):
    #print(i)
    if s[n//index*i]!=t[m//index*i]:
        print(-1)
        break
else:
    print(l)

Buggy submission (verdict: Runtime Error):
import fractions
n,m=map(int,input().split())
s=list(str(input()))
t=list(str(input()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

l=lcm(n, m)
ans=[0]*(l+1)

for i in range(n):
    index=l//n*i+1

    if ans[index]==0:
        ans[index]=s[i]
#print(ans)
for i in range(m):
    index=l//m*i+1
    if ans[index]==0:
        ans[index]=t[i]
    else:
        if t[i]!=ans[index]:
            print(-1)
            exit()
#print(ans)
print(l)

Buggy submission (verdict: Runtime Error):
import math 
n,m=map(int,input().split())
s=list(str(input()))
t=list(str(input()))

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l=lcm(n, m)
ans=[0]*(l+1)

for i in range(n):
    index=l//n*i+1

    if ans[index]==0:
        ans[index]=s[i]
#print(ans)
for i in range(m):
    index=l//m*i+1
    if ans[index]==0:
        ans[index]=t[i]
    else:
        if t[i]!=ans[index]:
            print(-1)
            exit()
#print(ans)
print(l)

Buggy submission (verdict: Runtime Error):
import math 
n,m=map(int,input().split())
s=list(str(input()))
t=list(str(input()))

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l=lcm(n, m)
ans=[0]*(l+1)

for i in range(n):
    index=l//n*i+1

    if ans[index]==0:
        ans[index]=s[i]
#print(ans)
for i in range(m):
    index=l//m*i+1
    if ans[index]==0:
        ans[index]=t[i]
    else:
        if t[i]!=ans[index]:
            print(-1)
            exit()
#print(ans)
print(l)
Problem p03241 (python)

Fixed submission:

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


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)

    divisors.sort()
    return divisors


b = make_divisors(m)
# print(b)
a = m//n
# print(a)
ans = 0
for i in b:
    if i <= a:
        ans = i
print(ans)

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


b = sympy.divisors(m)
# print(b)
a = m//n
# print(a)
ans = 0
for i in b:
    if i <= a:
        ans = i
print(ans)
Problem p03282 (python)

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

for i in range(min(len(str(s)),k)):
    if str(s)[i]!='1':
        print(str(s)[i])
        exit()
print(1)

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

for i in range(min(len(str(s),k))):
    if str(s)[i]!='1':
        print(str(s)[i])
        exit()
print(1)

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

for i in range(min(len(str(s),k)):
    if str(s)[i]!='1':
        print(str(s)[i])
        exit()
print(1)

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


if str(s)[0]=='1':
    print(str(s)[1])
else:
    print(str(s)[0])
Problem p03288 (python)

Fixed submission:
a=int(input())
if a<1200:
  print("ABC")
elif 2800<=a:
  print("AGC")
else:
  print("ARC")

Buggy submission (verdict: Runtime Error):
a=int(input())
if a<1200:
  print("ABC")
else if 2800<=a:
  print("AGC")
else:
  print("ARC")

Buggy submission (verdict: Runtime Error):
=int(input())
if a<1200:
  print("ABC")
elif 2800<=a:
  print("AGC")
else:
  print("ARC")

Buggy submission (verdict: Runtime Error):
=int(input())
if a<1200:
  print("ABC")
else if 2800<=a:
  print("AGC")
else:
  print("ARC")
Problem p03361 (python)

Fixed submission:
h,w=map(int,input().split())
s=[]
s.append(['.']*(w+2))
for i in range(h):
    s.append( list(map(str,input())))
    

s.append(['.']*(w+2))
for i in range(1,h+1):
    s[i].insert(0,'.')
    s[i].append('.')


for i in range(1,h):
    for j in range(1,w):
        if s[i][j]=='#':
            if s[i+1][j]!='#' and s[i-1][j]!='#' and s[i][j+1]!='#' and s[i][j-1]!='#' :
                print("No")
                exit()

print("Yes")

Buggy submission (verdict: Runtime Error):


a,b,ab,x,y=map(int,input().split())
ans=0
abcnt=min(x,y)
if (a+b)//2>=ab:
    if min(a,b)>ab*2:
        ans+=max(x,y)*2*ab
    else:
        ans+=abcnt*2*ab
        if x>y:
            ans+=(x-abcnt)*a
        else:
            ans+=(y-abcnt)*b
else:
    ans+=x*a+y*b
print(ans)
Problem p03387 (python)

Fixed submission:
a,b,c=map(int,input().split())
m=max(a,b,c)*3
f=a+b+c
if (m-f)%2==0:
    print((m-f)//2)
else:
    print((m-f)//2+2)

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

if a%2==b%2 and b%2==c%2 and a%2==c%2:
    m=max(a,b,c)
    count=(m-a)//2+(m-b)//2+(m-c)//2
else:
    count=(m-a)//2+(m-b)//2+(m-c)//2+1
print(count)
Problem p03393 (python)

Fixed submission:
s=str(input())
a=list("zyxwvutsrqponmlkjihgfedcba")
a=a[::-1]
#print(a)


if "zyxwvutsrqponmlkjihgfedcba"==s:
    print(-1)
    exit()


if len(s)==26:
    s=s[::-1]#後ろから見ていく
    for i in range(len(s)):
        for j in range(i+1):
            #print(i,j,s[i],s[j])
            if s[i]<s[j]:#xyzの降順の流れが切れたところを変える
                s=s[::-1]
               # print(s)
                print(s[:-(i+1)]+s[-(j+1)])
                exit()
else:
    for i in a:
        if i not in s:
            s+=i
            break
    print(s)

Buggy submission (verdict: Runtime Error):
s=str(input())
a=list("zyxwvutsrqponmlkjihgfedcba")
a=a[::-1]
#print(a)


if "zyxwvutsrqponmlkjihgfedcba"==s:
    print(-1)


if len(s)==26:
    s=s[::-1]#後ろから見ていく
    for i in range(len(s)):
        for j in range(i+1):
           # print(i,j,s[i+1],s[j+1])
            if s[i+1]<s[j+1]:#xyzの降順の流れが切れたところを変える
                s=s[::-1]
                print(s[:-(i+1)]+s[-(j+1)])
                exit()
else:
    for i in a:
        if i not in s:
            s+=i
            break
    print(s)
Problem p03408 (python)

Fixed submission:
import collections
n = int(input())
s = [str(input()) for _ in range(n)]
m = int(input())
t = [str(input()) for _ in range(m)]
s = collections.Counter(s)
t = collections.Counter(t)

for k, j in t.items():
    if k in s:
        s[k] -= j

values, counts = zip(*s.most_common())
print(max(0,counts[0]))

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
s = [str(input()) for _ in range(n)]
m = int(input())
t = [str(input()) for _ in range(m)]
s = collections.Counter(s)
t = collections.Counter(t)

for k, j in t.items():
    if k in s:
        s[k] -= j

values, counts = zip(*s.most_common())
print(max(0,counts[0))
Problem p03436 (python)

Fixed submission:
from collections import deque
q = deque()
h,w=map(int,input().split())
sx,sy=1,1#スタート位置
ex,ey=h,w#ゴール位置
q.append([sx-1,sy-1,0])
global finished 
finished = set()
c=[]
for i in range(h):
    c.append(list(map(str,input())))

def check(x,y):
    if 0<=x and x<h:
        if 0<=y and y<w:
            return True
    return False

count=0
def search():
    while (q):
        x,y,count=q.popleft()
        
        if check(x,y)==False or (x,y) in finished or c[x][y]=='#':
            continue
        else:
            q.append([x,y-1,count+1])
            q.append([x,y+1,count+1])
            q.append([x+1,y,count+1])
            q.append([x-1,y,count+1])
            finished.add((x,y))
            c[x][y]=count
            if x==ex-1 and y==ey-1:
                return c[x][y]+1 #通った道の合計を返す
    return -1
black_count=0
for i in range(h):
    black_count+=c[i].count("#")
path=search()#通る道
if path==-1:
    print(path)
else:
    print(h*w-black_count-path)#全体からもともと黒の#の数と通った白い道を削除

Buggy submission (verdict: Runtime Error):
from collections import deque
q = deque()
h,w=map(int,input().split())
sx,sy=1,1#スタート位置
ex,ey=h,w#ゴール位置
q.append([sx-1,sy-1,0])
global finished 
finished = set()
c=[]
for i in range(h):
    c.append(list(map(str,input())))

def check(x,y):
    if 0<=x and x<h:
        if 0<=y and y<w:
            return True
    return False

count=0
def search():
    while (q):
        x,y,count=q.popleft()
        
        if check(x,y)==False or (x,y) in finished or c[x][y]=='#':
            continue
        else:
            q.append([x,y-1,count+1])
            q.append([x,y+1,count+1])
            q.append([x+1,y,count+1])
            q.append([x-1,y,count+1])
            finished.add((x,y))
            c[x][y]=count
            if x==ex-1 and y==ey-1:
                return c[x][y]+1 #通った道の合計を返す

black_count=0
for i in range(h):
    black_count+=c[i].count("#")

print(h*w-black_count-search())#全体からもともと黒の#の数と通った白い道を削除
Problem p03486 (python)

Fixed submission:
s=list(str(input()))
t=list(str(input()))
s.sort()

t.sort(reverse=True)
#print(s,t)

for i in range(min(len(s),len(t))):
   # print(s[i],t[i])
    if s[i]<t[i]:
        print("Yes")
        exit()
    elif s[i]>t[i]:
        print("No")
        exit()
if len(s)<len(t):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=list(str(input()))
t=list(str(input()))
s.sort()
t.sort()
#print(s,t)

for i in range(min(len(s),len(t))):
    if s[i]>t[i]:
        print("Yes")
        exit()
    elif s[i]<t[i]:
        print("No")
        exit()
if len(s)<t:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=list(str(input()))
t=list(str(input()))
s.sort()
t.sort()
#print(s,t)

for i in range(min(len(s),len(t))):
    if s[i]<t[i]:
        print("Yes")
        exit()
    elif s[i]>t[i]:
        print("No")
        exit()
if len(s)<t:
    print("Yes")
else:
    print("No")
Problem p03599 (python)

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

water=set()#入れる可能性のある水の量O(A*B)
sugar=set()#入れる可能性のある佐藤の量O(C*D)

for i in range(31):
    for j in range(31):
        if 100*i*a+100*j*b<=f:
            water.add(100*i*a+100*j*b)

for i in range(1501):
    for j in range(1501):
        if c*i+d*j<=f:
            sugar.add(c*i+d*j)
water=sorted(list(water))
#print(water)
#print(sugar)
sugar=sorted(list(sugar))
#print(sugar)
ans=0
sugarans=0
sumans=0
for i in range(1,len(water)):
    for j in range(len(sugar)):
        if water[i]+sugar[j]<=f and sugar[j]<=e*(water[i]/100):
            if ans<(100*sugar[j])/(water[i]+sugar[j]):
                #print(sugar[j],water[j])
                ans=(100*sugar[j])/(water[i]+sugar[j])
                sugarans=sugar[j]
                sumans=water[i]+sugar[j]
               # print(ans)
if  sumans==0:
    print(100*a,sugarans)
else:
    print(sumans,sugarans)

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

water=set()#入れる可能性のある水の量O(A*B)
sugar=set()#入れる可能性のある佐藤の量O(C*D)

for i in range(31):
    for j in range(31):
        water.add(100*i*a+100*j*b)

for i in range(1501):
    for j in range(1501):
        sugar.add(c*i+d*j)
water=sorted(list(water))
#print(water)
sugar=sorted(list(sugar))
#print(sugar)
ans=0
sumans=0
for i in range(1,len(water)):
    for j in range(len(sugar)):
        if water[i]+sugar[j]<=f and (sugar[j]/(water[i]//100))<=e:
            if ans<(100*sugar[j])//(water[i]+sugar[j]):
                #print(sugar[j],water[j])
                ans=(100*sugar[j])/(water[i]+sugar[j])
                sugarans=sugar[j]
                sumans=water[i]+sugar[j]
print(sumans,sugarans)
Problem p03633 (python)

Fixed submission:
import fractions

n=int(input())
t=[int(input()) for _ in range(n)]
ans = t[0]
for i in range(1, n):
    ans = ans * t[i] // fractions.gcd(ans, t[i])
print(ans)

Buggy submission (verdict: Runtime Error):

n=int(input())
t=[int(input()) for _ in range(n)]
ans = t[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, t[i])
print(ans)

Buggy submission (verdict: Runtime Error):

import fractions

n=int(input())
t=[int(input()) for _ in range(n)]
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, t[i])
print(ans)
Problem p03637 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
count4=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
count1=0
for i in range(n):
    if a[i]%4==0:
        count4+=1
    elif a[i]%2==0:
        count2+=1
    else:
        count1+=1
if count2==0:
    if count1<=count4+1:
        print("Yes")
    else:
        print("No")
else:
    if count1<=count4:
        print("Yes")
    else:
        print("No")

    

    
"""
#print(count2)
if 1<=count2:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

    """
"""    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト

"""

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
count4=0#4の倍数
count2=0#2の倍数だが4の倍数じゃない
count1=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
    else:
        count1+=1
if count2==0:
    if count1<=count4+1:
        print("Yes")
    else:
        print("No")
else:
    if count1<count4:
        print("Yes")
    else:
        print("No")

    

    
"""
#print(count2)
if 1<=count2:
    if (n-count2//2)//2<=count or n//2<=count:
        print("Yes")
    elif count2%2==0:
        if   (n-count2)//2<count :
            print("Yes ")
        else:
            print("No")
    elif count2%2==1:
        if  (n-count2)//2<=count :
            print("Yes ")
        else:
            print("No")
else:
    if n//2<=count:
        print("Yes")
    else:
        print("No")

    """
"""    7
    2 2 2 2 3 4 3

    YES になる間違い13晩のテキスト

"""

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input(),split()))
count=0
for i in range(n):
    if a[i]%4==0:
        count+=1

if n//2<=count:
    print("Yes")
else:
    print("No")
Problem p03638 (python)

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

ans=[[0]*w for _ in range(h)]
i=0
j=0
jugh=0


if w==1:
    for i in range(n):
        for j in range(a[i]):
            print(i+1)
    exit()



for z in range(n):
    count=0
    while count<a[z]:
       # print(i,j,z+1)
        if jugh==0:
            ans[i][j]=z+1
            j+=1
            c=0
        elif jugh==2:
            if j==0:
                jugh=0
                c=1
                ans[i][j]=z+1
                j+=1
            else:
                
                jugh=1
                c=1
                
                ans[i][j]=z+1
                j-=1
        else:
            ans[i][j]=z+1
            j-=1
            c=0

        if j==w and c==0:
            i+=1
            j-=1
            jugh=2
        if j==-1 and c==0:
            i+=1
            j+=1
            jugh=2
            
        count+=1

for i in range(h):
    for j in range(w):
        print(ans[i][j],end=" ")
    print()

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

ans=[[0]*w for _ in range(h)]
i=0
j=0
jugh=0
for z in range(n):
    count=0
    while count<a[z]:
        #print(i,j,z+1)
        if jugh==0:
            ans[i][j]=z+1
            j+=1
            c=0
        elif jugh==2:
            if j==0:
                jugh=0
                c=1
                ans[i][j]=z+1
                j+=1
            else:
                
                jugh=1
                c=1
                
                ans[i][j]=z+1
                j-=1
        else:
            ans[i][j]=z+1
            j-=1
            c=0

        if j==w and c==0:
            i+=1
            j-=1
            jugh=2
        if j==-1 and c==0:
            i+=1
            j+=1
            jugh=2
            
        count+=1

for i in range(h):
    for j in range(w):
        print(ans[i][j],end=" ")
    print()