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

Fixed submission:
A = input().split()
A[0] = int(A[0])
A[1] = int(A[1])
if A[0] == 2 or A[1] == 2:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
A = input().split()
if A[0] == 2 or A[1] == 2:
    print(No)
else:
    print(Yes)

Buggy submission (verdict: Runtime Error):
A,B = int(input().split())
if A == 2 or B == 2:
    print('No')
else:
    print('Yes')
Problem p03281 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 09:15:46 2020

@author: black
"""
def check(x):
    div = [1]
    for j in range(1, x):
        if (x)%(j+1) == 0:
            div.extend([j+1])
    return len(div)




N = int(input())
ans = []

for x in range(1, N+1):
    if x%2 == 1:
        if check(x) == 8:
            ans.extend([x])


print(len(ans))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 09:15:46 2020

@author: black
"""
def check(x):
    div = [1]
    for j in range(1, x):
        if (x)%(j+1) == 0:
            div.extend([j+1])
            if (i+1)%(j+1) == 0:
                div.extend([j+1])
    return len(div)




N = int(input())
ans = []

for x in range(1, N+1):
    if x%2 == 1:
        if check(x) == 8:
            ans.extend([x])


print(len(ans))
Problem p02783 (python)

Fixed submission:
import math
H, A = map(int, input().split())
print(math.ceil(H/A))

Buggy submission (verdict: Runtime Error):
import math
H, A = map(int, input().split())
print(math.ceil(H,A))
Problem p02811 (python)

Fixed submission:
K, X = map(int, input().split())
print("Yes" if 500*K >= X else "No")

Buggy submission (verdict: Runtime Error):
K, X = map(int, input().split())
print("Yes" if 500*K > = X else "No")

Buggy submission (verdict: Runtime Error):
K, X = map(int, input().split())
print("Yes" if 500*K > = 2000 else "No")
Problem p02898 (python)

Fixed submission:
N, K = map(int, input().split())
List = list(map(int, input().split()))
count = 0
for i in List:
  if i>=K:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
List = list(map(int, input().split()))
count = 0
for i in List:
  if i>=K:
    count +=
print(count)
Problem p02910 (python)

Fixed submission:
S = input()
print("No" if "L" in S[0::2] or "R" in S[1::2] else "Yes")

Buggy submission (verdict: Runtime Error):
S = input()
print("No" if "L" in "S[0::2] or "R" in S[1::2] else "Yes")
Problem p02922 (python)

Fixed submission:
import math
A, B = map(int, input().split())
print(math.ceil((B-1)/(A-1)))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(math.ceil(B/A)))
Problem p02957 (python)

Fixed submission:
A, B = map(int, input().split())
print((A+B)//2 if (A+B)% 2 == 0 else "IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print((A+B)//2 if (A+B)% == 0 else "IMPOSSIBLE")
Problem p03101 (python)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input())
h, w = map(int, input())
print((H-h)*(W-w))
Problem p03109 (python)

Fixed submission:
S = input()
if S[5] == "1":
  print("TBD")
elif int(S[6]) > 4:
  print("TBD")
else:
  print("Heisei")

Buggy submission (verdict: Runtime Error):
S = input()
if S[5] == "1":
  print("TBD")
  elif int(S[6]) > 4:
    print("TBD")
  else:
    print("Heisei")

Buggy submission (verdict: Runtime Error):
S = input()
if S[5] == "1":
  print("TBD")
  elif int(S[6]) > 4:
    print("TBD")
else:
  print("Heisei")

Buggy submission (verdict: Runtime Error):
S = input()
if S[5] == "1":
  print("TBD")
  elif S[6] > "4":
    print("TBD")
else:
  print("Heisei")
Problem p03145 (python)

