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

Fixed submission:
N,K = map(int,input().split())
check = N*[0]

for i in range(K):
	d = int(input())
	a = list(map(int,input().split()))
	for i in a:
		check[i-1] = 1

print(check.count(0))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
check = N*[0]

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

print(check.count(0))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
check = N*[0]

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

print(check.count(0))

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

for i in range(1,N+1):
	N_list.append(i)

for i in range(K):
	d = int(input())
	a_list = map(int,input().split())
	for n in N_list:
		for a in a_list:
			if n == a:
				N_list.remove(n)

print(N_list[0])

Buggy submission (verdict: Runtime Error):

N,K = input().split()
N = int(N)
K = int(K)
N_list = list()

for i in range(1,N+1):
	N_list.append(i)

for i in range(K):
	d = int(input())
	a_list = input().split()
	
	for i in N_list:
		for j in a_list:
			if i == int(j):
				N_list.remove(i)
answer = N_list[0]

print(answer)

Buggy submission (verdict: Runtime Error):

N,K = input().split()
N = int(N)
K = int(K)
N_list = list()

for i in range(1,N+1):
	N_list.append(i)

for i in range(K):
	d = int(input())
	a_list = input().split()
	N_list += a_list
	N_list = map(N_list)

print(N_list)
Problem p02785 (python)

Fixed submission:
n,h=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
c=[0]*2
c[0]=h
c[1]=len(a)
for k in range(0,min(c)):
  a[k]=0
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,h=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
for k in range(0,h):
  a[k]=0
print(sum(a))
Problem p02829 (python)

Fixed submission:
a,b=[int(input()) for i in range(0,2)]
c=[1,2,3]
c.remove(a)
c.remove(b)
print((c[0]))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=[1,2,3]
c.remove(a)
c.remove(b)
print(c[0])
Problem p02847 (python)

Fixed submission:
li = ['SAT','FRI','THU','WED','TUE','MON','SUN']
x = input()
print(li.index(x)+1)

Buggy submission (verdict: Runtime Error):
li = ['SAT','FRI','THU','WED','TUE','MON','SAT']
x = input()
print(li.index(x)+1)

Buggy submission (verdict: Runtime Error):
li = ['SUN','SAT','FRY','THU','WED','TUE','MON']
x = input()
print(li.index(x))
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b = map(int,input().split())
c=0 
for i in range(a,b+1):
  if i%k == 0:
    c = c + 1
if c > 0:
  print("OK")
else:
  print("NG")

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

for i in range(a,b):
  if i%k == 0:
    print("OK")
    break
  if i%k!=0 and i == b:
    print("NG")
Problem p02693 (python)

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

res = "NG"
for i in range(a,b+1):
    if (i%k==0):
        res = "OK"
        break
print(res)

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map (int, input().split())
res = "NG"
for i in range(a,b+1):
  if((i%k==0):
     res="OK"
     break
print(res)
Problem p02819 (python)

Fixed submission:
def check(num):
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                return False
                break
        else:
            return True
    else:
        return False


a = int(input())

for i in range(a, 100500):
    if check(i):
        print(i)
        break

Buggy submission (verdict: Runtime Error):
import java.util.Scanner;

public class AtCoderTest {
    static boolean is_prime(int n)
    {

        if (n <= 1) return false;
        if (n <= 3) return true;


        if (n % 2 == 0 || n % 3 == 0) return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }
    static int nextPrime(int N)
    {
        if (N <= 1 || N == 2)
            return 2;

        int prime = N;
        boolean found = false;

        while (!found)
        {
            prime++;

            if (is_prime(prime))
                found = true;
        }

        return prime;
    }

    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (is_prime(N)){
            System.out.println(N);
        }
        else{
                System.out.println(nextPrime(N));
        }
    }
}
Problem p02723 (python)

Fixed submission:
s = input()
if s[2]==s[3] and s[4]==s[5]:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
s = input()
#sippuu
if s[3] == s[4]:
	if s[5] == s[6]:
  	    print("Yes")
    else:
      	    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
if s[3] == s[4]:
	if s[5] == s[6]:
  	    print("Yes")
else:
	print("No")
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())

if (w>=s):
    print('unsafe')
else:
    print('safe')

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

if(s>w):
    print('safe')
else
    print('unsafe')

Buggy submission (verdict: Runtime Error):
s, w = map(int, input().sprit())

if(s>w):
    print('safe')
else
    print('unsafe')

Buggy submission (verdict: Runtime Error):
s, w = map(int, input().sprit())

