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

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n #各要素の親要素の番号を格納するリスト

    def find(self, x): #要素xが属するグループの根を返す
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y): #要素xが属するグループと要素yが属するグループとを併合する
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return

        if self.parents[x]>self.parents[y]:
            x,y=y,x

        self.parents[x]+=self.parents[y]
        self.parents[y]=x

    def size(self,x): #要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self,x,y): #要素x, yが同じグループに属するかどうかを返す
        return self.find(x)==self.find(y)

    def members(self,x): #要素xが属するグループに属する要素をリストで返す
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]

    def roots(self): #すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x<0]

    def group_count(self): #グループの数を返す
        return len(self.roots())

    def all_group_members(self): #{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

#print(list(uf.all_group_members().values())) #グループ一覧を表示

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

uf=UnionFind(n)
cnt=[0]*n

for _ in range(m):
    x,y=map(int,input().split())
    uf.union(x-1,y-1)
    cnt[x-1]+=1
    cnt[y-1]+=1
for _ in range(k):
    x,y=map(int,input().split())
    if uf.same(x-1,y-1):
        cnt[x-1]+=1
        cnt[y-1]+=1
    
for i in range(n):
    print(uf.size(i)-cnt[i]-1,end=" ")

Buggy submission (verdict: Runtime Error):
#解答改良
n,m,k=map(int,input().split())

f=[[]for i in range(n)]
b=[[]for i in range(n)]
option=[]

for i in range(m):
    x,y=map(int,input().split())
    if i==0:
        option.append(x-1)
    f[x-1].append(y-1)
    f[y-1].append(x-1)
for i in range(k):
    x,y=map(int,input().split())
    b[x-1].append(y-1)
    b[y-1].append(x-1)

completed=[False for i in range(n)]
groups=[0]*n

x=0
while option:
    now=option.pop()
    groups[now]=x
    completed[now]=True
    for friend in f[now]:
        if completed[friend]==False and friend not in option:
            option.append(friend)
    if len(option)==0:
        x+=1
        for i in range(n):
            if completed[i]==False:
                option.append(i)
                break

size=[0]*(x)
for i in range(x):
    size[i]=groups.count(i)

for i in range(n):
    cnt=0
    for friend in f[i]:
        if groups[i]==groups[friend]:
            cnt+=1
    for block in b[i]:
        if groups[i]==groups[block]:
            cnt+=1
    print(size[groups[i]]-cnt-1,end=" ")
Problem p02771 (python)

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

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
import test
test.solve(a)
Problem p02836 (python)

