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

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(lambda x: int(x) - 1, input().split())
        edges[a].append(b)
        edges[b].append(a)

    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    def dfs(cur, par):
        for nex in edges[cur]:
            if nex == par:
                continue
            counter[nex] += counter[cur]
            dfs(nex, cur)

    dfs(0, -1)
    print(*counter, sep=" ")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
edge=[[]for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

ans=[0]*n
for _ in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x

l=[0]*n
l[0]=1

def dfs(now,last=-1):
    for to in edge[now]:
        if to==last:continue
        ans[to]+=ans[now]
        dfs(to,now)
dfs(0)


print(ans)
Problem p02973 (python)

Fixed submission:

from collections import deque

n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append(A)
l=deque([a[0]])
for i in range(1,n):
    if l[0]>=a[i]:
        l.appendleft(a[i])
    elif l[-1]<a[i]:
        l[-1]=a[i]
    else:
        p=0
        q=len(l)-1
        while q-p!=1:
            if l[(p+q)//2]>=a[i]:
                q=(p+q)//2
            else:
                p=(p+q)//2
        l[p]=a[i]
print(len(l))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append(A)
l=deque([a[0]])
for i in range(1,n):
    if l[0]>=a[i]:
        l.appendleft(a[i])
    elif l[-1]<=a[i]:
        l.append(a[i])
    else:
        p=0
        q=len(l)-1
        while q-p!=1:
            if l[(p+q)//2]>=a[i]:
                q=(p+q)//2
            else:
                p=(p+q)//2
        l[p]=a[i]
print(len(l))
Problem p03006 (python)

Fixed submission:
n=int(input())
l=[]
if n==1:
    print(1)
    exit()
else:
    for i in range(n):
        x,y=map(int,input().split())
        l.append((x,y))
    x={}
    for i in l:
        for j in l:
            if i!=j:
                t=(i[0]-j[0],i[1]-j[1])
                if t in x:
                    x[t]+=1
                else:
                    x[t]=1
    print(n-max(x.values()))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append((x,y))
x={}
for i in l:
    for j in l:
        if i!=j:
            t=(i[0]-j[0],i[1]-j[1])
            if t in x:
                x[t]+=1
            else:
                x[t]=1
print(n-max(x.values()))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
    x,y=map(int,input().split())
    l.append((x,y))
x={}
for i in l:
    for j in l:
        if i!=j:
            t=(i[0]-j[0],i[1]-j[1])
            if t in x:
                x[t]+=1
            else:
                x[t]=1
print(max(x.values()))
Problem p03161 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  dp[i]=float('inf')
  for j in range(1,k+1):
    if i-j>=0:
      dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]) , dp[i])
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(n+1)
for i in range(n):
  dp[i]=10**5
  if i<=k:
    dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]))
  else:
    dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]))
Problem p03163 (python)

Fixed submission:
N,W= map(int,input().split())
w=[]
v=[]
for  i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp =[ [0]*(W+1) for _ in range(N+1) ]

for i in range(N):
    for  j in range(W+1):
        dp[i+1][j]=dp[i][j]
        if j-w[i]>=0:
            dp[i+1][j]= max(dp[i][j] , dp[i][j-w[i]]+v[i])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N,W= map(int,input().split())
w=[]
v=[]
for  i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp =[ [0]*(N+3) for _ in range(W+3) ]

for i in range(N):
    for  j in range(W+1):
        dp[i+1][j]=dp[i][j]
        if j-w[i]>=0:
            dp[i+1][j]= max(dp[i][j] , dp[i][j-w[i]]+v[i])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N,W= map(int,input().split())
w=[]
v=[]
for  i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp =[ [0]*(N*10) for _ in range(W*10) ]

for i in range(N):
    for  j in range(W+1):
        dp[i+1][j]=dp[i][j]
        if j-w[i]>=0:
            dp[i+1][j]= max(dp[i][j] , dp[i][j-w[i]]+v[i])

print(dp[N][W])
Problem p03197 (python)

Fixed submission:
n=int(input())
cnt=0
for i in range(n):
    a=int(input())
    cnt+=(a%2)