if(s>=w):
    print(safe)
else
    print(unsafe)
Problem p02693 (python)

Fixed submission:

K = int(input())
A, B = [int(x) for x in input().split()]

print("OK" if A // K < B // K or A % K == 0 or B % K == 0 else "NG")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import random
import numpy as np


N, M = [int(x) for x in input().split()]


def try_get(N: int, M: int) -> (bool, list):
    used_flag = np.zeros(N)
    stage_marks = []  # [(v1,v2)]
    ones = np.ones(N)
    for length in reversed(range(1, M+1)):
        numbers = np.arange(N - length) + 1
        numbers = numbers[np.logical_and(used_flag[:(N-length)]==0,used_flag[length:N]==0)]
        if len(numbers) == 0:
            return False, []
        num = np.random.choice(numbers)
        stage_marks.append((num, num + length))
        used_flag[num-1] = 1
        used_flag[num+length-1] = 1

    return True, stage_marks


ok = False
marks = []
while not ok:
    ok, marks = try_get(N, M)

for src, dst in marks:
    print("{} {}".format(src, dst))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import random
import numpy as np


N, M = [int(x) for x in input().split()]


def try_get(N: int, M: int) -> (bool, list):
    used_flag = np.zeros(N)
    stage_marks = []  # [(v1,v2)]
    ones = np.ones(N)
    for length in reversed(range(1, M+1)):
        numbers = np.arange(N - length) + 1
        numbers = numbers[np.logical_and(used_flag[:(N-length)]==0,used_flag[length:N]==0)]
        if len(numbers) == 0:
            return False, []
        num = np.random.choice(numbers)
        stage_marks.append((num, num + length))
        used_flag[num-1] = 1
        used_flag[num+length-1] = 1

    return True, stage_marks


ok = False
marks = []
while not ok:
    ok, marks = try_get(N, M)

for src, dst in marks:
    print("{} {}".format(src, dst))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import random
import numpy as np


N, M = [int(x) for x in input().split()]


def try_get(N: int, M: int) -> (bool, list):
    used_flag = np.zeros(N)
    stage_marks = []  # [(v1,v2)]
    ones = np.ones(N)
    for length in reversed(range(1, M+1)):
        numbers = np.arange(N - length) + 1
        numbers = numbers[np.logical_and(used_flag[:(N-length)]==0,used_flag[length:N]==0)]
        if len(numbers) == 0:
            return False, []
        num = np.random.choice(numbers)
        stage_marks.append((num, num + length))
        used_flag[num-1] = 1
        used_flag[num+length-1] = 1

    return True, stage_marks


ok = False
marks = []
while not ok:
    ok, marks = try_get(N, M)

for src, dst in marks:
    print("{} {}".format(src, dst))
Problem p03201 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split(" ")))
A.sort()
used = [0] * N
pow2_set = reversed([ 1<<i for i in range(36)])
ans = 0
for pow2 in pow2_set:
    l,r = 0,N-1
    while l < r:
        if A[l] + A[r] < pow2:
            l += 1
        elif A[l] + A[r] == pow2:
            if used[l] == 0 and used[r] == 0:
                ans += 1
                used[l],used[r] = 1,1
            else:
                if used[l] == 1:
                    l += 1
                if used[r] == 1:
                    r -= 1
        else:
            r -= 1
 
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split(" ")))
A.sort()
used = [0] * N
pow2_set = reversed([ 1<<i for i in range(36)])
ans = 0

for pow2 in pow2_set:
    l,r = 0,N-1
    while l < r:
        count += 1
        if A[l] + A[r] < pow2:
            l += 1
        elif A[l] + A[r] == pow2:
            if used[l] == 0 and used[r] == 0:
                ans += 1
                used[l],used[r] = 1,1
            else:
                if used[l] == 1:
                    l += 1
                if used[r] == 1:
                    r -= 1
        else:
            r -= 1

print(ans)
Problem p03208 (python)

Fixed submission:
a, b = (int(i) for i in input().split()) 

list=[]
 
for i in range(a):
    list.append(int(input()))

new_list = sorted(list)

sabun = None

for i in range(len(new_list)):

    bbb = new_list[i+b-1] - new_list[i]

    if sabun == None:
        sabun = bbb
        continue

    if sabun > bbb:
        sabun = bbb

    if i+b == len(new_list):
        break
    
print(sabun)

Buggy submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split()) 

list=[]
 
for i in range(a):
    list.append(int(input()))

new_list = sorted(list)

sabun = None