Fixed submission:
x, y, z = map(int, input().split())
print(x*y//2)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
print(x*y/2)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
print(x*y//2)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input())
print(x*y//2)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
print(x*y/2)
Problem p03210 (python)

Fixed submission:
X = input()
if X in "753":
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
X = int(input())
if X in "753":
  print("YES")
else:
  print("NO")
Problem p03308 (python)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
print(A[N-1]-A[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))
print(A[N+-]-A[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split())))
print(A[N+1]-A[0])
Problem p03377 (python)

Fixed submission:
A, B, X = map(int, input().split())
print("YES" if A <= X and A+B >= X else "NO")

Buggy submission (verdict: Runtime Error):
A, B, X = map(int, inpput().split())
print("YES" if A <= X and A+B >= X else "NO")

Buggy submission (verdict: Runtime Error):
A, B, X = map(int, inpput().split())
print("YES" if A+B >= X else "NO")
Problem p03605 (python)

Fixed submission:
N = input()
print("Yes" if "9" in N else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
if 9 in N:
  print("Yes")
else:
  print("No")
Problem p03635 (python)

Fixed submission:
a, b = map(int, input().split())
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
a, b = int(input().split())
print((a-1)*(b-1))
Problem p03852 (python)

Fixed submission:
c = str(input())
if c in "aiueo":
  print("vowel")
else:
  print("consonant")

Buggy submission (verdict: Runtime Error):
c = str(input())
if "a", "e", "i", "o", "u" in c:
  print("vowel")
else:
  print("consonant")
Problem p03943 (python)

Fixed submission:
abc = sorted(list(map(int, input().split())))
print("Yes" if abc[0] + abc[1] == abc[2] else "No")

Buggy submission (verdict: Runtime Error):
abc = sorted(list(int, input().split()))
print("Yes" if abc[0] + abc[1] == abc[2] else "No")
Problem p02705 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import math


R = int(input())
PI = math.pi

ans = 2 * R * PI
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(input().split())
A = [int(i) for i in A]
B = len(A)+1

for i in range(B):
    print(A.count(i+1))
Problem p02705 (python)

Fixed submission:
a=int(input())
print(2*3.14*a)

Buggy submission (verdict: Runtime Error):
n,m=input().split()
n=int(n)
m=int(m)
s=0
for i in input().split():
  s=s+ int(i)
if s>n:
  print("-1")
else:
  print(n-s)

Buggy submission (verdict: Runtime Error):
a=float(input())
b=2*3.14.a
print(b)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=2*3.14.a
print(b)
Problem p02706 (python)

Fixed submission:
n,m=map(int, input().split())
s=0
for i in input().split():
    s=s+int(i)
if s>n:
    print("-1")
else:
    print(n-s)

Buggy submission (verdict: Runtime Error):
n,m=int(input.split())
s=0
for i in input.split():
  s=s+i
if s>n:
  print("-1")
else:
  print(n-s)
Problem p02705 (python)

Fixed submission:
import math
R=int(input())
print(2*math.pi*R)

Buggy submission (verdict: Runtime Error):
l=[list(map(int,input().split())) for _ in range(2)]
homework=0
for i in range(l[0][1]):
    homework=homework+l[1][i]
free=l[0][0]-homework
if free<0:
    print(-1)
else:
    print(free)
Problem p02706 (python)

Fixed submission:
l=[list(map(int,input().split())) for _ in range(2)]
homework=0
for i in range(l[0][1]):
    homework=homework+l[1][i]
free=l[0][0]-homework
if free<0:
    print(-1)
else:
    print(free)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
homework=0
for i in range(l[1]):
    homework=homework+l[i+2]
free=l[0]-homework
if free<0:
    print(-1)
else:
    print(free)
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())
i=1
list=[]

while a>=i and b>=i:
    if a%i==0 and b%i==0:
        list.append(i)
    i+=1

print(list[len(list)-k])

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
i=1
list=[]

while a>i and b>i:
    if a%i==0 and b%i==0:
        list.append(i)
    i+=1

print(list[k-1])
Problem p03323 (python)

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

if a<9 and b<9:
  print("Yay!")
elif a>8 or b>8:
  print(":(")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if 
if a>9 and b>9:
  print(":(")
else:
  print("yay!")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a>9 0r b>9:
  print(":(")
else:
  print("yay!")
Problem p02713 (python)

Fixed submission:
import numpy as np
 
K = int(input())
ans = 0

gcd2 = np.zeros((K+1, K+1), dtype=int)

for i in range(1, K):
    for j in range(i+1,K+1):
        gcd2[i,j] = gcd2[j,i] = np.gcd(i,j)
for i in range(1, K+1):
    gcd2[i,i] = i

for i in range(1,K+1):
    ans += i

for i in range(1, K):
    for j in range(i+1, K+1):
        ans += 3 * gcd2[i,j]
for i in range(1, K+1):
    for j in range(1, i):
        ans += 3 * gcd2[i,j]
        
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            ans += 6 * gcd2[i,gcd2[j,k]]
            
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
K = int(input())
ans = 0
for i in range(1,K+1):
    ans += np.gcd.reduce([i,i,i])

for i in range(1, K):
    for j in range(i+1, K+1):
        ans += 3 * np.gcd.reduce([i,j,j])
for i in range(1, K+1):
    for j in range(1, i):
        ans += 3 * np.gcd.reduce([i,j,j])
        
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            ans += 6 * np.gcd.reduce([i,j,k])
            
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
K = int(input())
ans = 0
for i in range(1,K+1):
    ans += np.gcd.reduce([i,i,i])

for i in range(1, K):
    for j in range(i+1, K+1):
        ans += 3 * np.gcd.reduce([i,j,j])
for i in range(1, K+1):
    for j in range(1, i):
        ans += 3 * np.gcd.reduce([i,j,j])
        
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            ans += 6 * np.gcd.reduce([i,j,k])
            
print(ans)

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

# K = int(input())
ans = 0
for i in range(1,K+1):
#     print(1, (i,i,i))
    ans += np.gcd.reduce([i,i,i])

for i in range(1, K):
    for j in range(i+1, K+1):
#         print(3, (i,j,j))
        ans += 3 * np.gcd.reduce([i,j,j])
for i in range(1, K+1):
    for j in range(1, i):
#         print(3, (i,j,j))
        ans += 3 * np.gcd.reduce([i,j,j])
        
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
#             print(6, (i,j,k))
            ans += 6 * np.gcd.reduce([i,j,k])
print(ans)
Problem p02721 (python)

Fixed submission:
n, k, c = map(int, input().split())
s = input()

def solve_dp(s):
  dp = [0]*(n+2)
  for i in range(n):
    if i <= c and s[i] == 'o':
      dp[i+1] = 1
    else:
      if s[i] == 'o':
        dp[i+1] = max(dp[i], dp[i-c]+1)
      else:
        dp[i+1] = dp[i]
  return dp

mae = solve_dp(s)
ushiro = solve_dp(s[::-1])[::-1]

for i in range(1,n+1):
  if mae[i-1] + ushiro[i+1] < k:
    print(i)

Buggy submission (verdict: Runtime Error):
k = int(input())
lunluns = list(map(str, range(1,10)))
new = list(map(str, range(1,10)))
new_fueta = 9
end = False
while len(lunluns) < k:
  new_new_fueta = 0
  for x in lunluns[-new_fueta:]:
    str_x = str(x)
    if str_x[-1] == '0':
      lunluns += [int(str_x+'0'),int(str_x+'1')]
      new_new_fueta += 2
    elif str_x[-1] == '9':
      lunluns += [int(str_x+'8'),int(str_x+'9')]
      new_new_fueta += 2
    else:
      l = int(str_x[-1])
      lunluns += [int(str_x+str(l-1)), int(str_x+str(l)), int(str_x+str(l+1))]
      new_new_fueta += 3
  if end:
    break
  new_fueta = new_new_fueta
print(lunluns[k-1])
Problem p02755 (python)

Fixed submission:
import math
 
A, B = list(map(int, input().split()))
x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  for x in range(max(x_minA, x_minB), min(x_maxA, x_maxB)+1):
    if int(x * 8 / 100) == A and int(x / 10)==B:
      print(x)
      break
  else:
    print(-1)

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))
for i in range(1,1010):
  if int(i*8/100)==A and if int(i/10)==B:
    print(i)
    break
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
import math
import bisect
import numpy as np

