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

Fixed submission:
from collections import defaultdict

N = int(input())
d = defaultdict(list)
cd = set()
D = 100000
used = [0]*(2*D+1)
ans = 0

for _ in range(N):
    x, y = map(int, input().split())
    y += D
    cd.add(x)
    d[x].append(y)
    d[y].append(x)

for x in cd:
    if used[x]:continue
    q = [x]
    used[x] = 1
    cx, sx = 0, 0

    while q:
        a = q.pop()
        if a<=D:
            cx += 1
        sx += 1
        for b in d[a]:
            if used[b]:continue
            used[b] = 1
            q.append(b)
    ans += cx*(sx-cx)

print(ans-N)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
d = defaultdict(list)
cd = set()
D = 100000

for _ in range(N):
    x, y = map(int, input().split())
    y += D
    cd.add(x)
    d[x].append(y)
    d[y].append(x)

used = [0]*(D+1)
ans = 0

for x in cd:
    if used[x]:continue
    q = [x]
    used[x] = 1
    cx, sx = 0, 0

    while q:
        a = q.pop()
        if a<=D:
            cx += 1
        sx += 1
        for b in d[a]:
            if used[b]:continue
            used[b] = 1
            q.append(b)
    ans += cx*(sx-cx)

print(ans-N)
Problem p03013 (python)

Fixed submission:
from functools import lru_cache
import sys
sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
mod = 10**9+7

a = [1] * (N+1)
for _ in range(M):
    a[int(input())] = 0

@lru_cache()
def f(x):
    v = 0
    if x<0:
        return 0
    if x == 0:
        return 1
    if a[x-1]:
        v += f(x-1)
    if a[x-2]:
        v += f(x-2)
    v %= mod
    return v

print(f(N))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
N, M = map(int, input().split())

mod = 10**9+7

a = [1] * (N+1)
for _ in range(M):
    a[int(input())] = 0

@lru_cache()
def f(x):
    v = 0
    if x<0:
        return 0
    if x == 0:
        return 1
    if a[x-1]:
        v += f(x-1)
    if a[x-2]:
        v += f(x-2)
    v %= mod
    return v

print(f(N))
Problem p03053 (python)

Fixed submission:
from collections import deque


def solve():
    H, W = map(int, input().split())
    m = [[-1]*W for _ in range(H)]
    l = [list(input()) for _ in range(H)]
    dx = [-1, 1, 0, 0]
    dy = [0, 0, -1, 1]
    q = deque([])

    for i in range(H):
        for j in range(W):
            if l[i][j]=="#":
                q.append((i, j))
                m[i][j] = 0
    
    while q:
        y, x = q.popleft()

        for px, py in zip(dx, dy):
            x1, y1 = x + px, y + py
            if not (0<=x1<W and 0<=y1<H):
                continue
            if m[y1][x1] == -1:
                q.append((y1, x1))
                m[y1][x1] = m[y][x] + 1

    print(max(map(max, m)))


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
input=sys.stdin.readline


def solve():
    H, W = map(int, input().split())
    m = [[-1]*W for _ in range(H)]
    candidate = [(i, j, 0) for i in range(H) for j, s in enumerate(input()) if s=="#"]
    q = deque(candidate)
    dx = [-1, 1, 0, 0]
    dy = [0, 0, -1, 1]

    while q:
        y, x, cost = q.popleft()
        m[y][x] = cost

        for i in range(4):
            x1, x2 = x + dx[i], y + dy[i]
            if not (0<=x1<W and 0<=y1<H):
                continue
            if m[y1][x1] == -1:
                q.append((y1, x1, cost+1))

    print(max(map(max, m)))


if __name__ == "__main__":
    solve()
Problem p03055 (python)

Fixed submission:
import sys
input = sys.stdin.readline


def dfs(V, start):
    q = [(start, 0)]
    used = [False] * (n+1)
    farthest = 0
    pos = 0

    while q:
        s, cost = q.pop()
        if farthest < cost:
            pos = s
            farthest = cost
        used[s] = True
        for t, c in V[s].items():
            if used[t]:
                continue
            q.append((t, cost + c))
    
    return farthest, pos