for i in range(len(new_list)-1):

    if b - i < 1:
        break

#    if i+b-1 > len(new_list):
#        break

    bbb = new_list[i+b-1] - new_list[i]

    if sabun == None:
        sabun = bbb
        continue

    if sabun > bbb:
        sabun = bbb
    
print(sabun)

Buggy submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split()) 

list=[]
 
for i in range(a):
    list.append(int(input()))

new_list = sorted(list)

sabun = None

for i in range(len(new_list)):

    if b - i < 1:
        break

    bbb = new_list[i+b-1] - new_list[i]

    if sabun == None:
        sabun = bbb
        continue

    if sabun > bbb:
        sabun = bbb
    
print(sabun)

Buggy submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split()) 

list=[]
 
for i in range(a):
    list.append(int(input()))

new_list = sorted(list)

sabun = None

for i in range(len(new_list)):

    if b - i < 1:
        break

    bbb = new_list[i+b-1] - new_list[i]

    if sabun == None:
        sabun = bbb
        continue

    if sabun > bbb:
        sabun = bbb
    
print(sabun)
Problem p03209 (python)

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

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])


print(f(N,X))

Buggy submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split()) 

pan = "P"

for i in range(a):
    pan = "B" + pan + "P" + pan + "B"

count = 0

for i in range(b):
    if "P" == pan[i]:
        count += 1

print(count)
Problem p02701 (python)

Fixed submission:
count = int(input())
zenbu = set()
 
for x in range(count):
    keihin = input()
    zenbu.add(keihin)
print(len(zenbu))

Buggy submission (verdict: Runtime Error):
import sys
count = int(sys.stdin.readline())
zenbu = []

for x in range(count):
    keihin = sys.stdin.readline()

    if not keihin in zenbu:
        zenbu[len(zenbu)] = keihin
print(len(zenbu))
Problem p02688 (python)

Fixed submission:
n, k = [int(i) for i in input().split()]
ds = []
As = []
for i in range(k):
    ds.append(int(input()))
    As += [int(j) for j in input().split()]
 
 
print(n-len(set(As)))

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
ds = []
As = []
for i in range(2*k):
    ds.append(int(input()))
    As += [int(j) for j in input().split()]
 
 
print(n-len(set(As)))

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
ds = []
As = ()
for i in range(2*k):
    ds.append(int(input()))
    As += set([int(j) for j in input().split()])


print(n-len(As))
Problem p02847 (python)

Fixed submission:
inp = str(input())

dic = { "SUN":7, "MON":6, "TUE":5, "WED":4, "THU":3, "FRI":2, "SAT":1}
print(dic.get(inp))

Buggy submission (verdict: Runtime Error):
 dic = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
print(dic[str(input())])
Problem p02916 (python)

Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
sat = 0

pre = -1
for i in a:
  sat += b[i-1]
  #print(b[i-1])
  if pre + 1 == i:
    sat += c[pre-1]
    #print("c", c[pre-1])
  pre = i
print(sat)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
sat = 0

for i in a:
  sat += b[i]
  pre = i
  if pre + 1 == i:
    sat += c[pre]

print(sat)
Problem p02753 (python)

Fixed submission:
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('No\n')
else:
  print('Yes\n')

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

Buggy submission (verdict: Runtime Error):
if S[0] == S[1] == S[2]:
  print('No')
else
  print('Yes')
Problem p03038 (python)

Fixed submission:
import numpy

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

a = numpy.array([int(e) for e in input().split(" ")],dtype=numpy.int64)
changes=[]
for i in range(m):
    changes.append([int(e) for e in input().split(" ")])


a.sort()
#昇順ソート

changes.sort(key=lambda x:(x[1],x[0]),reverse = True)

change_num = 0
for change in changes:
    for i in range(change_num, min(change[0] + change_num,n)):
        if a[i] < change[1]:
            change_num += 1
            a[i] = change[1]
        else:
            break

print(a.sum())

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]

	for i in range(m):
    	changes.append([int(e) for e in input().split(" ")])
	changes.sort(key=lambda x:(x[1],x[0]),reverse = True)
	
    cnt = N
	for i in changes:
    	A.extend([i[1]] * min(i[0],cnt))
    	cnt -= min(i[0],cnt)
    A.sort()
    A.reverse()
    A = A[:N]
    print(sum(A))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy

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

a = numpy.array([int(e) for e in input().split(" ")],dtype=numpy.int64)
changes=[]
for i in range(m):
    changes.append([int(e) for e in input().split(" ")])


