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

Fixed submission:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from math import gcd
from collections import Counter
from functools import cmp_to_key

def cmp(A1, A2):
    x1, y1 = A1[0]
    x2, y2 = A2[0]
    if (x1, y1) == (x2, y2):
        return 0
    return -1 if x2 * y1 < x1 * y2 else 1

def resolve():
    n = int(input())
    zero = 0
    counter = Counter()
    for _ in range(n):
        x, y = map(int, input().split())
        if x == 0 and y == 0:
            zero += 1
            continue

        g = gcd(x, y)
        x //= g
        y //= g

        if y == 0:
            x, y = 1, 0
        elif y < 0:
            x, y = -x, -y
        counter[x, y] += 1

    C = list(counter.items())
    C.sort(cmp_to_key(cmp))

    k = len(C)
    dp = [0] * (k + 1)
    dp[0] = 1
    for i in range(k):
        x, y = C[i][0]
        dp[i + 1] += dp[i]
        dp[i + 1] += (pow(2, counter[x, y], MOD) - 1) * dp[i] * pow(2, -counter[y, -x] % (MOD - 1), MOD)
        dp[i + 1] %= MOD

    res = dp[k]
    res -= 1
    res += zero
    print(res % MOD)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from cmath import phase
from math import gcd
from collections import Counter
def resolve():
    n = int(input())
    zero = 0
    counter = Counter()
    for _ in range(n):
        x, y = map(int, input().split())
        # eliminate 0 vector
        if x == 0 and y == 0:
            zero += 1
            continue
        # standardize (0 <= arg(z) < pi)
        g = gcd(x, y)
        x //= g
        y //= g
        if y < 0:
            x *= -1
            y *= -1
        elif y == 0:
            x, y = 1, 0
        counter[complex(x, y)] += 1

    k = len(counter)
    C = list(counter.items())
    C.sort(key = lambda tup:phase(tup[0]))
    vector = [tup[0] for tup in C]
    count = [tup[1] for tup in C]

    res = 0
    dp = [0] * (k + 1)
    dp[0] = 1
    for i in range(k):
        z = vector[i]
        vert = z.imag - z.real * 1j
        dp[i + 1] += dp[i]
        dp[i + 1] += (pow(2, count[i], MOD) - 1) * dp[i] * pow(2, -counter[vert] % (MOD - 1), MOD)
        dp[i + 1] %= MOD

    res = dp[k]
    res -= 1
    res += zero
    assert(zero > 0)
    print(res % MOD)
resolve()
Problem p02777 (python)

Fixed submission:
S, T = input().split()
a, b = map(int, input().split())
U = input()

if S==U: a-=1
else: b-=1

print(a, b)

Buggy submission (verdict: Runtime Error):
S, T = input().split()
a, b = map(int, input().spilt())
U = input()

if S==U: a-=1
else: b-=1

print(a, b)
Problem p02862 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

def modfact(n):
    fact=[1]*(n+1)
    invfact=[1]*(n+1)
    for i in range(1,n+1):
        fact[i]=i*fact[i-1]%MOD
    invfact[n]=pow(fact[n],MOD-2,MOD)
    for i in range(n-1,-1,-1):
        invfact[i]=invfact[i+1]*(i+1)%MOD
    return fact,invfact

def resolve():
    x,y=map(int,input().split())
    if((x+y)%3):
        print(0)
        return

    z=(x+y)//3
    if(x-z<0 or y-z<0):
        print(0)
        return
    
    fact,invfact=modfact(z)
    print(fact[z]*invfact[x-z]%MOD*invfact[y-z]%MOD)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

def modfact(n):
    fact=[1]*(n+1)
    invfact=[1]*(n+1)
    for i in range(1,n+1):
        fact[i]=i*fact[i-1]%MOD
    invfact[n]=pow(fact[n],MOD-2,MOD)
    for i in range(n-1,-1,-1):
        invfact[i]=invfact[i+1]*(i+1)%MOD
    return fact,invfact

def resolve():
    x,y=map(int,input().split())
    if((x+y)%3):
        print(0)
        return

    z=(x+y)//3
    fact,invfact=modfact(z)
    print(fact[z]*invfact[x-z]%MOD*invfact[y-z]%MOD)
