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

Fixed submission:
from fractions import gcd
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
kyori_list = [abs(X-i) for i in x_list]
ans_gcd = kyori_list[0]
for i in kyori_list[1:]:
    ans_gcd = gcd(ans_gcd, i)
print(ans_gcd)

Buggy submission (verdict: Runtime Error):
from math import gcd
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
kyori_list = [abs(X-i) for i in x_list]
ans_gcd = kyori_list[0]
for i in kyori_list[1:]:
    ans_gcd = gcd(ans_gcd, i)
print(ans_gcd)

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

from math import gcd

N, X = map(int, input().split())
x_list = list(map(int, input().split()))

kyori_list = [abs(X-i) for i in x_list]

ans_gcd = kyori_list[0]
for i in kyori_list[1:]:
    ans_gcd = gcd(ans_gcd, i)
print(ans_gcd)

Buggy submission (verdict: Runtime Error):
from math import gcd
N, X = map(int, input().split())
x = [abs(X - i) for i in map(int, input().split())]
d = x[0]
for X in x[1:]:
    d = gcd(d,X)
print(d)
Problem p02999 (python)

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

if x < a:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
import sys

w, h, x, y = input().split()
w = float(w)
h = float(h)
x = float(x)
y = float(y)
s=0

for i in range(100000000):
  a=i/1000
  if a<=h/w:
    cand=w*(a*w-2*a*x+2*y)/2
    s_cand=min(cand,w*h-cand)
    if s_cand>s:
      s=s_cand
  else:
    cand=h*(h+2*a*x-2*y)/(2*a)
    s_cand=min(cand,w*h-cand)
    if s_cand>s:
      s=s_cand
      
if w/2==x and h/2==y:
  print(w*h/2, 1)
else:
  print(s,0)
Problem p03000 (python)

Fixed submission:
import sys

n, x = input().split()
n = int(n)
x = int(x)
l = input().split()
a = 0

for i in range(n):
  a += int(l[i])
  if a > x:
    print(i+1)
    sys.exit()
    
print(n+1)

Buggy submission (verdict: Runtime Error):
n, x = input().split()
n = int(n)
x = int(x)
l = input().split()
a = 0

for i in range(n):
  a += int(l[i])
  if a > x:
    j = i
    break
    
print(j + 1)
Problem p03005 (python)

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

if k == 1:
  print(0)
else:
  print(n-k)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
  a.append(input().split())
  a[i][0] = int(a[i][0])
  a[i][1] = int(a[i][1])
b = []
d = []
e = []
a.sort()
dic = {}
for i in range(n-1):
  if [a[i+1][0] - a[i][0], a[i+1][1] - a[i][1]] not in d:
    d.append([a[i+1][0] - a[i][0], a[i+1][1] - a[i][1]])
    e.append(1)
  else:
    e[d.index([a[i+1][0] - a[i][0], a[i+1][1] - a[i][1]])] += 1
# f = d[e.index(max(e))]
# p = f[0]
# q = f[1]
print(n-max(e))
Problem p02994 (python)

Fixed submission:
import numpy as np
a = input()
n, l = [int(i) for i in a.split(" ")]
apples = np.array([i for i in range(n)])
aji = apples + l
abss = [np.abs(aji[apples != i].sum() - aji.sum()) for i in range(n)]
i = abss.index(np.min(abss))
print(aji[apples != i].sum())

Buggy submission (verdict: Runtime Error):
import numpy as np
a = input()
n, l = [int(i) for i in a.split(" ")]
apples = np.array([i for i in range(n)])
aji = apples + l
abss = [np.abs(aji[apples != i].sum() - aji.sum()) for i in range(n)]
i = abss.index(np.min(abss))
print([aji[apples != i].sum()][i])

Buggy submission (verdict: Runtime Error):
import numpy as np
a = input()
int(n), int(l) = a.split(" ")
apples = [i for i in range(n)]
abs_app = np.abs(apples)
m = abs_app.min()
app = np.array(apples)
app = app + l - 1
print(app[abs_app != m].sum())

Buggy submission (verdict: Runtime Error):
import numpy as np
a = input()
n, l= a.split(" ")
apples = [i for i in range(n)]
abs_app = np.abs(apples)
m = abs_app.min()
print((np.array(apples)[abs_app == m]).sum())
Problem p02995 (python)