a.sort()
#昇順ソート

changes.sort(key=lambda x:(x[1],x[0]),reverse = True)

change_num = 0
for change in changes:
    for i in range(change_num, change[0] + change_num):
        if a[i] < change[1]:
            change_num += 1
            a[i] = change[1]
        else:
            break

print(a.sum())
Problem p02723 (python)

Fixed submission:
S=input()
if S[2]==S[3] and S[4]==S[5]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s='S'
if s[2]==s[3] and s[4]==s[5]:
  print('Yes")
else:
  print('No')

Buggy submission (verdict: Runtime Error):
p=S
if p[3]==p[4] and p[5]=p[6]:
  print('Yes')
else:
  print('No')
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
if S > W:
    print('safe')
else:
    print('unsafe')

Buggy submission (verdict: Runtime Error):
S, W = map(int, input().split())
if S <= w:
	print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
S, W = map(int, input().split())
if S <= W 
	print("unsafe")
else:
    print("safe")
Problem p02707 (python)

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
for n in range(N):
  print(count[n+1])

Buggy submission (verdict: Runtime Error):
import collection
N = int(input())
A = list(map(int, input().split()))
count = collections.Counter(A)
for n in range(N):
  print(count[n + 1])
Problem p02711 (python)

Fixed submission:
N = input()
if N[0] == '7' or N[1] == '7' or N[2] == '7':
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if N[0] == '7' or N[1] == '7' or N[2] == '7':
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if N[0] == "7" or N[1] == "7" or N[2] == "7":
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if N[0] == "7" or N[1] == "7" or N[2] == "7":
	print("Yes")
else:
    print("No")
Problem p02777 (python)

Fixed submission:
a,b=input().split()
x,y=map(int,input().split())
c=input()
if a==c:
  x=x-1
else:
  y=y-1
print(x,y)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]=(1+a[i])/2
x=[0]*(n+k-1)
for i in range(n):
  for j in range(i,i+k):
    x[j]+=a[i]
print('{:.10f}'.format(max(x)))
Problem p03835 (python)

Fixed submission:
n,k=map(int,input().split())
ans=0
for i in range(n+1):
  for j in range(n+1):
    if 0<=k-i-j<=n:
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans=0
for i in range(n+1):
  for j in range(n+1):
    for l in range(n+1):
if i+j+l==k:
  ans+=1
print(ans)
Problem p02699 (python)

Fixed submission:
S,W = map(int, input().split())

if S > W :
    print("safe")
else :
    print("unsafe")

Buggy submission (verdict: Runtime Error):
S,W = map(int, input.split())

        if S > W :
            print("safe")
        else :
            print("unsafe")
Problem p02897 (python)

Fixed submission:
import sys

N = int(sys.stdin.readline())

if N % 2 == 0:
  a = 1 / 2
else:
  a = (N+1) / (2 * N)

print('%.10f' %a)

Buggy submission (verdict: Runtime Error):
import sys
N = int(sys.stdin.readline())

 if N % 2 == 0:
    print(0.5)
else:
    print(N / (2*N + 1))
Problem p02711 (python)

Fixed submission:
N=str(input())
if int(N[0])==7:
    print("Yes")
elif int(N[1])==7:
    print("Yes")
elif int(N[2])==7:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=str(inut())
if int(N[0])==7 or int(N[1])==7 or int(N[2])==7:
    print("Yes")
else:
    print("No")
Problem p02829 (python)

Fixed submission:
A = int(input())  
B = int(input())  

print(6-A-B)

Buggy submission (verdict: Runtime Error):
m=int(n)
e2=0
e5=0

while m>1:
    if m%5!=0 and m%2!=0:
        continue
    m2=m
    m5=m
    while m2%2==0:
        e2=e2+1
        m2=m2/2
    while m5%5==0:
        e5=e5+1
        m5=m5/5
    m=m-2

print(min(e2,e5))
Problem p02831 (python)

Fixed submission:
import fractions

a,b=map(int, input().split())

lcm = int(a * b / fractions.gcd(a, b))
print(lcm)

Buggy submission (verdict: Runtime Error):
import numpy

a,b=map(int, input().split())

lcm = int(a * b / numpy.gcd(a, b))
print(lcm)

Buggy submission (verdict: Runtime Error):
import numpy

a,b=map(int, input().split())

lcm = int(a * b / numpy.gcd(a, b))
print(lcm)

Buggy submission (verdict: Runtime Error):
import math

a,b=map(int, input().split())