resolve()
Problem p02884 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(m):
        s,t=map(int,input().split())
        s-=1; t-=1;
        E[s].append(t)
    dp=[0]*n
    for v in range(n-2,-1,-1):
        res=0
        for nv in E[v]: res+=dp[nv]
        dp[v]=1+res/len(E[v])
    ans=dp[0] # 辺を消さなかった時のscore

    # 各 v に対し、削除する辺 v→u は、dp[u]が最大のもの
    for v in range(n-1):
        if(len(E[v])==1): continue
        u=max(*((dp[nv],nv) for nv in E[v]))[1]
        # vu を削除したときの期待値DPを行う
        dp2=[0]*n
        for x in range(n-2,-1,-1):
            res=0
            for nx in E[x]:
                if(x==v and nx==u): continue
                res+=dp2[nx]
            if(v!=x):
                dp2[x]=1+res/len(E[x])
            else:
                dp2[x]=1+res/(len(E[x])-1)
        ans=min(ans,dp2[0])
    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(m):
        u,v=map(int,input().split())
        u-=1; v-=1
        E[u].append(v)

    # 辺を除かなかったときの期待値dp
    dp=[None]*n
    dp[-1]=0
    def dfs(v):
        if(dp[v] is not None): return dp[v]
        res=0
        deg=len(E[v])
        for nv in E[v]:
            res+=dfs(nv)
        dp[v]=res/deg+1
        return dp[v]

    ans=dfs(0)

    # 辺を除いたときの期待値dp
    dp1=[None]*n
    v0,w0=-1,-1
    def dfs1(v):
        if(dp1[v] is not None): return dp1[v]
        res=0
        deg=len(E[v])
        for nv in E[v]:
            if((v,nv)==(v0,w0)):
                deg-=1
            else:
                res+=dfs1(nv)
        dp1[v]=res/deg+1
        return dp1[v]

    for v0 in range(n):
        if(len(E[v0])<=1): continue
        dp1=[None]*n
        dp1[-1]=0
        w0=max((dp[w0],w0) for w0 in E[v0])[1]
        ans=min(ans,dfs1(0))

    print(ans)
resolve()
Problem p03072 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    if n==1:
        print(1)
        return
    H=list(map(int,input().split()))
    M=[0]*n
    M[1]=H[0]
    for i in range(2,n):
        M[i]=max(M[i-1],H[i-1])
    print(sum(1 for i in range(n) if H[i]>=M[i]))
resolve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    H=list(map(int,input().split()))
    M=[0]*n
    M[1]=H[0]
    for i in range(2,n):
        M[i]=max(M[i-1],H[i-1])
    print(sum(1 for i in range(n) if H[i]>=M[i]))
resolve()
Problem p03127 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n=int(input())
    A=map(int,input().split())
    from fractions import gcd
    from functools import reduce
    print(reduce(gcd,A))
resolve()

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
input()
print(reduce(gcd,map(input().split())))
Problem p03221 (python)

Fixed submission:
n,m = map(int,input().split())
C = [[i]+list(map(int,input().split())) for i in range(m)]
C.sort(key=lambda c:c[1:])
prev = 0
count = 0
for c in C:
    if prev==c[1]: count+=1
    else: count=1
    c.append(format(c[1],'0>6')+format(count,'0>6'))
    prev=c[1]

for c in sorted(C, key=lambda c:c[0]):
    print(c[3])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
C = [[i,*map(int,input().split())] for i in range(m)]
C.sort(key=lambda c:c[1:])
prev = 0
count = 0
for c in C:
    if prev==c[1]: count+=1
    else: count=1
    c.append(format(c[1],'0>6')+format(count,'0>6'))
    prev=c[1]

for c in sorted(C, key=lambda c:c[0]):
    print(c[3])
Problem p03253 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def modfact(n):
    fact=[1]*(n+1)
    invfact=[1]*(n+1)
    for i in range(1,n+1):
        fact[i]=i*fact[i-1]%MOD
    invfact[n]=pow(fact[n],MOD-2,MOD)
    for i in range(n-1,-1,-1):
        invfact[i]=invfact[i+1]*(i+1)%MOD
    return fact,invfact

