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

Fixed submission:
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

for y in range(h):
  for x in range(w):
    if s[y][x]=='.':
      cnt=0
      for dy,dx in [[0,1],[0,-1],[1,0],[-1,0],[1,1],[-1,1],[1,-1],[-1,-1]]:
        ny=y+dy
        nx=x+dx
        if 0<=ny<h and 0<=nx<w and s[ny][nx]=='#':
          cnt+=1
      s[y][x]=str(cnt)

for i in s:
  print(''.join(i))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

for y in range(h):
  for x in range(w):
    if s[y][x]=='.':
      cnt=0
      for dy,dx in [[0,1],[0,-1],[1,0],[-1,0],[1,1],[-1,1],[1,-1],[-1,-1]]:
        ny=y+dy
        nx=x+dx
        if 0<=ny<h and 0<=nx<w and s[ny][nx]=='#':
          cnt+=1
      s[y][x]=str(cnt)

print(''.join(s))
Problem p03720 (python)

Fixed submission:
def counting_sort(array,city,road):
    bucket = [0] * city

    for i in range(road):
        for j in range(2):
            bucket[ (array[i][j] - 1) ] += 1

    return bucket

def main():
    n,m = map(int, input().split())
    way = [list(map(int,input().split())) for _ in range(m)]
    ans_list = counting_sort(way, n, m)
    for k in range(n):
        print( ans_list[k] )

main()

Buggy submission (verdict: Runtime Error):
def counting_sort(array,city,road):
    bucket = [0] * city

    for i in range(road):
        for j in range(2):
            bucket[ array[i][j] ] += 1

    return bucket

def main():
    n,m = map(int, input().split())
    way = [list(map(int,input().split())) for _ in range(m)]
    ans_list = counting_sort(way, n, m)
    for k in range(n):
        print( ans_list[i] )

main()
Problem p02582 (python)

Fixed submission:
def main():
    tenki = input()
    leng = len(tenki)

    count = 0
    lst = []
    for i in range(leng):
        if tenki[i] == "R":
            count += 1
        else:
            lst.append(count)
            count = 0
    lst.append(count)
    count = 0
    print(max(lst))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    tenki = input()
    leng = len(tenki)

    count = 0
    lst = []
    for i in range(leng):
        if tenki[i] == "R":
            count += 1
        else:
            lst.append(count)
            count = 0
    
    print(max(lst))


if __name__ == '__main__':
    main()
Problem p02601 (python)

Fixed submission:
def judge(red, green,blue):
    if blue > green:
        if green > red:
            return (True)
    else:
        return(False)


def main():
    red, green, blue  = map(int, input().split())
    K = int(input())

    while(K > 0):
        if green <= red:
            green *= 2
            K -= 1
            continue
        if blue <= green:
            blue *= 2
            K -= 1
            continue
        if judge(red, green, blue):
            break
        
    if judge(red, green, blue):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    red, green, blue  = map(int, input().split())
    K = int(input())

    while(K > 0):
        if green <= red:
            green *= 2
            K -= 1
            continue
        if blue <= green:
            blue *= 2
            K -= 1
            continue
        if judge(red, green, blue):
            break
        
    if judge(red, green, blue):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()
Problem p02641 (python)

Fixed submission:
def challenge(X, numlist, vec):
  while True:
    try:
      numlist.index(X)
    except:
      return(X)
    if vec:
      X -= 1
    else:
      X += 1

list1 = input().split()
X = int(list1[0])
N = int(list1[1])
  
if N == 0:
  print(X)
else:
  list2 = input().split()
  numlist = []
  for i in list2:
    numlist.append(int(i))

  num1 = challenge(X, numlist,True)
  num2 = challenge(X, numlist,False)
  wk1 = abs(X - num1)
  wk2 = abs(X - num2)
  if wk1 > wk2:
    print(num2)
  else:
    print(num1)