lcm = int(a * b / math.gcd(a, b))
print(lcm)
Problem p02777 (python)

Fixed submission:
input_list = input().split()
input_list2 = list(map(int, input().split()))
delete_ball = input()
for ind, n in enumerate(input_list):
  if n == delete_ball:
    input_list2[ind] -= 1
ans = ""
for m in input_list2:
  ans += str(m) + " "
print(ans.rstrip())

Buggy submission (verdict: Runtime Error):
input_list = input().split()
input_list2 = list(map(input().split()))
delete_ball = input()
for ind, n in enumerate(input_list):
  if n == delete_ball:
    input_list2[ind] -= 1
print(input_list2)
Problem p02693 (python)

Fixed submission:
K=int(input())
AB=input().split()
A=int(AB[0])
B=int(AB[1])
for i in range(A,B+1):
    if(i%K==0):
        print('OK')
        exit()
print('NG')

Buggy submission (verdict: Runtime Error):
K=int(input())
AB=input().split()
A=int(AB[0])
B=int(AB[1])
for i in rage(A,B+1):
    i=567
    if(i%K==0):
        print('OK')
        exit()
print('NG')
Problem p02699 (python)

Fixed submission:
SW=input()
SW=SW.split()
if(int(SW[1])>=int(SW[0])):
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
s=input()
lens=len(s)
count=0
for i in range(lens):
    for k in range(i,lens):
        num=s[i:k]
        if(len(num)>=4):
            if(int(num)%2019==0):
                count=count+1
print(count)

Buggy submission (verdict: Runtime Error):
ABCD=input()
ABCD=ABCD.split()
A=int(ABCD[0])
B=int(ABCD[1])
C=int(ABCD[2])
D=int(ABCD[3])
while(1):
    C=C-B
    if(C<=0):
        print('Yes')
        break
    A=A-D
    if(A<=0):
        print('No')
        break
Problem p02860 (python)

Fixed submission:
N=int(input())
S=input()
if S[0:int(N/2)]==S[int(N/2):int(N)] and N%2==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
if S[0:N/2]==S[N/2:N] and N/2==0:
  print("Yes")
else:
  print("No")
Problem p02693 (python)

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

flag = 0

i = 1
while i * k <= b:
    if i*k >= a and i*k <=b:
        flag = 1
    
    i += 1

if flag:
    print("OK")
else:
    print("NG")

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

temp_prev = 0
temp_curr = 0
x = min(n, b-1)

while x <= n:
    temp_prev = temp_curr
    temp_curr = int(a * x / b) - a * int(x / b)
    x += 1.0

    if temp_curr <= temp_prev:
        break

print(max(temp_curr, temp_prev))
Problem p02711 (python)

Fixed submission:
n = input()

ans = n.find('7')

if ans == -1:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

# 1つ目の条件を満たす組の数
ans = r * g * b

# 2つ目の条件を満たす組の数
c = 0
for i in range(n):
    for j in range(i+1,n):
        k = 2 * j -i
        if k > n-1:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c += 1

print(ans - c)
Problem p02990 (python)

Fixed submission:
from math import factorial
n,k=[int(_) for _ in input().split()]
mod=10**9+7
if n!=k:
    if k+1 > n-k+2:
        for i in range(1,n-k+2):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
        for i in range(2*k-n-1):print(0)
    else:
        for i in range(1,k+1):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
else:
    print(1)
    for i in range(1,k):print(0)

Buggy submission (verdict: Runtime Error):
from math import factorial
n,k=[int(_) for _ in input().split()]
mod=10**9+7
if n!=k:
    for i in range(1,k+1):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
else:
    print(1)
    for i in range(1,k):print(0)

Buggy submission (verdict: Runtime Error):
from math import factorial
n,k=[int(_) for _ in input().split()]
mod=10**9+7
for i in range(1,k+1):
    print(((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))
Problem p02847 (python)

Fixed submission:
week =input()

if week=="SUN":
  print("7")
elif week=="MON":
  print("6")
elif week=="TUE":
  print("5")
elif week=="WED":
  print("4")  
elif week=="THU":
  print("3")
elif week=="FRI":
  print("2")
else:
  print("1")

Buggy submission (verdict: Runtime Error):
if scan()=="SUN":
  print("7")
elif scan()=="MON":
  print("6")
elif scan()=="TUE":
  print("5")
elif scan()=="WED":
  print("4")  
elif scan()=="TUH":
  print("3")
elif scan()=="FRI":
  print("2")
else:
  print("1")