Fixed submission:
a=input()
n=len(a)
if len(a)%2==0:
    a1=a[:n//2]
    a2=a[n//2:]
    a2=a2[::-1]
else:
    a1=a[:n//2]
    a2=a[n//2+1:]
    a2=a2[::-1]
cnt=0
for i in range(len(a1)):
    if a1[i]!=a2[i]:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
a=input()
n=len(a)
if n%2==0:
    a1=a[:n//2]
    a2=a[n//2:]
else:
    a1=a[:n//2]
    a2=a[(n//2)+1:]
cnt=0
for x,i in enumerate(a1):
    if i!=a2[-x+1]:
        cnt+=1
print(cnt)
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[None]*(n+1)
dp[0]=1
dp[1]=1
if 1 in a:
    dp[1]=0
for i in a:
    dp[i]=0
for i in range(2,n+1):
    if dp[i]!=0 :
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if a[0]==1:
    dp[1]=0
else:
    dp[1]=1

a=set(a)
for i in range(2,n+1):
    if i in a:
        dp[i]=0
    else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[0]*n
if 1 not in a and 2 not in a:
    dp[0]=1
    dp[1]=2
elif 1 not in a and 2 in a:
    dp[0]=1
    dp[1]=0
elif 1 in a and 2 not in a:
    dp[0]=0
    dp[1]=1
else:
    print(0)
    exit()
for i in range(2,n):
    if i+1 in a:
        continue
    dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%((10**9)+7))
Problem p03038 (python)

Fixed submission:
def main():
    import sys
    input=sys.stdin.readline
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    a=sorted(a)
    k=[[int(i) for i in input().split()] for i in range(m)]
    k=sorted(k,key=lambda x:-x[1])
    
    now=0
    flag=True
    for x,y in k:
        if flag:
            for i in range(x):
                if i+now>=n:
                    print(sum(a))
                    exit()
                if flag:
                    if y>a[i+now]:
                        a[i+now]=y
                    else:
                        flag=False
        now+=x
    print(sum(a))
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
k=[[int(i) for i in input().split()] for i in range(m)]
k=sorted(k,key=lambda x:-x[1])

now=0
flag=True
for x,y in k:
    if flag:
        for i in range(x):
            if flag:
                if y>a[i+now]:
                    a[i+now]=y
                else:
                    flag=False
    now+=x
print(sum(a))
Problem p03073 (python)

Fixed submission:
n=input()
cnt=0
for i in range(len(n)):
    if n[0]=="0":
        if i%2==0 and n[i]=="1" :
            cnt+=1
        if i%2==1 and n[i]=="0" :
            cnt+=1
    else:
        if i%2==0 and n[i]=="0" :
            cnt+=1
        if i%2==1 and n[i]=="1" :
            cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
cnt=0
for i in range(len(n)):
    if n[0]==0:
        if i%2==0 and n[i]!=0 :
            cnt+=1
        if i&2==1 and n[i]!=1 :
            cnt+=1
    else:
        if i%2==0 and n[i]!=1 :
            cnt+=1
        if i&2==1 and n[i]!=0 :
            cnt+=1
print(cnt-1)
Problem p03107 (python)

Fixed submission:
n=input()
s=len(n)
if s%2==0:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2:].count("0")
    r1=s//2-r0
    print(min(l0,r1)*2+min(l1,r0)*2)
if s%2==1:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2+1:].count("0")
    r1=s//2-r0
    tmp=min(l0,r1)*2+min(l1,r0)*2
    if n[s//2]=="0":
        if r1-l0>0 or r0-l1>0:
            tmp+=2
    else:
        if l0-r1>0 or l1-r0>0:
            tmp+=2
    print(tmp)

Buggy submission (verdict: Runtime Error):
n=input()
s=len(n)
if s%2==0:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2:].count("0")
    r1=s//2-r0
    print(min(l0,r1)*2+min(l1,r0)*2)
if s%2==1:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2+1:].count("0")
    r1=s//2-r0
    tmp=min(l0,r1)*2+min(l1,r0)*2
    if n[s//2]=="0":
        if ri-l0>0 or r0-l1>0:
            tmp+=2
    else:
        if l0-r1>0 or l1-r0>0:
            tmp+=2
    print(tmp)
Problem p03127 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
import fractions as f
mini=float('inf')
for i in range(n-1):
    x=f.gcd(a[i],a[i+1])
    mini=min(mini,x)
print(mini)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
import math
mini=float('inf')
for i in range(n-1):
    x=math.gcd(a[i],a[i+1])
    mini=min(mini,x)
print(mini)
Problem p03775 (python)

Fixed submission:
n=int(input())
def di(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
li=di(n)
a=li[-1]
if a**2==n:
    print(len(str(a)))
elif n==1:
    print(1)
else:
    b=li[-2]
    print(max(len(str(a)),len(str(b))))

Buggy submission (verdict: Runtime Error):
n=int(input())
def di(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
li=di(n)
a=li[-1]
b=li[-2]
if a**2==n:
    print(len(str(a)))
else:
    print(max(len(str(a)),len(str(b))))

Buggy submission (verdict: Runtime Error):
n=int(input())
def di(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
li=di(n)
a=li[-1]
b=li[-2]
print(max(len(str(a)),len(str(b))))
Problem p03834 (python)

Fixed submission:
a=input().split(",")
for i in a:
    print(i,end=" ")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
cnt=0
for x in range(a+1):
    for y in range(a+1):
        z = b-x-y
        if 0<=z<=a and x+y+z==b:
            cnt+=1
print(cnt)
Problem p02659 (python)

Fixed submission:
import math
A, B = map(str,input().split(" "))
B_ = int(B.split(".")[0])*100 + int(B.split(".")[1])

print(int(A) * B_ // 100)

Buggy submission (verdict: Runtime Error):
import math
A, B = map(float,input().split(" "))
print(math.floor(A * int(B * 100) / 100)

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split(" "))
print(int(A * B))
Problem p03201 (python)

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

print(ans)

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

print(ans)
Problem p03250 (python)

Fixed submission:
A,B,C = map(str,input().split(" "))

AB = max(int(A+B),int(B+A))
AC = max(int(A+C),int(C+A))
BC = max(int(B+C),int(C+B))
A,B,C = map(int,[A,B,C])
print(max([A+BC,B+AC,C+AB]))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split(" "))
fact = {}
for i in range(2,M):
    while (M%i == 0):
        if i in fact:
            fact[i] += 1
        else:
            fact[i] = 1
        M //= i
    if (M == 1):
        break


MOD = 10**9+7

def nCr_mod(n,r,mod): #nCrmod
    r = min(n-r,r)
    v = 1
    for i in range(r):
        v = (v * ((n-i)%mod) * pow((i+1),mod-2,mod)) % mod
    return v

ans = 1
for key,item in fact.items():
    ans *= nCr_mod((item + (N) - 1),N-1,MOD)
    ans %= MOD
print(ans)
Problem p03291 (python)

Fixed submission:
S = input()
l = len(S)
A,B,C,q = [0]*l,[0]*l,[0]*l,[0]*l
inf = 1000000007
for i in range(l):
    if S[i] == 'A':
        A[i] = 1
    elif S[i] == 'B':
        B[i] = 1
    elif S[i] == 'C':
        C[i] = 1
    else:
        q[i] = 1

for i in range(l-1):
    A[i+1] += A[i]
    B[i+1] += B[i]
    C[i+1] += C[i]
    q[i+1] += q[i]

ans = 0
for i in range(1,l-1):
    if S[i] == 'B':
        ans += (A[i-1]) * (C[-1]-C[i]) * pow(3,q[-1],inf)
        ans %= inf
        if q[-1] >= 1:
            ans += (q[i-1]) * (C[-1] - C[i]) * pow(3,q[-1]-1,inf)
            ans %= inf
            ans += (A[i-1]) * (q[-1] - q[i]) * pow(3,q[-1]-1,inf)
            ans %= inf
        if q[-1] >= 2:
            ans += (q[i-1]) * (q[-1] - q[i]) * pow(3,q[-1]-2,inf)
            ans %= inf

    elif S[i] == '?':
        ans += (A[i-1]) * (C[-1]-C[i]) * pow(3,q[-1]-1,inf)
        ans %= inf
        if q[-1] >= 2:
            ans += (q[i-1]) * (C[-1] - C[i]) * pow(3,q[-1]-2,inf)
            ans %= inf
            ans += (A[i-1]) * (q[-1] - q[i]) * pow(3,q[-1]-2,inf)
            ans %= inf
        if q[-1] >= 3:
            ans += (q[i-1]) * (q[-1] - q[i]) * pow(3,q[-1]-3,inf)
            ans %= inf

print(ans%inf)

Buggy submission (verdict: Runtime Error):
S = input()
l = len(S)
A,B,C,q = [0]*l,[0]*l,[0]*l,[0]*l
inf = 1000000007
for i in range(l):
    if S[i] == 'A':
        A[i] = 1
    elif S[i] == 'B':
        B[i] = 1
    elif S[i] == 'C':
        C[i] = 1
    else:
        q[i] = 1
    A[]

for i in range(l-1):
    A[i+1] += A[i]
    B[i+1] += B[i]
    C[i+1] += C[i]
    q[i+1] += q[i]

ans = 0
for i in range(1,l-1):
    if S[i] == 'B':
        ans += (A[i-1]) * (C[-1]-C[i]) * (3**q[-1])%inf
        ans %= inf
        if q[-1] >= 1:
            ans += (q[i-1]) * (C[-1] - C[i]) * (3**(q[-1]-1)%inf)
            ans %= inf
            ans += (A[i-1]) * (q[-1] - q[i]) * (3**(q[-1]-1)%inf)
            ans %= inf
        if q[-1] >= 2:
            ans += (q[i-1]) * (q[-1] - q[i]) * (3**(q[-1]-2)%inf)
            ans %= inf

    elif S[i] == '?':
        ans += (A[i-1]) * (C[-1]-C[i]) * (3**(q[-1]-1)%inf)
        ans %= inf
        if q[-1] >= 2:
            ans += (q[i-1]) * (C[-1] - C[i]) * (3**(q[-1]-2)%inf)
            ans %= inf
            ans += (A[i-1]) * (q[-1] - q[i]) * (3**(q[-1]-2)%inf)
            ans %= inf
        if q[-1] >= 3:
            ans += (q[i-1]) * (q[-1] - q[i]) * (3**(q[-1]-3)%inf)
            ans %= inf

print(ans%inf)
Problem p03332 (python)

Fixed submission:
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

pat = 0
for a in range(N+1):
	if (K - (a * A) < 0):
		break
	if (K - (a * A)) % B == 0 and ((K - (a * A))//B) <= N:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)

Buggy submission (verdict: Runtime Error):
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)

Buggy submission (verdict: Runtime Error):
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)

def gcd(a,b):
	return a if b == 0 else gcd(b,a%b)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

g = gcd(max(A,B),min(A,B))
if K % g != 0:
	print(0)
	exit(0)

A //= g
B //= g
K //= g
pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)

Buggy submission (verdict: Runtime Error):
import math
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

g = math.gcd(A,B)
if K % g != 0:
	print(0)
	exit(0)

A //= g
B //= g
K //= g
pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)

Buggy submission (verdict: Runtime Error):
import math
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod
	ncr[i+1] = v%mod

g = math.gcd(A,B)
if K % g != 0:
	print(0)
	exit(0)

A //= g
B //= g
K //= g
pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)

Buggy submission (verdict: Runtime Error):
import math
N,A,B,K = map(int,input().split(" "))
mod = 998244353
ncr = [1]*(N+1)
v = 1
for i in range(N):
	v = (v * (N-i)//(i+1))
	ncr[i+1] = v%mod																															


g = math.gcd(A,B)
if K % g != 0:
	print(0)
	exit(0)

A //= g
B //= g
K //= g
pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += ncr[a]*ncr[(K - (a * A))//B]
		pat %= mod

print(pat % mod)

Buggy submission (verdict: Runtime Error):
from math import gcd
N,A,B,K = map(int,input().split(" "))
mod = 998244353
def nCr(n,r):
	r = min(n,n-r)
	up,lw = 1,1
	for i in range(r):
		up *= (n-i)
		lw *= (r-i)
	return (up // lw)%mod

g = gcd(A,B)
if K % g != 0:
	print(0)
	exit(0)

A //= g
B //= g
K //= g
pat = 0
for a in range(N):
	if (K - (a * A)) % B == 0:
		pat += nCr(N,a)*nCr(N,(K - (a * A))//B)
		pat %= mod

print(pat % mod)
Problem p03464 (python)

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

if A[-1] != 2:
	print(-1)
	exit(0)

minval = 2
maxval = 3
for i in range(K-1,-1,-1):
	if maxval < A[i] or (minval > A[i] and ((maxval - (maxval % A[i]) < minval))):
		print(-1)
		exit(0)

	if minval > A[i]:
		if minval % A[i] != 0:
			minval = minval + (A[i] - (minval % A[i]))

		maxval = (maxval - (maxval % A[i]) + A[i] - 1)

	else:
		maxval = A[i] + (A[i] - 1)
		minval = A[i]
		

print(str(minval) + " " + str(maxval))

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

if A[-1] != 2:
	print(-1)
	exit(0)

minval = 2
maxval = 3
for i in range(K-1,-1,-1):
	if maxval < A[i] or (minval > A[i] and ((maxval - (maxval % A[i]) < minval)):
		print(-1)
		exit(0)

	if minval > A[i]:
		if minval % A[i] != 0:
			minval = minval + (A[i] - (minval % A[i]))

		maxval = (maxval - (maxval % A[i]) + A[i] - 1)

	else:
		maxval = A[i] + (A[i] - 1)
		minval = A[i]
		

print(str(minval) + " " + str(maxval))
Problem p03775 (python)

Fixed submission:
from math import sqrt
N = int(input())

div = 1
max_v = int(sqrt(N))
for num in range(max_v,1,(-1)):
	if N % num == 0:
		div = num
		break

#print(div)
print(max(len(str(div)),len(str(N//div))))

Buggy submission (verdict: Runtime Error):
from math import sqrt
N = int(input())

max_v = int(sqrt(N))
for num in range(max_v,1,(-1)):
	if N % num == 0:
		div = num
		break

print(max(len(str(div)),len(str(N//max_v))))
Problem p02759 (python)

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

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(M)]

matches = []
for i in range(0, 1000):
    if len(str(i)) == N:
        temp = True
        for s, c in sc:
            if str(i)[s - 1] != str(c):
                temp = False
        if temp: matches.append(i)
print(-1) if len(matches) == 0 else print(min(matches))
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
cards = sorted(list(map(int, input().split())))
op = sorted([tuple(map(int, input().split())) for _ in range(M)], key = lambda x: x[1], reverse=True)

cursor = 0
for b, c in op:
    for i in range(b):
        if  cursor < N and cards[cursor] < c:
            cards[cursor] = c
            cursor += 1
        else:
            break
print(sum(cards))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
cards = sorted(list(map(int, input().split())))
op = sorted([tuple(map(int, input().split())) for _ in range(M)], key = lambda x: x[1], reverse=True)

cursor = 0
for b, c in op:
    for i in range(b):
        if cards[cursor] < c:
            cards[cursor] = c
            cursor += 1
        else:
            break
print(sum(cards))
Problem p03072 (python)

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

ans = 1
if N > 1:
  for i in range(1, N):
    if H[i] >= max(H[:i]):
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
h1 = H[0]
h2 = H[1]

ans = 0
for i in range(1,N):
  if H[i] >= h1 and H[i] >=h2 and H[i] >= H[i-1]:
    ans += 1
    
print(ans+1)
Problem p03073 (python)

Fixed submission:
import itertools
S = input()

p1 = itertools.cycle('01')
p2 = itertools.cycle('10')

ans1=0
ans2=0
for s,P1,P2 in zip(S,p1,p2):
  if s == P1:
    ans1 += 1
  if s == P2:
    ans2 += 1
print(min(ans1,ans2))

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

ans = 0
if N > 1:
  for i in range(1, N):
    if (H[i] >= H[i - 1]:
      ans += 1

print(ans + 1)
Problem p02779 (python)

Fixed submission:
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
N=int(input())
A  = list(map(int,input().split()))

# print(A)
dictA={}

for i in A:
    if i in dictA: 
        print("NO")
        exit(0)
    dictA[i]=1
print("YES")

Buggy submission (verdict: Runtime Error):
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
N=int(input())
A  = list(map(int,input().split()))

# print(A)
dictA={}

for i in A:
    if i in dictA: 
        print("NO")
        exit(0)
    dictA[i]=1
print("YES"
)
[myoden@ubuntu002 C]$ cat testC.py  ;echo 
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
N=int(input())
A  = list(map(int,input().split()))

# print(A)
dictA={}

for i in A:
    if i in dictA: 
        print("NO")
        exit(0)
    dictA[i]=1
print("YES")
Problem p02847 (python)

Fixed submission:
import math
import sys

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)
elif S == "SAT":
    print(1)

Buggy submission (verdict: Runtime Error):
import math
import sys

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


if X < A * 1 + B:
    print(0)
    exit(0)
for i in range(1,10): 
    if X < A * 10**i  + B * (i+1) : 
        print ( (X - B * i)  // A )
        exit(0)

print(10**9)
Problem p03291 (python)

Fixed submission:
inf = 1000000007
 
a = 0
ab = 0
abc = 0
r = 1
 
s = input()
 
for c in s:
    if c == "A":
        a += r
    elif c == "B":
        ab += a
    elif c == "C":
        abc += ab
    else:
        abc = abc * 3 + ab
        ab = ab * 3 + a
        a = a * 3 + r
        r *= 3
        
    a %= inf
    ab %= inf
    abc %= inf
    r %= inf

print(abc)

Buggy submission (verdict: Runtime Error):
inf = 1000000007

a = 0
ab = 0
abc = 0
r = 1
 
s = input()
 
for c in s:
    if c == "A":
        a += r
    elif c == "B":
        ab += a
    elif c == "C":
        abc += ab
    else:
        abc = abc * 3 + ab
        ab = ab * 3 + a
        a = a * 3 + r
        r *= 3
 
	a %= inf
	ab %= inf
    abc %= inf
    r %= inf

print(abc)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long llint;
llint inf = 1000000007;

llint a = 0;
llint b = 0;
llint c = 0;
llint r = 1;

string s;

int main() {
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        switch (s[i]) {
        case 'A':
            a = (a + r) % inf;
            break;
        case 'B':
            b = (b + a) % inf;
            break;
        case 'C':
            c = (c + b) % inf;
            break;
        default:
            c = (c * 3 + b) % inf;
            b = (b * 3 + a) % inf;
            a = (a * 3 + r) % inf;
            r = (r * 3) % inf;
        }
    }
    cout << c << endl;
    return 0;
}

Buggy submission (verdict: Runtime Error):
a = 0
ab = 0
abc = 0
r = 1

s = input()

for c in s:
    if c == "A":
        a += r
    elif c == "B":
        ab += a
    elif c == "C":
        abc += ab
    else:
        abc = abc * 3 + ab
        ab = ab * 3 + a
        a = a * 3 + r
        r *= 3

print(abc % 1_000_000_007)