def prime_factorization(n):
    assert(n>=2)
    factor=[]
    sqrt=int(n**.5)
    for d in range(2,sqrt+1):
        while(n%d==0):
            n//=d
            factor.append(d)
    if n!=1: factor.append(n)
    return factor

def resolve():
    from collections import Counter
    n,m=map(int,input().split())
    if(m==1):
        print(1)
        return
        
    P=prime_factorization(m)
    C=Counter(P)
    C=list(C.values())

    N=max(C)
    fact,invfact=modfact(N+n)

    ans=1
    for v in C:
        ans*=fact[v+n-1]*invfact[n-1]*invfact[v]
        ans%=MOD
    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def modfact(n):
    fact=[1]*(n+1)
    invfact=[1]*(n+1)
    for i in range(1,n+1):
        fact[i]=i*fact[i-1]%MOD
    invfact[n]=pow(fact[n],MOD-2,MOD)
    for i in range(n-1,-1,-1):
        invfact[i]=invfact[i+1]*(i+1)%MOD
    return fact,invfact

def prime_factorization(n):
    factor=[]
    sqrt=int(n**.5)
    for d in range(2,sqrt+1):
        while(n%d==0):
            n//=d
            factor.append(d)
    if n!=1: factor.append(n)
    return factor

def resolve():
    from collections import Counter
    n,m=map(int,input().split())
    if(n==1):
        print(1)
        return
        
    P=prime_factorization(m)
    C=Counter(P)
    C=list(C.values())

    N=max(C)
    fact,invfact=modfact(N+n)

    ans=1
    for v in C:
        ans*=fact[v+n-1]*invfact[n-1]*invfact[v]
        ans%=MOD
    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def modfact(n):
    fact=[1]*(n+1)
    invfact=[1]*(n+1)
    for i in range(1,n+1):
        fact[i]=i*fact[i-1]%MOD
    invfact[n]=pow(fact[n],MOD-2,MOD)
    for i in range(n-1,-1,-1):
        invfact[i]=invfact[i+1]*(i+1)%MOD
    return fact,invfact

def prime_factorization(n):
    factor=[]
    sqrt=int(n**.5)
    for d in range(2,sqrt+1):
        while(n%d==0):
            n//=d
            factor.append(d)
    if n!=1: factor.append(n)
    return factor

def resolve():
    from collections import Counter
    n,m=map(int,input().split())
    P=prime_factorization(m)
    C=Counter(P)
    C=list(C.values())

    N=max(C)
    fact,invfact=modfact(N+n)

    ans=1
    for v in C:
        ans*=fact[v+n-1]*invfact[n-1]*invfact[v]
        ans%=MOD
    print(ans)