Buggy submission (verdict: Runtime Error):
def challenge(X, numlist, vec):
  for i in range(len(numlist)):
    try:
      numlist.index(X)
    except:
      return(X)
    if vec:
      X -= 1
    else:
      X += 1

list1 = input().split()
X = int(list1[0])
N = int(list1[1])
  
if N == 0:
  print(X)
else:
  list2 = input().split()
  numlist = []
  for i in list2:
    numlist.append(int(i))

  num1 = challenge(X, numlist,True)
  num2 = challenge(X, numlist,False)
  wk1 = abs(X - num1)
  wk2 = abs(X - num2)
  if wk1 > wk2:
    print(num2)
  else:
    print(num1)
Problem p02645 (python)

Fixed submission:
hoge=input()
print(hoge[0:3])

Buggy submission (verdict: Runtime Error):
def calc(oniend, kid , pase):
  if (pase <= 0) or ((oniend * pase) < kid):
    return "NO"
  #elif ((oniend - kid) % pase) == 0:
  else:
    return "YES"

in1 = input().split()
in2 = input().split()
in3 = input()
oni = int(in1[0])
onispeed = int(in1[1])
kid = int(in2[0])
kidspeed = int(in2[1])
time = int(in3)

pase = onispeed - kidspeed
oniend = (pase * time) + oni

if (pase <= 0) or ((oniend * pase) < kid):
  print("NO")
  #elif ((oniend - kid) % pase) == 0:
else:
  print("YES")
Problem p02657 (python)

Fixed submission:
inlist = input().split()
print(int(inlist[0]) * int(inlist[1]))

Buggy submission (verdict: Runtime Error):
inlist = input().split()
print(inlist[0] * inlist[1])
Problem p02804 (python)

Fixed submission:
n,k=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]
ans=0
mod=10**9+7
arr.sort() 
c=[0 for i in range(n)]
r=k-1
c[r]=1
def modinv(x,mod):
    return pow(x,mod-2,mod)
for i in range(r+1,n):
    c[i]=((c[i-1]*(i))*modinv(i-r,mod))%mod
pos=0
neg=0
for i in range(n):
    pos+=(arr[-1-i]*c[-1-i])%mod
    neg+=(arr[i]*c[-1-i])%mod
    pos%=mod
    neg%=mod
print((pos-neg)%mod)

Buggy submission (verdict: Runtime Error):
n,k=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]
ans=0
mod=10**9+7
arr.sort() 
c=[0 for i in range(n)]
r=k-1
c[r]=1
def modinv(x.mod):
    return pow(x,mod-2,mod)
for i in range(r+1,n):
    c[i]=((c[i-1]*(i))*modinv(i-r,mod))%mod
pos=0
neg=0
for i in range(n):
    pos+=(arr[-1-i]*c[-1-i])%mod
    neg+=(arr[i]*c[-1-i])%mod
    pos%=mod
    neg%=mod
print((pos-neg)%mod)
Problem p03161 (python)

Fixed submission:
n,k=map(int,raw_input().split())
arr=map(int,raw_input().split())
na=[0 for i in range(n)]
for i in range(1,n):
    m=999999999
    for j in range(max(i-k,0),i):
        m=min(m,na[j]+abs(arr[i]-arr[j]))
    na[i]=m
print na[-1]

Buggy submission (verdict: Runtime Error):
n,k=map(int,raw_input().split())
arr=map(int,raw_input().split())
na=[]
for i in range(k+1):
    na.append(abs(arr[0]-arr[i]))
for i in range(k+1,n):
    m=9999999
    for j in range(i-k,i):
        m=min(na[j]+abs(arr[i]-arr[j]),m)
    na.append(m)
print na[-1]
Problem p03323 (python)

Fixed submission:
a = input().split()
 
if(int(a[0])<=8 and int(a[1])<=8):
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a = input().split()

if(a[0]<=8 and a[1]<=8):
  print("Yay!")
else:
  print(":(")
Problem p02621 (python)

