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

Fixed submission:
a,b,c=map(int,input().split())
print(9*max(a,b,c)+a+b+c)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input())
print(9*max(a,b,c)+a+b+c)
Problem p02699 (python)

Fixed submission:
s, w = [int(i) for i in input().split()]
if s <= w:
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
import numpy as np
s = input()
cnt = 0
ss = []
nums = np.array([(i+1)*2019 for i in range(200000//2019) if not "0" in str((i+1)*2019)])
for start in range(len(s)):
  end = start + 3
  while(end+1<=len(s)):
    if int(s[start:end+1]) in nums:
      cnt += 1
    end += 1
print(cnt)
Problem p02754 (python)

Fixed submission:
import math

N, A, B = map(int, input().split())
tmp = 10**100
a = A * (N //(A+B))
b = (N %(A+B))
if b > A:
    print(a + A)
else: 
    print(a + b)

Buggy submission (verdict: Runtime Error):
import math

N, A, B = map(int, input().split())

string = 'r'* A + 'b'*B
res = ''
for _ in range(math.ceil(N/(A+B))):
    res += string

print(res[:N].count('r'))
Problem p02831 (python)

Fixed submission:
import fractions

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

A, B = map(int, input().split())

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 p02682 (python)

Fixed submission:
a,b,c,k=map(int,input().split())
if k<=a:
  print(k)
elif k<=a+b:
  print(a)
else: 
  print(2*a-k+b)

Buggy submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split())
if k<=a+b:
  print(a)
elif k<=a+b+c:
  print(2a-k+b)
else:
  print(a-c)
Problem p02688 (python)

Fixed submission:
n,k=map(int,input().split())
l=[0]*n
for i in range(k):
  d=int(input())
  h=list(map(int,input().split()))
  for j in h:
    l[j-1]=1
print(l.count(0))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=[0]*n
for i in range(k):
  d=int(input())
  h=[int(input()) for i in range(d)]
  for j in d:
    l[j-1]=1
print(l.count(0))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=[0]*n
for i in range(k):
  d=int(input())
  for j in range(d):
    a=int(input())
    l[a-1]=1
print(l.count(0))
Problem p02707 (python)

Fixed submission:
x=[0]*int(input())
for i in input().split():
    x[int(i)-1]+=1
print(*x)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
  print(a.count(i,1,i))
Problem p02729 (python)

Fixed submission:
import math
n,m=map(int,input().split())
def comb(k, r):
  if k<2:
    return 0
  else:
    return math.factorial(k) // (math.factorial(k - r) * math.factorial(r))

print(comb(n,2)+comb(m,2))

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h> 
using namespace std;
 
int main() {
	int n, m;
	cin >> n >> m;
	cout << (n*(n-1) / 2) + (m * (m-1) / 2) << "\n";
	return 0;
}

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
def comb(k, r):
  if n<2:
    return 0
  else:
    return math.factorial(k) // (math.factorial(k - r) * math.factorial(r))

print(comb(n,2)+comb(m,2))
Problem p02753 (python)

Fixed submission:
s=input()
if s=='AAA' or s=='BBB':
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
s=input()
if s==="AAA" or "BBB":
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
s=input()
if s==="A" or "B":
  print('Yes')
else:
  print("No")
Problem p02759 (python)

Fixed submission:
n=int(input())
if n%2==0:
  print(n//2)
else:
  print((n+1)//2)

Buggy submission (verdict: Runtime Error):
A=[[int(x) for x in input().split()]for i in range(3)]
n=int(input())
b=list(map(int,input().split()))
for i in range(3):
    if A[i][0] in b and A[i][1] in b and A[i][2] in b:
        print('Yes')
        exit()
    elif A[0][i] in b and A[1][i] in b and A[2][i] in b:
        print('Yes')
        exit()
if A[0][0] in b and A[1][1] in b and A[2][2] in b:
    print('Yes')
    exit()
if A[2][0] in b and A[1][1] in b and A[0][2] in b:
    print('Yes')
    exit()
print('No')
Problem p02766 (python)

Fixed submission:
import sys
n,k=map(int,input().split())
for i in range(n):
  if k**i<=n and n<k**(i+1):
    print(i+1)
    sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
n,k=map(int,input().split())
for i in range(length.n):
  if k**i<=n and n<k**(i+1):
    print(i+1)
    sys.exit()
Problem p02773 (python)

Fixed submission:
import collections

N=int(input())
S=[]
for i in range(N):
	S.append(input())
M=collections.Counter(S)
A=max(M.values())
tmp=[]
for i,j in M.items():
	if j==A:
		tmp.append(i)
ans=sorted(tmp)
for i in range(len(ans)):
	print(ans[i])

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
s=list(map(str,input().split()))
k=collections.Counter(s).c.most_common()
l=[]
for i in k:
    if  i[1]==i[0][1]:
      l.append(i[0])
l.sort()
for i in l:
    print(i)

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
s=input().split()
k=collections.Counter(s).c.most_common()
l=[]
for i in k:
    if  i[1]==i[0][1]:
      l.append(i[0])
l.sort()
for i in l:
    print(i)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
s=input().split()
k=collections.Counter(s).c.most_common()
l=[]
for i in k:
    if  i[1]==i[0][1]:
      l.append(i[0])
l.sort()
for i in l:
    print(i)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
s=input().split()
c=collections.Counter(s)
k=list(c.most_common())
cnt=0
for i in range(n):
    if k[i][1]>cnt:
        cnt=k[i][1]
        l=[k[i][0]]
    elif k[i][1]==cnt:
        l.append(k[i][0])
    else:
        break 
for i in l:
    print(i)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
s=input().split()
c=collections.Counter(s)
k=list(c.most_common())
#print(k[0][0])
cnt=0
for i in range(n):
    if k[i][1]>cnt:
        cnt=k[i][1]
        l=[k[i][0]]
    elif k[i][1]==cnt:
        l.append(k[i][0])
    else:
        break 
for i in l:
    print(i)

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
s=input().split()
c=collections.Counter(s)
k=list(c.most_common())
cnt=0
for i in range(n):
    if k[i][1]>cnt:
        cnt=k[i][1]
        l=[k[i][0]]
    elif k[i][1]==cnt:
        l.append(k[i][0])
    else:
        break 
for i in l:
    print(i)
Problem p02790 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
l=[]
if a<b:
  for i in range(a):
    l.append(b)
    l=[str(i) for i in l]
    L=''.join(l)
	print(L)
else:
   for i in range(b):
    l.append(a)
    l=[str(i) for i in l]
    L=''.join(l)
	print(L)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
l=[]
if a<b:
  for i in range(a):
    l.append(b)
    l=[str(i) for i in l]
    L=''.join(l)
	print(L)
else:
   for i in range(b):
    l.append(a)
     l=[str(i) for i in l]
    L=''.join(l)
	print(L)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
l=[]
if a<b:
  for i in range(a):
    l.append(b)
    L=''.join(l)
	print(L)
else:
   for i in range(b):
    l.append(a)
    L=''.join(l)
	print(L)
Problem p02829 (python)

Fixed submission:
l=[1,2,3]
a=int(input())
l.remove(a)
b=int(input())
l.remove(b)
print(l[0])

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
l=[1,2,3]
l.remove(a)
l.remove(b)
print(l)
Problem p02831 (python)

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

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

Fixed submission:
N=int(input())
A=map(int,input().split())
i=1
for a in A:
  if a==i: i+=1
i-=1
print(N-i if i>0 else -1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
i=1
for k in a:
  if k==i: i+=1
1-=1
print(N-i if i>0 else -1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
i=1
for k in a:
  if k==i: i+=1
print(N-i+1 if i>1 else -1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
i=1
for k in a:
  if k==i: i+=1
print(N-i+1 if i>1 else -1)
Problem p02836 (python)

Fixed submission:
s = input()
 
cnt = 0
b = int(len(s))
 
for a in range(int(b/2)):
    if s[a] != s[(b-a-1)]:
       cnt = cnt +1
print(cnt)

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

if len(s)%2==0:
  for i in range(len(s)/2):
    if s[i]!=s[len(s)-1-i]:
      cnt+=1
      
else:
  for i in range((len(s)+1)/2):
    if s[i]!=s[len(s)-1-i]:
      cnt+=1
print(cnt)

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

if len(s)%2==0:
  for i in range(len(s)/2):
    if s[i]!=s[len(s)-i]:
      cnt+=1
else:
  for i in range((len(s)+1)/2):
    if s[i]!=s[len(s)-i]:
      cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
s=input()
cnt=0
if len(s)%2==0:
  for i in range(len(s)//2):
    if s[i]!=s[len(s)-i]:
      cnt+=1
else:
  for i in range((len(s)+1)//2):
    if s[i]!=s[len(s)-i]:
      cnt+=1
print(cnt)
Problem p02847 (python)

Fixed submission:
s=input()
if s=='SUN':
  print('7')
elif s=='MON':
  print('6')
elif s=='TUE':
  print('5')
elif s=='WED':
  print('4')
elif s=='THU':
  print('3')
elif s=='FRI':
  print('2')
else:
  print('1')

Buggy submission (verdict: Runtime Error):
s=input()
l=[SUN,MON,TUE,WED,THU,FRI,SAT]
print(7-l.index(s))
Problem p02859 (python)

Fixed submission:
r = int(input())
s = 1
for i in range(2):
  s = s * r
print(s)

Buggy submission (verdict: Runtime Error):
r = map(int, input())
print(r**2)
Problem p02916 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
   
s=0
bb=sum(b)
for i in range(n-1):
       if a[i]+1==a[i+1]:
               s+=c[a[i]-1]
s+=bb
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split())
b=list(map(int,input().split())
c=list(map(int,input().split())
   
s=0
bb=sum(b)
for i in range(n-1):
       if a[i]+1==a[i+1]:
               s+=c[a[i]-1]
s+=bb
print(s)
Problem p03073 (python)

Fixed submission:
s=input()
a=s[0]
cnt=0
for i in s[1:]:
    if i==a:
        cnt+=1
        if i=="0":
            a="1"
        else:
            a="0"
    else:
        a=i
print(cnt)

Buggy submission (verdict: Runtime Error):
s=int(input())
t=s[::2]
u=s[1::2]
a=t.count(0)
b=u.count(0)
if a>=b:
  print(len(t)-a+b)
else:
  print(len(t)-b+a)
Problem p02659 (python)

Fixed submission:
import math


def main():
    a, b = input().split()
    A = int(a)
    # B = int(math.floor(float(b) * 100))
    B = int(b.replace('.', ''))
    print(int(A * B // 100))


if __name__ == '__main__':
    main()

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

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
b = math.floor(float(b) * 100)
print(a * b // 100)
Problem p02735 (python)

Fixed submission:
H,W,*L = open(0).read().split()
H,W = map(int, (H,W))
dp = [[0]*W for i in range(H)]
for i in range(1,H):
  if L[i][0]!=L[i-1][0]:
    dp[i][0] = dp[i-1][0]+1
  else:
    dp[i][0] = dp[i-1][0]
for j in range(1,W):
  if L[0][j]!=L[0][j-1]:
    dp[0][j] = dp[0][j-1]+1
  else:
    dp[0][j] = dp[0][j-1]
for i in range(1,H):
  for j in range(1,W):
    if L[i][j]!=L[i-1][j] and L[i][j]!=L[i][j-1]:
      dp[i][j] = min(dp[i-1][j],dp[i][j-1])+1
    elif L[i][j]!=L[i-1][j]:
      dp[i][j] = min(dp[i-1][j]+1,dp[i][j-1])
    elif L[i][j]!=L[i][j-1]:
      dp[i][j] = min(dp[i-1][j],dp[i][j-1]+1)
    else:
      dp[i][j] = min(dp[i-1][j],dp[i][j-1])
if L[0][0]=='.':
  ans = (dp[H-1][W-1]+1)//2
else:
  ans = (dp[H-1][W-1]+2)//2
print(ans)

Buggy submission (verdict: Runtime Error):
H,W,*L = open('0').read().split()
H,W = map(int, (H,W))
dp = [[0]*W for i in range(H)]
if L[0][0]=='#':
  dp[0][0] = 1
for i in range(1,H):
  if L[i][0]=='#':
    dp[i][0] = dp[i-1][0]+1
  else:
    dp[i][0] = dp[i-1][0]
for j in range(1,W):
  if L[0][j]=='#':
    dp[0][j] = dp[0][j-1]+1
  else:
    dp[0][j] = dp[0][j-1]
for i in range(1,H):
  for j in range(1,W):
    if L[i][j]=='#':
      dp[i][j] = min(dp[i-1][j],dp[i][j-1])+1
    else:
      dp[i][j] = min(dp[i-1][j],dp[i][j-1])
print(dp[H-1][W-1])
Problem p02793 (python)

Fixed submission:
import numpy as np
N = int(input())
a = np.array(input().split(), np.int64)
MOD = 10**9+7
U = 10**6+10
is_prime = np.zeros(U, np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, U, 2):
  if p*p>U:
    break
  if is_prime[p]==1:
    is_prime[p*p::p+p] = 0

M = 10**3
small_primes = np.where(is_prime[:M])[0].tolist()

B = a.copy()
lcm = 1
for p in small_primes:
  e = 0
  while np.any(a%p==0):
    a[a%p==0] //= p
    e += 1
  lcm *= p**e
  lcm %= MOD

for x in set(a.tolist()):
  lcm *= x
  lcm %= MOD

answer = sum(pow(x, MOD-2, MOD) for x in B.tolist())%MOD
answer *= lcm
answer %= MOD
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = np.array([int(c) for c in input().split()])
MOD = 10**9+7
U = 10**6+10
B = np.zeros(U)
B[2] = 1
B[3::2] = 1
for i in range(3,U):
  if i*i>U:
    break
  if B[i]:
    B[i*i::i+i] = 0
pls = np.where(B[:1000])[0].tolist()
B = A.copy()
lcm = 1
for p in pls:
  e = 0
  if np.any(A%p==0):
    A[A%p==0] //= p
    e += 1
  lcm *= p**e
  lcm %= MOD
for x in set(A.tolist()):
  lcm *= x
  lcm %= MOD
x = sum(pow(c, MOD-2, MOD) for c in B.tolist())
print(x*lcm%MOD)
Problem p02833 (python)

Fixed submission:
N = int(input())

if N%2==1:
  print(0)
else:
  ans = 0
  m = 5
  n = 1
  while m<=N:
    c = N//m
    c = c//2
    ans += c
    m *= 5
  print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N%2==1:
  print(0)
else:
  ans = 0
  m = 5
  n = 1
  while m<=N:
    c = N//m
    c = c//2
    ans += c
    m *= 5
print(ans)
Problem p02851 (python)

Fixed submission:
from collections import defaultdict
import itertools

N, K = map(int, input().split())
A = [int(c)-1 for c in input().split()]
A = [0] + A
Acum = list(itertools.accumulate(A))
Acum = [x%K for x in Acum]

counter = defaultdict(int)

ans = 0
for i,x in enumerate(Acum):
  ans += counter[x]
  counter[x] += 1
  if i>=K-1:
    counter[Acum[i-K+1]] -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from bisect import bisect_left
N, K = map(int, input().split())
a = [int(c)-1 for c in input().split()]
s = [0]
for i in range(N):
  s += [(s[-1]+a[i])%K]
dic = defaultdict(list)

for i in range(N+1):
  dic[s[i]] += [i]

ans = 0
for k in dic.keys():
  ls = dic[k]
  for j in range(len(ls)):
    ind = bisect_left(ls, ls[j]-K+2)
    ans += j-ind
    if ind>0 and ls[ind-1]+1 == ls[ind]:
      ans += 1
    elif ind<ls[0]:
      ans += 1
#  print(k, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from bisect import bisect_left
N, K = map(int, input().split())
a = [int(c)-1 for c in input().split()]
s = [0]
for i in range(N):
  s += [(s[-1]+a[i])%K]
dic = defaultdict(list)

for i in range(N+1):
  dic[s[i]] += [i]

ans = 0
for k in dic.keys():
  ls = dic[k]
  for j in range(len(ls)):
    ind = bisect_left(ls, ls[j]-K+2)
    ans += j-ind
    if ind>0 and ls[ind-1]+1 == ls[ind]:
      ans += 1
#  print(k, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from bisect import bisect_left
N, K = map(int, input().split())
a = [int(c)-1 for c in input().split()]
s = [0]
for i in range(N):
  s += [(s[-1]+a[i])%K]
dic = defaultdict(list)

for i in range(N+1):
  dic[s[i]] += [i]

ans = 0
for k in dic.keys():
  ls = dic[k]
  for j in range(len(ls)):
    ind = bisect_left(ls, ls[j]-K+2)
    ans += j-ind
    if ind!=0 and ls[ind-1]+1 == ls[ind]:
      ans += 1
#  print(k, ans)

print(ans)
Problem p02879 (python)

Fixed submission:
A, B = map(int, input().split())
if 0<A<10 and 0<B<10:
  print(A*B)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())
if 0<A<10 and 0<B<10:
  print(A*B)
else:
  print(-1)
Problem p02948 (python)

Fixed submission:
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):  # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
dic = {i:[] for i in range(1,M+1)}
for i in range(N):
  A, B = map(int, input().split())
  if A<=M:
    dic[A] += [B]
key = list(dic.keys())
key.sort()
ans = 0
ls = []
pm = 0
m = 0
for i in range(1,M+1):
  if dic[i]:
    x = max(dic[i])
    if m < x:
      ans += x
      dic[i].remove(x)
      ls += dic[i]
    else:
      ans += m
      ls.remove(m)
      ls += dic[i]
  else:
    ans += m
    ls.remove(m)
  m = max(ls)
  
  
print(ans)
Problem p02964 (python)

Fixed submission:
from bisect import bisect_left
from collections import defaultdict
N, K, *A = map(int, open(0).read().split())
dic = defaultdict(list)
for i, a in enumerate(A):
  dic[a] += [i]
ls = []
ps = 0
m = A[0]
cycle = 0
while True:
  ls.append(ps+N*cycle+1)
  i = bisect_left(dic[m],ps+1)
  ps = dic[m][i%len(dic[m])]
  if i>=len(dic[m]):
    cycle += 1
  ps += 1
  ps %= N
  m = A[ps]
  if ps==0:
    cycle += 1
    break
k = K%cycle
j = bisect_left(ls,k*N)
if ls[j]==k*N:
  c = (ls[j]-1)%N
  print(A[c])
elif ls[j]==k*N+1:
  pass
else:
  c = (ls[j-1]-1)%N
  M = k*N-ls[j-1]
  ans = [A[c]]
  log = set(ans)
  ind = {}
  ind[A[c]] = 0
  cnt = 0
  while M:
    c += 1
    c %= N
    cnt += 1
    cnt %= N
    M -= 1
    if not A[c] in log:
      log.add(A[c])
      ind[A[c]] = cnt
      ans += [A[c]]
    else:
      log.remove(A[c])
      ans = ans[:ind[A[c]]]
      log = set(ans)
      cnt = ind[A[c]]-1
  print(*ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from bisect import bisect_right
N,K,*A = map(int, open(0).read().split())
a = A[0]
p = 0
ls = []
dic = defaultdict(list)
for i,c in enumerate(A):
  dic[c].append(i)
while True:
  ls.append(p)
  ind = bisect_right(dic[a],p%N)
  if ind==len(dic[a]):
    ind = 0
    p += N
  p = (p//N)*N+dic[a][ind]+1
  if p%N==0:
    M = p//N
    break
  a = A[p%N]
K %= M
X = N*K
I = bisect_right(ls,X)-1
X -= ls[I]
p = ls[I]%N
S = set()
cnt = 0
ans = []
while X:
  if A[p] not in S:
    S.add(A[p])
    ans.append(A[p])
    cnt += 1
  else:
    i = ans.index(A[p])
    ans = ans[:i]
    cnt = i
  X -= 1
  p += 1
  p %= N
print(' '.join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
from collections import defaultdict
N, K, *A = map(int, open('0').read().split())
dic = defaultdict(list)
for i, a in enumerate(A):
  dic[a] += [i]
ls = []
ps = 0
m = A[0]
cycle = 0
while True:
  ls.append(ps+N*cycle+1)
  i = bisect_left(dic[m],ps+1)
  ps = dic[m][i%len(dic[m])]
  if i>=len(dic[m]):
    cycle += 1
  ps += 1
  ps %= N
  m = A[ps]
  if ps==0:
    cycle += 1
    break
k = K%cycle
j = bisect_left(ls,k*N)
if ls[j]==k*N:
  c = (ls[j]-1)%N
  print(A[c])
elif ls[j]==k*N+1:
  pass
else:
  c = (ls[j-1]-1)%N
  M = k*N-ls[j-1]
  ans = [A[c]]
  log = set(ans)
  ind = {}
  ind[A[c]] = 0
  cnt = 0
  while M:
    c += 1
    c %= N
    cnt += 1
    cnt %= N
    M -= 1
    if not A[c] in log:
      log.add(A[c])
      ind[A[c]] = cnt
      ans += [A[c]]
    else:
      log.remove(A[c])
      ans = ans[:ind[A[c]]]
      cnt = ind[A[c]]-1
  print(*ans)
Problem p03003 (python)

Fixed submission:
N, M = map(int, input().split())
s = [int(c) for c in input().split()]
t = [int(c) for c in input().split()]
MOD = 10**9+7

dp = [[0]*(M+1) for i in range(N+1)]
dp_cum = [[0]*(M+1) for i in range(N+1)]

dp[0][0] = 1
for i in range(N+1):
  dp_cum[i][0] = 1
for j in range(M+1):
  dp_cum[0][j] = 1
  
for i in range(N):
  for j in range(M):
    if s[i]!=t[j]:
      dp[i+1][j+1] = 0
    else:
      dp[i+1][j+1] = dp_cum[i][j]
    dp_cum[i+1][j+1] = dp_cum[i][j+1] + dp_cum[i+1][j] - dp_cum[i][j] + dp[i+1][j+1]
    dp_cum[i+1][j+1] %= MOD

print(dp_cum[-1][-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
MOD = 10**9+7
N, M = map(int, input().split())
s = np.array(input().split(), dtype=np.int32)
t = np.array(input().split(), dtype=np.int32)

dp = np.zeros((N+1,M+1), dtype=np.int64)
dp[0] = 1

for i in range(N):
  same = (s[i]==t)
  dp[i+1,1:][same] = dp[i,:-1][same]
  dp[i+1] = (dp[i+1].cumsum()+dp[i])%MOD

print(dp[-1,-1])
Problem p03012 (python)

Fixed submission:
n = input()
line = map(int, input().split())
line = list(line)
m = abs(sum(line))
for i in range(1, len(line)):
  score = abs(sum(line[:i]) - sum(line[i:]))
  if m > score:
    m = score
print(m)

Buggy submission (verdict: Runtime Error):
N = input()
source = map(int, input().split())
source = list(source)
score = sum(souce)
for i in range(1, len(source)):
  value = sum(souce[:i])-sum(souce[i:])
  value = abs(value)
  if score > value:
    score = value
print(score)
Problem p03013 (python)

Fixed submission:
line = input().split()
N = int(line[0])
M = int(line[1])
broken = []
count = 0
step = []
def check(value):
  if count < M:
    return broken[count]==value
  else:
    return False
for i in range(M):
  a = int(input())
  broken += [a]
if check(1):
  step+=[0]
  count += 1
else:
  step +=[1]
if check(2):
  step += [0]
  count += 1
else:
  step += [1+step[0]]
for j in range(2, N):
  if check(j+1):
    step += [0]
    count += 1
  else:
    step += [step[j-2]+step[j-1]]
ans = step[N-1]%(10**9+7)
print(ans)

Buggy submission (verdict: Runtime Error):
inf = input().split()
N = int(inf[0])
M = int(inf[1])
ls = []
for i in range(M):
  a = int(input())
  ls += [a]
step = [0 for i in range(N)]
if 1 not in ls:
  step[0] = 1
if 2 not in ls:
  step[1] = 1 + step[0]
for j in range(2, N):
  if j not in ls:
    step[j] = step[j-1]+step[j-2]
  else:
    step[j] = 0
ans = step[N-1]%(10^9+7)
print(ans)
Problem p03015 (python)

Fixed submission:
L = input()
MOD = 10**9+7

pow_3=[1]
for _ in range(2*10**5):
  pow_3.append((pow_3[-1]*3)%MOD)
  
pow_2=[1]
for _ in range(2*10**5):
  pow_2.append((pow_2[-1]*2)%MOD)
  
count = L.count('1')
ans = pow_2[count]

for i in range(len(L)-1,-1,-1):
  if L[i]=='1':
    count -= 1
    m = pow_3[len(L)-i-1]*pow_2[count]
    ans += m
    ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
L = int(input(),2)
MOD = 10**9+7
@lru_cache(None)
def f(n):
  if n==1:
    return 3
  elif n==0:
    return 1
  a = n>>1
  if n%2==1:
    return (f(a)*3)%MOD
  return (f(a)+f(a-1)*2)%MOD

print(f(L))
Problem p03038 (python)

Fixed submission:
from collections import defaultdict
inf = input().split()
N = int(inf[0])
W = int(inf[1])
dic = defaultdict(int)

line = input().split()

for a in line:
    dic[int(a)] += 1

for w in range(W):
    inf = input().split()
    b = int(inf[0])
    c = int(inf[1])
    dic[c] += b
    
keys = list(dic.keys())

keys.sort(reverse=True)

count = 0
ans = 0
for k in keys:
    while dic[k]>0:
        if count == N:
            break
        ans += k
        dic[k] -= 1
        count += 1
    if count == N:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
#include<vector>
#include<iostream>
#include<algorithm>
#include<numeric>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<long long int> A(N);
    for(int i = 0; i<N; i++) {
        cin >> A.at(i);
    }
    for(int j = 0; j<M; j++) {
        long long int b, c;
        cin >> b >> c;
        vector<long long int> x(b,c);
        A.insert(A.end(), x.begin(), x.end());
    }
    sort(A.begin(), A.end(), std::greater<long long int>());
    cout << accumulate(A.begin(), A.begin()+N, 0LL) << endl;
    return 0;
}