resolve()
Problem p03725 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
from collections import deque
def resolve():
    h,w,k=map(int,input().split())
    G=[list(input()) for _ in range(h)]
    D=[(1,0),(-1,0),(0,1),(0,-1)]
    for i,j in product(range(h),range(w)):
        if(G[i][j]=='S'):
            i0,j0=i,j
            break

    dist=[[INF]*w for _ in range(h)]
    dist[i0][j0]=0
    # BFS
    Q=deque([(i0,j0)])
    while(Q):
        i,j=Q.popleft()
        for di,dj in D:
            ni=i+di; nj=j+dj
            if(not (0<=ni<h and 0<=nj<w)): continue
            if(dist[ni][nj]!=INF or G[ni][nj]=='#'): continue
            dist[ni][nj]=dist[i][j]+1
            Q.append((ni,nj))

    # 後は距離が k 以下の点から一直線に外に向かえばよい
    ans=INF
    for i,j in product(range(h),range(w)):
        if(dist[i][j]<=k):
            d=min(i,j,h-i-1,w-j-1)
            if(d==0):
                print(1)
                return
            else:
                ans=min(ans,2+(d-1)//k)
    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
from collections import deque
def resolve():
    h,w,k=map(int,input().split())
    G=[list(input()) for _ in range(h)]
    D=[(1,0),(-1,0),(0,1),(0,-1)]
    for i,j in product(range(h),range(w)):
        if(G[i][j]=='S'):
            i0,j0=i,j
            break

    dist=[[INF]*w for _ in range(h)]
    dist[i0][j0]=0
    # BFS
    Q=deque([(i0,j0)])
    while(Q):
        i,j=Q.popleft()
        for di,dj in D:
            ni=i+di; nj=j+dj
            if(not (0<=ni<h and 0<=nj<w)): continue
            if(dist[ni][nj]!=INF or G[ni][nj]=='#'): continue
            dist[ni][nj]=dist[i][j]+1
            Q.append((ni,nj))

    print(dist)

    後は距離が k 以下の点から一直線に外に向かえばよい
    ans=INF
    for i,j in product(range(h),range(w)):
        if(dist[i][j]<=k):
            d=min(i,j,h-i-1,w-j-1)
            if(d==0):
                print(1)
                return
            else:
                ans=min(ans,2+(d-1)//k)
    print(ans)
resolve()
Problem p02546 (python)

Fixed submission:
val = input()

if(val[-1] == 's'):
  print(val + 'es')
else:
  print(val+'s')

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



a = []
c = []
f = 0

for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)

    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c.append(1)
		else:
			f=0


if(len(c) >= 3):
  print("Yes")
else:
  print("No")

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



a = []
c =0
f = 0

for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)

    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c+=1
		else:
			f=0
			c=0
	else :
		f=0
		c=0

if(c >= 3):
  print("Yes")
else:
  print("No")

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



a = []
c =0
f = 0

for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)

    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c+=1
		else:
			f=0
			c=0
	else :
      f=0
      c=0

if(c >= 3):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import sys
N = int(input().strip())

if(N == 0):
  sys.exit()



a = []
c =0
f = 0
for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)
#print(a[4][1])
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f=i
			c+=1
		else:
			f=0
			c=0
if(c >= 3):
  print("Yes")
else:
  print("No")
Problem p03041 (python)

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

           
if(S[K-1] == "A"):
  S[K-1] = "a"
elif(S[K-1] == "B"):
  S[K-1] = "b"
elif(S[K-1] == "C"):
  S[K-1] = "c"
           
"".join(S)

S_1 = S[0]
for i in range(1,N):
  S_1 = S_1 + S[i]
print(S_1)

Buggy submission (verdict: Runtime Error):
S = list(input())
a = S[0] + S[1]
b = S[2] + S[3]
A = int(a)
B = int(b)

if (0 < A < 13 and 0 < B < 13):
  print("AMBIGUOUS")
elif (0 < A < 13 and 12 < B < 100):
  print("MMYY")
elif (0 < A < 13 and B == 0):
  print("MMYY")
elif (0 < B < 13 and 12 < A < 100):
  print("YYMM")
elif (0 < B < 13 and A == 0):
  print("YYMM")
  
else:
  print("NA")

Buggy submission (verdict: Runtime Error):
S = list(input())
a = S[0] + S[1]
b = S[2] + S[3]
A = int(a)
B = int(b)

if (0 < A < 13 and 0 < B < 13):
  print("AMBIGUOUS")
elif (0 < A < 13 and (12 < B < 100 or B == 0)):
  print("MMYY")
elif (0 < B < 13 and (12 < A < 100 or A == 0)):
  print("YYMM")
else:
  print("NA")

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str()
if(S[K] = 'A'):
  S[K] = 'a'
elif(S[K] = 'B'):
  S[K-1] = 'b'
elif(S[K] = 'C'):
  S[K] = 'c'

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str()
if(S[K-1] = 'A'):
  S[K-1] = 'a'
elif(S[K-1] = 'B'):
  S[K-1] = 'b'
elif(S[K-1] = 'C'):
  S[K-1] = 'c'
Problem p03307 (python)

Fixed submission:
# 2とNのどちらでも割り切れる最小の整数

N=int(input())

N_MAX = int(10e9)

start = N
interval = N

ans = 0

for x in range(N,N_MAX,N):
	# print(x)
	if x % N == 0 and x % 2 == 0:
		ans = x
		break

print(ans)