Fixed submission:
a=int(input())

print(a + a**2 + a**3)

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

import numpy as np
import bisect

ra=[0]+list(np.cumsum(a))
rb=[0]+list(np.cumsum(b))

ans=0
for i in range(n+1):    
    capa = k - ra[i]
    if ra[i]<0:
        break
    j=bisect.bisect_right(rb,capa)


    ans=max(ans,i-1+j)
            
print(ans)
Problem p02658 (python)

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

if a.count(0)>0:
    print(0)
    exit(0)

total=1
for i in a:
    total *=i

    if total>10**18:
        print(-1)
        exit(0)
    
print(total)

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

import math

total=1
for i in range(n):
    total*=a[i]

b = int(math.pow(10,18))

if int(math.log10(total))-18>0:
    print(-1)
else:
    print(total)
Problem p02705 (python)

Fixed submission:
R=int(input())

import math

print(math.pi*R*2)

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

for i in range(1,N+1):
    print(IDs.count(i))
Problem p02727 (python)

Fixed submission:
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p=sorted(p,reverse=True)
q=sorted(q,reverse=True)
r=sorted(r)
p=p[:x]
q=q[:y]

import heapq
from collections import deque

heapq.heapify(p)
heapq.heapify(q)
r=deque(r)

for i in range(c):
    v_p=heapq.heappop(p)
    v_q=heapq.heappop(q)

    v_r=r.pop()
    if v_p<=v_q:
        heapq.heappush(q,v_q)
        if v_p<v_r:
            heapq.heappush(p,v_r)
        else:
            heapq.heappush(p,v_p)
    else:
        heapq.heappush(p,v_p)
        if v_q<v_r:
            heapq.heappush(q,v_r)
        else:
            heapq.heappush(q,v_q)

ans=sum(p)+sum(q)

print(ans)

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

p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p=sorted(p,reverse=True)
q=sorted(q,reverse=True)
r=sorted(r)

cntx=0
cnty=0

ans=0


for i in range(a):
    if p[i]>=r[-1]:
        ans+=p[i]
    else:
        ans+=r.pop()

    cntx+=1    

    if cntx==x:
        break

for j in range(b):
    if q[j]>=r[-1]:
        ans+=q[j]
    else:
        ans+=r.pop()

    cnty+=1

    if cnty==y:
        break

print(ans)
Problem p02732 (python)

Fixed submission:
import math
from collections import Counter

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

def combinations_count(n, r):
    if n==1:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
c = Counter(Balls)
d={}
ALL_SUM=0
for i,j in c.most_common():
    d[i]=j
    ALL_SUM+=combinations_count(j,2)
for k in Balls:
    print(ALL_SUM-(d[k] - 1))

# for k in range(N):
#     tmp=Balls[k]
#     array_k = Balls
#     sum_k=0
#     c= Counter(array_k)


#     for j in list(c.values()):
#         sum_k += combinations_count(j,2)
    
#     Balls.insert(k,tmp)
#     print(sum_k)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

def combinations_count(n, r):
    if n==1:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for k in range(N):
    tmp=Balls[k]
    del Balls[k]

    array_k = Balls
    sum_k=0
    c= Counter(array_k)
    for j in list(c.values()):
        sum_k += combinations_count(j,2)
    
    Balls.insert(k,tmp)
    print(sum_k)
Problem p02761 (python)

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

d={}

condi = []

string = ['0']*N

flg=0
for _ in range(M):
    s,c = map(int,input().split())

    condi.append([s,c])

    if s not in d:
        d[s]=c
    elif s in d :
        if d[s]!=c:
            flg+=1

if flg!=0:
    print(-1)
    exit(0)

if 1 in d:
    if d[1]==0 and N!=1:
        print(-1)
        exit(0)

if N==1 and M==0:
    print(0)
    exit(0)

for i in range(N):
    if i==0 and 1 not in d :
        string[0] = '1'
    else:
        if i+1 in d:
            string[i] = str(d[i+1])