if __name__ == "__main__":
    n = int(input())
    V = {i:dict() for i in range(1, n+1)}

    for _ in range(n - 1):
        s, t = map(int, input().split())
        V[s][t] = 1
        V[t][s] = 1

    if n==1:
        print("First")
    else:
        d = dfs(V, dfs(V, 1)[1])[0]
        if d==1:
            print("Second")
        elif d==2:
            print("First")
        elif (d-1)%3==0:
            print("Second")
        else:
            print("First")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


def dfs(V, start):
    q = [(start, 0)]
    used = [False] * (n+1)
    farthest = 0
    pos = 0

    while q:
        s, cost = q.pop()
        if farthest < cost:
            pos = s
            farthest = cost
        used[s] = True
        for t, c in V[s].items():
            if used[t]:
                continue
            q.append((t, cost + c))
    
    return farthest, pos


if __name__ == "__main__":
    n = int(input())
    V = {i:dict() for i in range(1, n+1)}

    for _ in range(n - 1):
        s, t = map(int, input().split())
        V[s][t] = 1
        V[t][s] = 1

    d = dfs(V, dfs(V, 1)[1])[0]
    if d==0:
        print("First")
    elif d==1:
        print("Second")
    elif d==2:
        print("First")
    elif (d-1)%3==0:
        print("Second")
    else:
        print("First")
Problem p03107 (python)

Fixed submission:
a,b=0,0
for i in input():
  if i=="1":a+=1
  else:b+=1
print(2*min(a,b))

Buggy submission (verdict: Runtime Error):
l = []
ans = 0

for s in input():
    if s == "0":
        if l and l[-1] == "1":
            l.pop()
            ans += 2
        else:
            l.append(s)
    else:
        if l and l[-1] == "0":
            l.pop()
            ans += 2
        else:
            l.append(i)

print(ans)
Problem p03209 (python)

Fixed submission:
#l==0 P
#l==n B+bg(l-1)+P+bg(l-1)+B
#f(n,x) returns the number of bans below x layers

#a[i] returns the size of level i burger -> a[0]=1
#b[i] returns the numbers of patties in level i burger -> b[0]=1

n,x=map(int,input().split())
a,p=[1]*(n+1),[1]*(n+1)
for i in range(n):
    a[i+1]=2*a[i]+3
    p[i+1]=2*p[i]+1

def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    elif x<=a[n-1]+1:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])

print(f(n,x))

Buggy submission (verdict: Runtime Error):
def f(n):
    if n==0:
        return 1
    return 2*f(n-1)+1

N, X = map(int, input().split())
l, r = 0, g(N)
ans = 0

while N:
    m = (l+r)//2
    if m<=X:
        l = m
        ans += f(N-1) + 1
    else:
        r = m
    N -= 1

print(ans)
Problem p03250 (python)

Fixed submission:
*l,=map(int,input().split())
l.sort()
print(l[2]*10+l[1]+l[0])

Buggy submission (verdict: Runtime Error):
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d=c()
  for i in range(2,1+int(n**0.5)):
    while n%i==0:
      d[i]+=1
      n//=i
  if n:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod=10**9+7
print(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True),f(m)))%mod)
Problem p03253 (python)

Fixed submission:
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod,v=10**9+7,1
for x in f(m):
  v*=comb(x+n-1,x,exact=True)%mod
print(v%mod)

Buggy submission (verdict: Runtime Error):
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod=10**9+7
print(reduce(lambda x,y:((x%mod)*(y%mod))%mod,map(lambda x:comb(x+n-1,x,exact=True)%mod,f(m)))%mod)

Buggy submission (verdict: Runtime Error):
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod=10**9+7
print(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True)%mod,f(m)))%mod)

Buggy submission (verdict: Runtime Error):
from collections import Counter as c
from scipy.misc import comb
from functools import reduce

def f(n):
  d,i=c(),2
  while i*i<=n:
    while n%i==0:
      n//=i
      d[i]+=1
    i+=1
  if n>1:d[n]+=1
  return d.values()

n,m=map(int,input().split())
mod=10**9+7
print(reduce(lambda x,y:x*y%mod,map(lambda x:comb(x+n-1,x,exact=True),f(m)))%mod)

