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

Fixed submission:
MAX=200000
def get_prime(x):
  is_prime = [True] * 200000
  for i in range(2,MAX):
    if is_prime[i] and i >= x:
      return i
    elif is_prime[i]:
      for j in range(2 * i, MAX, i):
        is_prime[j] = False

print(get_prime(int(input())))

Buggy submission (verdict: Runtime Error):
# Original Submission At: https://atcoder.jp/contests/abc149/submissions/16823042
x= int(input())

def prime_check(num,count):
  	while True:
        while num % count == 0:
            num = num + 1
            count = 2
    	if num <= count**2:
        	print(num)
            break
        else:
          count = count + 1

if x==2 :
    print (2)
else:
    prime_check(x,2)

Buggy submission (verdict: Runtime Error):
# Original Submission At: https://atcoder.jp/contests/abc149/submissions/16823042
x= int(input())

def prime_check(num,count):
    while num % count == 0:
        num = num + 1
        count = 2
    if num <= count**2:
        print(num)
    else:
        prime_check(num,count+1)

if x==2 :
    print (2)
else:
    prime_check(x,2)
Problem p02596 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


k = I()
now = 0
for i in range(k):
    now = (now * 10 + 7) % k
    if now == 0:
        print(i + 1)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
¥from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


k = I()
now = 0
for i in range(k):
    now = (now * 10 + 7) % k
    if now == 0:
        print(i + 1)
        exit()
print(-1)
Problem p02688 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, k = LI()
B = [0] * n
for _ in range(k):
    d = I()
    A = LI()
    for a in A:
        B[a - 1] = 1

ans = 0
for i in range(n):
    if B[i] == 0:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import networkx as nx
import matplotlib.pyplot as plt
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, k = LI()
B = [0] * n
for _ in range(k):
    d = I()
    A = LI()
    for a in A:
        B[a - 1] = 1

ans = 0
for i in range(n):
    if B[i] == 0:
        ans += 1

print(ans)
Problem p02689 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
G = [[] for _ in range(n)]
H = LI()
for _ in range(m):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]

ans = 0
for i in range(n):
    j = H[i]
    for v in G[i]:
        if H[v] >= j:
            break
    else:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import networkx as nx
import matplotlib.pyplot as plt
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
G = [[] for _ in range(n)]
H = LI()
for _ in range(m):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]

ans = 0
for i in range(n):
    j = H[i]
    for v in G[i]:
        if H[v] >= j:
            break
    else:
        ans += 1

print(ans)
Problem p02891 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