str_num = ''.join(string)
print(str_num)

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

d={}

condi = []

string = ['0']*N

flg=0
for _ in range(M):
    s,c = map(int,input().split())

    condi.append([s,c])

    if s not in d:
        d[s]=c
    elif s in d :
        if d[s]!=c:
            flg+=1

if flg!=0:
    print(-1)
    exit(0)

if d[1]==0:
    print(-1)
    exit(0)



for i in range(N):
    if i==0 and 1 not in d :
        string[0] = '1'
    else:
        if i+1 in d:
            string[i] = str(d[i+1])

str_num = ''.join(string)
print(str_num)

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

d={}

condi = []

string = ['0']*N

flg=0
for _ in range(M):
    s,c = map(int,input().split())

    condi.append([s,c])

    if s not in d:
        d[s]=c
    elif s in d and d[s]!=c:
        flg+=1

if flg!=0:
    print(-1)
    exit(0)

if d[1]==0:
    print(-1)
    exit(0)



for i in range(N):
    if i==0 and 1 not in d :
        string[0] = '1'
    else:
        if i+1 in d:
            string[i] = str(d[i+1])

str_num = ''.join(string)
print(str_num)
Problem p02845 (python)

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

hat = [0,0,0]

mod = 10**9 + 7

ans=1

for i in range(n):
    tmp=0
    index=0
    for j,k in enumerate(hat):
        if k==a[i]:
            tmp+=1
            index=j

    ans = (ans*tmp)%mod

    hat[index]+=1

print(ans)

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

hat = [0,0,0]

mod = 10**9 + 7

ans=1
def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

for i in range(n):
    arr=my_index_multi(hat,a[i])

    ans = (ans*len(arr))%mod

    hat[arr[0]]+=1

print(ans)

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

hat = [0,0,0]

mod = 10**9 + 7
ans=1

def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

for i in range(n):
    arr=my_index_multi(hat,a[i])

    ans = ans*len(arr)%mod

    hat[arr[0]]+=1

print(ans)
Problem p02900 (python)

Fixed submission:
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

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

A_s = set(prime_factor(A))
B_s = set(prime_factor(B))

from fractions import gcd

print(len(A_s&B_s)+1)

Buggy submission (verdict: Runtime Error):
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

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

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

A_s = set(make_divisors(A))
B_s = set(make_divisors(B))

from fractions import gcd

prime_N=set(primes(gcd(A,B)))

ans = A_s&B_s&prime_N

print(len(ans)+1)

Buggy submission (verdict: Runtime Error):
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

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

A,B = map(int,input().split())
A_s = set(make_divisors(A))
B_s = set(make_divisors(B))
divs = A_s&B_s

max_div = max(list(divs))
prime_N=set(primes(max_div))

ans = divs&prime_N

print(len(ans)+1)

Buggy submission (verdict: Runtime Error):
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


def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


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

A_s = set(make_divisors(A))
B_s = set(make_divisors(B))

divs = A_s&B_s

max_div = max(list(divs))

prime_N=set(primes(max_div))

ans = divs&prime_N
ans = list(ans)

print(len(ans)+1)
Problem p02936 (python)

Fixed submission:
import sys #追加
sys.setrecursionlimit(500*500)

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

cost=[0]*n
edge = [[] for _ in range(n)]

for _ in range(n-1):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    edge[a].append(b)
    edge[b].append(a)

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


visited=[-1]*n


def dfs(n,c):

    cost[n]+=c
    tmp=cost[n]
    visited[n]=0

    for v in edge[n]:
        if visited[v]==-1:
            dfs(v,tmp)
    

dfs(0,0)

print(*cost)

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

cost=[0]*n
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    edge[a].append(b)
    edge[b].append(a)

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

from collections import deque

visited=[-1]*n
visited[0]=0
d=deque([0])
f=cost[0]