Buggy submission (verdict: Runtime Error):
from collections import Counter as c
from math import factorial as fac
from functools import reduce

def f(n):
  d=c()
  for i in range(2,1+int(n**0.5)):
    while n%i==0:
      d[i]+=1
      n/=i
  return d.values()

def comb(n,r):
  return fac(n)//fac(r)//fac(n-r)%mod

n,m=map(int,input().split())
mod=10**9+7
g=lambda x:comb(x+n-1,x)
h=lambda x,y:x*y%mod
print(reduce(h,map(g,f(m)))%mod)
Problem p03332 (python)

Fixed submission:
n,a,b,k=map(int,input().split())
mod=998244353
s=0
fac=[1]*(n+1)
rev=[1]*(n+1)

for i in range(1,n+1):
  fac[i]=i*fac[i-1]%mod
  rev[i]=pow(fac[i],mod-2,mod)

f=lambda a,b:(fac[a]*rev[a-b]*rev[b])%mod

for i in range(n+1):
  j,r=divmod((k-a*i),b)
  if r==0 and 0<=j<=n:
    s+=(f(n,i)*f(n,j))%mod

print(s%mod)

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

mod=998244353
fac=[None]*(n+1)
rev=[None]*(n+1)

fac[0]=1
rev[0]=1

for i in range(1,n+1):
  fac[i]=i*fac[i-1]%mod
  rev[i]=pow(fac[i],mod-2,mod)

f=lambda a,b:(fac[a]*rev[a-b]*rev[b])%mod

for i in range(n+1):
  if not (k-a*i)%b:
    j=(k-a*i)//b
    if 0<=j<=n+1:
      l.extend([(i,j)])

s=0
for (i,j) in l:
  s+=(f(n,i)*f(n,j))%mod

print(s)
Problem p03634 (python)

Fixed submission:
from collections import deque
n=int(input())
l=[[] for _ in [0]*n]
for _ in [0]*(n-1):
  a,b,c=map(int,input().split())
  l[a-1].extend([(b-1,c)])
  l[b-1].extend([(a-1,c)])

q,k=map(int,input().split())
dst=[0 for _ in [0]*n]
que=deque([])
v,p,d=k-1,-1,0
que.append((v,p,d))
while que:
  v,p,d=que.pop()
  dst[v]=d
  for i,j in l[v]:
    if i==p:continue
    que.append((i,v,d+j))

for _ in [0]*q:
  x,y=map(int,input().split())
  print(dst[x-1]+dst[y-1])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

d=defaultdict(list)

N=int(input())
for _ in range(N-1):
    a,b,c=map(int,input().split())
    d[a].append((b,c))
    d[b].append((a,c))

Q,K=map(int,input().split())

# Kを中心とした距離を求める
dists=[None]*(N+1)
isused=[False]*(N+1)
dists[K]=0
isused[K]=True

def dfs(n):
    for i,j in d[n]:
        if isused[i]:continue
        isused[i]=True
        dists[i]=dists[n]+j
        dfs(i)

dfs(K)
for _ in range(Q):
    x,y=map(int,input().split())
    print(dists[x]+dists[y])
Problem p03804 (python)

Fixed submission:
def func():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  q=[]
  for i in range(n-m+1):
    for j in range(n-m+1):
      fl=True
      for k in range(m):
        for l in range(m):
          if p[k][l]!=o[i+k][j+l]:
            fl=False
      q.extend([fl])
  return q

a=func()
if sum(a):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def f():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  for i in range(n-m+1):
    for j in range(n-m+1):
      for k in range(i,n-m+1):
        for l in range(j,n-m+1):
          if p[k-i][l-j]!=o[k][l]:
            return False
  return True

if f():
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def f():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  for i in range(n-m+1):
    for j in range(n-m+1):
      for k in range(i,n-m+1):
        for l in range(j,n-m+1):
          if p[k-i][l-i]!=o[k][l]:
            return False
  return True

if f():
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def f():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  for i in range(n-m+1):
    for j in range(n-m+1):
      for k in range(i,n-1):
        for l in range(j,n-1):
          if p[k-i][l-i]!=o[k][l]:
            return False
  return True