if cnt==0:
    print("second")    
else:
    print("first")

Buggy submission (verdict: Runtime Error):
n=int(input())
cnt=0
for i in range(n):
    a=int(input())
    cnt+=(a%2)
if:
    if cnt==0:
        print("second")
    else:
        print("first")

Buggy submission (verdict: Runtime Error):
n=int(input())
x=0
for i in range(n):
    a=int(input())
    cnt+=(a-1)%2
    cnt%=2
    x=max(a,x)
if x==1:
    print("first")
    if n%2==0:
        if cnt==0:
            print("second")
        else:
            print("first")
    else:
        if cnt==0:
            print("second")
        else:
            print("first")

Buggy submission (verdict: Runtime Error):
n=int(input())
x=0
cnt=0
for i in range(n):
    a=int(input())
    x=max(a,x)
    cnt+=a
if x==1:
    print(first)
else:
    if (a-2)%2==1:
        print("first")
    else:
        print("second")
Problem p04001 (python)

Fixed submission:
s=input()
n=len(s)
sum=0
for i in range(1<<n-1):
  t=0
  for j in range(n-1):
    if i & (1<<j):
      sum += int("".join(s[t:j+1]))
      t = j+1 
  sum += int(''.join(s[t:]))
print(sum)

Buggy submission (verdict: Runtime Error):
s=int(input())
n=len(s)
sum=0
for i in range(1<<n-1):
  t=0
  for j in range(n-1):
    if i & (1<<j):
      sum += int("".join(s[t:j+1]))
      t = j+1 
print(sum)
Problem p03494 (python)

Fixed submission:
N = int(input())
res = 1000000000000
x = list(map(int, input().split()))
for x in x:
    count = 0
    while x%2==0:
        x /= 2
        count += 1
    if res > count: res = count
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
res = 1000000000000
for i in range(N):
    count = 0
    x = int(input())
    while x%2==0:
        x /= 2
        count += 1
    if res > count: res = count
print(res)
Problem p02613 (python)

Fixed submission:
verdicts = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
N = int(input())
for i in range(N):
    v = input()
    verdicts[v] += 1

for v, f in verdicts.items():
    print(f'{v} x {f}')

Buggy submission (verdict: Runtime Error):
verdicts = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

v = input()
while v:
    verdicts[v] += 1
    v = input()

for v, f in verdicts.items():
    print(f'{v} x {f}')
Problem p02697 (python)

Fixed submission:
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
a,b=list(map(int,input().split()))
b_i=a
a_i=1
for i in range(b,0,-1):
    if i%2==1:
        print(b_i-i,b_i)
        b_i-=1

    else:
        print(a_i,a_i+i)
        a_i+=1

Buggy submission (verdict: Runtime Error):
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
a,b=list(map(int,input().split()))
ans=[False for _ in range(a)]
t=0
for i in range(a):
    if ans[i]:
        continue
    t+=1
    n=i+1
    ans[i+t]=True
    print(n,n+t)
    if t==b:
        exit()
Problem p02756 (python)

Fixed submission:
from collections import deque
s=input()
q=int(input())
rev=0
head=deque()
tail=deque()
for _ in range(q):
    Q=input().split()
    if len(Q)==1:
        rev=1-rev
    if len(Q)==3:
        if(rev==0 and Q[1]=="1" )or (rev==1 and Q[1]=="2"):
            head.appendleft(Q[2])
        else :
            tail.append(Q[2])
if rev==0:
    ans="".join(head)+s+"".join(tail)

else:
    ans="".join(tail)[::-1]+s[::-1]+"".join(head)[::-1]

print(ans)

Buggy submission (verdict: Runtime Error):
head=deque()
tail=deque()
for _ in range(q):
    Q=input().split()
    if len(Q)==1:
        rev=1-rev
    if len(Q)==3:
        if(rev==0 and Q[1]=="1" )or (rev==1 and Q[1]=="2"):
            head.appendleft(Q[2])
        else :
            tail.append(Q[2])
if rev==0:
    ans="".join(head)+s+"".join(tail)

