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

Fixed submission:
N, K = [int(n) for n in input().split()]
S = input()

sentous = []
sentou = 0
counts = [0]
count = 0
prev = 0
for s in S:
    count += 1
    sentou += 1
    if s != prev and s == '1':
        if count > 1:
            sentous.append(sentou - 1)
        sentou = 1
    elif s != prev and s == '0':
        # sentou = 0
        if K > 0:
            K -= 1
        else:
            counts.append(count - 1)
            count -= sentous.pop(0)
    prev = s

print(max(max(counts), count))

Buggy submission (verdict: Runtime Error):
N, K = [int(n) for n in input().split()]
S = input()

sentous = []
sentou = 0
counts = [0]
count = 0
prev = 0
for s in S:
    count += 1
    if s == prev and count > 0:
        sentou += 1
    elif s != prev and s == '1':
        sentou += 1
    elif s != prev and s == '0':
        sentous.append(sentou + 1)
        sentou = 0
        if K > 0:
            K -= 1
        else:
            count -= sentous.pop(0)
        counts.append(count)
    prev = s

print(max(*counts, count))
Problem p02818 (python)

Fixed submission:
i = input().split()
a = int(i[0])
b = int(i[1])
k = int(i[2])
c = a 
d = b

if k >= a+b:
  c = d = 0

elif k == a:
  c = 0

elif k > a:
  c = 0
  d = b - (k - a)

else:
  c = a - k
  
print(c,d)

Buggy submission (verdict: Runtime Error):
i = input().split()
a = int(i[0])
b = int(i[1])
k = int(i[2])

if k >= a+b:
  c = d = 0

elif k == a:
  c = 0

elif k > a:
  c = 0
  d = b - (k - a)

else:
  c = a - k
  
print(c,d)
Problem p02684 (python)

Fixed submission:
N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))
T={}
T[1]=1
t=1
for i in range(2,K+1):
    a=A[t]
    t=a
    K-=1
    if a in T:
        l=list(T.keys())[T[a]-1:]
        print(l[K%len(l)])
        break
    else:
        T[a]=i
else:
    print(A[t])

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
A = [0] + list(map(int,input().split()))
T = [1]
current_town = 1
for i in range(2,K+1):
    current_town = A[current_town]
    K -= 1
    if current_town in T:
        loop_towns = T[T[current_town]-1:]
        print(loop_towns[K%len(loop_towns)])
        break
    else:
        T.append(current_town)
else:
    print(A[current_town])
Problem p02706 (python)

Fixed submission:
n,m=(int(x) for x in input().split())
a = [int(x) for x in input().split()]
ans = max(n - sum(a), -1)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=(int(x) for x in input().split())
a,A = (int(x) for x in input().split())
ans = max(n - (a+A), -1)
print(ans)
Problem p03470 (python)

Fixed submission:
N = int(input())
d = []

for i in range(N):
    d.append(int(input()))

d = list(set(d))

print(len(d))

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

for i in range(N):
    d.append(int(input()))

d = list(set(d))

print(length(d))
Problem p02684 (python)

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

root = [1]
setroot = set(root)

for i in range(N):
    if A[root[-1]-1] in setroot:
        start = root.index(A[root[-1]-1])
        break
    setroot.add(A[root[-1]-1])
    root.append(A[root[-1]-1])

roop = root[start:]

if K <= start:
    print(root[K])
else:
    print(root[(K-start)%len(roop)+start])

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

roop = [1]
start=0

for i in range(N):
    roop.append(A[roop[-1]-1])
    if roop[-1] in set(roop[:-1]):
        start=roop[:-1].index(roop[-1])
        break
print(roop[2:-1][(K-start)%len(roop[2:-1])])
Problem p02866 (python)

Fixed submission:
import numpy as np
import collections
input1 = list(map(int,input().split()))
input2 = list(map(int,input().split()))

N = input1[0]
D = input2

if D[0] != 0:
  print(0)
  exit()

counter = collections.Counter(D)

ans = 1

D.sort()
D_numpy = np.array(D)
if (np.diff(D_numpy)<=1).prod():
  if counter[0] != 1:
    ans = 0
  else:
    for i in range(len(counter)):
      ans *= counter[i]**counter[i+1]
      if ans >= 998244353:
        ans = ans%998244353

else:
  ans = 0



print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import collections
input1 = list(map(int,input().split()))
input2 = list(map(int,input().split()))

N = input1[0]
D = input2

if D[0] != 0:
  print(0)
  exit()

counter = collections.Counter(D)

ans = 1