if f():
  print("Yes")
else:
  print("No")
Problem p03806 (python)

Fixed submission:
nmax,abmax=40,10
n,ma,mb=map(int,input().split())
a,b,c=[None]*n,[None]*n,[None]*n
inf=float("inf")
for i in range(n):
  a[i],b[i],c[i]=map(int, input().split())
dp = [[[inf for _ in range(nmax*abmax+1)] for _ in range(nmax*abmax+1)] for _ in range(nmax+1)]
dp[0][0][0]=0
for i in range(n):
  for ca in range(nmax*abmax+1):
    for cb in range(nmax*abmax+1):
      if dp[i][ca][cb]==inf:continue
      dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb])
      dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i])

ans=inf
for ca in range(1,nmax*abmax+1):
  for cb in range(1,nmax*abmax+1):
    if ca*mb==cb*ma:ans=min(ans,dp[n][ca][cb])
if ans==inf:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
n,Ma,Mb=map(int,input().split())
inf=float("inf")
dp=[[[inf]*401 for _ in range(401)] for _ in range(n+1)]
dp[0][0][0]=0

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

for i in range(1,n+1):
    for j in range(401):
        for k in range(401):
            a,b,c=l[i-1]
            dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k])
            if j-a>=0 and k-b>=0:
                dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a][k-b]+c)

ans=inf
for i in range(1,1+max(400//Ma,400//Mb)):
    ans=min(ans,dp[n][Ma*i][Mb*i])

print(ans if ans!=inf else -1)
Problem p02711 (python)

Fixed submission:
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=str(input())
    if '7' in n:
        print("Yes")
    else:
        print("No")
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Buggy submission (verdict: Runtime Error):
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=1
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=str(input())
    if '7' in n:
        print("Yes")
    else:
        print("No")
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()
Problem p02682 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, c, x = map(int, input().split())
alist = [1]
blist = [0]
clist = [-1]
list = alist*a + blist*b + clist*c
print(sum(list[:x]))
Problem p02689 (python)

Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))
x = [0 for _ in range(n)]
for j in range(m):
    a = list(map(int, input().split()))
    s = a[0] - 1
    t = a[1] - 1
    if h[s] < h[t]:
        x[s] = 1
    elif h[s] > h[t]:
        x[t] =1
    else:
        x[s] = 1
        x[t] = 1

print(x.count(0))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
x = []
for j in range(m):
    a = list(map(int, input().split()))
    s = a[0] - 1
    t = a[1] - 1
    if h[s] <= h[t]:
        x.append(t)
    else
        x.append(s)

print(len(set(x)))
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
    if i % k == 0:
        print('OK')
        exit()
print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input())
a, b = map(int, input(),split())
for i in range(a, b+1):
    if i % k == 0:
        print('OK')
        exit()
print('NO')
Problem p02762 (python)

Fixed submission:
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n, m, k = map(int, input().split())
    fgraph = [list() for i in range(n)]
    bgraph = [list() for i in range(n)]
    cgraph = [list() for i in range(n)]
    
    rks = [None] *n
    sys.setrecursionlimit(10**9)
    # r: どの連結成分に存在するかをメモするid
    def dfs(graph,s,r):
        if rks[s] is None:
            rks[s] = r
        for i in range(len(graph[s])):
            if rks[graph[s][i]-1] is not None:
                continue
            dfs(graph, graph[s][i]-1,r)

    for i in range(m):
        a,b = map(int, input().split())
        fgraph[a-1].append(b)
        fgraph[b-1].append(a)

    # print(fgraph)
    #print(bgraph)
    # 連結成分に対してid的なindexをつける
    c = -1
    for i in range(n):
        if rks[i] is None:
            c += 1
            dfs(fgraph, i, c)
    
    for i in range(k):
        c,d = map(int, input().split())
        if rks[c-1] == rks[d-1]:
            bgraph[d-1].append(c)
            bgraph[c-1].append(d)

    counter = Counter(rks)
    for i in range(n):
        # counter[rks[i]] 連結成分のサイズ
        # len(fgraph[i]) 友達の数
        # len(bgraph[i]) 連結成分内のブロックの数
        # 1 自分
        print(counter[rks[i]] - len(fgraph[i]) - len(bgraph[i]) - 1)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque, Counter, defaultdict