else:
    ans="".join(tail)[::-1]+s[::-1]+"".join(head)[::-1]

print(ans)
Problem p02775 (python)

Fixed submission:
def dp_solver(tmp):
    l=len(tmp)
    rev=tmp[::-1]+"0"
    dp=[[float("inf") for _ in range(2)] for _ in range(l+2)]
    dp[0][0]=0
    for i in range(l+1):
        for j in range(2):
            num=int(rev[i])
            num+=j
            if num<10:
                dp[i+1][0]=min(dp[i+1][0],dp[i][j]+num)
            if num>0:
                dp[i+1][1]=min(dp[i+1][1],dp[i][j]+(10-num))

    import numpy as np
    dp=np.array(dp)
    return(dp[l+1])

def y_solver(tmp):
    l=len(tmp)
    rev=tmp[::-1]+"0"
    seq_flag=False
    ans=0
    next_bit=0
    kuri_cal=0
    for i in range(l-1):
        num=int(rev[i])+next_bit
        next_num=int(rev[i+1])
        if not seq_flag:
            if (num<5) or (num==5 and next_num<5):
                ans+=num
                next_bit=0
                kuri_cal=0
                continue
            seq_s=i
            seq_flag=True
            kuri_cal=10-num
            next_bit+=1
            continue
        #print(kuri_cal)
        if num<5:
            ans+=(kuri_cal+num)
            kuri_cal=0
            next_bit=0
            seq_flag=False
        elif num>5:
            kuri_cal+=10-num
        else:
            if next_num<5:
                ans+=(kuri_cal+num)
                next_bit=0
                kuri_cal=0
                seq_flag=False
            else:
                kuri_cal+=10-num
    last=int(tmp[0])+next_bit
    ans+=kuri_cal+min(last,11-last)
    return ans

n=input()
ans=y_solver(n)
print(ans)

Buggy submission (verdict: Runtime Error):
###間違っとる！！！！
#tmp="9"*(10**6)
tmp=input()
#tmp="78164062862089986280348253421170"
#tmp="314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170"
#tmp="846"
#tmp="253421170"
l=len(tmp)
#print(l)
rev=tmp[::-1]+"0"
seq_flag=False
ans=0
debug=[]
ans_arr=[]
next_bit=0
for i in range(l-1):
    num=int(rev[i])+next_bit
    next_num=int(rev[i+1])
    if not seq_flag:
        if (num<5) or (num==5 and next_num<5):
            ans+=num
            ans_arr.append(ans)
            next_bit=0
            kuri_cal=0
            continue
        seq_s=i
        seq_flag=True
        kuri_cal=10-num
        next_bit+=1
        continue
    #print(kuri_cal)
    if num<5:
        ans+=(kuri_cal+num)
        next_bit=0
        seq_flag=False
    elif num>5:
        kuri_cal+=10-num
    else:
        if next_num<5:
            ans+=(kuri_cal+num)
            next_bit=0
            seq_flag=False
        else:
            kuri_cal+=10-num
        
"""    
        
    if next_num+next_bit<5:
        ans+=(kuri_cal+2)
        ans_arr.append(ans)
        debug.append([i,ans-1])
        seq_flag=False"""
#print(ans)
last=int(tmp[0])+next_bit
#print(last)
#print(kuri_cal)
ans+=kuri_cal+min(last,11-last)
ans_arr.append(ans)
print(ans)
Problem p02780 (python)

Fixed submission:
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
cal=lambda x:(1+x)/2
a=list(map(cal,a))
#print(a)
now=sum(a[:k])
ans=now
#print(now)
d=a[0]
for i in range(1,n-k+1):
    #print(i)
    tmp=now-d+a[i+k-1]
    ans=max(ans,tmp)
    d=a[i]
    now=tmp
    #print(now)
    #print()
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
cal=lambda x:(1+x)/2
a=list(map(cal,a))
#print(a)
now=sum(a[:k])
#print(now)
d=a[0]
for i in range(1,n-k+1):
    #print(i)
    tmp=now-d+a[i+k-1]
    ans=max(now,tmp)
    d=a[i]
    now=tmp
    #print(now)
    #print()