x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:x_min = max(x_minA, x_minB)
  x_max = min(x_maxA, x_maxB)
  tansaku = np.array(range(max(x_minA, x_minB), min(x_maxA, x_maxB)+1))
  insert_index_a = bisect.bisect_left(tansaku*8/100-A,1)
  insert_index_b = bisect.bisect_left(tansaku/10-B,1)
  print(int(tansaku[min(insert_index_a, insert_index_b)]))

Buggy submission (verdict: Runtime Error):
import math

x_minA = math.ceil(100 / 8 * A)
x_minB =  10 * B
x_maxA = math.floor(100 / 8 * (A+1))
x_maxB = 10 * (B+1)
if x_minA > x_maxB or x_minB > x_maxA:
  print(-1)
else:
  x = max(x_minA, x_minB)
  while (x * 8 / 100 - A >= 1) or (x / 10 - B >= 1):
    print(x, x * 8 / 100, x / 10)
    x += 1
  print(x)
Problem p02787 (python)

Fixed submission:
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for x in range(1, H + max_damage):
    dp[x] = min(dp[x - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

print(ans)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>

#define REP(i,n) for(int i=0;i<n;i++)
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


using namespace std;
using ll=long long;
ll mod = 1e9 + 7;

//int dp[1e5];
//memset(dp, BMAX*HMAX, sizeof(dp));
  
int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
    }
    vector<ll> dp(H+1, 1e9);
    dp[0] = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<N;j++){
            chmin(dp[min(i+A[j], H)], dp[i]+B[j]);
        }
    }
    cout << dp[H] << endl;
	return 0;
}
Problem p02788 (python)