s = S()
k = I()
L = []
cnt = 0
ret = 1
if len(s) == 1:
    print(k // 2)
else:
    for j in range(len(s) - 1):
        if s[j] != s[0]:
            break

    for l in range(len(s) - 1):
        if s[-1] != s[-1 - l]:
            break


    for i in range(len(s) - 1):
        if s[i] == s[i + 1]:
            ret += 1
        else:
            if ret > 1:
                cnt += ret // 2
            ret = 1


    cnt += ret // 2


    ans = cnt * k
    if len(set(s)) == 1 and k % 2:
        ans = k * len(s) // 2
    elif s[0] == s[-1] and j % 2 and l % 2:
        ans += k - 1
    print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


s = S()
k = I()
L = []
cnt = 0
ret = 1
if len(s) == 1:
    print(k // 2)
else:
    for j in range(1, len(s) - 1):
        if s[j] != s[0]:
            break

    for l in range(len(s) - 1):
        if s[-1] != s[-1 - l]:
            break


    for i in range(len(s) - 1):
        if s[i] == s[i + 1]:
            ret += 1
        else:
            if ret > 1:
                cnt += ret // 2
            ret = 1


    cnt += ret // 2


    ans = cnt * k
    if s[0] == s[-1] and j % 2 and l % 2:
        ans += k - 1


    print(ans)
Problem p02948 (python)

Fixed submission:
import heapq

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

t_r_list.sort()
que = []
total = 0
l = 0
for j in range(1, m + 1):
    while True:
        if l == n:
            break
        if t_r_list[l][0] != j:
            break
        heapq.heappush(que, -t_r_list[l][1])
        l += 1

    if que:
        total -= heapq.heappop(que)


print(total)

Buggy submission (verdict: Runtime Error):
import heapq
 
 
 
n, m = map(int, input().split())
t_r_list = []
for i in range(n):
    t_r_list.append(list(map(int, input().split())))


t_r_list.sort()
que = []
total = 0
l = 0
for j in range(1, m+1):
    while t_r_list[l][0] == j:
        heapq.heappush(que, -t_r_list[l][1])
        l += 1
        if l >= n:
            break
        
 
    if que:
        total -= heapq.heappop(que)
      
      
print(total)

Buggy submission (verdict: Runtime Error):
import heapq
 
 
 
n, m = map(int, input().split())
t_r_list = []
for i in range(n):
    t_r_list.append(list(map(int, input().split())))


t_r_list.sort()
que = []
total = 0
l = 0
for j in range(1, m+1):
    while j < m and t_r_list[l][0] == j:
        heapq.heappush(que, -t_r_list[l][1])
        l += 1
        if l >= n:
            break
        
 
    if que:
        total -= heapq.heappop(que)
      
      
print(total)
Problem p02954 (python)

Fixed submission:
li=input()
n=len(li)
child_li=[0]*n


ruiseki=0
for i in range(n-1):
    if li[i]=='R':
        ruiseki+=1
        if li[i+1]=='L':
            child_li[i+1]=ruiseki//2
            child_li[i]=(ruiseki+1)//2
    else:
        ruiseki=0

        
ruiseki=0
for i in range(n-1, 0, -1):
    if li[i]=='L':
        ruiseki+=1
        if li[i-1]=='R':
            child_li[i-1]+=ruiseki//2
            child_li[i]+=(ruiseki+1)//2
    else:
        ruiseki=0
        
print(*child_li)

Buggy submission (verdict: Runtime Error):
li=input().split()[0]
child_li=[1]*len(li)
for i in range(len(li)):
    new_child_li=[0]*len(li)
    for j in range(len(li)):
# jでそれぞれのますをみる
        if li[j]=='R':
            new_child_li[j+1]+=child_li[j]
        else:
            new_child_li[j-1]+=child_li[j]
    child_li=new_child_li


rl_list=[(i,i+1) for i in range(len(li)-1) if li[i]=='R' and li[i+1]=='L']

        
if len(li)%2:
    for i in rl_list:
        new_child_li[i], new_child_li[i+1]=new_child_li[i+1], new_child_li[i]
print(*new_child_li, sep=' ')
Problem p02959 (python)

Fixed submission:
from collections import defaultdict, deque
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


def main():
    n = I()
    monster = LI()
    ret = 0
    ans = sum(monster)
    savor_lim = LI()
    for i in range(n - 1, -1, -1):
        k = min(savor_lim[i], monster[i + 1])
        monster[i + 1] -= k
        savor_lim[i] -= k
        monster[i] -= min(savor_lim[i], monster[i])
    return ans - sum(monster)



print(main())

Buggy submission (verdict: Runtime Error):
raw_input = [int(i)for i in input().split()]
n = raw_input[0]
m = raw_input[1:len(raw_input)-2]
y = raw_input[-n:]
y += [0]
remainder = 0
total = 0
for i in range(n+1):
    y[i] += remainder
    total += min(y[i], m[i])
    remainder = max(y[i] - m[i], 0)
print(total)

Buggy submission (verdict: Runtime Error):
n = raw_input[0]
m = raw_input[1:len(raw_input)-2]
y = raw_input[-2:]
y += [0]
remainder = 0
total = 0
for i in range(n+1):
    y[i] += remainder
    total += min(y[i], m[i])
    remainder = max(y[i] - m[i], 0)
    print(remainder)
print(total)
Problem p03011 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


a, b, c = LI()
print(min([i + j for i, j in list(combinations([a, b, c], 2))]))

Buggy submission (verdict: Runtime Error):
# ABC129C - Typical Stairs
import sys
input = sys.stdin.readline
 
def main():
    N, M = tuple(map(int, input().split()))
    A = set(map(int, [input() for _ in range(M)]))
    MOD = 10 ** 9 + 7
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in A else 0
    for i in range(2, N + 1):
        if i in A:
            continue
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
    print(dp[-1])
 
 
if __name__ == "__main__":
    main()
Problem p03038 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys



def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, m = LI()
nums = LI()
que = []
for k, v in Counter(nums).items():
    heappush(que, (-k, v))
for i, j in LIR(m):
    heappush(que, (-j, i))


ret = 0
ans = 0
while ret < n:
    k, v = heappop(que)
    ret += v
    ans += -k * v


print(ans + (ret - n) * k)

Buggy submission (verdict: Runtime Error):
from math import factorial


n, m, k = list(map(int, input().split()))
# 　ある配置を固定した時、その2つの配置でmanhattan距離が計算される回数は、他の組み合わせ数。
combination = factorial(n*m-2)//factorial(k-2)//factorial((n*m-2)-(k-2))
# n=5なら1,2,3,4それぞれにm**2をかける。
print((sum([m**2*i*(n-i) for i in range(1, n)]) + sum([n**2*i*(m-i) for i in range(1, m)])) * combination)
# あるマンハッタン距離の時の配置の数
Problem p03221 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, m = LI()
L = LIR(m)
for i in range(m):
    L[i] = [i, str(L[i][0]).zfill(6), L[i][1]]


L.sort(key=lambda x:x[1:])
cnt = 1
L[0][2] = str(1).zfill(6)
for i in range(1, m):
    if L[i][1] != L[i-1][1]:
        cnt = 1
    else:
        cnt += 1
    L[i][2] = str(cnt).zfill(6)



L.sort(key=lambda x:x[0])
for i in L:
    print(i[1] + i[2])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, m = LI()
L = LIR(m)
for i in range(m):
    L[i] = [i, f'{L[i][0]:0>6}', L[i][1]]


L.sort(key=lambda x:x[1:])
cnt = 1
L[0][2] = f'{1:0>6}'
for i in range(1, m):
    if L[i][1] != L[i-1][1]:
        cnt = 1
    else:
        cnt += 1
    L[i][2] = f'{cnt:0>6}'



L.sort(key=lambda x:x[0])
for i in L:
    print(i[1] + i[2])
Problem p02682 (python)

Fixed submission:
a,b,c,k=[int(i) for i in input().split()]
print(k if k<=a else a if k <=a+b else 2*a+b-k)

Buggy submission (verdict: Runtime Error):
a,b,c,k=[int(i) for i in input().split()]
print(k if k<= a else a if k <=a+b else 2a+b-k)
Problem p02580 (python)

Fixed submission:
h, w, m = map(int, input().split())
a_list = []
b_list = []
h_list = [0 for _ in range(h)]
w_list = [0 for _ in range(w)]
for i in range(m):
    a, b = map(int, input().split())
    a_list.append([a,b])
    h_list[a - 1] += 1
    w_list[b - 1] += 1
h_max = max(h_list)
w_max = max(w_list)
w_flag = [0 for _ in range(w)]
for i in range(w):
    if w_list[i] == w_max:
        w_flag[i] = 1
h_flag = [0 for _ in range(h)]
for i in range(h):
    if h_list[i] == h_max:
        h_flag[i] = 1
flag = 0   
for i in range(m):
    if h_flag[a_list[i][0] - 1] == 1 and w_flag[a_list[i][1] - 1] == 1:
        flag += 1
s = sum(h_flag) * sum(w_flag)
print(h_max + w_max - 1 if flag == s else h_max + w_max)

Buggy submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(m)]
high = [0] * h
weig = [0] * w
for i in range(m):
    high[hw[i][0] - 1] += 1
    weig[hw[i][1] - 1] += 1
m_high = high.index(max(high))
m_weig = weig.index(max(weig))
ans = max(high) + max(weig)
for i, x in enumerate(high) if x == max(high):
    for j, y in enumerate(l_dup) if x == max(weig):
        ans -= 1
print(ans)