print(ans)
Problem p02818 (python)

Fixed submission:
a,b,k=list(map(int,input().split()))
if a>=k:
  a-=k
  print(a," ",b)
  exit()

k-=a
a=0
b-=k
b=max(b,0)
print(a," ",b)

Buggy submission (verdict: Runtime Error):
a,b,k=int(list(input().split()))
if a>=k:
  a-=k
  k=0
  print(a," ",b)
  exit()
a=0
k-=a
b-=k
print(a," ",b)
Problem p02917 (python)

Fixed submission:
N=int(input())
B=list(map(int,input().split()))
total=B[0]
if N==2:
    print(B[0]*2)
    exit()
    
if N==3:
    print(B[0]+min(B[1],B[0])+B[1])
    exit()
for i in range(N-2):
    total+=min(B[i],B[i+1])
    
#if N%2==0:
total+=B[-1]
print(total)

Buggy submission (verdict: Runtime Error):
N=int(input())
B=list(map(int,input().split()))
total=B[0]
if N==2:
    print(B[0]*2)
    exit()
    
if N==3:
    print(B[0]+min(B[1],B[0])+B[2])
    exit()
for i in range(N-2):
    total+=min(B[i],B[i+1])
    
#if N%2==0:
total+=max(B[-1],B[-2])
print(total)
Problem p02960 (python)

Fixed submission:
#%%time
mod=10**9+7
s=input()


#p=[[i*j%13 for i in range(10)] for j in range(13)]
rev=reversed(s)
d=[0 for i in range(13)]
d[0]=1
keep=[0 for _ in range(13)]
mul=1
cal=0
for v in rev:
    #print(i+num+1)
    if v=="?":
        t_d=[0 for _ in range(13)]
        #print("i,tmp:",i+num+1,",",tmp)
        for k in range(0,13):
            for j in range(0,10):
                t_d[(mul*j+k)%13]+=d[k]
            t_d[k]%=mod
        d=t_d
    else:
        cal+=mul*int(v)%13
    mul*=10
    mul%=13
        #print(t_d)
cal%=13
if cal<=5:
    cal=5-cal
else:
    cal=18-cal
print(d[cal]%mod)
#print(d)
#h=d
#print([i%mod for i in h])

Buggy submission (verdict: Runtime Error):
%%time
import numpy as np

mod=10**9+7
#s=input()
s="?"*10**5


p=[[i*j%13 for i in range(10)] for j in range(13)]
rev=reversed(s)
d=np.array([0 for i in range(13)])
d[0]=1
keep=np.array([0 for _ in range(13)])
mul=1
cal=0
t=np.array([i for i in range(13)])
for v in rev:
    if v!="?":
        cal+=mul*int(v)%13
    else:
        t_d=keep.copy()
        for j in range(1,10):
            t_d[(t+mul*j)%13]+=d
        d+=t_d
        d%=mod
        
    mul*=10
    mul%=13

cal%=13
if cal<=5:
    cal=5-cal
else:
    cal=18-cal
print(d[cal]%mod)
#print(d)
#h=d
#print([i%mod for i in h])

Buggy submission (verdict: Runtime Error):
mod=10**9+7
s=input()

b=int(s.replace("?","0"))%13
if b<=5:
    cal=5-b
else:
    cal=18-b
d=[0 for _ in range(13)]
p=[[i*j%13 for i in range(10)] for j in range(13)]
rev=s[::-1]
num=rev.find("?")
if num==-1:
    if cal==0:
        print(1)
    else:
        print(0)
else:
    tmp=10**(i+num+1)%13
    for i in p[tmp]:
        d[i]+=1
    c=rev[num+1:]
    for i,v in enumerate(c):
        #print(i+num+1)
        if v=="?":
            tmp=10**i%13
            t_d=[0 for _ in range(13)]
            #print("i,tmp:",i+num+1,",",tmp)
            for k in range(0,13):
                for j in range(0,10):
                    t_d[(p[tmp][j]+k)%13]+=d[k]
                #print(t_d)
            #for j in range(13):
                #d[j]=t_d[j]
            d=t_d
            #print(t_d)
    #print(d)
    print(d[cal]%mod)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