Fixed submission:
from math import ceil
from collections import deque
N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h / A)] for x, h in Monsters]


acc_damage = 0
que = deque([])

ans = 0
for x, h in Monsters:
    # 期限切れの蓄積ダメージを削除
    while que and x > que[0][0]:
        limit, damage = que.popleft()
        acc_damage -= damage

    need = max(0, h - acc_damage)
    ans += need
    acc_damage += need

    if need:
        que.append([x + 2 * D, need])

print(ans)

Buggy submission (verdict: Runtime Error):
from math import ceil
import bisect

N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
X = [x for x, h in Monsters]
H = [ceil(h / A) for x, h in Monsters]

min_n = 0

for i in range(N):
  if H[i] <= 0:
    continue
  #i_2Di = bisect.bisect_left(X, X[i]+2*D)
  for j in range(i+1,N):
    if X[j] - X[i] > 2*D:
      i_2Di = j
      break
  H[i:i_2Di] -= A * ni
  min_n += ni
  
print(min_n)

Buggy submission (verdict: Runtime Error):
from math import ceil
import bisect

N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
X = [x for x, h in Monsters]
H = [ceil(h / A) for x, h in Monsters]

min_n = 0

for i in range(N):
  if H[i] <= 0:
    continue
  i_2Di = bisect.bisect_left(X, X[i]+2*D)
  H[i:i_2Di] -= A * ni
  min_n += ni
  
print(min_n)
Problem p02789 (python)

Fixed submission:
N, M = list(map(int, input().split()))
print('Yes' if N == M else 'No')

Buggy submission (verdict: Runtime Error):
N, M = lit(map(int, input().split()))
print('Yes' if N == M else 'No')
Problem p02813 (python)

Fixed submission:
import itertools
N = int(input())
P = int(''.join(input().split()))
Q = int(''.join(input().split()))
Ns = list(itertools.permutations([str(i) for i in range(1,N+1)], N))
NP = 0
NQ = 0
for ni in Ns:
  nii = int(''.join(ni))
  if nii < P:
    NP += 1
  if nii < Q:
    NQ += 1
print(abs(NP - NQ))

