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

Fixed submission:
MOD = 998244353
MAX = 510000
fac = [1,1] # factorial
finv = [1,1] # inverse of factorial
inv = [None, 1] # inverse

def comb_init():
	for i in range(2, MAX):
		fac.append(fac[i-1] * i % MOD)
		inv.append(MOD - inv[MOD % i] * (MOD//i) % MOD)
		finv.append(finv[i-1] * inv[i] % MOD)

def inverse_mod(a):
	""" Calculate inverse of the integer in a modulo MOD """
	return pow(a, MOD-2, MOD)

def comb_mod(n, r):
	""" Calculate nCr modulo MOD. """
	if n < r: return 0
	if n < 0 or r < 0: return 0
	return fac[n]* (finv[r]*finv[n-r] % MOD) % MOD

def solve(n, m, k):
	ans = 0
	for k in range(K+1):
		ans = (ans + m*(comb_mod(n-1,k)*pow(m-1, n-k-1, MOD) % MOD) % MOD) % MOD
	return ans

comb_init()
N, M, K = map(int, input().split())
print(solve(N, M, K))

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
from scipy.special import comb

mod = 998244353

N,M,K = map(int, input().split())

# DP = [[0]*N for _ in range(N)]
# DP[0][0] = M

# DP = []


# for n in range(1,N):
# 	for k in range(N):
# 		if k==0:
# 			DP[n][k] = DP[n-1][k]*(M-1) % mod
# 		else:
# 			DP[n][k] = (DP[n-1][k]*(M-1) + DP[n][k-1]) % mod

# ans = sum(DP[N-1][:(K+1)]) % mod
# print(ans)

ans = 0
for k in range(K+1):
	ans += comb(N-1, k)*(M-1)**(N-k-1) % mod

print(int(ans*M) % mod)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
from scipy.special import comb

mod = 998244353

N,M,K = map(int, input().split())

# DP = [[0]*N for _ in range(N)]
# DP[0][0] = M

# DP = []


# for n in range(1,N):
# 	for k in range(N):
# 		if k==0:
# 			DP[n][k] = DP[n-1][k]*(M-1) % mod
# 		else:
# 			DP[n][k] = (DP[n-1][k]*(M-1) + DP[n][k-1]) % mod

# ans = sum(DP[N-1][:(K+1)]) % mod
# print(ans)

ans = 0
for k in range(K+1):
	ans += comb(N, k)*(M-1)**(N-k-1) % mod

print(int(ans*M) % mod)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
from scipy.special import comb

mod = 998244353

N,M,K = map(int, input().split())

# DP = [[0]*N for _ in range(N)]
# DP[0][0] = M

# DP = []


# for n in range(1,N):
# 	for k in range(N):
# 		if k==0:
# 			DP[n][k] = DP[n-1][k]*(M-1) % mod
# 		else:
# 			DP[n][k] = (DP[n-1][k]*(M-1) + DP[n][k-1]) % mod

# ans = sum(DP[N-1][:(K+1)]) % mod
# print(ans)

ans = 0
for k in range(1,K+1):
	ans += comb(N, k-1)*(M-1)**(N-k) % mod

print(int(ans*M) % mod)
Problem p03221 (python)

Fixed submission:
import numpy as np
N, M = map(int, input().split())
cities = {}
P = {}
Y = {}
for i in range(M):
    p,y = map(int, input().split())
    cities[i] = p
    Y[i] = y

ans = {}
sorted_Y = sorted(Y.items(), key=lambda x:x[1])
P_i = np.zeros(N)
for i,y in sorted_Y:
    p = cities[i]
    P_i[p-1] += 1
    ans[i] = (p, int(P_i[p-1]))

for i in range(M):
    print('{0:06}{1:06}'.format(ans[i][0], ans[i][1]))

Buggy submission (verdict: Runtime Error):
"""
import numpy as np
N, M = map(int, input().split())
cities = {}
Y = {}
for i in range(M):
    p,y = map(int, input().split())
    cities[i] = p
    Y[i] = y

ans = {}
sorted_Y = sorted(Y.items(), key=lambda x:x[1])
P_i = np.zeros(N)
for i,y in sorted_Y:
    p = cities[i]
    P_i[p-1] += 1
    ans[i] = (p, int(P_i[p-1]))

for i in range(M):
    print('{0:06}{1:06}'.format(ans[i][0], ans[i][1]))
"""

n, m = map(int,input().split())
pys = []
for i in range(m):
    x = map(int, input().split())
    x = [x[0],x[1],i]
    pys.append(x)

pys.sort()
pp = -1
lid = 0
ans = []
for i in range(m):
    if pp == pys[i][0]:
        lid += 1
    else:
        lid = 1
        pp = pys[i][0]
    ans.append(pp*10**6+lid)

for v in ans:
    print(':012d'.format(v))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
cities = {}
P = {}
Y = {}
for i in range(M):
    p,y = map(int, input().split())
    cities[i] = p
    Y[i] = y

ans = []
sorted_Y = sorted(Y.items(), key=lambda x:x[1])
P_i = np.zeros(N)
for i,y in sorted_Y:
    p = cities[i]
    P_i[p] += 1
    ans.append(p,P_i[p])

for p,x in ans:
    print('{0:06}{1:06}'.format(p, x))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
cities = {}
P = {}
Y = []
for i in range(M):
    p,y = map(int, input().split())
    cities[i] = (p,y)
    Y.append(y)

sorted_Y = sorted(Y)
sorted_P = {p:sorted(P[p].items(), key=lambda x:x[1]) for p in P}

P_i = np.zeros(N)
ans = {}
for i in sorted_Y:
    city = Y.index(i)+1
    ans[city] = i

for i in ans:
    p,y = cities[i]
    print('{0:06}{1:06}'.format(p, i))
Problem p03252 (python)

Fixed submission:
S=input()
T=input()

Rs = {}
Rt = {}
for i in range(len(S)):
    if S[i] in Rs.keys():
        if Rs[S[i]] != T[i]:
             print("No")
             exit()
    else:
        Rs[S[i]] = T[i]

    if T[i] in Rt.keys():
        if Rt[T[i]] != S[i]:
            print("No")
            exit()
    else:
        Rt[T[i]] = S[i]
print("Yes")

Buggy submission (verdict: Runtime Error):
S=input()
T=input()

Rs = {}
Rt = {}
for i in range(len(S)):
    if S[i] in Rs.keys:
        if Rs[S[i]] != T[i]:
             print("No")
             exit()
    else:
        Rs[S[i]] = T[i]

    if T[i] in Rt.keys:
        if Rt[T[i]] != S[i]:
            print("No")
            exit()
    else:
        Rt[T[i]] = S[i]
print("Yes")
Problem p03253 (python)

Fixed submission:
from math import sqrt

def cal_factors(num):
    factors = {}
    i = 0
    while True:
        d, q = divmod(num, 2)
        if q == 0:
            num = d
            i += 1
            factors[2] = i
        else:
            break

    maxmod = int(sqrt(num)) + 1
    for mod in range(3, maxmod, 2):
        i = 0
        while True:
            d, q = divmod(num, mod)
            if q == 0:
                num = d
                i += 1
                factors[mod] = i
            else:
                break

    if num > 1:
        factors[num] = 1

    return factors


def comb(n, r, mod):
    result = 1
    r = min(r, n-r)
    for i in range(n, n-r, -1):
        result *= i
    for i in range(2, r+1):
        result //= i
    result %= mod

    return result


n, m = [int(v) for v in input().split()]

mod = 1000000000 + 7
factors = cal_factors(m)
ans = 1
for v in factors.values():
    ans *= comb(v + n - 1, v, mod)
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
from math import sqrt
from scipy.special import comb

def cal_factors(num):
    factors = {}
    maxmod = int(sqrt(num)) + 1
    for mod in range(2, maxmod):
        i = 0
        while True:
            d, q = divmod(num, mod)
            if q == 0:
                num = d
                i += 1
                factors[mod] = i
            else:
                break

    if num > 1:
        factors[num] = 1

    return factors


n, m = [int(v) for v in input().split()]

mod = 1000000000 + 7
factors = cal_factors(m)
ans = 1
for v in factors.values():
    ans *= comb(v + n - 1, v, exact=True) % mod
    ans %= mod

print(ans)
Problem p02627 (python)

Fixed submission:
s=input()
print("A"if s==s.upper()else"a")

Buggy submission (verdict: Runtime Error):
n=int(input())
c=""
while n:
    n-=1
    c=chr(n%26+97)+c
    n//=26
print(c)
Problem p02685 (python)

Fixed submission:
n,m,k=map(int,input().split())
g=998244353
r=1
p=pow(m-1,n-1,g)
for i in range(1,k+1):
    r=(r*(n-i)*pow(i,g-2,g))%g
    p=(p+r*pow(m-1,n-1-i,g))%g
print((m*p)%g)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
g=998244353
r=pow(m-1,n-1,g)
p=r
for i in range(1,k+1):
    r=(r*(n-i)*pow((m-1)*i,-1,g))%g
    p=(p+r)%g
print((m*p)%g)
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b=map(int,input().split())
print("OK" if (a-1)//k!=b//k else"NG")

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left as bl
n=int(input())
a=list(map(int,input().split()))
t=[[]for i in range(n)]
for i in range(n-1):
    u,v=map(int,input().split())
    t[u-1].append(v-1)
    t[v-1].append(u-1)
b=[1]+[0]*(n-1)
q=[[0,[a[0]],1]]
while q:
    c,d,e=q.pop(0)
    for i in t[c]:
        s=d[::]
        g=e
        if b[i]==0:
            h=bl(d,a[i])
            if e>h:
                s[h]=a[i]
            else:
                s.append(a[i])
                g+=1
            b[i]=g
            q.append([i,s,g])
for i in range(n):
    print(b[i])
Problem p02757 (python)

Fixed submission:
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            a+=i+1
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    d=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]+int(s[i])*d)%p
        a+=t[g[i]]
        t[g[i]]+=1
        d*=10
        d%=p
    print(a)

Buggy submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            ans+=n
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    d=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]+int(s[i])*d)%p
        a+=t[g[i]]
        t[g[i]]+=1
        d*=10
        d%=p
    print(a)