s=input()

b=int(s.replace("?","0"))%13
if b<=5:
    cal=5-b
else:
    cal=18-b

p=[[i*j%13 for i in range(10)] for j in range(13)]
rev=s[::-1]
d={i:0 for i in range(13)}
num=rev.find("?")
tmp=10**num%13
for i in p[tmp]:
    d[i]+=1

for i,v in enumerate(rev[num+1:]):
    #print(i+num+1)
    if v=="?":
        tmp=10**(i+num+1)%13
        t_d={i:0 for i in range(13)}
        #print("i,tmp:",i+num+1,",",tmp)
        for k in range(0,13):
            for j in range(0,10):
                t_d[(p[tmp][j]+k)%13]+=d[k]
            #print(t_d.values())
        for j in range(13):
            d[j]=t_d[j]
        #print(t_d)
#print(d)
print(d[cal]%mod)
Problem p02973 (python)

Fixed submission:
#import bisect
def desc_bin(a, x, lo=0, hi=None):
    """Insert item x in list a, and keep it reverse-sorted assuming a
    is reverse-sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x > a[mid]: hi = mid
        else: lo = mid+1
    return lo
N=int(input())
ans=[]
for _ in range(N):
    num=int(input())
    
    index=desc_bin(ans,num)
    if index==len(ans):
        ans.append(num)
    else:
        ans[index]=num
    #print(ans)
print(len(ans))

Buggy submission (verdict: Runtime Error):
#import bisect
def desc_bin(a, x, lo=0, hi=None):
    """Insert item x in list a, and keep it reverse-sorted assuming a
    is reverse-sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x > a[mid]: hi = mid
        else: lo = mid+1
    return lo
N=int(input())
ans=[]
for _ in range(N):
    num=int(input())
    
    index=desc_bin(ans,num)
    if index==len(ans):
        ans.append(num)
    else:
        ans[index]=num
    print(ans)
print(len(ans))
Problem p02995 (python)

Fixed submission:
import math
import fractions
a,b,c,d=list(map(int,input().split()))
a-=1
calc_c=(b-b//c)-(a-a//c)
calc_d=(b-b//d)-(a-a//d)
count=calc_c+calc_d
def lcm(x, y):
    #return (x * y) // math.gcd(x, y)
    return math.floor((x * y) /fractions.gcd(x, y))


com=lcm(c, d)
tmp=(b-b//com)-(a-a//com)
print(count-tmp)

Buggy submission (verdict: Runtime Error):
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))


a,b,c,d=input_list()

l_c=math.ceil(a/c)
h_c=b//c
c_num=h_c-l_c+1

l_d=math.ceil(a/d)
h_d=b//d
d_num=h_d-l_d+1


g=c*d//math.gcd(c,d)
l_g=math.ceil(a/g)
h_g=b//g
g_num=h_g-l_g+1

ans=b-a+1-c_num-d_num+g_num
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=list(map(int,input().split()))
a-=1
calc_c=(b-b//c)-(a-a//c)
calc_d=(b-b//d)-(a-a//d)
count=calc_c+calc_d
def lcm(x, y):
    #return (x * y) // math.gcd(x, y)
    return math.floor((x * y) /math.gcd(x, y))


com=lcm(c, d)
tmp=(b-b//com)-(a-a//com)
print(count-tmp)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=list(map(int,input().split()))
a-=1
s=math.floor(b/c)-math.floor(a/c)
e=math.floor(b/d)-math.floor(a/d)
count=b-a-s-e
def lcm(x, y):
    #return (x * y) // math.gcd(x, y)
    return math.floor((x * y) /math.gcd(x, y))


com=lcm(c, d)
tmp=math.floor(b/com)-math.floor(a/com)
print(count+tmp)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=list(map(int,input().split()))
a-=1
s=math.floor(b/c)-math.floor(a/c)
e=math.floor(b/d)-math.floor(a/d)
count=b-a-s-e
def lcm(x, y):
  return (x * y)//math.gcd(x, y)


com=lcm(c, d)
tmp=math.floor(b/com)-math.floor(a/com)
print(count+tmp)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=list(map(int,input().split()))
a-=1
s=math.floor(b/c)-math.floor(a/c)
e=math.floor(b/d)-math.floor(a/d)
count=b-a-s-e
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


com=lcm(c, d)
tmp=math.floor(b/com)-math.floor(a/com)
print(count+tmp)
Problem p03001 (python)

Fixed submission:
W,H,x,y=list(map(int,input().split()))
ans=0
if x*2==W and y*2==H:
    ans=1
print("{0} {1}".format(W*H/2,ans))

Buggy submission (verdict: Runtime Error):
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))


w,h,x,y=input_list()
ans=w*h/2
mul=0
if w//2=x and h//2=y:
    mul=1

print(ans,mul)
Problem p03031 (python)

Fixed submission:
from collections import Counter 
from collections import defaultdict
from collections import deque
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))