def dfs(n,c):

    cost[n]+=c
    tmp=cost[n]
    visited[n]=0

    for v in edge[n]:
        if visited[v]==-1:
            dfs(v,tmp)
    

dfs(0,0)

print(*cost)

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

tree={}
tree[1]=-1
cnt=[0]*N

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

for j in range(Q):
    p,x=map(int,input().split())
    p-=1
    cnt[p]+=x

for k in range(1,N):
    cnt[k]+=cnt[tree[k+1]-1]

# def search(root,x):
#     leaf =[]
#     for i,j in tree.items():
#         if j ==root:
#             leaf.append(i)
        
#     if len(leaf)!=0:
#         for k in leaf:
#             search(k,x)
#             cnt[k-1]+=x

# for i in range(N-1):
#     a,b = map(int,input().split())
#     tree[b]=a
# for j in range(Q):
#     p,x=map(int,input().split())
#     if p==1:
#         cnt+=x
#     else:
#         cnt[p-1]+=x
#         search(p,x)


print(*cnt)

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

import numpy as np
cnt = np.array([0]*N)

tree={}
tree[1]=-1

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

for j in range(Q):
    p,x=map(int,input().split())
    p-=1
    cnt[p]+=x

for k in range(1,N):
    cnt[k]+=cnt[tree[k+1]-1]

# def search(root,x):
#     leaf =[]
#     for i,j in tree.items():
#         if j ==root:
#             leaf.append(i)
        
#     if len(leaf)!=0:
#         for k in leaf:
#             search(k,x)
#             cnt[k-1]+=x

# for i in range(N-1):
#     a,b = map(int,input().split())
#     tree[b]=a
# for j in range(Q):
#     p,x=map(int,input().split())
#     if p==1:
#         cnt+=x
#     else:
#         cnt[p-1]+=x
#         search(p,x)


print(*cnt)
Problem p02971 (python)

Fixed submission:
N=int(input())

seq=[]

for i in range(N):
    a= int(input())
    seq.append(a)

import heapq

tmp=list(map(lambda x: x*(-1),seq))
heapq.heapify(tmp)

a=heapq.heappop(tmp)*(-1)
b=heapq.heappop(tmp)*(-1)

for j in range(N):
    if seq[j]==a:
        print(b)
    else:
        print(a)

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

seq=[]

for i in range(N):

    a= int(input())
    
    seq.append(a)

numbers=set(seq)
numbers=sorted(numbers,reverse=True)

A_max=numbers[0]

if len(numbers)>=2:
    A_second = numbers[1]

for k in range(N):
    if seq[k]==A_max:
        print(A_second)
    else:
        print(A_max)

# 2.両端から
# left=[0]
# for i in range(N-1):
#     left_i=max(left[i],seq[i])

#     left.append(left_i)

# right=[0]

# for j in range(N-1):
#     right_j = max(right[j],list(reversed(seq))[j])

#     right.append(right_j)

# right = list(reversed(right))

# for k in range(N):
#     print(max(left[k],right[k]))
Problem p02975 (python)

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

ans='No'
from collections import Counter

c=Counter(a)
keys = list(c.keys())
values =list(c.values())

if keys==[0]:
    ans='Yes'
elif len(keys)==3 and values[0]==n/3 and values[1]==n/3 and keys[0]^keys[1]==keys[2]:
    ans='Yes'
elif len(keys)==2 and c[0]==n/3:
    ans='Yes'

print(ans)

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

from collections import Counter

c=Counter(a)

v=list(c.values())
k=list(c.keys())

v=sorted(v)

ans='Yes'
if len(k)==3:
    for i in range(3):
        if v[i]!=n/3:
            ans='No'
            break
elif len(k)==2:
    for j in range(2):
        if v[j]!=n/3 and j==0:
            ans='No'
        elif v[j]!=2*n/3 andj==1:
            ans='No'
elif len(k)==1 and k[0]==0:
    ans='Yes'
else:
    ans='No'

print(ans)

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

