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

Fixed submission:
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ruia=[0]
ruib=[0]
mx=0
for (i,j) in zip(a,range(n)):
  ruia.append(ruia[j]+i)

for (i,j) in zip(b,range(m)):
  ruib.append(ruib[j]+i)
ans=0
for i in range(n+1):
  if ruia[i] > k:
    break
  while ruib[m] > k - ruia[i]:
    m -= 1
  ans = max(ans, i + m)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ruia=[0]
ruib=[0]
mx=0
for (i,j) in zip(a,range(n)):
  ruia.append(ruia[j]+i)

for (i,j) in zip(b,range(m)):
  ruib.append(ruib[j]+i)

for i in range(n+1,-1,-1):
  ans=-1
  if ruia[i]>k:
    continue
  for j in range(mx,m):
    if rui[i]+rui[j]>k:
      ans=i+j-1
      break
  else:
    ans=i+m
  if ans>mx:
    mx=ans
print(mx)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
ati=[0]
bti=[0]
for i in range(n):
  ati.append(ati[i]+a[i])
for i in range(m):
  bti.append(bti[i]+b[i])
x=0
y=0
while 1:
  if x==m and ati[x]+bti[y+1]<k:
    y+=1
  elif y==n and ati[x+1]+bti[y]<k:
    x+=1
  elif  ati[x+1]>bti[y+1]:
    y+=1
  elif y<n-1 and x<m-1 and ati[x+1]<bti[y+1]:
    x+=1
  else:
    ans=x+y
    break
  z=ati[x]+bti[y]
  if z>k:
    ans=x+y-1
    break
print(ans)
Problem p02629 (python)

Fixed submission:
s=int(input())
a=s
alp=list("abcdefghijklmnopqrstuvwxyz")
ans=""
i=1
#try:
while s!=0:
    jo=(26**i)
    x=s%jo
    if x==0:
      x=jo
    s-=x
    x//=26**(i-1)
    #print("{}%{} {} {}".format(s+x,jo,i,x))
    ans=alp[x-1]+ans
    i+=1
#except:
#  pass
  
print(ans)

Buggy submission (verdict: Runtime Error):
s=int(input())
alp=list("abcdefghijklmnopqrstuvwxyz")
ans=""
i=0
while 26**i<s:
  i+=1
i-=1
while s!=0:
  x=s//(26**i)
  s-=(26**i)*x
  ans+=alp[x-1]
  i-=1
print(ans)
Problem p02659 (python)

Fixed submission:
from decimal import *
a,b=input().split()
a=Decimal(a)
b=Decimal(b)
ans=int(a*b)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
x,y = map(str,input().split())
y=int(float(y)*100)
a=int(x)*y

a=int(str(a)[:-2])
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=1
li = input().split()
zero=False
for i in li:
  ans*=int(i)
  if ans==0:
    zero=True
  if ans>1000000000000000000:
    ans=-1

if ans<0:
  ans=-1
if zero:
  ans=0
print(ans)
Problem p02766 (python)

Fixed submission:
x,k=map(int,input().split())
ans=0
while k**ans<=x:
  ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