Buggy submission (verdict: Runtime Error):
# 整数列A 
# 3箇所で切って、４つに
# それぞれの総和の最大値と最小値の差の絶対値の最小値

# 中央を固定することを考える(結局、その固定を全検索するが)
# 中央固定後、左側について、両方が同じくらいの値になるのが最適と考えて良いらしい

from itertools import accumulate

N=int(input())
A=list(map(int,input().split()))
SumA=list(accumulate(A))

tmpP=tmpQ=tmpR=tmpS=0
P=Q=R=S=0
ans=10e9
l = 0
r = 2

# midとmid+1の間が中間の切断
for mid in range(1,N-2):

	# l,rは、単調増加であるため、全ての中間点を求めるループの間、クリアの必要がないらしい

	# 次のやつよりも、今のやつの方が大きい限り、継続
	# 必ず、それが逆転する時が最小のはず、という考え。。。
	while l < mid and abs((SumA[mid] - SumA[l+1])-SumA[l+1]) < abs((SumA[mid] - SumA[l])-SumA[l]):
		l += 1

	# 次のやつよりも、今のやつの方が大きい限り、継続
	# 必ず、それが逆転する時が最小のはず、という考え。。。
	while r < N-1 and abs((SumA[N-1]-SumA[r+1])-(SumA[r+1]-SumA[mid])) < abs((SumA[N-1] - SumA[r])-(SumA[r] - SumA[mid])):
		r += 1

	#print("{},{}".format(mid,l))

	P=SumA[l]
	Q=SumA[mid]-SumA[l]
	R=SumA[r]-SumA[mid]
	S=SumA[N-1]-SumA[r]

	#print(P,Q,R,S)
	diff=max(P,Q,R,S)-min(P,Q,R,S)
	diff=abs(diff)
	ans = min(ans,diff)

print(ans)
Problem p02547 (python)

Fixed submission:
def judge():
    cnt = 0  # 今何連続でゾロ目が出ているか記録しておきます
 
    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            # ゾロ目ストリークが1増えました
            cnt += 1
        else:
            # ゾロ目ストリークが切れました
            cnt = 0
 
        if cnt == 3:
            # 3連続になった瞬間、return True していいです
            return True
    
    # ダメでした
    return False
 
N = int(input())
 
if judge():
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [list(map(int, input().split())) for l in range(N)]
    
for i in range(len(l)):
  if l[i][0]==l[i][1]:
    if l[i+1][0]==l[i+1][1]:
      if l[i+2][0]==l[i+2][1]:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
        
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
rows = int(input())
x = []
for i in range(rows):
    x.append(list(map(int, input().split())))
    
for i in range(len(x)):
  if x[i][0]==x[i][1]:
    if [i+1][0]==[i+1][1]:
      if [i+2][0]==[i+2][1]:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
        
  else:
    print('No')
Problem p02552 (python)

Fixed submission:
x = int(input())
if x==0:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
def fun(x):
    x = int(input())
    if x==0:
        return 1
    else:
        return 0

print(fun(x))

Buggy submission (verdict: Runtime Error):
def fun(x):
    x = int(input())
    if x=0:
        return 1
    else:
        return 0

print(fun(x))

Buggy submission (verdict: Runtime Error):
def fun(x)

x = int(input())

if x=0:
    return 1
else:
    return 0

print(fun(x))
Problem p02676 (python)

Fixed submission:
n=int(input())
k=input()
if(len(k)>n):
  k=k[:n]+"..."
print(k)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=input()
l=[]
ol=len(k)
for i in range(n):
  l.append(k[i])
if(ol>n):
  print("".join(l)+"...")
elif(ol<=n):
  print(k)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=input()
l=[]
ol=len(k)
nl=len(l)
for i in range(n):
  l.append(k[i])
if(ol>n):
  print("".join(l)+"...")
elif(ol<=n):
  print(k)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=input()
l=[]
ol=len(k)
nl=len(l)
for i in range(n):
  l.append(k[i])
if(ol>nl):
  print("".join(l)+"...")
else:
  print(k)
Problem p02577 (python)

Fixed submission:
n = int(input())
print('Yes' if n % 9 == 0 else 'No')