n,m=input_list()
a=[input_list() for _ in range(m)]
p=input_list()
ans=0
for i in range(2**n):
    bit=bin(i)[2:].zfill(n)
    flag=True
    for num,each in enumerate(a):
        now=0
        light=each[1:]
        #print(light)
        for v in light:
            
            if bit[int(v)-1]=="1":
                now=1-now
        if now!=p[num]:
            flag=False
            break
    if flag:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
#from operater import itemgetter
from collections import Counter
import numpy as np
N=int(input())
c=[]
v=[]
ans=[]
c_v={}
for i in range(N):
    tmp=input().split()
    ans.append(tmp)
    c.append(tmp[0])
    v.append(int(tmp[1]))
    if tmp[0] in c_v.keys():
        c_v[tmp[0]].append(int(tmp[1]))
    else:
        c_v[tmp[0]]=[int(tmp[1])]
    
hoge=np.array(list(Counter(c).keys()))
huga=np.argsort(np.array(c))
for i in range(N):
    city=ans[i][0]
    if len(c_v[city])==1:
        print(huga[np.where(hoge==ans[i][0])][0]+1)
    else:
        tmp=np.array(c_v[city])
        h=np.argsort(tmp)[::-1]
        print(huga[np.where(hoge==ans[i][0])][0]+h[c_v[city].index(int(ans[i][1]))]+1)
Problem p03047 (python)

Fixed submission:
A,B=map(int,input().split())
print(A-B+1)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().map)
print(A-B+1)
Problem p03049 (python)

Fixed submission:
N=int(input())
s=[]
total=0
A=0
B=0
BA=0
for i in range(N):
    tmp=input()
    while True:
        if len(tmp)>=2:
            if "AB" in tmp[:2]:
                total+=1
                tmp=tmp[2:]
            else:
                break
        else:
            break
    while True:
        
        if len(tmp)>=2:
            if "AB" in tmp[-2:]:
                total+=1
                tmp=tmp[-2:]
            else:
                break
        else:
            break
    total+=tmp.count("AB")
    if len(tmp)>0:
        if tmp[0]=="B" and tmp[-1]=="A":
            BA+=1
        elif tmp[0]=="B":
            B+=1
        elif tmp[-1]=="A":
            A+=1

if BA>0:
    if B>0 and A>0:
        total+=BA+1
        B-=1
        A-=1
    elif A>0:
        total+=BA
    elif B>0:
        total+=BA
    else:
        total+=BA-1
        
        
print(total+min(A,B))

Buggy submission (verdict: Runtime Error):
N=int(input())
s=[]
total=0
A=0
B=0
for i in range(N):
    tmp=input()
    while True:
        if len(tmp)>=2:
            if "AB" in tmp[:2]:
                total+=1
                tmp=tmp[2:]
            else:
                break
        else:
            break
    while True:
        
        if len(tmp)>=2:
            if "AB" in tmp[-2:]:
                total+=1
                tmp=tmp[-2:]
            else:
                break
        else:
            break
    total+=tmp.count("AB")
    if len(tmp)>0:
        if tmp[0]=="B":
            B+=1
        if tmp[-1]=="A":
            A+=1"A":
            A+=1

print(total+min(A,B))