Buggy submission (verdict: Runtime Error):
import itertools
N = int(input())
P = list(map(int, input()))
Q = list(map(int, input()))
Ns = list(itertools.permutations(range(1,N+1), N))
NP = 0
NQ = 0
for ni in Ns:
  if ni < P:
    NP += 1
  if ni < Q:
    NQ += 1
print(abs(NP - NQ)
Problem p03161 (python)

Fixed submission:
import numpy as np

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

k = min(k, n-1)
dp = np.zeros(n+1)

for i in range(2, k+1):
    dp[i] = np.min(dp[1:i] + np.abs(h[i-1] - h[0:i-1]))

for i in range(k+1, n+1):
    dp[i] = (dp[i-k:i] + np.abs(h[i-1] - h[i-k-1:i-1])).min()
    
print(int(dp[n]))

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

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))

k = min(k, n-1)
dp = np.zeros(n+1)

for i in range(2, k+1):
    dp[i] = np.min(dp[1:i] + np.abs(h[i-1] - h[0:i-1]))

for i in range(k+1, n+1):
    dp[i] = (dp[i-k:i] + np.abs(h[i-1] - h[i-k-1:i-1])).min()
    
print(int(dp[n]))
Problem p03164 (python)

Fixed submission:
# dp[n][w]とすると，O(nw)でwが大きすぎて大変
# dp[n][v]として，価値vを達成するための最小のwを記録するO(N^2 V_{max})
# さらにdp[v]としてw, vを使うかどうかで更新する
import sys
input = sys.stdin.readline
import numpy as np

n, W = map(int, input().split())
dp = np.full(10**5 + 1, 10**12, dtype='int64')
dp[0] = 0 
for _ in range(n):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[:-v]+w, dp[v:])

#print(np.max(np.where(dp <= W)))
print(np.where(dp <= W)[0][-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
import numpy as np
 
def main():
  n, W = map(int, input().split())
  dp = np.zeros(W+1, dtype=np.int64)
  for _ in range(n):
    w, v = map(int, input().split())
    # 状態n,wにおいてwi,viを使うかどうかで更新する
    dp[w:W+1] = np.maximum(dp[:W-w+1]+v, dp[w:W+1])
  print(dp[W])

if __name__ == "__main__":
  main()
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

def rec(n):
  if dp[n] != -1:
    return dp[n]
  else:
    max_n = 0
    for i in graph[n]:
      max_n = max(max_n, rec(i)+1)
    dp[n] = max_n
    return dp[n]
  
N, M = list(map(int, input().split()))

dp = [-1]*N # nを始点としたときの最大値

graph = [[] for _ in range(N)]
for _ in range(M):
  xi, yi = list(map(int, input().split()))
  graph[xi-1].append(yi-1)

ans = 0
for n in range(N):
  ans = max(rec(n), ans)
print(ans)

Buggy submission (verdict: Runtime Error):
def rec(n):
  if dp[n] != -1:
    return dp[n]
  else:
    max_n = 0
    for i in graph[n]:
      max_n = max(max_n, rec(i)+1)
    dp[n] = max_n
    return dp[n]
  
N, M = list(map(int, input().split()))

dp = [-1]*n # nを始点としたときの最大値

graph = [[] for _ in range(N)]
for _ in range(M):
  xi, yi = list(map(int, input().split()))
  graph[xi-1].append(yi-1)

ans = 0
for n in range(N):
  ans = max(rec(n), ans)
print(ans)

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

def rec(n):
  if dp[n] != -1:
    return dp[n]
  else:
    max_n = 0
    for i in graph[n]:
      max_n = max(max_n, rec(i)+1)
    dp[n] = max_n
    return dp[n]
  
N, M = list(map(int, input().split()))

dp = np.full(N, -1, dtype=int) # nを始点としたときの最大値

graph = [[] for _ in range(N)]
for _ in range(M):
  xi, yi = list(map(int, input().split()))
  graph[xi-1].append(yi-1)

ans = 0
for n in range(N):
  ans = max(rec(n), ans)
print(ans)
Problem p03632 (python)

Fixed submission:
a, b, c, d = list(map(int, input().split()))
print(max(0, min(b, d) - max(a, c)))

Buggy submission (verdict: Runtime Error):
a, b, c, d = list(map(int, input()))
print(max(0, min(b, d) - max(a, c)))
Problem p04001 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2000)

s = list(input())
n = len(s)-1
ans = 0

def rec(plus):
  if len(plus) == n:
    global ans
    si = s[0]
    for i in range(n):
      if plus[i] == '-':
        si += s[i+1]
      else:
        ans = ans + int(si)
        si = s[i+1]
    ans = ans + int(si)
  else:
    rec(plus+'-')
    rec(plus+'+')

if n == 0:
  print(1)
else:
  rec('-')
  rec('+')
  print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

s = list(input())
n = len(s)-1
ans = 0

def rec(plus):
  if len(plus) == n:
    global ans
    si = s[0]
    for i in range(n):
      if plus[i] == '-':
        si += s[i+1]
      else:
        ans = ans + int(si)
        si = s[i+1]
    ans = ans + int(si)
  else:
    rec(plus+'-')
    rec(plus+'+')

rec('-')
rec('+')
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)