Fixed submission:
import fractions

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

a = input()
a, b, c, d = [int(i) for i in a.split(" ")]
dc = (b // c) - ((a-1) // c)
dd = (b // d) - ((a-1)  // d)
dcd = (b // lcm(c, d)) - ((a-1) // lcm(c, d))
print((b - a) + 1 - (dc + dd - dcd))

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

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

a = input()
a, b, c, d = [int(i) for i in a.split(" ")]
dc = (b // c) - ((a-1) // c)
dd = (b // d) - ((a-1)  // d)
dcd = (b // lcm(c, d)) - ((a-1) // lcm(c, d))
print((b - a) + 1 - (dc + dd - dcd))

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
def lcm(x, y):
	return (x * y) // math.gcd(x, y)

a = input()
a, b, c, d = [int(i) for i in a.split(" ")]
dc = (b // c) - ((a-1) // c)
dd = (b // d) - ((a-1)  // d)
dcd = (b // lcm(c, d)) - (a // lcm(c, d))
print((b - a) + 1 - (dc + dd - dcd))

Buggy submission (verdict: Runtime Error):
import numpy as np
import concurrent.futures as confu

def cou(i):
		if i % c != 0:
			if i % d != 0:
				return 1
		return 0
		
		
a = input()
a, b, c, d = [int(i) for i in a.split(" ")]
count = 0
with confu.ProcessPoolExecutor() as ex:
	th = ex.map(cou, range(a,b))
	for i in th:
		count += i
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
import concurrent.futures as confu

def cou(i):
		if i % c != 0:
			if i % d != 0:
				return 1
		return 0
		
		
a = input()
a, b, c, d = [int(i) for i in a.split(" ")]
count = 0
with confu.ThreadPoolExecutor() as ex:
	th = ex.map(cou, range(a,b))
	for i in th:
		count += i
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
a = input()
a, b, c, d = [int(i) for i in a.split(" ")]
num = np.arange(a, b)
print((num % (c * d) == 0).sum())
Problem p03415 (python)

Fixed submission:
A=raw_input()
B=raw_input()
C=raw_input()

D=A[0]+B[1]+C[2]

print(D)

Buggy submission (verdict: Runtime Error):
A=raw_input()
B=raw_input()
C=raw_input()

D=A[0]+B[1]+C[2]

print(D)
Problem p03473 (python)

Fixed submission:
print(48 - int(input()))

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

posts = input().split('-')
if len(s) == 2 and a == len(post[0]) and b == len(post[1]) and s[0].isnumeric() and s[1].isnumeric():
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
print(48 - int(input())
Problem p03567 (python)

Fixed submission:
if "AC" in input():
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
if "AC" in input():
    print("Yes")
else
    print("No")
Problem p03624 (python)

Fixed submission:
s = input()

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

for c in s:
    if c in a:
        a.remove(c)
if len(a) > 0:
    print(a[0])
else:
    print("None")

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

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

for c in s:
    if c in a:
        a.remove(c)

print(a[0])
Problem p03777 (python)

Fixed submission:
a,b = input().split(' ')
 
if a == "H":
    print(b)
elif b == "H":
    print(a)
else:
    print("H")

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

if a == "H":
    print(b)
else if b == "H":
    print(a)
else:
    print("H")

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

if a == "H":
    print(b)
else if b == "H":
    print(a)
else:
    print("H")
Problem p03951 (python)

Fixed submission:
import sys

N = int(input())

a = input()
b = input()

for i in range(N):
	if a[i:N] == b[0:N-i]:
		print(N+i)
		sys.exit()
		
print(2 * N)

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())

a = input()
b = input()

for i in range(N):
	if(a[0:N-i] == b[i:N]){
		print(N+i)
		sys.exit()
		
print(2 * N)
Problem p03962 (python)

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

if a == b == c:
  print(1)
elif a == b or b == c or c == a:
  print(2)
else:
  print(3)

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

print(k * ((k-1) ** (n-1)))
Problem p03005 (python)

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

if K==1:
  print(0)
else:
  print(N-K)

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

f = [(B_lis[_]/A_lis[_], A_lis[_], B_lis[_]) for _ in range(3)]

f.sort()
f.reverse()

rest = N
gain = 0

for j in range(3):
  if f[j][0] > 1.0:
    g = rest // f[j][1]
    rest -= g * f[j][1]
    gain += g * f[j][2]

print(gain+rest)
Problem p03030 (python)

Fixed submission:
#from IPython import embed
N=int(input())
n = []

from collections import Counter

c = Counter()

for i in range(N):
    k = input().split()
    k[1] = int(k[1])
    k.append(i+1)
    n.append(k)
    c.update([k[0]])



n.sort()
#n = n[::-1]
prev = ""
l = []
cnt = 0
#print(c)
for a in n:
    #print(a)

    if c[a[0]] > 1:
        l.append(a[1:])
        #print(a[1:])
        cnt+=1
        #print(a[0])
        #embed()
        if cnt == c[a[0]]:
            l.sort()
            #print(l)
            for i in l[::-1]:
                print(i[1])
            cnt = 0
            l = []
    else:
        print(a[2])

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;
char in[120];
pair<pair<string, int>, int> p[110];

int main () {
  int N;
  cin >> N;
  for (int i = 0; i< N; i++) {
    int t;
    string tmp;
    cin >> tmp >> t;
    
    p[i]=make_pair(make_pair(tmp,-t),i);
  }  
  sort(p,p+N);
  for (int i = 0; i<N;i++) {
    cout << p[i].second+1 << endl;
  }
}
Problem p02993 (python)

Fixed submission:
n=list(input())
f=0
for i in range(len(n)-1):
    if(n[i]==n[i+1]):
        f=1
if(f==1):
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
n=list(input())
f=0
for i in range(len(n)):
    if(n[i]==n[i+1]):
    	f=1
if(f==1):
	print("Bad")
else:
	print("Good")
Problem p03076 (python)

Fixed submission:
import math

i = []
for l in range(5):
    i.append(int(input()))
m = 0
l = 0
mx = -1
for x in range(5):
    if m < (10 - i[x] % 10) and 10 - i[x] % 10 != 10:
        if x != 0:
            l += math.ceil(i[mx] / 10) * 10
        m = 10 - i[x] % 10
        mx = x
    else:
        l += math.ceil(i[x] / 10) * 10
if mx != -1:
    l += i[mx]
print(l)

Buggy submission (verdict: Runtime Error):
import math

i = []
for l in range(5):
    i.append(int(input()))
m = -1
l = 0
for x in range(5):
    if m < (10 - i[x] % 10) and 10 - i[x] % 10 != 10:
        if x != 0:
            l += math.ceil(i[mx] / 10) * 10
        m = 10 - i[x] % 10
        mx = x
    else:
        l += math.ceil(i[x] / 10) * 10
l += i[mx]
print(l)
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
L = [l for l in map(int, input().split())]

dist = 0
num = 1

for (i, v) in enumerate(L):
  dist += v
  if dist <= x:
    num += 1
    continue
  else:
    break
    
print(num)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
L = [l for l in map(int, input().split())]

num = 0
dist = 0
while dist <= x:
  dist += L[num]
  num += 1
  
print(num)
Problem p03037 (python)

Fixed submission:
import numpy as np
N, M = [int(i) for i in input().split()]

gate = np.zeros(N+1)
for i in range(0, M):
    L, R = [int(j) for j in input().split()]
    gate[L-1] += 1
    gate[R] -=1

count = 0
for i in range(1, len(gate)):
    gate[i] = gate[i] + gate[i-1]
    if gate[i] == M:
        count += 1

if gate[0] == M:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = [int(i) for i in input().split()]

gate = np.zeros(N+1)
for i in range(0, M):
    L, R = [int(j) for j in input().split()]
    gate[L-1] += 1
    gate[R] -=1

count = 0
for i in range(1, len(gate)):
    gate[i] = gate[i] + gate[i-1]

for i in range(0, M):
    if gate[i] == M:
        count += 1

print(count)
Problem p03059 (python)

Fixed submission:
A,B,T=map(int, input().split())
t_max = int((T+0.5)/A)
print(t_max*B)

Buggy submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
X = 0
for i in range(N):
    if(V[i]-C[i] > 0):
        X += V[i] - C[i]
print(int(X))

Buggy submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
X = 0
for i in range(N):
    if(V[i]-C[i] > 0):
        X += V[i] - C[i]
print(X)

Buggy submission (verdict: Runtime Error):
N = int(input())
V=list(map(int, input().split()))
C= list(map(int, input().split()))
X = 0
for i in range(N):
  if(V[i]-C[i]>0):
    X += V[i] -C[i]
print(X)

Buggy submission (verdict: Runtime Error):
A, B, T map(int, input().split()) 
t_max = int((T+0.5)/A)
bis = 0
for t in range(t_max):
  bis += B*(t+1)
print(bis)

Buggy submission (verdict: Runtime Error):
A,B,T=map(int, input().split())
t_max = int((T+0.5)/(A))
for t in range(t_max):
	bis += B*(t+1)
print(bis)
Problem p03060 (python)

Fixed submission:
N = int(input())
V = list(map(int, input().split( )))
C = list(map(int, input().split( )))
X = 0
for i in range(N):
    if(V[i]-C[i]>0):
        X += V[i] - C[i]
print(X)

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

X_Y = 0
for i in range(N):
  if cost[i] > 0:
	X_Y += V[i] - C[i]
print(X_Y)
Problem p03068 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
s = input()
k = int(input())

selected = s[k - 1]
print(''.join(['*' if l != selected else l for l in s ]))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
s = input()
k = int(input())

selected = s[k]
print(''.join(['*' if l != selected else l for l in s ]))
Problem p02995 (python)

Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
cn = b//c + (-a//c) + 1
dn = b//d + (-a//d) + 1
cd = (c*d)//fractions.gcd(c, d)
cdn = b//cd + (-a//cd) + 1
print(b-a+1-(cn+dn-cdn))

Buggy submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
cn = b//c + (-a//c) + 1
dn = b//d + (-a//d) + 1
cd = (c*d)//math.gcd(c, d)
cdn = b//cd + (-a//cd) + 1
print(b-a+1-(cn+dn-cdn))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a, b, c, d = map(int, input().split())
cn = b//c + (-a//c) + 1
dn = b//d + (-a//d) + 1
cd = lcm(c, d)
cdn = b//cd + (-a//cd) + 1
#print(cn, dn, cdn)
print(b-a+1-(cn+dn-cdn))
Problem p02999 (python)

Fixed submission:
X, A = map(int, input().split())
if(X < A): print(0)
else: print(10)

Buggy submission (verdict: Runtime Error):
X, A = map(int(input().split()))
if(X < A): print(0)
else: print(10)
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
L = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A.sort(reverse = True)

dp = [0] + ([-1]*N)
for i in range(1, N+1):
    for a in A:
        if L[a] <= i:
            dp[i] = max(dp[i], dp[i-L[a]] * 10 + a)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
L = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A.sort(reverse = True)

dp = [0] + ([-1]*N)
for i in range(1, N+1):
    for a in A:
        if L[a] <= i:
            dp[i] = max(dp[i], dp[i-L[a]] * 10 + a)
    print(dp)
print(dp[-1])
Problem p03129 (python)

Fixed submission:
N, K = map(int, input().split())
if(K == 1): print("YES")
else:
    if((N-1)//(K-1)>=2):print("YES")
    else: print("NO")

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
if((N-1)//(K-1)>=2):print("YES")
else: print("NO")
Problem p03147 (python)

Fixed submission:
n = int(input())
flowers = list(map(int, input().split()))
flowers.append(0)
cnt = 0
if(all([x<=0 for x in flowers])): print(0)
else: 
    for i in range(sum(flowers)+1):
        #print(i)
        if(all([x<=0 for x in flowers])): break
        #print(flowers, i, cnt)
        for j in range(n-2):
            if(flowers[j] > 0 and flowers[j+1] <= 0 and any([x>0 for x in flowers[j+2:]])): cnt+=1
        flowers = list(map(lambda x: (x-1), flowers))
    print(i + cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
flowers = list(map(int, input().split()))
flowers.append(max(flowers))
cnt = 0
for i in range(sum(flowers)):
    if(all([x<0 for x in flowers])): break
    print(flowers, i, cnt)
    flowers = list(map(lambda x: (x-1), flowers))
    for j in range(n):
        if(flowers[j] > 0 and flowers[j+1] <= 0): cnt+=1
print(i + cnt)
Problem p03148 (python)

Fixed submission:
n, k = map(int, input().split())
nai = [list(map(int, input().split())) for _ in range(n)]

nai = sorted(nai, key=lambda x: -x[1])

ans = 0
aru = []
spe = set()
m = 0
for i in range(k):
    anstmp = nai.pop(0)
    if(anstmp[0] not in spe):
        ans+=anstmp[1]
        spe.add(anstmp[0])
    else:
        aru.append(anstmp[1])
sumaru = sum(aru)
m = ans + sumaru + len(spe)**2

for i in range(len(nai)):
    if(len(aru) == 0): break
    if(nai[i][0] not in spe):
        sumaru-=aru.pop()
        ans+=nai[i][1]
        spe.add(nai[i][0])
    m = max(m, ans + sumaru + len(spe)**2)
print(m)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = []
aru = []
nai = []
spe = set()
f = []
m = 0
for i in range(n):
    t, d = map(int, input().split())
    nai.append([t,d])
nai = sorted(nai, key=lambda x: x[1], reverse = True)
for i in range(k):
    anstmp = nai.pop(0)
    if(anstmp[0] not in spe):
        ans.append(anstmp[1])
        spe.add(anstmp[0])
    else:
        aru.append(anstmp[1])

s = len(spe)
m = sum(ans) + sum(aru) + s**2
print(ans, aru, s)

for i in range(len(nai)):
    if(len(aru) == 0): break
    if(nai[i][0] not in spe):
        aru.pop()
        ans.append(nai[i][1])
        s += 1
        print(ans, aru, s)
    m = max(m, sum(ans) + sum(aru) + s**2)
print(m)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = []
aru = []
nai = []
spe = []
f = []
m = 0
for i in range(n):
    t, d = map(int, input().split())
    nai.append([t,d])
nai = sorted(nai, key=lambda x: x[1], reverse = True)
for i in range(k):
    anstmp = nai.pop(0)
    if(anstmp[0] not in spe):
        ans.append(anstmp[1])
        spe.append(anstmp[0])
    else:
        aru.append(anstmp[1])

#print(ans, spe, aru)
#print("nai", nai)
f.append(sum(ans) + sum(aru))
s = len(spe)
for i in range(len(nai)):
    if(nai[i][0] not in spe):
        aru.pop(-1)
        ans.append(nai[i][1])
        spe.append(nai[i][0])
        f.append(sum(ans) + sum(aru))
#print(f)
for i in range(len(f)):
    m = max(m, f[i] + (s + i)**2)
print(m)
Problem p03187 (python)

Fixed submission:
L, N = map(int, input().split())
X=[0]
sumL=[0]
sumR=[0]
for i in range(N):
    X.append(int(input()))
    sumL.append(sumL[-1]+X[-1])
for i in range(N):
    sumR.append(sumR[-1]+L-X[N-i])
sumR.append(0)
sumR.reverse()
#print(X)
#print("sumL",sumL)
#print("sumR",sumR)
ans = 0
for b in range(N+1):
    z = sumL[b] + sumR[b+1]
    if(b > 0):
        if(b <= N-b):
            ans = max(ans, z+sumL[b-1]+sumR[b+1]-2*sumR[N+1-(N-b-b)])
            #print("A", b, z+sumL[b-1]+sumR[b+1]-2*sumR[N+1-(N-b-b)])
        else:
            ans = max(ans, z+sumL[b-1]+sumR[b+1]-2*sumL[b-(N-b)-1])
            #print("B", b, z+sumL[b-1]+sumR[b+1]-2*sumL[b-(N-b)-1])
    if(b < N):
        if(b >= N-b):
            ans = max(ans, z+sumL[b]+sumR[b+2]-2*sumL[b-(N-b)])
            #print("C", b, z+sumL[b]+sumR[b+2]-2*sumL[b-(N-b)])
            #print(b, z, sumR[b+1], sumL[b], sumR[b+2], sumL[b-(N-b)])
        else:
            ans = max(ans, z+sumL[b]+sumR[b+2]-2*sumR[N+1-(N-b-b)+1])
            #print("D", b, z+sumL[b]+sumR[b+2]-2*sumR[N+1-(N-b-b)+1])
    #print("------------------------")
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
pos = 0
length = 0
tree=[]

def position(b,i,pos,posA, posB):
    print(posA, posB)
    if(posA == posB):
        for j in range(b-1-i):
            neia, neib = (tree[j+1]-tree[j], tree[b-i-1-j]-tree[b-i-2-j])
            print(neia, neib)
            if(neia > neib):
                posB = 0
                break
            elif(neib > neia):
                posA = 0
                break
    target = max(posA, posB)
    print(posA, posB)
    if(posA == target):
        pos = tree[0]
        del tree[0]
    else:
        pos = tree[b-i-1]
        del tree[b-i-1]
    return (pos, target)

for i in range(b):
    tree.append(int(input()))
for i in range(b):
    print(tree)
    if(pos > tree[b-i-1]):
        pos, target = position(b,i,pos,abs(tree[0]+a-pos),abs(tree[b-i-1]-pos))
    else:
        pos, target = position(b,i,pos,abs(tree[0]-pos),a-abs(tree[b-i-1]-pos))
    length += target
    print(i+1, "----", pos, target, length) 
print(length)
Problem p02995 (python)

Fixed submission:
import sys

input = sys.stdin.readline


def gcd(*args):
    a = max(args)
    b = min(args)
    while b != 0:
        a, b = b, a % b
    return a


def main():
    A, B, C, D = [int(i) for i in input().split()]
    # X : AとBの間の整数の数
    X = B - A + 1
    # Y : AとBの間でCの倍数の数
    Y = (B // C) - ((A - 1) // C)
    # Z : AとBの間でDの倍数の数
    Z = (B // D) - ((A - 1) // D)
    # V : CとDの最小公倍数
    V = (C * D) // gcd(C, D)
    # W : AとBの間でVの倍数の数
    W = (B // V) - ((A - 1) // V)
    print(X - Y - Z + W)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
import sys

input = sys.stdin.readline


def main():
    A, B, C, D = [int(i) for i in input().split()]
    # X : AとBの間の整数の数
    X = B - A + 1
    # Y : AとBの間でCの倍数の数
    Y = (B // C) - ((A - 1) // C)
    # Z : AとBの間でDの倍数の数
    Z = (B // D) - ((A - 1) // D)
    # V : CとDの最小公倍数
    V = (C * D) // math.gcd(C, D)
    # W : AとBの間でVの倍数の数
    W = (B // V) - ((A - 1) // V)
    print(X - Y - Z + W)


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

Fixed submission:
A, P = [int(i) for i in input().split()]
print((A * 3 + P) // 2)

Buggy submission (verdict: Runtime Error):
A, P = [int(i) for i in input().split()]
print((A * 3 + P) // ￼2)
Problem p02993 (python)

Fixed submission:
pc = input()

if pc[0] != pc[1] and pc[1] != pc[2] and pc[2] != pc[3] :
  print("Good")
else :
  print("Bad")

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

if pc[0] != pc[1] and pc[1] != pc[2] and pc[2] != pc[3] :
  print("Good")
else :
  print("Bad")
Problem p02994 (python)

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

sum_N = int(N*((N+1)/2 + L - 1))

if L >= 0 :
  print(sum_N - L)
elif L + N - 1 < 0 :
  print(sum_N - (L + N - 1))
else :
  print(sum_N)

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

sum_N = N*((N+1)/2 + L - 1)

if L >= 0 :
  print(sum_N - L)
else if L + N - 1 < 0 :
  print(sum_N - (L + N - 1))
else :
  print(sum_N)
Problem p02996 (python)

Fixed submission:
N = int(input())
data = [list(map(int, input().split())) for i in range(N)]

data.sort(key=lambda x: x[1])

now = 0

for i in range(N) :
  if now + data[i][0] > data[i][1] :
    print("No")
    break
  else :
    now = now + data[i][0]
  
  if i == N-1 :
    print("Yes")

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

ds = sorted(data, key=lambda x: x[1])

now = 0

for i in range(N) :
  if now + ds[i][0] > ds[i][1] :
    print("No")
    break
  else :
    now = now + ds[0]
  
  if i == N-1 :
    print("Yes)
Problem p02999 (python)

Fixed submission:
X, A = map(int, input().split())

if X < A :
  print(0)
else :
  print(10)

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

if X < A :
  print(0)
else :
  print(10)

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

if X < A :
  print 0
else :
  print 10