Buggy submission (verdict: Runtime Error):
n = int(input())
print('Yes' if n/9 == n//9 else 'No')
Problem p02578 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
 
total = 0
m = 0
 
for x in a:
  if m > x:
    total += m - x
  m = max(m,x)
  
print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [map(int,input().split())]
 
total = 0
m = 0
 
for x in a:
  if m > x:
    total += m - x
  m =max(m,x)
  
print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [map(int,input().split())]

total = 0
m = a[0]

for x in a:
  if m > x:
    total += m - x
  m =max(m,x)
  
print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [map(int,input().split())]
h = 0
if n >= 2:
  for i in range(1,n):
    if a[i] < a[i-1]:
      h += a[i-1] - a[i]
  print(h)
if n = 1:
  print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [map(int,input().split())]
h = 0
for i in range(1,n):
  if a[i] < a[i-1]:
    h += a[i-1] - a[i]
print(h)
Problem p02571 (python)

Fixed submission:
S = input().rstrip()
T = input().rstrip()
count = 0
lens = len(S)
lent = len(T)
for i in range(lens-lent+1):
    tempcount=0
    for j in range(lent):
        if S[i+j]==T[j]:
            tempcount += 1
    #print(tempcount)
    count = max(count,tempcount)

print(lent-count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
ans = 0
m0 = 10**9+7
for i in range(0,N-1):
    for j in range(i+1,N):
        ans = (ans + A[i]*A[j]) % m0
print(ans)
Problem p03013 (python)

Fixed submission:
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]

for i in range(len(a)-1):
    if a[i+1] == a[i]+1:
        print(0)
        exit()
x = []
temp=0
for i in range(m):
    x.append(a[i]-temp-1)
    temp = a[i]+1
x.append(n-temp)

temp = 1
div = 1000000007

for i in x:
    temp = (temp*Fib(i+1))%div

print(temp)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

@lru_cache(maxsize=None)
def fib(n):
    if n < 2:
        return n
    else:
        return fib(n - 2) + fib(n - 1)

n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]

for i in range(len(a)-1):
    if a[i+1] == a[i]+1:
        print(0)
        exit()
x = []
temp=0
for i in range(m):
    x.append(a[i]-temp-1)
    temp = a[i]+1
x.append(n-temp)

temp = 1
div = 1000000007

for i in x:
    temp = (temp*fib(i+1))%div

print(temp)
Problem p02571 (python)

Fixed submission:
s = input()
t = input()
ls = []
for i in range(len(s) - len(t) + 1):
    ls.append(s[i:i+len(t)])
now = 0
minimum = len(t)
for i in range(len(ls)):
    now = 0
    for j in range(len(t)):
        if t[j] == ls[i][j]:
            now += 1
    if len(t) - now < minimum:
        minimum = len(t) - now
print(minimum)

Buggy submission (verdict: Runtime Error):
d,t,s = map(int,input().split())
if d <= s * t:
    print("Yes")
else:
    print("No")
Problem p02577 (python)

Fixed submission:
print("Yes") if int(input())%9 == 0 else print("No")

Buggy submission (verdict: Runtime Error):
N = input()
ans = 0
for i in range(len(N)):
  ans += N[i]
print("Yes") if ans%9 == 0 else print("No")
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
import math

a,b=map(Decimal,input().split())

print(math.floor(a*b))

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
s = map(float,input().split())
S = Decimal(A)*Decimal(B)
print(S//1)
Problem p02693 (python)

Fixed submission:
K = int(input())
a,b = map(int,input().split())
flag = 0
for i in range(a,b+1):
    if i%K == 0:
        flag += 1
        print("OK")
        break
if flag == 0:
    print("NG")

Buggy submission (verdict: Runtime Error):
import math
def equation(a,b,n):
  return math.floor((a*n)/b)-a*math.floor(n/b)
d,e,f = map(int,input().split())
K = min(e-1,f)
print(equation(K))
Problem p02699 (python)

Fixed submission:
a,b = map(int,input().split())
if b>=a:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
for i in range(10**2):
  c -= b
  if c <= 0:
    print("Yes")
    break
  a -= d
  if a <= 0:
    print("No")
    break