D.sort()
D_numpy = np.array(D)
if (np.diff(D_numpy)<=1).prod():
  if counter[0] != 1:
    ans = 0
  else:
    for i in range(len(counter)):
      try:
        counter[i]
      ans *= counter[i]**counter[i+1]
      if ans >= 998244353:
        ans = ans%998244353

else:
  ans = 0



print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import collections
input1 = list(map(int,input().split()))
input2 = list(map(int,input().split()))

N = input1[0]
D = input2


counter = collections.Counter(D)

ans = 1

D.sort()
D_numpy = np.array(D)
if (np.diff(D_numpy)<=1).prod():
  if counter[0] != 1:
    ans = 0
  else:
    for i in range(len(counter)):
      try:
        counter[i]
      ans *= counter[i]**counter[i+1]
      if ans >= 998244353:
        ans = ans%998244353

else:
  ans = 0

if D[0] != 0:
  ans = 0

print(ans)
Problem p02684 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:56 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N,K = map(int,input().split())
A = list(map(int,input().split()))

city = [False for i in range(N)]
city[1-1] =True
now = 1

counta1 = 0
while True:
    counta1 += 1
    prev = now
    now = A[now-1]
#    print(prev,now,counta1)
    if city[now-1]:
        break
    elif counta1 == K:
        print(now)
        sys.exit()
    else:
        city[now-1] = True

counta = 1
rout = []
rout.append(now)
while now != prev:
    now = A[now-1]
    rout.append(now)
    counta +=1
#    print(now,rout,counta)

ans = rout[(K-counta1) % counta]
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:56 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
N,K = map(int,input().split())
A = list(map(int,input().split()))

city = [False for i in range(N)]
city[1-1] =True
now = 1

counta1 = 0
while True:
    counta1 += 1
    prev = now
    now = A[now-1]
    print(prev,now,counta1)
    if city[now-1]:
        break
    elif counta1 == K:
        print(now)
        sys.exit()
    else:
        city[now-1] = True

counta = 1
rout = []
rout.append(now)
while now != prev:
    now = A[now-1]
    rout.append(now)
    counta +=1
    print(now,rout,counta)

ans = rout[(K-counta1) % counta]
print(ans)
Problem p02691 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 21:27:48 2020
"""

import sys
import numpy as np
import itertools

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
A = list(map(int,input().split()))

A = np.array(A)
B = np.arange(N)

x = A - B
y = A + B

x.sort()
y.sort()

ans = 0
i, j = 0, N - 1
#pre = 10**10
x1, y1 = 0, 0
while i < N and j >= 0:
    if -x[i] < y[j]:
        j -= 1
    elif -x[i] > y[j]:
        i += 1
    else:
        x1,y1 = 1, 1
        pre = y[j]
        while pre == -x[i+1]:
            x1 += 1
            i += 1
#            print('x',pre,x1)
        while pre == y[j-1]:
            y1 += 1
            j -= 1
#            print('y',pre,y1)
        i += 1
        j -= 1
        ans += x1 * y1
#        print()
#    print(i,j,x[i],y[j],x1,y1,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 21:27:48 2020
"""

import sys
import numpy as np
import itertools

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
A = list(map(int,input().split()))

A = np.array(A)
B = np.arange(N)

x = A - B
y = A + B

x.sort()
y.sort()

ans = 0
i, j = 0, N - 1
#pre = 10**10
x1, y1 = 0, 0
while i < N and j >= 0:
    if -x[i] < y[j]:
        j -= 1
    elif -x[i] > y[j]:
        i += 1
    else:
        x1,y1 = 1, 1
        pre = y[j]
        while pre == -x[i+1]:
            x1 += 1
            i += 1
#            print('x',pre,x1)
        while pre == y[j-1]:
            y1 += 1
            j -= 1
#            print('y',pre,y1)
        i += 1
        j -= 1
        ans += x1 * y1
#        print()
#    print(i,j,x[i],y[j],x1,y1,ans)
print(ans)
Problem p02713 (python)

Fixed submission:
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

K = int(input())
mod = 10**9 + 7

N = 3

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

ans = 0

M = np.zeros(K+1, dtype=int)