Buggy submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            ans+=n
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]*10+int(s[n-i-1]))%p
        a+=t[g[i]]
        t[g[i]]+=1
    print(a)
Problem p02759 (python)

Fixed submission:
n=int(input())
print((n+1)//2)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
w=[i for i in range(n+1)]
s=[1]*(n+1)
g=[list(map(int,input().split()))for i in range(n)]
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=1
        else:
            w[y]=x
            s[x]+=1
for i in range(m):
    a,b=g[i][0],g[i][1]
    unite(a,b)
for i in range(1,n+1):
    w[i]=root(i)
    s[i]=s[w[i]]
for i in range(m):
    s[g[i][0]]-=1
    s[g[i][1]]-=1
for i in range(k):
    a,b=map(int,input().split())
    if w[a]==w[b]:
        s[a]-=1
        s[b]-=1
for i in range(1,n+1):s[i]-=1
print(*s[1:])
Problem p02762 (python)

Fixed submission:
n,m,k=map(int,input().split())
w=[i for i in range(n+1)]
s=[1]*(n+1)
g=[list(map(int,input().split()))for i in range(m)]
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=s[x]
        else:
            w[y]=x
            s[x]+=s[y]
for i in range(m):
    a,b=g[i][0],g[i][1]
    unite(a,b)
for i in range(1,n+1):
    w[i]=root(i)
    s[i]=s[w[i]]
for i in range(m):
    s[g[i][0]]-=1
    s[g[i][1]]-=1
for i in range(k):
    a,b=map(int,input().split())
    if w[a]==w[b]:
        s[a]-=1
        s[b]-=1
for i in range(1,n+1):s[i]-=1
print(*s[1:])

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
w=[i for i in range(n+1)]
s=[1]*(n+1)
g=[list(map(int,input().split()))for i in range(n)]
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=1
        else:
            w[y]=x
            s[x]+=1
for i in range(m):
    a,b=g[i][0],g[i][1]
    unite(a,b)
for i in range(1,n+1):
    w[i]=root(i)
    s[i]=s[w[i]]
for i in range(m):
    s[g[i][0]]-=1
    s[g[i][1]]-=1
for i in range(k):
    a,b=map(int,input().split())
    if w[a]==w[b]:
        s[a]-=1
        s[b]-=1
for i in range(1,n+1):s[i]-=1
print(*s[1:])
Problem p02771 (python)

Fixed submission:
a=list(map(int,input().split()))
print("Yes" if len(set(a))==2 else"No")

Buggy submission (verdict: Runtime Error):
from bisect import bisect_right as br
from bisect import bisect_left as bl
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
l,r=10**18,-10**18-1
while l-r>1:
    t=(l+r)//2
    p=0
    for i in a:
        if i<0:
            p+=n-bl(a,t/i)
        elif i==0:
            if t>=0:
                p+=n
        else:
            p+=br(a,t/i)
        if i**2<=t:
            p-=1
    p//=2
    if p>=k:
        l=t
    else:
        r=t
g=-float("INF")
for i in range(n):
    if a[i]<0:
        c=bl(a,l/a[i])
        if c==i:
            c+=1
        if c<n:
            g=max(g,a[c]*a[i])
    elif a[i]==0:
        g=max(g,0)
    else:
        c=br(a,l/a[i])-1
        if c==i:
            c-=1
        if c>0:
            g=max(g,a[c]*a[i])
print(g)
Problem p02862 (python)

Fixed submission:
x,y=map(int,input().split())
m=10**9+7
if (2*x-y)%3==0 and (2*y-x)%3==0 and 2*x>=y and 2*y>=x:
    a,b=(2*x-y)//3,(2*y-x)//3
    c=min(a,b)
    p=1
    for i in range(c):
        p=(p*(a+b-i)*pow(i+1,m-2,m))%m
    print(p)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
m=10**9+7
if (2*x-y)%3==0 and (2*y-x)%3==0 and 2*x=>y and 2*y=>x:
    a,b=(2*x-y)//3,(2*y-x)//3
    c=min(a,b)
    p=1
    for i in range(c):
        p=(p*(a+b-i)*pow(i+1,m-2,m))%m
    print(p)
else:
    print(0)
Problem p02863 (python)

Fixed submission:
import numpy as np
n,t=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
b=np.zeros((n+1,t))
c=np.zeros((n+1,t))
for i in range(n):
    b[i+1]=b[i]
    b[i+1][a[i][0]:]=np.maximum(b[i+1][a[i][0]:],b[i][:-a[i][0]]+a[i][1])
    c[-i-2]=c[-i-1]
    c[-i-2][a[-i-1][0]:]=np.maximum(c[-i-2][a[-i-1][0]:],c[-i-1][:-a[-i-1][0]]+a[-i-1][1])
q=0
for i in range(n):
    q=max(q,max(b[i]+c[i+1][::-1])+a[i][1])
print(int(q))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,t=map(int,input().split())
s=[list(map(int,input().split()))for i in range(n)]
a,b=np.zeros((n+1,t+1)),np.zeros((n+1,t+1))
for i in range(n):
    a[i+1]=a[i]
    a[i+1][s[i][0]:]=np.maximum(a[i+1][s[i][0]:],a[i][:t+1-s[i][0]]+s[i][1])
    b[n-i-1]=b[n-i]
    b[n-i-1][s[n-i-1][0]:]=np.maximum(b[n-i-1][s[n-i-1][0]:],b[n-i][:t-s[n-i-1][0]+1]+s[n-i-1][1])
p=0
print(a,b)
for i in range(n):
    for j in range(t):
        p=max(p,a[i][j]+b[i+1][t-1-j]+s[i][1])
print(int(p))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,t=map(int,input().split())
s=[list(map(int,input().split()))for i in range(n)]
a,b=np.zeros((n+1,t+1)),np.zeros((n+1,t+1))
for i in range(n):
    a[i+1]=a[i]
    a[i+1][s[i][1]:]=np.maximum(a[i+1][s[i][1]:],a[i][:t+1-s[i][1]]+s[i][0])
    b[n-i-1]=b[n-i]
    b[n-i-1][s[n-i-1][1]:]=np.maximum(b[n-i-1][s[n-i-1][1]:],b[n-i][:t-s[n-i-1][1]+1]+s[n-i-1][0])
p=0
for i in range(n):
    for j in range(t+1):
        p=max(p,a[i][j]+b[i+1][t-j]+s[i][0])
print(int(p))
Problem p02880 (python)

Fixed submission:
n=int(input())
for i in range(1,10):
    if 1<=n//i<10 and (n//i)*i==n:
        print("Yes")
        break
else:
    print("No")

Buggy submission (verdict: Runtime Error):
print("YNeos"[1-int(bin(2375063778094260874239)[-int(input())])::2])
Problem p03011 (python)

Fixed submission:
a=list(map(int,input().split()));print(sum(a)-max(a))

Buggy submission (verdict: Runtime Error):
mod=10**9+7
def f(a,r):
    s=[[0,0],[0,0]]
    s[0][0]=(a[0][0]*r[0][0]+a[0][1]*r[1][0])%mod
    s[0][1]=(a[0][0]*r[0][1]+a[0][1]*r[1][1])%mod
    s[1][0]=(a[1][0]*r[0][0]+a[1][1]*r[1][0])%mod
    s[1][1]=(a[1][0]*r[0][1]+a[1][1]*r[1][1])%mod
    return s
b=[[1,1],[1,0]]
k=[b]
for i in range(20):
    k.append(f(k[-1],k[-1]))
n,m=map(int,input().split())
t=0
ans=1
for i in range(m):
    a=int(input())
    if t==a:
        print(0)
        break
    else:
        s=bin(a-1-t)[2:]
        s="0"*(21-len(s))+s
        s=s[::-1]
        p=[[1,0],[0,1]]
        for j in range(21):
            if s[j]=="1":
                p=f(p,k[j])
        ans=(ans*p[0][0])%mod
        t=a+1
        if i==m-1:
            s=bin(n-t)[2:]
            s="0"*(21-len(s))+s
            s=s[::-1]
            p=[[1,0],[0,1]]
            for j in range(21):
                if s[j]=="1":
                    p=f(p,k[j])
            ans=(ans*p[0][0])%mod
else:
    print(ans)
Problem p03038 (python)

Fixed submission:
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
k=sorted([list(map(int,input().split()))for i in range(m)],key=lambda x:-x[1])+[[0,0]]
c,d=0,0
t=0
ans=0
while c<n:
    if a[d]>=k[t][1]:
        ans+=a[d]
        d+=1
        c+=1
    else:
        ans+=k[t][1]*min(n-c,k[t][0])
        c+=k[t][0]
        t+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left as bl
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    t=bl(a,c)
    print(a)
    if t<=b:
        a=[c]*t+a[t:]
    else:
        a=a[b:t]+[c]*b+a[t:]
print(sum(a))
Problem p03053 (python)

Fixed submission:
import numpy as np
from scipy.ndimage import distance_transform_cdt as d
h,w=map(int,input().split())
s=[[1 if i=="." else 0 for i in input()]for i in range(h)]
a=d(s,metric='taxicab')
print(a.max())

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=[list(input())for i in range(h)]
a=[[float("inf")]*w for i in range(h)]
b=[[False]*w for i in range(h)]
def f(x,y,t):
    if 0<=x<h and 0<=y<w:
        if s[x][y]=="#":
            if b[x][y]==False:
                a[x][y]=0
                b[x][y]=True
                f(x,y+1,1)
                f(x+1,y,1)
                f(x-1,y,1)
                f(x,y-1,1)
        else:
            if a[x][y]>t:
                a[x][y]=t
                f(x,y+1,t+1)
                f(x+1,y,t+1)
                f(x-1,y,t+1)
                f(x,y-1,t+1)
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            f(i,j,0)
            break
print(max(max(i)for i in a))
Problem p03104 (python)

Fixed submission:
a,b=map(int,input().split())
s=[2**i for i in range(42)]
d=[0]*42
i=1
if ((b+1)//2-a//2)%2==1:
    d[0]+=1
while i<42:
    if s[i]>b:
        break
    elif s[i]>a: 
        a=s[i]
    p,q=a%s[i],a//s[i]
    o,t=b%s[i],b//s[i]
    if q==t:
        if q%2==1:
            if (b-a+1)%2==1:
                d[i]=1
    else:
        h=0
        if q%2==1:
            h+=(q+1)*s[i]-a  
        if t%2==1:
            h+=b-t*s[i]+1
        if h%2==1:
            d[i]=1
    i+=1
ans=0
for i in range(42):
    ans+=d[i]*s[i]
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=[2**i for i in range(38)]
d=[0]*38
i=1
if ((b+1)//2-a//2)%2==1:
    d[0]+=1
while i<39:
    if s[i]>b:
        break
    elif s[i]>a: 
        a=s[i]
    p,q=a%s[i],a//s[i]
    o,t=b%s[i],b//s[i]
    if q==t:
        if q%2==1:
            if (b-a+1)%2==1:
                d[i]=1
    else:
        h=0
        if q%2==1:
            h+=(q+1)*s[i]-a  
        if t%2==1:
            h+=b-t*s[i]+1
        if h%2==1:
            d[i]=1
    i+=1
ans=0
for i in range(38):
    ans+=d[i]*s[i]
print(ans)
Problem p03135 (python)

Fixed submission:
t,x=map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
t,x=map(int,inpyt().split())
print(t/x)
Problem p03464 (python)

Fixed submission:
k=int(input())
a=list(map(int,input().split()))
s=2+k*max(a)
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>=2:
        l=p
    else:
        r=p
e=l
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>2:
        l=p
    else:
        r=p
print(str(max(e,2))+" "+str(r)if r>e or r<2 else -1)

Buggy submission (verdict: Runtime Error):
k=int(input())
a=list(map(int,input().split()))
l,r=1,10**18
def f(x,a):
    for i in a:
        x=max(0,x-x%i)
    return x
while r-l>1:
    t=(l+r)//2
    if f(t,a)>2:
        r=t
    else:
        l=t
p,q=1,10**18
while q-p>1:
    t=(p+q)//2
    if f(t,a)<=1:
        p=t
    else:
        q=t
print(*(q,l) if q<=l else -1)

Buggy submission (verdict: Runtime Error):
k=int(input())
a=list(map(int,input().split()))
l,r=1,10**18
def f(x,a):
    for i in a:
        x=x-x%i
    return x
while r-l>1:
    t=(l+r)//2
    if f(t,a)>2:
        r=t
    else:
        l=t
p,q=1,10**18
while q-p>1:
    t=(p+q)//2
    if f(t,a)<=1:
        p=t
    else:
        q=t
print(*(q,l) if q<=l else -1)

Buggy submission (verdict: Runtime Error):
k=int(input())
a=list(map(int,input().split()))
l,r=1,10**18
def f(x,a):
    for i in a:
        x=x-x%i
    return x
while r-l>1:
    t=(l+r)//2
    if f(t,a)>2:
        r=t
    else:
        l=t
p,q=1,10**18
while q-p>1:
    t=(p+q)//2
    if f(t,a)<=1:
        p=t
    else:
        q=t
print(*(q,l) if q<=l else -1)
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
n=int(input())
s=[[]for i in range(n+1)]
g=[0]*(n+1)
h=[True]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    s[a].append([b,c])
    s[b].append([a,c])
def dfs(x):
    h[x]=False
    for i in s[x]:
        if h[i[0]]:
            g[i[0]]=g[x]+i[1]
            dfs(i[0])
q,k=map(int,input().split())
dfs(k)
for i in range(q):
    x,y=map(int,input().split())
    print(g[x]+g[y])

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[[]for i in range(n+1)]
g=[0]*(n+1)
h=[True]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    s[a].append([b,c])
    s[b].append([a,c])
def dfs(x):
    h[x]=False
    for i in s[x]:
        if h[i[0]]:
            g[i[0]]=g[x]+i[1]
            dfs(i[0])
q,k=map(int,input().split())
dfs(k)
for i in range(q):
    x,y=map(int,input().split())
    print(g[x]+g[y])
Problem p03723 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a==b and b==c and a%2!=1:
    print(-1)
else:
    s=a+b+c
    d=0
    j=0
    while a%2!=1 and b%2!=1 and c%2!=1:
        d+=1
        h=s
        j=a
        a=(s-a)//2
        b=j//2+c//2
        c=h-a-b
    print(d)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a%4!=0 and b%4!=0 and c%4!=0 or(a==b and b==c):
    print(-1)
else:
    s=a+b+c
    d=0
    j=0
    while a%2!=1 and b%2!=1 and c%2!=1:
        d+=1
        h=s
        j=a
        a=(s-a)//2
        b=j//2+c//2
        c=h-a-b
print(d)
Problem p04021 (python)

Fixed submission:
from collections import defaultdict as d
a=[int(input()) for i in range(int(input()))]
b=sorted(a)
c=d(int)
e=0
for i in b[::2]:
    c[i]=1
for i in a[1::2]:
    e+=c[i]
print(e)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict as d
a=[int(input()) for i in range(int(input()))]
b=sorted(a)
c=d(int)
e=0
for i in range(0,n,2):
    d[b[i]]=1
for i in a[1::2]:
    e+=d[i]
print(e)
Problem p02627 (python)

Fixed submission:
alpha = input()
if alpha.isupper():
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
alpha = input()
a = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]

if alpha in a:
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
alpha = int(input())
a = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]

if alpha in a:
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
alpha = int(input())
a = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]

if alpha in a:
  print('A')
else:
  prnt('a')
Problem p02711 (python)

Fixed submission:
n = list(input())
n = list(map(int, n))
if 7 in n:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(list(input()))
if 7 in n:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = list(int, input().split())
if 7 in n:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n1, n2, n3 = map(int, input().split())
n = [n1, n2, n3]
if 7 in n:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
for i in range(3):
  if n[i] == 7:
    print('Yes')
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
for i in range(3)
if n[i] == 7:
  print('Yes')
else:
  print('No')