import math as mt
n,k=map(int,input().split())
print(mt.ceil(mt.log(n,k))
Problem p02785 (python)

Fixed submission:
n,k=map(int,input().split())
mon=list(map(int,input().split()))
mon.sort(reverse=True)

print(sum(mon[k:]))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
mon=list(map(int,input().split()))
mon.sort(reverse=True)
for i in range(k):
  mon.pop(0)
print(sum(mon))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
mon=list(map(int,input().split()))
mon.sort(reverse=true)
for i in range(k):
  mon.pop(0)
print(sum(mon))
Problem p02829 (python)

Fixed submission:
li=[1,2,3]
li.pop(li.index(int(input())))
li.pop(li.index(int(input())))
print(li[0])

Buggy submission (verdict: Runtime Error):
li=[1,2,3]
li.pop(int(input())-1)
li.pop(int(input())-1)
print(li[0])

Buggy submission (verdict: Runtime Error):
li=[1,2,3]
li.pop(int(input()))
li.pop(int(input()))
print(li[0])
Problem p02916 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

bef=a[0]-1
man=b[bef]

for i in a[1:]:
  ind=i-1
  if ind==bef+1:
    man+=c[bef]
  man+=b[ind]
  bef=ind
print(man)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

bef=a[0]-1
man=b[0]

for i in a[1:]:
  if i-1=bef+1:
    man+=c[bef]
  man+=b[i-1]
  bef=i-1
print(man)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

bef=a[0]
man=b[0]

for i in a[1:]:
  if i==bef+1:
    man+=c[bef]
  man+=b[i]
  bef=i
print(man)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

bef=a[0]
man=b[0]

for i in a[1:]:
  if i=bef+1:
    man+=c[bef]
  man+=b[i]
  bef=i
print(man)
Problem p02951 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(max(c-a+b,0))

Buggy submission (verdict: Runtime Error):
#c-(a-b)
print(max(-1*int(input())+int(input())+int(input()),0))
Problem p03011 (python)

Fixed submission:
print(sum(sorted(list(map(int,input().split())))[:2]))

Buggy submission (verdict: Runtime Error):
print(sum(sorted(list(map(int,input().split())[:2]))))
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
k-=1
s=input()
print(s[:k]+s[k].lower()+s[k+1:])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
print(s[:k]+s[k].lower()+s[k+1:])
Problem p02580 (python)

Fixed submission:
from collections import defaultdict
H,W,M = map(int,input().split())
bomb = [set() for _ in range(H+1)]
hdic = [0]*(H+1)
wdic = [0]*(W+1)
for i in range(M):
    hi,wi = map(int,input().split())
    hdic[hi] += 1
    wdic[wi] += 1
    bomb[hi].add(wi)
hmax = 0
hlist = []
wmax = 0
wlist = []
for i in range(1,H+1):
    if hdic[i] > hmax:
        hlist = [i]
        hmax = hdic[i]
    elif hdic[i] == hmax:
        hlist.append(i)
for i in range(1,W+1):
    if wdic[i] > wmax:
        wlist = [i]
        wmax = wdic[i]
    elif wdic[i] == wmax:
        wlist.append(i)
for i in hlist:
    for j in wlist:
        if j not in bomb[i]:
            print(hmax+wmax)
            exit()
print(hmax+wmax-1)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
H,W,M = map(int,input().split())
bomb = [[0]*(W+1) for _ in range(H+1)]
hdic = defaultdict(int)
wdic = defaultdict(int)
for i in range(M):
    hi,wi = map(int,input().split())
    hdic[hi] += 1
    wdic[wi] += 1
    bomb[hi][wi] = 1
hmax = 0
hlist = []
wmax = 0
wlist = []
for i in hdic.keys():
    if hdic[i] > hmax:
        hlist = [i]
        hmax = hdic[i]
    elif hdic[i] == hmax:
        hlist.append(i)
for i in wdic.keys():
    if wdic[i] > wmax:
        wlist = [i]
        wmax = wdic[i]
    elif wdic[i] == wmax:
        wlist.append(i)
for i in hlist:
    for j in wlist:
        if bomb[i][j] == 0:
            print(hmax+wmax)
            exit()
print(hmax+wmax-1)
Problem p02695 (python)

Fixed submission:
from collections import deque
de = deque()
n,m,q = map(int,input().split())
queries = []
for i in range(q):
    a,b,c,d = map(int,input().split())
    queries.append((a,b,c,d))
de.append([1])
maxscore = 0
while de: 
    li = de.popleft()
    if len(li) < n:
        for i in range(li[-1],m+1):
            new_li = li + [i]
            de.append(new_li)
    else:
        score = 0
        for i in range(q):
            a,b,c,d = queries[i]
            if li[b-1]-li[a-1] == c:
                score += d
        maxscore = max(maxscore,score)
print(maxscore)

Buggy submission (verdict: Runtime Error):
from collections import deque
de = deque()
n,m,q = map(int,input().split())
queries = []
for i in range(q):
    a,b,c,d = map(int,input().split())
    queries.append((a,b,c,d))
de.append([1])
maxscore = 0
while de: 
    li = de.popleft()
    if len(li) < m:
        for i in range(li[-1],11):
            new_li = li + [i]
            de.append(new_li)
    else:
        score = 0
        for i in range(q):
            a,b,c,d = queries[i]
            if li[b-1]-li[a-1] == c:
                score += d
        maxscore = max(maxscore,score)
print(maxscore)
Problem p02736 (python)

Fixed submission:
n = int(input())
a = list(map(lambda x:int(x)-1,input()))
ans = 0
for i in range(n):
    if (n-1) & i == i:
        ans += a[i]
if ans % 2 == 1:
    print(1)
else:
    if a.count(1) != 0:
        print(0)
    else:
        ans = 0
        b = list(map(lambda x:x//2,a))
        for i in range(n):
            if (n-1) & i == i:
                ans += b[i]
        if ans % 2 == 1:
            print(2)
        else:
            print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(lambda x:int(x)-1,input()))
ans = 0
for i in range(n):
    if (n-1) & i == i:
        ans += a[i]
if ans % 2 == 1:
    print(1)
else:
    if a.count(1) != 0:
        print(0)
    else:
        ans = 0
        b = map(lambda x:x//2,a)
        for i in range(n):
            if (n-1) & i == i:
                ans += b[i]
        if ans % 2 == 1:
            print(2)
        else:
            print(0)
Problem p02753 (python)

Fixed submission:
s = input()
if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n,p = map(int,input().split())
s = list(map(int,(list(input()))))

def keychange(dic,x):
    newdic = {}
    for k in dic:
        b = (k*10 + x) % p
        newdic[b] = dic[k]
    return newdic
dic = {}
count = 0
for i in range(n):
    x = s[i] % p
    dic = keychange(dic,x)
    if x in dic:
        dic[x] += 1
    else:
        dic[x] = 1
    if 0 in dic:
        count += dic[0]
print(count)
Problem p02762 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)
class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n
        self.count = [1]*n
    def find(self, 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 = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parents[y] = x
        self.count[x] +=  self.count[y]
n,m,k = map(int,input().split())
uf = UnionFind(n)
block = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1) 
    block[a-1].append(b-1)
    block[b-1].append(a-1)
for i in range(k):
    c,d = map(int,input().split())
    if uf.find(c-1) == uf.find(d-1):
        block[c-1].append(d-1)
        block[d-1].append(c-1)
ans = []
for i in range(n):
    ans.append(uf.count[uf.find(i)]-len(block[i])-1)
print(" ".join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.parents = [-1]*n
        self.count = [1]*n
    def find(self, 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 = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parents[y] = x
        self.count[x] +=  self.count[y]

n,m,k = map(int,input().split())
uf = UnionFind(n)
block = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1) 
    block[a-1].append(b-1)
    block[b-1].append(a-1)
for i in range(k):
    c,d = map(int,input().split())
    if uf.find(c-1) == uf.find(d-1):
        block[c-1].append(d-1)
        block[d-1].append(c-1)
ans = []
for i in range(n):
    ans.append(uf.count[uf.find(i)]-len(block[i])-1)
print(" ".join(map(str,ans)))
Problem p02773 (python)

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
ans = []
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
    if max_count == 1:
      ans.append(s[i])
if max_count == 1:
  ans.append(s[n-1])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
ans = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
for i in range(n):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
length = 0
word_list = []
for i in range(n):
  word = input()
  if len(word) > length:
    word_list = [word]
  if len(word) = length:
    word_list.append(word)
word_list.sort()
for k in range(len(word_list)):
  print(word_list[k])

Buggy submission (verdict: Runtime Error):
n = int(input())
length = 0
word_list = []
for i in range(n):
  word = input()
  if len(word) > length:
    word_list = [word]
  if len(word) = length:
    word.append(word_list)
word_list.sort()
for k in range(len(word_list)):
  print(word_list[k])
Problem p02785 (python)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
del a[:min(n,k)]
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=true)
for i in range(min(n,k)):
  pop(0)
print(sum(a))
Problem p02793 (python)

Fixed submission:
from fractions import gcd
mod = 10**9+7
n = int(input())
a = list(map(int,input().split()))
ans = 0
l = 1
for i in a:
    l = l*i//gcd(l,i)
l %= mod
for i in a:
    ans = (ans +l*pow(i,mod-2,mod)) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
mod = 10**9+7
n = int(input())
a = list(map(int(input().split())))
ans = 0
l = 1
for i in range(n):
    l = l*a[i]//gcd(l,a[i])
for i in a:
    ans = (ans + l*pow(i,mod-2,mod)) % mod
print(ans)
Problem p02833 (python)

Fixed submission:
n = int(input())
if n % 2 == 1:
    print(0)
else:
    count = 0
    n //= 2
    while n > 0:
        n //= 5
        count += n
    print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 1:
    print(0)
else:
    count = 0
    n //= 2
    while n > 0:
        n//= 5
        count += n
	print(count)
Problem p02862 (python)

Fixed submission:
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
        return 1
    if r == 1:
        return n % mod 
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
x,y = map(int,input().split())
if 2*x-y < 0 or 2*y-x<0 or (2*x-y) % 3 != 0:
    print(0)
    exit()
a = (2*x-y)//3
b = (2*y-x)//3
print(cmb(a+b,min(a,b),mod))

Buggy submission (verdict: Runtime Error):
from functools import reduce
import sys
sys.setrecursionlimit(100000)
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
x,y = map(int,input().split())
if 2*x-y < 0 or 2*y-x<0 or (2*x-y) % 3 != 0:
    print(0)
    exit()
a = (2*x-y)//3
b = (2*y-x)//3
print(cmb(a+b,min(a,b),mod))

Buggy submission (verdict: Runtime Error):
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
x,y = map(int,input().split())
if 2*x-y < 0 or 2*y-x<0 or (2*x-y) % 3 != 0:
    print(0)
    exit()
a = (2*x-y)//3
b = (2*y-x)//3
print(cmb(a+b,min(a,b),mod))
Problem p02925 (python)

Fixed submission:
from collections import defaultdict,deque
def hash(x,y):
    x,y =min(x,y),max(x,y)
    return x*(N+1)+y
s = set()
N = int(input())
edge = [[] for _ in range(N*N+N)]
ind = [0]*(N*N+N)
for i in range(1,N+1):
    A = list(map(int,input().split()))
    s.add(hash(i,A[0]))
    for j in range(N-2):
            edge[hash(i,A[j])].append(hash(i,A[j+1]))
            ind[hash(i,A[j+1])] += 1
d = deque()
nd = deque()
for hash in s:
    if ind[hash] == 0:
        d.append(hash)
ans = 0
finished = 0
while d:
    while d:
        hash = d.popleft()
        finished += 1
        for nhash in edge[hash]:
            ind[nhash] -= 1
            if ind[nhash] == 0:
                nd.append(nhash)
    d = nd
    nd = deque()
    ans += 1
if finished == N*(N-1)//2:
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from numba import njit

@njit('(i4,i4[:])',cache=True)
def solve(N,A):
    cur = np.zeros(N,np.int32)
    for i in range(N*(N-1)//2):
        already = np.zeros(N,np.int32)
        for j in range(N):
            if already[j]:
                continue
            k = A[j][cur[j]]-1
            if already[k]:
                continue
            if A[k][cur[k]]-1 == j:
                already[j] = 1
                already[k] = 1
                cur[j] += 1
                cur[k] += 1
        for j in range(N):
            if cur[j] != N-1:
                break
        else:
            return i+1
    return -1

N = int(readline())
A = np.zeros((N,N),np.int32)
for i in range(N):
    A[i][:-1] = np.array(readline().split(),np.int32)
    A[i][-1] = -1
print(solve(N,A))
Problem p02990 (python)

Fixed submission:
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    r = min(r,n-r)
    if r == 0:
        return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans

n,k = map(int,input().split())
for i in range(1,k+1):
    if n-k+1  < i :
        print(0)
    else:
        print(cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod) % mod)

Buggy submission (verdict: Runtime Error):
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    r = min(r,n-r)
    if r == 0:
        return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans

n,k = map(int,input().split())
for i in range(1,k+1):
    print(cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod) % mod)
Problem p03003 (python)

Fixed submission:
mod = 10**9+7
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
dp = [[1]*(M+1) for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = (dp[i-1][j]+dp[i][j-1]) % mod
        else:
            dp[i][j] = (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]) % mod
print(dp[N][M])

Buggy submission (verdict: Runtime Error):
mod = 10**9+7
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
dp = [[1]*(N+1) for _ in range(M+1)]
for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = (dp[i-1][j]+dp[i][j-1]) % mod
        else:
            dp[i][j] = (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]) % mod