for i in range(K, 0, -1):
#    print(i)
    M[i] += pow(K//i, N)
    
    for j in range(2,K//i+1):
        j *= i
        M[i] -= M[j]
    
    ans += M[i] * i
    
        
print(ans)

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

#sys.setrecursionlimit(10 ** 9)

K = int(input())

def gcd(x,y):
    while y:
        x, y = y, x % y
    return x

ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += gcd(gcd(i+1,j+1), k+1)

print(ans)

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

#from fractions import gcd

sys.setrecursionlimit(10 ** 9)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

K = int(input())

ans = 0
M = np.zeros(K+1, dtype=int)
for i in range(1,K+1):
    for j in range(1,K+1):
        M[j] =  gcd(i,j)
        
        for k in range(1,K+1):
            ans += gcd(M[j],k)
            ans += gcd(gcd(i,j),k)

print(ans)
Problem p02714 (python)

Fixed submission:

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

N = int(input())
S = input()

rgb = [0,0,0]
for i in range(N):
    if S[i] == 'R':
        rgb[0] += 1
    elif S[i] == 'G':
        rgb[1] += 1
    else:
        rgb[2] += 1

ans = rgb[0] * rgb[1] * rgb [2]
#print(ans)

for i in range(N):
    for j in range(1,(N-i+1)//2):
        if S[i] != S[i+j] and S[i] != S[i+2*j] and S[i+j] != S[i+2*j]:
            ans -= 1
#        print(ans,i,i+j,i+2*j)
print(ans)

Buggy submission (verdict: Runtime Error):

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

N = int(input())
S = input()

rgb = [0,0,0]
for i in range(N):
    if S[i] == 'R':
        rgb[0] += 1
    elif S[i] == 'G':
        rgb[1] += 1
    else:
        rgb[2] += 1

ans = rgb[0] * rgb[1] * rgb [2]
#print(ans)

for i in range(N):
    for j in range(1,(N-i+1)//2):
        if S[i] != S[i+j] and S[i] != S[i+2*j] and S[i+j] != S[i+2*j]:
            ans -= 1
#        print(ans,i,i+j,i+2*j)
print(ans)
Problem p02719 (python)

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

x = N % K

ans = min(x,K-x)

print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)

K = int(input())

ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd(gcd(i,j), k)
print(ans)
Problem p02727 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:12:42 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
X, Y, A, B, C = map(int,input().split())
r = list(map(int,input().split()))
g = list(map(int,input().split()))
n = list(map(int,input().split()))

r.sort()
g.sort()
n.sort()

x, y = A-X, B-Y
z = C-1
ans = 0
ans += sum(r[x:])
ans += sum(g[y:])
g.append(10**10)
#print(x,y,z,r[x],g[y],n[z],ans)
while z >= 0:
#    print(x,y,z,r[x],g[y],n[z],ans)
    flg = True
    if x < A and r[x] < n[z] and r[x] < g[y]:
        ans += (n[z] - r[x])
        x += 1
        z -= 1
        flg = False
    elif y < B and g[y] < n[z]:
        ans += (n[z] - g[y])
        y += 1
        z -= 1
        flg = False
    if flg:
        break
#print(x,y,z,r[x],g[y],n[z],ans)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:12:42 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7



#N = int(input())
X, Y, A, B, C = map(int,input().split())
r = list(map(int,input().split()))
g = list(map(int,input().split()))
n = list(map(int,input().split()))

r.sort()
g.sort()
n.sort()

x, y = A-X, B-Y
z = C-1
ans = 0
ans += sum(r[x:])
ans += sum(g[y:])
#print(x,y,z,r[x],g[y],n[z],ans)
while (n[z] > r[x] or n[z] > g[y]) and z >= 0:
    if r[x] < g[y]:
        ans += (n[z] - r[x])
        x += 1
        z -= 1
    else:
        ans += (n[z] - g[y])
        y += 1
        z -= 1
#    print(x,y,z,r[x],g[y],n[z],ans)
print(ans)
Problem p02866 (python)

Fixed submission:

N = int(input())
D = list(map(int,input().split()))
mod = 998244353 
flg = True

if D[0] != 0:
    flg = False
    
D.sort()
T = [0 for _ in range(N + 1)]

for i in range(N):
    T[D[i]] += 1

i = 0
ans = 1
if T[i] != 1:
    flg = False

pre = T[i]
i += 1
while T[i] != 0:
    ans *= pow(pre,T[i])
    ans %= mod
    pre = T[i]
    i += 1

while i < N:
    if T[i] > 0:
        flg = False
    i += 1

ans %= mod
if flg:
    print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):

import sys

N = int(input())
D = list(map(int,input().split()))
mod = 998244353 

D.sort()
T = [0 for _ in range(N)]

for i in range(N):
    T[D[i]] += 1

i = 0
ans = 1
if T[i] != 1:
    print(0)
    sys.exit()
pre = T[i]
i += 1
while T[i] != 0:
    ans *= pow(pre,T[i],mod)
    ans %= mod
    pre = T[i]
    i += 1

while i < N:
    if T[i] > 0:
        print(0)
        sys.exit()
    i += 1

ans %= mod
print(ans)
Problem p02991 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Jul  1 11:43:19 2019

@author: Yamazaki Kenichi
"""
from collections import deque

N, M = map(int,input().split())
uv = [list(map(int,input().split())) for i in range(M)]
S, T = map(int,input().split())

Ta = [[] for i in range(3*N+1)]
for c in uv:
    Ta[c[0]].append(c[1]+N)
    Ta[c[0]+N].append(c[1]+2*N)
    Ta[c[0]+2*N].append(c[1])

check = [0 for i in range(3*N+1)]

q = deque([S])
check[S] = 1
counta = 0
flg = False
while len(q) > 0:
    for i in range(len(q)):
        nexts = Ta[q.popleft()]
        for next_ in nexts:
            if check[next_] != 1:
                q.append(next_)
                check[next_] = 1
    counta += 1
    if check[T] == 1:
        flg = True
        break
if flg:
    print(counta//3)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon Jul  1 11:43:19 2019

@author: Yamazaki Kenichi
"""
from collections import deque

N, M = map(int,input().split())
uv = [list(map(int,input().split())) for i in range(M)]
S, T = map(int,input().split())

Ta = [[] for i in range(3*N+1)]
for c in uv:
    Ta[c[0]].append(c[1]+N)
    Ta[c[0]+N].append(c[1]+2*N)
    Ta[c[0]+2*N].append(c[1])
del c

check = [0 for i in range(3*N+1)]

q = deque([S])
check[S] = 1
counta = 0
while len(q) > 0:
    for i in range(len(q)):
        nexts = Ta[q.popleft()]
        for next_ in nexts:
            if check[next_] != 1:
                q.append(next_)
                check[next_] = 1
    counta += 1
    if check[T] == 1:
        break

print(counta//3)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 20:53:20 2019

@author: Yamazaki Kenichi
"""
from collections import deque
import sys

N, M = map(int,input().split())
uv = [list(map(int,input().split())) for i in range(N)]
S, T = map(int,input().split())

Ta = [[] for i in range(N+1)]
for c in uv:
    Ta[c[0]].append(c[1])

counta = 0
rout = [[] for i in range(N+1)]
while len(rout[S]) < 3:
    next_ = deque([S])
    for i in range(3):
        for j in range(len(next_)):
            tmp = next_.popleft()
            for k in Ta[tmp]:
                next_.append(k)
            rout[tmp].append(i)
        
        if rout[T].count(2) >= 1:
            print(counta)
            sys.exit()
        counta += 1
print(-1)
Problem p03032 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:56:05 2019

@author: Yamazaki Kenichi
"""
import heapq

N,K = map(int,input().split())
V = list(map(int,input().split()))

def a(K):
    if K > N:
        return N
    else:
        return K

ans = 0
for i in range(K):
    for j in range(a(K-i)+1):
        tmp = 0
        minus = [0]
        for k in range(a(K-i)):
            tmp += V[k-j]
            heapq.heappush(minus,V[k-j])
#            print(tmp,minus)
        for k2 in range(i):
            if minus[0] < 0:
                tmp += (-heapq.heappop(minus))
            else:
                break
#        print(ans,tmp,i,j,k)
        ans = max(ans,tmp)
    
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon May 27 22:13:19 2019

@author: Yamazaki Kenichi
"""

N, M = map(int,input().split())
ks = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))

S = [0 for i in range(M)]
for i in range(M):
    for j in range(1,ks[i][0]+1):
        S[i] += 2**(ks[i][j]-1)

ans = 0
for bit in range(1<<N):
    now = [0 for i in range(M)]
    for i in range(N):
        if bit & 1<<i:
            for j in range(M):
                now[j] += S[j]//(1<<i)
    flg = True
    for j in range(M):
        if now[j]%2 != p[j]:
            flg = False
    ans += flg
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 20:56:05 2019

@author: Yamazaki Kenichi
"""
import heapq

N,K = map(int,input().split())
V = list(map(int,input().split()))

ans = 0
for i in range(K):
    for j in range(K-i+1):
        tmp = 0
        minus = [0]
        for k in range(K-i):
            tmp += V[k-j]
            heapq.heappush(minus,V[k-j])
#            print(tmp,minus)
        tmp += (-sum(minus[:i]))
#        print(ans,tmp,i,j,k)
        ans = max(ans,tmp)
    
print(ans)
Problem p03081 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 30 21:21:19 2019

@author: Yamazaki Kenichi
"""

N,Q = map(int,input().split())
s = input()
A = [list(input().split()) for i in range(Q)]

def a(b,i):
    if i == -1 or i == N:
        return i        
    if b[0] == s[i]:
        return i - 1 if b[1] == 'L' else i + 1
    else:
        return i
def ar(i):
    for j in range(Q):
        if i == N:
            return False
        i = a(A[j],i)
    return False if i == N else True
def al(i):
    for j in range(Q):
        if i == -1:
            return False
        i = a(A[j],i)
    return False if i == -1 else True
def bir(i,j):
    if i + 1 == j:
        return i
    if ar((i+j)//2):
        return bir((i+j)//2,j)
    else:
        return bir(i,(i+j)//2)
def bil(i,j):
    if i + 1 == j:
        return i
    if al((i+j)//2):
        return bil(i,(i+j)//2)
    else:
        return bil((i+j)//2,j)
ans = bir(0,N) - bil(0,N)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 30 21:21:19 2019

@author: Yamazaki Kenichi
"""

N,Q = map(int,input().split())
s = input()
A = [list(input().split()) for i in range(Q)]

def a(b,i):
    if b[0] == s[i]:
        return i - 1 if b[1] == 'L' else i + 1
    else:
        return i
def ar(i):
    for j in range(Q):
        if i == N:
            return False
        i = a(A[j],i)
    return False if i == N else True
def al(i):
    for j in range(Q):
        if i == -1:
            return False
        i = a(A[j],i)
    return False if i == -1 else True
def bir(i,j):
    if i + 1 == j:
        return i
    if ar((i+j)//2):
        return bir((i+j)//2,j)
    else:
        return bir(i,(i+j)//2)
def bil(i,j):
    if i + 1 == j:
        return i
    if al((i+j)//2):
        return bil(i,(i+j)//2)
    else:
        return bil((i+j)//2,j)
ans = bir(0,N) - bil(0,N)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 30 21:21:19 2019

@author: Yamazaki Kenichi
"""

N,Q = map(int,input().split())
s = input()
A = [list(input().split()) for i in range(Q)]

def a(b,i):
    if b[0] == s[i]:
        return i - 1 if b[1] == 'L' else i + 1
    else:
        return i
def ar(i):
    for j in range(Q):
        i = a(A[j],i)
        if i == Q:
            return False
    return True
def al(i):
    for j in range(Q):
        i = a(A[j],i)
        if i == -1:
            return False
    return True

def bir(i,j):
    if i + 1 == j:
        return i
    if ar((i+j)//2):
        return bir((i+j)//2,j)
    else:
        return bir(i,(i+j)//2)
def bil(i,j):
    if i + 1 == j:
        return i
    if al((i+j)//2):
        return bil(i,(i+j)//2)
    else:
        return bil((i+j)//2,j)
ans = bir(0,N) - bil(0,N)
print(ans)
Problem p03096 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 16 20:36:58 2019

@author: Yamazaki Kenichi
"""

N = int(input())
C = [int(input()) for i in range(N)]
mod = 10**9+7
T = [[0] for i in range(2*10**5+1)]
ans = [1 for i in range(N+1)]
for i in range(N): 
    if i == 0 or C[i] != C[i-1]:
        T[C[i]][0] += 1
        T[C[i]].append(i)
        if T[C[i]][0] >=2:
            ans[i] = (ans[i-1] + ans[T[C[i]][-2]])%mod
        else:
            ans[i] = ans[i-1]%mod
    else:
        ans[i] = ans[i-1]%mod
        
print(ans[N-1]%mod)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 16 20:36:58 2019

@author: Yamazaki Kenichi
"""

N = int(input())
C = [int(input()) for i in range(N)]
mod = 10**9+7
T = [[0] for i in range(N+1)]
ans = [1 for i in range(N+1)]
for i in range(N): 
    if i == 0 or C[i] != C[i-1]:
        T[C[i]][0] += 1
        T[C[i]].append(i)
        if T[C[i]][0] >=2:
            ans[i] = (ans[i-1] + ans[T[C[i]][-2]])%mod
        else:
            ans[i] = ans[i-1]%mod
    else:
        ans[i] = ans[i-1]%mod
        
print(ans[N-1]%mod)
Problem p03106 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:44 2019

@author: Yamazaki Kenichi
"""

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

counta = 0
ans = []
for i in range(1,101):
    if A%i == 0 and B%i == 0:
        ans.append(i)
print(ans[-K])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:44 2019

@author: Yamazaki Kenichi
"""

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

counta = 0
for i in range(1,K):
    if len(str(A/i)) < 10**10 and len(str(B%i)) < 10**10:
        counta += 1
    if counta == K:
        ans = i
        break
print(ans)