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

Fixed submission:
a = int(input())
s = input()
if a>=3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
def walk(n):
    global adj, point
    if len(adj[n])==0:
        return
    else:
        for a in adj[n]:
            point[a] += point[n]
        for a in adj[n]:
            walk(a)
N, Q = map(int, input().split())
adj = [[] for _ in range(N)]
point = [0 for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
for _ in range(Q):
    p, x = map(int, input().split())
    point[p-1] += x
walk(0)
print(" ".join(map(str, point)))
Problem p03018 (python)

Fixed submission:
import re
s = input()
s_ = s.replace("BC", "D")
group = re.findall(r"[AD]+", s_)
ans = 0
for grp in group:
    a = 0
    for g in grp:
        if g=="A":
            a += 1
        if g=="D":
            ans += a
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
s_ = s.replace("BC", "D")
group = re.findall(r"[AD]+", s_)
ans = 0
for grp in group:
    a = 0
    for g in grp:
        if g=="A":
            a += 1
        if g=="D":
            ans += a
print(ans)
Problem p02659 (python)

Fixed submission:
a,b = map(str,input().split())
a = int(a)
b = float(b)
 
b = round(b*100)
 
print(a*b//100)

Buggy submission (verdict: Runtime Error):
import math
a,b = map(flaot,input().split())
print(math.floor(a*(100*b)/100))

Buggy submission (verdict: Runtime Error):
a,b = map(flaot,input().split())
print(math.floor(a*(100*b)/100))
Problem p02726 (python)

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

distance_list =[0]*n

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list[min(a,b)] += 1

for i in range(1,n):
    print(distance_list[i])

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

distance_list =[]

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list.append(min(a,b)

count_list = []

for i in range(n-1):
    count_list.append(distance_list.count(i+1))

for i in range(n-1):
    print(count_list[i])
Problem p02790 (python)

Fixed submission:
a, b = map(int,input().split())
if b >= a:
  a = str(a)
  print(a*b)
else:
  b = str(b)
  print(b*a)

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().split())
if a >= b:
  a = str(a)a
  print(a*b)
else:
  b = str(b)
  print(b*a)
Problem p02831 (python)

Fixed submission:
a,b = map(int,input().split())
#最大公約数
def gcd(a,b):#a<=b
    while a != 0:
        a,b = b%a,a
    return b
#最小公約数
def lcm(a,b):
    return a*b // gcd(a,b)
print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
#最大公約数
def gcd(a,b):#a<=b
    while b != 0:
        a = b
        b = b % a
    return a
#最小公約数
def lcm(a,b):
    return a*b / gcd(a,b)

print(lem(a,b))
Problem p02951 (python)

Fixed submission:
A, B, C = map(int, input().split())
rest = C - (A - B)
result = (rest if rest >= 0 else 0)
print(result)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
rest: int = C - (A - B)
result: int = (rest if rest >= 0 else 0)
print(result)
Problem p02959 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = A.copy()
for i in range(N):
    if C[i] - B[i] > 0:
        C[i] -= B[i]
    else:
        C[i+1] = C[i+1] - (B[i] - C[i]) if C[i+1] - (B[i] - C[i]) > 0 else 0
        C[i] = 0
    # print(C)

beaten_monster = sum(A) - sum(C)
print(beaten_monster)

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

C = A.copy()
for i in range(N):
    if C[i] - B[i] > 0:
        C[i] -= B[i]
    else:
        C[i+1] = C[i+1] - (B[i] - C[i]) if C[i+1] - (B[i] - C[i]) > 0 else 0
        C[i] = 0
    # print(C)

beaten_monster: int = sum(A) - sum(C)
print(beaten_monster)
Problem p03107 (python)

Fixed submission:
S = input()
N = len(S)

count0 = S.count('0')
count1 = S.count('1')
ans = 2 * min(count0, count1)
print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
N = len(S)

counter = 0
i = 0
while(True):
    if not '0' in S or not '1' in S or S == []:
        break
    elif (S[i] == '1' and S[i+1] == '0') or (S[i] == '0' and S[i+1] == '1'):
        S.pop(i)
        S.pop(i)
        counter += 2
        i -= 1
    else:
        i += 1

print(counter)
Problem p03242 (python)

Fixed submission:
num = input()
out = ''
for i in range(len(num)):
  if num[i] == '1':
    out += '9'
  else:
    out += '1'
print(out)

Buggy submission (verdict: Runtime Error):
num = input()
for i in range(len(num)):
  if num[i] == '1':
    num[i] = '9'
  else:
    num[i] = '1'
print(num)
Problem p02629 (python)

Fixed submission:
t="abcdefghijklmnopqrstuvwxyz"
n=int(input())
def f(n):
    if n<=26:
        return t[n-1]
    return f((n-1)//26)+t[(n-1)%26]

print(f(n))

Buggy submission (verdict: Runtime Error):
moji="abcdefghijklmnopqrstuvwxyz"
N=int(input())
def f(N):
    if N<=26:
        return moji[n-1]
    return f(N//26)+moji[N%26-1]

print(f(N))

Buggy submission (verdict: Runtime Error):
moji="abcdefghijklmnopqrstuvwxyz"
N=int(input())
def f(n):
    if N<=26:
        return moji[n-1]
    return f(N//26)+moji[N%26-1]

print(f(N))
Problem p02659 (python)

Fixed submission:
#ACになったコード（その2）
a, b = input().split()
a = int(a)
b = int(b.replace('.',''))
print(a*b//100)

Buggy submission (verdict: Runtime Error):
import math
a,b=map(float,input().split())
a=int(a)
b=int(b.replace('.',''))
print((a*b)//100)
Problem p02701 (python)

Fixed submission:
import collections
N=int(input())
S=[]
for i in range(N):
    S.append(input())
s=collections.Counter(S)
s_key=s.keys()
print(len(s_key))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [input() for i in range(n)] 
ans = 1
s = [a[0]]
 
for i in a[1:]:
    if not i in s:
        ans += 1
        s.append(i)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [input() for i in range(n)] 
ans =1
s = [a[0]]
 
for i in a[1:]:
    if not i in s:
        ans += 1
        s.append(i)
print(ans)
Problem p02779 (python)

Fixed submission:
import sys
N=int(input())
A=list(map(int,input().split()))
A.sort()
for i in range(1,N):
    if A[i-1]==A[i]:
        print('NO')
        sys.exit()
print('YES')

Buggy submission (verdict: Runtime Error):
import sys
N=int(input())
A=list(map(int,input().split()))
A.sort()
for i in range(N):
    if A[i]==A[i+1]:
        print('NO')
        sys.exit()
print('YES')
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
if a+b == 3:
    print(3)
elif a+b == 5:
    print(1)
else:
    print(2)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a+b == 3:
    print(3)
elif a+b ==5
    print(1)
else:
    print(2)
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
print((a*b)//gcd(a,b))

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b=map(int,input().split())
print((a*b)//np.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print((a*b)//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a,b=map(int,input().split())
print(lcm(a, b))
Problem p02987 (python)

Fixed submission:
S = list(str(input()))
if (S[0]==S[1]) and (S[0]==S[2]) and (S[0]==S[3]):
    print('No')
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = list(str(input()))
if (S[0]==S[1]) and (S[0]==S[2]) and (S[0]==S[3]):
    print('No')
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:

Buggy submission (verdict: Runtime Error):
S = list(str(input()))
if S[0]==S[1]==S[2]==S[3]:
    print('No')
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:

Buggy submission (verdict: Runtime Error):
S = list(str(input()))
if S[0]==S[1]==S[2]==S[3:
    print('No')]
elif (S[0]==S[1]) and (S[2]==S[3]):
    print('Yes')
elif (S[0]==S[2]) and (S[1]==S[3]):
    print('Yes')
elif (S[0]==S[3]) and (S[1]==S[2]):
    print('Yes')
else:
Problem p03835 (python)

Fixed submission:
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        z=s-(x+y)
        if z>=0 and z<=k:
            ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):

import sys
import itertools
k,s=map(int,input().split())
ans=0

for x in range(k+1):
    for y in range(k+1):
        z=s-(x+y)
        if z>=0 andz<=k:
            ans+=1

print(ans)
Problem p02661 (python)

Fixed submission:
from sys import stdin
from decimal import Decimal
N = int(stdin.readline().rstrip())
A = []
B = []
for i in range(N):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]
    A.append(a)
    B.append(b)
    
A.sort()
B.sort()

if N % 2 == 0:
    n = N // 2
    med1 = A[n-1] + A[n]
    med2 = B[n-1] + B[n]
    print(med2-med1+1)
else:
    ans = B[N//2] - A[N//2] + 1
    print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from decimal import Decimal
N = int(stdin.readline().rstrip())
A = []
B = []
for i in range(N):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]
    A.append(a)
    B.append(b)
    
A.sort()
B.sort()
if N % 2 == 0:
    C = A+B
    C.sort()
    ans = 2 * sum(C[::-1][:N]) - 2 * sum(C[:N])
    print(ans//2+1)
else:
    ans = B[N//2] - A[N//2] + 1
    print(ans
Problem p02862 (python)

Fixed submission:
from sys import stdin
import numpy as np
mod = 10**9+7
X,Y = [int(x) for x in stdin.readline().rstrip().split()]

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
 
def power(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1
 
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x % mod
        x *= x % mod
        n //= 2
 
    return K * x % mod
 
def div(a, b):
    return mul(a, power(b, mod-2))
 
def fact(n):
    f = 1
    for i in range(1,n+1):
        f *= i
        f %= mod
    return f

if (X+Y) % 3 != 0:
    print(0)

else:
    A = np.matrix([[2, 1],[1, 2]])
    Y = np.matrix([[X],[Y]])
    x,y = np.linalg.solve(A,Y)
    x = int(x)
    y = int(y)
    ans = fact(x+y)
    ans = div(ans,fact(x))
    ans = div(ans,fact(y))
    if x < 0 or y <0:
        print(0)
    else:
        print(ans%mod)

Buggy submission (verdict: Runtime Error):
from sys import stdin
mod = 10**9+7
X,Y = [int(x) for x in stdin.readline().rstrip().split()]

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x % mod
        x *= x % mod
        n //= 2

    return K * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def fact(n):
    f = 1
    for i in range(1,n+1):
        f *= i
        f %= mod
    return f

flag = True
if X == 0 or Y == 0:
    flag = False
x = 0
y = 0
x += min(X//3,Y//3)
y += min(X//3,Y//3)
tmp = min(X//3,Y//3)
X = X-tmp*3
Y = Y-tmp*3
if X == 0 and Y == 0:
    X = X
    Y = Y
elif (Y % (X*2) == 0):
    y += (Y//2)

elif (X % (Y*2) == 0):
    x += (X//2)
else:
    flag = False

if flag:
    ans = fact(x+y)
    ans = div(ans,fact(x))
    ans = div(ans,fact(y))
    print(ans%mod)
    
else:
    print(0)

Buggy submission (verdict: Runtime Error):
from sys import stdin
mod = 10**9+7
X,Y = [int(x) for x in stdin.readline().rstrip().split()]

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x % mod
        x *= x % mod
        n //= 2

    return K * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def fact(n):
    f = 1
    for i in range(1,n+1):
        f *= i
        f %= mod
    return f

flag = True
x = 0
y = 0
x += min(X//3,Y//3)
y += min(X//3,Y//3)
tmp = min(X//3,Y//3)
X = X-tmp*3
Y = Y-tmp*3
if X == 0 and Y == 0:
    X = X
    Y = Y
elif (Y % (X*2) == 0):
    y += (Y//2)

elif (X % (Y*2) == 0):
    x += (X//2)
else:
    flag = False

if flag:
    ans = fact(x+y)
    ans = div(ans,fact(x))
    ans = div(ans,fact(y))
    print(ans)
    
else:
    print(0)
Problem p02990 (python)

Fixed submission:
from sys import stdin
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(1, K+1):
    if i <= (N - K) + 1 :
        ans = cmb(N-K+1, i) * cmb(K-1, i-1)
    else:
        ans = 0
    print(ans % (10**9+7))

Buggy submission (verdict: Runtime Error):
from sys import stdin
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(1, K+1):
    ans = cmb(N-K+1, i) * cmb(K-1, i-1)
    if i == N:
        ans = 0
    print(ans % (10**9+7))
Problem p03053 (python)

Fixed submission:
from sys import stdin
from collections import deque
H, W = [int(x) for x in stdin.readline().rstrip().split()]

data = []

for _ in range(H):
    data.append(list(input()))

searched = [[0]*(W+2)]

for _ in range(H):
    searched.append([0] + [1000000]*W + [0])
searched.append([0]*(W+2))

visit_p = deque()
for h,i in enumerate(data):
    for w, j in enumerate(i):
        if j == "#":
            searched[h+1][w+1] = 0
            visit_p.append((h+1, w+1, 0))
while visit_p:
    nh,nw,num = visit_p.popleft()
    if searched[nh][nw] < num:
        continue
    for dh,dw in [(0,1),(1,0),(0,-1),(-1,0)]:
        if searched[nh+dh][nw+dw] > num + 1:
            searched[nh+dh][nw+dw] = num + 1
            visit_p.append((nh+dh,nw+dw,num+1))
print(max(map(max, searched)))

Buggy submission (verdict: Runtime Error):
a
Problem p03208 (python)

Fixed submission:
import numpy as np
from sys import stdin
N,K=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(N):
    data.append(int(input()))
data.sort()
data.reverse()
ans=float("inf")
for i in range(N-K+1):
    tmp=data[i]-data[i+K-1]
    if ans > tmp:
        ans=tmp
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
from sys import stdin
N,K=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(N):
    data.append(int(input()))
data.sort()
data.reverse()
ans=float("inf")
for i in range(N-K+1):
    tmp=data[i]-data[i+K-1]
    if ans > tmp:
Problem p03209 (python)

Fixed submission:
from sys import stdin
N, X = [int(x) for x in stdin.readline().rstrip().split()]

heights = [1]
putties = [1]
for _ in range(N):
    heights.append(heights[-1] * 2 + 3)
    putties.append(putties[-1] * 2 + 1)


def solve(n, x):
    if n == 0 and x == 1:
        return 1
    elif x == 1:
        return 0
    elif 1 < x <= 1+heights[n-1]:
        return solve(n-1, x-1)
    elif x == 2+heights[n-1]:
        return 1+putties[n-1]
    elif 2+heights[n-1] < x <= 2+2*heights[n-1]:
        return putties[n-1]+1+solve(n-1,x-2-heights[n-1]) 
    elif x == 3+2*heights[n-1]:
        return 2*putties[n-1]+1
print(solve(N, X))

Buggy submission (verdict: Runtime Error):
from sys import stdin
N, X = [int(x) for x in stdin.readline().rstrip().split()]

heights = [1]
putties = [1]
for _ in range(N):
    heights.append(heights[-1] * 2 + 3)
    putties.append(putties[-1] * 2 + 1)


def solve(n, x):
    if x == 1:
        return 0
    elif 1 < x <= 1+heights[n-1]:
        return solve(n-1, x-1)
    elif x == 2+heights[n-1]:
        return 1+putties[n-1]
    elif 2+heights[n-1] < x < 2+2*heights[n-1]:
        return putties[n-1]+1+solve(n-1,x-2-heights[n-1]) 
    elif x == 3+2*heights[n-1]:
        return 2*putties[n-1]+1
print(solve(N, X))

Buggy submission (verdict: Runtime Error):
from sys import stdin
N,X=[int(x) for x in stdin.readline().rstrip().split()]
burger_set=["P"]
for i in range(N):
    new_burger="B"+burger_set[0]+"P"+burger_set[0]+"B"
    burger_set[0]=(new_burger)
ans=burger_set[0][0:X].count('P')
print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
N,X=[int(x) for x in stdin.readline().rstrip().split()]
burger_set=["P"]
for i in range(N):
    new_burger="B"+burger_set[0]+"P"+burger_set[0]+"B"
    burger_set.append(new_burger)
    del burger_set[0]
print(burger_set[0].count('P'))

Buggy submission (verdict: Runtime Error):
from sys import stdin
N,X=[int(x) for x in stdin.readline().rstrip().split()]
burger_set=["P"]
for i in range(N):
    new_burger="B"+burger_set[i]+"P"+burger_set[i]+"B"
    burger_set.append(new_burger)
print(burger_set[N][0:X].count('P'))
Problem p03250 (python)

Fixed submission:
from sys import stdin
a,b,c=[x for x in stdin.readline().rstrip().split()]
print(max(int(a)+int(b+c),int(a+b)+int(c),int(c+b)+int(a)))

Buggy submission (verdict: Runtime Error):
from sys import stdin
a,b,c=[x for x in stdin.readline().rstrip().split()]
print(max(int(a)+int(b+c),int(a+b)+int(c))
Problem p03634 (python)

Fixed submission:
from sys import stdin
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
N = int(stdin.readline().rstrip())
adj = defaultdict(set)

for i in range(N-1):
    a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
    adj[a].add((b,c))
    adj[b].add((a,c))
    
Q,K = [int(x) for x in stdin.readline().rstrip().split()]

visited = [False]*(N+1)
dist = [0]*(N+1)

def dfs(i,j):
    if visited[i]:
        return
    dist[i] = j
    visited[i] = True
    
    for node,d in adj[i]:
        dfs(node,d+j)
        
dfs(K,0)

for i in range(Q):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    print(dist[x]+dist[y])

Buggy submission (verdict: Runtime Error):
from sys import stdin
from collections import defaultdict
N = int(stdin.readline().rstrip())
adj = defaultdict(set)

for i in range(N-1):
    a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
    adj[a].add((b,c))
    adj[b].add((a,c))
    
Q,K = [int(x) for x in stdin.readline().rstrip().split()]

visited = [False]*(N+1)
dist = [0]*(N+1)

def dfs(i,j):
    if visited[i]:
        return
    dist[i] = j
    visited[i] = True
    
    for node,d in adj[i]:
        dfs(node,d+j)
        
dfs(K,0)

for i in range(Q):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    print(dist[x]+dist[y])
Problem p03723 (python)

Fixed submission:
from sys import stdin
A,B,C = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0

if A == B == C:
    if A % 2 == 0:
        ans = -1
    else:
        ans = 0
elif A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
     ans = 0
else:
    for _ in range(1000):
        ta = A
        tb = B
        tc = C
        A = (tb/2) + (tc/2)
        B = (ta/2) + (tc/2)
        C = (ta/2) + (tb/2)
        ans += 1
        if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
            break
        
print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

a = factorize(A)[0][1]
b = factorize(B)[0][1]
c = factorize(C)[0][1]

ans = max(a,b,c)
if ans == 1:
    ans = -1
print(ans)
Problem p03774 (python)

Fixed submission:
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
students = []
for _ in range(N):
    students.append([int(x) for x in stdin.readline().rstrip().split()])

checkpoints = []
for _ in range(M):
    checkpoints.append([int(x) for x in stdin.readline().rstrip().split()])

for i in students:
    tmp = 10**9 
    for ind,j in enumerate(checkpoints):
        dist = abs(i[0] - j[0]) + abs(i[1] - j[1])
        if dist < tmp:
            tmp = dist
            ans = ind+1
    print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
students = []
for _ in range(N):
    students.append([int(x) for x in stdin.readline().rstrip().split()])

checkpoints = []
for _ in range(M):
    checkpoints.append([int(x) for x in stdin.readline().rstrip().split()])

for i in students:
    tmp = 10000 
    for ind,j in enumerate(checkpoints):
        dist = abs(i[0] - j[0]) + abs(i[1] - j[1])
        if dist < tmp:
            tmp = dist
            ans = ind+1
    print(ans)
Problem p03986 (python)

Fixed submission:
from sys import stdin
from collections import deque
X = (stdin.readline().rstrip())
stack = []
for i in X:
    if i == "S":
        stack.append(i)
    elif (i == "T" and stack == []):
        stack.append(i)
    elif (i == "T" and stack[-1] == "S"):
        stack.pop()
    else:
        stack.append(i)
print(len(stack))

Buggy submission (verdict: Runtime Error):
from sys import stdin
X = (stdin.readline().rstrip())
stack = []
for i in X:
    if i == "S":
        stack.append(i)
    elif i == "T" and stack[-1] == "S":
        stack.pop()
    else:
        stack.append(i)
print(len(stack))

Buggy submission (verdict: Runtime Error):
from sys import stdin
X = (stdin.readline().rstrip())
X_l = X[:(len(X)/2)]
X_r = X[(len(X)/2):]
print(len(X) - min(X_l.count("S"),X_r.count("T")) * 2)
Problem p02682 (python)

Fixed submission:
A, B,C,K = map(int, input().split())
if(K<A):
  print(K)
elif(K>A+B):
  print(A - (K-A-B))
else:
  print(A)

Buggy submission (verdict: Runtime Error):
A, B,C,K = map(int, input().split())
K_list = [0]*K

for i in range(K):
  if(i+1<=A):
    K_list[i] = 1
  elif(i+1<=A+B):
     K_list[i] = 0
  elif(i+1<=A+B+C):
     K_list[i] = -1
  
        
        


sun = sum(K_list)
print(sun)
Problem p02688 (python)

Fixed submission:
#整数の入力
N,K = map(int, input().split())

d_list = []
A_list_list = []
for i in range(K):
  #整数の入力
  d = int(input())
  d_list.append(d)
  #スペース区切りの整数の入力リスト
  A_list = list(map(int, input().split()))
  #print(A_list)
  A_list_list.extend(A_list)
#print(A_list)
counter = 0
for i in range(N):
  if((i+1 in A_list_list) ==True):
    counter = counter
  else:
    counter = counter + 1
print(counter)

Buggy submission (verdict: Runtime Error):
#整数の入力
N,K = int(input())

d_list = []
A_list_list = []
for i in range(K):
  #整数の入力
  d = int(input())
  d_list.append(d)
  #スペース区切りの整数の入力リスト
  A_list = list(map(int, input().split()))
  A_list_list.append(A_list)
  
counter = 0
for i in range(N):
  if((i+1 in A_list) ==True):
    counter = counter
  else:
    counter = counter + 1
print(counter)
Problem p02707 (python)

Fixed submission:
#整数の入力
N = int(input())
#スペース区切りの整数の入力リスト
A_list = list(map(int, input().split()))

ans = 0
  
  
ans_list = [0]*N
  
for i in range(len(A_list)):
  #ans = A_list.count(i+1)
  ans_list[A_list[i]-1]+=1


for i in range(len(ans_list)):
  print(ans_list[i])

Buggy submission (verdict: Runtime Error):
#整数の入力
N = int(input())
#スペース区切りの整数の入力リスト
A_list = list(map(int, input().split()))

ans = 0
for i in range(len(A_list)):
  ans = A _list.count(i+1)
  print(ans)