print(dp[N][M])
Problem p03017 (python)

Fixed submission:
N,A,B,C,D = map(int,input().split())
S = ['#']+list(input())
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
if C < D:
    CanChange = True
else:
    for i in range(B,D+1):
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
            CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N,A,B,C,D = map(int,input().split())
S = ['#']+list(input())
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
if C < D:
    CanChange = True
for i in range(B,D+1):
    if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
        CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')
Problem p03042 (python)

Fixed submission:
s = list(map(int,list(input())))
a = s[0]*10+s[1]
b = s[2]*10+s[3]
lst = [1,2,3,4,5,6,7,8,9,10,11,12]
if a in lst:
    if b in lst:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b in lst:
        print('YYMM')
    else:
        print('NA')

Buggy submission (verdict: Runtime Error):
s = list(map(int,list(input()))
a = s[0]*10+s[1]
b = s[2]*10+s[3]
lst = [1,2,3,4,5,6,7,8,9,10,11,12]
if a in lst:
    if b in lst:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b in lst:
        print('YYMM')
    else:
        print('NA')
Problem p03332 (python)

Fixed submission:
mod = 998244353
N,A,B,K = map(int,input().split())
def cmb(n,k):
    return fac[n]*inv_fac[n-k]*inv_fac[k] % mod
fac = [1]
for i in range(1,N+1):
    fac.append(fac[-1]*i % mod)
inv_fac = [pow(fac[N],mod-2,mod)]
for i in range(1,N+1)[::-1]:
    inv_fac.append(inv_fac[-1]*i % mod)
inv_fac = inv_fac[::-1]

ans = 0
for i in range(N+1):
    if i*A > K:
        break
    if (K-i*A) % B == 0:
        j = (K-i*A)//B
        if j <= N:
            ans += cmb(N,i)*cmb(N,j)
            ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
mod = 998244353
N,A,B,K = map(int,input().split())
def cmb(n,k):
    return fac[n]*inv_fac[n-k]*inv_fac[k] % mod
fac = [1]
for i in range(1,N+1):
    fac.append(fac[-1]*i % mod)
inv_fac = [pow(fac[N],mod-2,mod)]
for i in range(1,N+1)[::-1]:
    inv_fac.append(inv_fac[-1]*i % mod)
inv_fac = inv_fac[::-1]

ans = 0
for i in range(N+1):
    if i*A > K:
        break
    if (K-i*A) % B == 0:
        j = (K-i*A)//B
        ans += cmb(N,i)*cmb(N,j)
        ans %= mod
print(ans)
Problem p03617 (python)

Fixed submission:
Q,H,S,D = map(int,input().split())
N = int(input())
X = min(4*Q,2*H,S)
Y = min(2*X,D)
print((N//2)*Y+(N%2)*X)

Buggy submission (verdict: Runtime Error):
Q,H,S,D = map(int,input().split())
X = min(4*Q,2*H,S)
Y = min(2*X,D)
print((N//2)*Y+(N%2)*X)
Problem p03723 (python)

Fixed submission:
from time import time
t = time()
count = 0
a,b,c = map(int,input().split())
while True:
    if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
        print(count)
        exit()
    count += 1
    a1 = b//2+c//2
    b1 = c//2+a//2
    c1 = a//2+b//2
    a = a1
    b = b1
    c = c1
    if time()-t >= 1.8:
        print(-1)
        exit()

Buggy submission (verdict: Runtime Error):
from time import time
t = time()
count = 0
a = int(input())
b = int(input())
c = int(input())
while True:
    if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
        print(count)
        exit()
    count += 1
    a1 = b//2+c//2
    b1 = c//2+a//2
    c1 = a//2+b//2
    a = a1
    b = b1
    c = c1
    if time()-t >= 1.8:
        print(-1)
        exit()
Problem p02550 (python)

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

if N==1 or M==1:
    print(X)
    exit()

F=(N-1).bit_length()

A=[[0]*M for _ in range(F)]

for x in range(M):
    A[0][x]=(x*x)%M

for d in range(1,F):
    for x in range(M):
        A[d][x]=A[d-1][A[d-1][x]]

S=[[0]*M for _ in range(F)]
for x in range(M):
    S[0][x]=A[0][x]

for d in range(1,F):
    for x in range(M):
        S[d][x]=S[d-1][x]+S[d-1][A[d-1][x]]

Ans=0
depth=0
N-=1
Y=X
while N>0:
    if N%2:
        Ans+=S[depth][X]
        X=A[depth][X]
    depth+=1
    N>>=1
print(Ans+Y)

Buggy submission (verdict: Runtime Error):
N,X,M=map(int,input().split())
F=(N-1).bit_length()

A=[[0]*M for _ in range(F)]

for x in range(M):
    A[0][x]=(x*x)%M

for d in range(1,F):
    for x in range(M):
        A[d][x]=A[d-1][A[d-1][x]]

S=[[0]*M for _ in range(F)]
for x in range(M):
    S[0][x]=A[0][x]

for d in range(1,F):
    for x in range(M):
        S[d][x]=S[d-1][x]+S[d-1][A[d-1][x]]

Ans=0
depth=0
N-=1
Y=X
while N>0:
    if N%2:
        Ans+=S[depth][X]
        X=A[depth][X]
    depth+=1
    N>>=1
print(Ans+Y)