s = list(input())
n = len(s)-1
ans = 0

def rec(plus):
  if len(plus) == n:
    global ans
    si = s[0]
    for i in range(n):
      if plus[i] == '-':
        si += s[i+1]
      else:
        ans = ans + int(si)
        si = s[i+1]
    ans = ans + int(si)
  else:
    rec(plus+'-')
    rec(plus+'+')

rec('-')
rec('+')
print(ans)
Problem p03837 (python)

Fixed submission:
import numpy as np

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

d = np.ones((n, n)) * 1001

es = []
for i in range(m):
    es.append(list(map(int, input().split())))

for (i, j, w) in es:
    d[i - 1][j - 1] = w
    d[j - 1][i - 1] = w


for k in range(n):
    for i in range(n):
        for j in range(n):
            l = d[i][k] + d[k][j]
            if d[i][j] > l:
                d[i][j] = l

c = 0
for (i, j, w) in es:
    if d[i - 1][j - 1] < w:
        c += 1

print(c)

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

d = np.ones((n, n)) * 1001

es = []
for i in range(m):
    es.append(list(map(int, input().split())))

for (i, j, w) in es:
    d[i - 1][j - 1] = w
    d[j - 1][i - 1] = w


for k in range(n):
    for i in range(n):
        for j in range(n):
            l = d[i][k] + d[k][j]
            if d[i][j] > l:
                d[i][j] = l

c = 0
for (i, j, w) in es:
    if d[i - 1][j - 1] < w:
        c += 1

print(c)
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
N = int(input())
# N=3
# M=1
# A=[5,4,2,1]
 
cnt = 0
cnt1 = 0
 
# for i in range(N):
#     cnt = cnt + A[i]
#
# for i in range(N):
#     if A[i] / cnt > 1 / 4 / M:
#         cnt1 = cnt1 + 1
 
sum=0
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N + 1):
            sum =sum + gcd(i,j,k)
            # print(i,j,k)
 
# a1 = N % 10
# a2 = ((N-a1*10) % 100)/10
# a3 = ((N-a1*100-a2*10))/100
 
print(sum)

Buggy submission (verdict: Runtime Error):

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
N = map(int, input().split())
# N=3
# M=1
# A=[5,4,2,1]

cnt = 0
cnt1 = 0

# for i in range(N):
#     cnt = cnt + A[i]
#
# for i in range(N):
#     if A[i] / cnt > 1 / 4 / M:
#         cnt1 = cnt1 + 1

sum=0
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N + 1):
            sum =sum + gcd(i,j,k)
            # print(i,j,k)

# a1 = N % 10
# a2 = ((N-a1*10) % 100)/10
# a3 = ((N-a1*100-a2*10))/100

print(sum)