from collections import Counter

c=Counter(a)

if len(list(c.keys())) ==3:
    if list(c.values())==[n//3,n//3,n//3]:
        print('Yes')
elif len(list(c.keys()))==2:
    if c.most_common()[0][1]==2*n//3:
        print('Yes')
elif len(list(c.keys()))==1:
    if c.keys()[0]==0:
        print('Yes')
else:
    print('No')
Problem p02995 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
from fractions import gcd

lcm = c*d//gcd(c,d)

num_b_c = b//c
num_b_d = b//d
num_b_cd = b//lcm

if a%c==0:
    num_a_c = a//c - 1
else:
    num_a_c = a//c

if a%d==0:
    num_a_d = a//d - 1
else:
    num_a_d = a//d

if a%lcm==0:
    num_a_cd = a//lcm - 1 
else:

    num_a_cd = a//lcm


alls = b - a + 1


c_div = num_b_c - num_a_c
d_div = num_b_d - num_a_d

cd_div = num_b_cd -num_a_cd


print(alls - ( c_div + d_div - cd_div))

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

lcm = c*d//math.gcd(c,d)

num_b_c = b//c
num_b_d = b//d
num_b_cd = b//lcm

if a%c==0:
    num_a_c = a//c - 1
else:
    num_a_c = a//c

if a%d==0:
    num_a_d = a//d - 1
else:
    num_a_d = a//d

if a%lcm==0:
    num_a_cd = a//lcm - 1 
else:

    num_a_cd = a//lcm


alls = b - a + 1


c_div = num_b_c - num_a_c
d_div = num_b_d - num_a_d

cd_div = num_b_cd -num_a_cd


print(alls - ( c_div + d_div - cd_div))
Problem p03001 (python)

Fixed submission:
w,h,x,y = map(int,input().split())

print(w*h/2, 1 if x==w/2 and y==h/2 else 0)

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

flg = 0
s=0

if x<=w/2 and y <= h/2:
    if x*h==w*y:
        flg=1
    s = max(x*h,w*y)

elif x<=w/2 and y>h/2:
    if x*h==w*(h-y):
        flg=1
    s = max(x*h,w*(h-y))
    
elif x>w/2 and y <= h/2:
    if (w-x)*h==w*y:
        flg==1:

    s = max( (w-x)*h , w*y)

elif x>w/2 and y > h/2:
    if (w-x)*h==w*(h-y):
        flg=1

    s = max( (w-x)*h, w*(h-y))

# if  x==w/2 and y==h/2:
#     flg = 1

# if w==h and x==y:
#     flg ==1

print(s,flg)
Problem p03103 (python)

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

d={}

for i in range(n):
    A,B=map(int,input().split())

    if A in d:
        d[A]+=B
    else:
        d[A]=B

l = sorted(list(d.items()),key=lambda x: x[0])

total=0
cnt=0

for i in range(len(l)):
    total+=l[i][0]*l[i][1]

    cnt+=l[i][1]

    if cnt>m:
        total -= l[i][0]*(cnt-m)
        print(total)
        exit(0) 

print(total)

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

d={}

for i in range(n):
    A,B=map(int,input().split())

    if A in d:
        d[A]+=B
    else:
        d[A]=B

l = sorted(list(d.items()),key=lambda x: x[0])

total=0
cnt=0

for i in range(n):
    total+=l[i][0]*l[i][1]

    cnt+=l[i][1]

    if cnt>m:
        total -= l[i][0]*(cnt-m)
        print(total)
        exit(0) 

print(total)

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

d={}

for i in range(n):
    A,B=map(int,input().split())

    d[A]=B

l = sorted(list(d.items()),key=lambda x: x[0])

total=0
cnt=0
for i in range(n):
    total+=l[i][0]*l[i][1]

    cnt+=l[i][1]

    if cnt>m:
        total -= l[i][0]*(cnt-m)
        print(total)
        exit(0) 

print(total)