n, m, k = map(int, input().split())
F = [[] for _ in range(n+1)]
B = [[] for _ in range(n+1)]

for _ in range(m):
    a, b = map(int, input().split())
    F[a].append(b)
    F[b].append(a)

rks = [0]*(n+1)

def dfs(s,r):
    if rks[s] == 0:
        rks[s] = r
    else:
        return
    for i in F[s]:
        dfs(i,r)

r = 0
for i in range(1,n+1):
    if rks[i] == 0:
        r += 1
        dfs(i,r)

for _ in range(k):
    c, d = map(int, input().split())
    if rks[c] == rks[d]:
        B[c].append(d)
        B[d].append(c)

counter = Counter(rks)
for i in range(1,n+1):
    print(counter[rks[i]] - len(F[i]) - len(B[i]) - 1)
Problem p02831 (python)

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

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

Fixed submission:
# -*- coding: utf-8 -*-
W,H,M=[int(_) for _ in input().split()]
HW=[[int(_) for _ in input().split()]for i in range(M)]
yoko = [0]*W
tate = [0]*H
for hw in HW:
    yoko[hw[0]-1]+=1
    tate[hw[1]-1]+=1

my=max(yoko)
mt =max(tate)
ans = mt+my

cu=yoko.count(my)*tate.count(mt)
c = 0

for hw in HW:
    if yoko[hw[0]-1]==my and tate[hw[1]-1]==mt:
        c+=1
if c== cu:
    ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import itertools
H, W, M = [int(j) for j in input().split()]
Hx = [0]*H
Wx = [0]*W
dict = [[0] * W for i in range(H)]
for i in range(M):
    h, w =  [int(j) for j in input().split()]
    dict[h-1][w-1]=1
    Hx[h-1] += 1
    Wx[w-1] += 1
maxIndex_Hx = [i for i, x in enumerate(Hx) if x == max(Hx)]
maxIndex_Wx = [i for i, x in enumerate(Wx) if x == max(Wx)]
ans = max(Hx)+ max(Wx)
flag = 1
#print(dict)
for j in list(itertools.product(maxIndex_Hx, maxIndex_Wx)):
    if dict[j[0]][j[1]] == 0:
        print(ans)
        flag = 0
        break
if flag:
    print(ans-1)
Problem p02594 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
if N >= 30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    K = int(input())
    # = "7"*999982
    #print(int(t)%999983)

    if K%2 == 0 or K%5 == 0:
        print(-1)
    else:
        f = len(factorization(K))
        i = 0
        while(20000>i):
            i+=1
            if 7 * (10**i-1)//9 %K == 0:
                print(i)
                return
        if f > 2:
            print(-1)
        else:
            print(K-1)

if __name__ == "__main__":
    main()
Problem p02682 (python)

Fixed submission:
# -*- coding: utf-8 -*-

A, B, C, K =  [int(i) for i in input().split()]

if K <= A:
    print(K)
elif K <= A+B:
    print(A)
else:
    print((K-(A+B))*(-1)+A)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

A, B, C, K =  [int(i) for i in input().split()]

if K <= A:
    print(K)
elif k <= A+B:
    print(A)
else:
    print((K-(A+B))*(-1)+A)
Problem p02685 (python)

Fixed submission:
# -*- coding: utf-8 -*-
#https://mathtrain.jp/tyohukuc

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

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = n+1 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0
beki = [1,m-1]
for i in range(2,N+1):
    beki.append(((beki[-1]*(m-1)) % p))

for x in range(k+1):
    ans += m * beki[n-x-1] %p * cmb(n-1,x,p) %p
    ans = ans % p
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#https://mathtrain.jp/tyohukuc

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

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = n+1 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0
beki = [1,m-1]
for i in range(2,N+1):
    beki.append(((beki[-1]*(m-1)) % p))

for x in range(k+1):
    ans += m * beki[n-x-1] %p * cmb(n-1,x,p)) %p
    ans = ans % p
print(ans)