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

Fixed submission:
array = ['L','R','U','D']
s = input()
c = 0
for i in range(len(s)):
  if i%2 == 1:
    if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
      continue
    else:
      c = 1
  if i%2 == 0:
    if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
      continue
    else:
      c = 1
if c== 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
array = ['L','R','U','D']
s = input()
c = 0
for i in range(len(s)):
  if i%2 == 0:
    if s[i] = 'L' or s[i] = 'U' or s[i] = 'D':
      continue
    else:
      c = 1
  if i%2 == 1:
    if s[i] = 'R' or s[i] = 'U' or s[i] = 'D':
      continue
    else:
      c = 1
if c== 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
c = 0
for i in range(50):
  if S[2*i] == 'R' or S[2*i] == 'U' or S[2*i] == 'D':
    continue
  else:
    c = 1
for j in range(49):
  if S[2*j+1] == 'L' or S[2*j+1] == 'U' or S[2*j+1] == 'D':
    continue
  else:
    c = 1
if c == 1:
  print('No')
else:
  print('Yes')
Problem p02922 (python)

Fixed submission:
A,B = map(int,input().split())
sum = 1
c = 0
if B == 1:
  print(0)
else:
  while sum < B:
    sum = sum + A -1
    c += 1
  print(c)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
sum = 1
if B == 1:
  print(0)
else:
  for i in range(1,A+1):
    sum = sum + A -1
    if sum >= B:
      break
print(i)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
sum = 1
if A >= B:
  print(0)
else:
  for i in range(1,A+1):
    sum = sum + A -1
    if sum >= B:
      break
print(i)
Problem p02937 (python)

Fixed submission:
s = input()
t = input()
lent = len(t)
tcount = 0
snow = 0
count = 0
flag = True
if t[0] not in s:
    print(-1)
else:
    snow = s.index(t[0])
    while True:
        tcount += 1
        if tcount == lent:
            break
        if t[tcount] in s[snow+1:]:
            snow = s[snow+1:].index(t[tcount])+snow+1
        elif t[tcount] in s:
            snow = s.index(t[tcount])
            count += 1
        else:
            flag = False
            break
    if flag:
        print(count*len(s) + snow+1)
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
lent = len(t)
tcount = 0
snow = 0
count = 0
flag = True
while True:
    snow = s.index(t[tcount])
    tcount += 1
    if tcount == lent:
        break
    if t[tcount] not in s:
        flag = False
        break
    if t[tcount] in s[snow+1:]:
        snow = s[snow+1:].index(t[tcount])
    else:
        snow = s.index(t[tcount])
        count += 1
if flag:
    print(count*len(s) + s.index(t[-1])+1)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
lent = len(t)
tcount = 0
snow = 0
count = 0
flag = True
while True:
    if tcount == lent:
        break
    if t[tcount] not in s:
        flag = False
        break
    snow = s.index(t[tcount])
    tcount += 1
    if t[tcount] in s[snow+1:]:
        snow = s[snow+1:].index(t[tcount])
    else:
        snow = s.index(t[tcount])
        count += 1
if flag:
    print(count*len(s) + s.index(t[-1])+1)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
lent = len(t)
tcount = 0
snow = 0
count = 0
flag = True
while True:
    if t[tcount] not in s:
        flag = False
        break
    snow = s.index(t[tcount])
    tcount += 1
    if tcount == lent:
        break
    if t[tcount] in s[snow+1:]:
        snow = s[snow+1:].index(t[tcount])
    else:
        snow = s.index(t[tcount])
        count += 1
if flag:
    print(count*len(s) + s.index(t[-1])+1)
else:
    print(-1)
Problem p02957 (python)

Fixed submission:
A,B = map(int,input().split())
if (A+B)%2 == 0:
  print(int((A+B)//2))
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
if (A+B)%2 == 0:
  pint(int((A+B)//2))
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
if (A+B)%2 == 0:
  pint(int((A+B)//2))
else:
  print(('IMPOSSIBLE')
Problem p03029 (python)

Fixed submission:
A,P = map(int,input().split())
print(int(((3*A)+P)//2))

Buggy submission (verdict: Runtime Error):
A,P = map(int,input())
print(int(((3*A)+P)//2))
Problem p03037 (python)

Fixed submission:
N,M = map(int,input().split())
array = []
for i in range(M):
    a = list(map(int,input().split()))
    array.append(a)
maxa = max([i[1] for i in array])
array2 = [0 for i in range(maxa+2)]
for i in array:
    array2[i[0]] += 1
    array2[i[1]+1] -= 1
for i in range(len(array2)-1):
    array2[i+1] += array2[i]
print(array2.count(M))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
array = []
for i in range(M):
    a = list(map(int,input().split()))
    array.append(a)
maxa = max(array)
maxa = maxa[1]
array2 = [0 for i in range(maxa+2)]
for i in array:
    array2[i[0]] += 1
    array2[i[1]+1] -= 1
for i in range(len(array2)-1):
    array2[i+1] += array2[i]
print(array2.count(M))
Problem p03061 (python)

Fixed submission:
N = int(input())
A=sorted(list(map(int,input().split())))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
ans = []
gcdlist = [A[0]]
for i in range(1,N):
    gcdlist.append(gcd(gcdlist[i-1],A[i]))
gcdlistr = [A[-1]]
for i in range(N-2,-1,-1):
    gcdlistr.append(gcd(gcdlistr[N-i-2],A[i]))
gcdlistr.reverse()
gcdlist.insert(0,0)
gcdlist.append(0)
gcdlistr.insert(0,0)
gcdlistr.append(0)
for i in range(N):
    ans.append(gcd(gcdlist[i],gcdlistr[i+2]))
print(max(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
A=sorted(list(map(int,input().split())))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def gcdlist(lista):
    if len(lista) == 1:
        return lista[0]
    else:
        from functools import reduce
        return reduce(gcd,lista)
first = A.pop(0)
ans = []
second = A[0]
gcda = gcdlist(A[1:])
for i in range(first,second+1):
    ans.append(gcd(i,gcda))
print(max(ans))
Problem p03062 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
absA = [abs(i) for i in A]
minusA = [i for i in A if i<0]
mina = min(absA)
if (0 in A) or (len(minusA)%2 == 0):
    print(sum(absA))
else:
    print(sum(absA) -2*mina)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
absA = [abs(i) for i in A]
minusA = [i for i in A if i<0]
mina = min(absA)
if (0 in A) or (len(minusA)%2 == 0):
    print(sum(absA))
else:
    print(absA -2*mina)
Problem p03068 (python)

Fixed submission:
N = int(input())
S = input()
K = int(input())
ans = ''
for i in S:
  if i == S[K-1]:
    ans += i
  else:
    ans += '*'
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
K = int(input())
ans = ''
for i in S:
  if i = S[K-1]:
    ans += S[i]
  else:
    ans += '*'
print(ans)
Problem p03126 (python)

Fixed submission:
N,M = map(int,input().split())
array2 = [0 for i in range(M+1)]
for i in range(N):
  array = list(map(int,input().split()))
  array.pop(0)
  for j in array:
    array2[j] += 1
c = 0
for k in array2:
  if k == N:
    c += 1
print(c)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
array2 = [0 for i in range(M+1)]
for i in range(N):
  array = list(map(int,input().split()))
  array.pop[0]
  for j in array:
    array2[j] += 1
c = 0
for k in array2:
  if k == N:
    c += 1
print(c)
Problem p03130 (python)

Fixed submission:
lista = []
for i in range(3):
  a,b = map(int,input().split())
  lista.append(a)
  lista.append(b)
l1 = 0
l2 = 0
l3 = 0
l4 = 0
for j in lista:
  if j == 1:
    l1 += 1
  if j == 2:
    l2 += 1
  if j == 3:
    l3 += 1
  if j == 4:
    l4 += 1
c = (l1)%2 + (l2)%2 + (l3)%2 + (l4)%2
if c <= 2:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
lista = []
for i in range(3):
  a,b = map(int,input().split()))
  lista.append(a)
  lista.append(b)
l1 = 0
l2 = 0
l3 = 0
l4 = 0
for j in lista:
  if j == 1:
    l1 += 1
  if j == 2:
    l2 += 1
  if j == 3:
    l3 += 1
  if j == 4:
    l4 += 1
c = l1%2 + l2%2 + l3%2 + l4%2
if c%2 == 0:
  print('YES')
else:
  print('NO')
Problem p03136 (python)

Fixed submission:
N = int(input())
Larray = list(map(int,input().split()))
lmax = max(Larray)
Larray.remove(lmax)
ltot = 0
for i in Larray:
  ltot += i
if lmax < ltot:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
Larray = list(map(int,input().split()))
lmax = max(Larray)
Larray.remove(lmax)
ltot = 0
for i in range(Larray):
  ltot += i
if lmax > ltot:
  print('Yes')
else:
  print('No')
Problem p03148 (python)

Fixed submission:
import heapq
N,K = map(int,input().split())
td = [list(map(int,input().split())) for i in range(N)]
td.sort(key = lambda x:-x[1])
sumn = [[] for i in range(N)]
for i in range(N):
    heapq.heapify(sumn[i])
ans = 0
kind = {}
for t,d in td[:K]:
    if t not in kind:
        kind[t] = 1
    else:
        kind[t] += 1
    heapq.heappush(sumn[t-1],d)
kinds = len(kind)
ans = sum(sum(i) for i in sumn)
ans1 = ans +kinds**2
rem = td[K:]
nex = 0
candel = []
heapq.heapify(candel)
for k,v in kind.items():
    for i in range(v-1):
        heapq.heappush(candel,heapq.heappop(sumn[k-1]))
if candel:
    qd = heapq.heappop(candel)
    while K+nex < N:
        if td[K+nex][0] not in kind:
            kind[td[K+nex][0]] = 1
            kinds += 1
            ans = ans - qd + td[K+nex][1]
            ans1 = max(ans1,ans+kinds**2)
            nex += 1
            if candel:
                qd = heapq.heappop(candel)
            else:
                break
        else:
            nex += 1
print(ans1)

Buggy submission (verdict: Runtime Error):
import heapq
N,K = map(int,input().split())
td = [list(map(int,input().split())) for i in range(N)]
td.sort(key = lambda x:-x[1])
sumn = [[] for i in range(N)]
for i in range(N):
    heapq.heapify(sumn[i])
ans = 0
kind = {}
for t,d in td[:K]:
    if t not in kind:
        kind[t] = 1
    else:
        kind[t] += 1
    heapq.heappush(sumn[t-1],d)
kinds = len(kind)
ans = sum(sum(i) for i in sumn)
ans1 = ans +kinds**2
rem = td[K:]
nex = 0
candel = []
heapq.heapify(candel)
for k,v in kind.items():
    for i in range(v-1):
        candel.append(heapq.heappop(sumn[k-1]))
qd = heapq.heappop(candel)
while K+nex < N:
    if td[K+nex][0] not in kind:
        kind[td[K+nex][0]] = 1
        kinds += 1
        ans = ans - qd + td[K+nex][1]
        ans1 = max(ans1,ans+kinds**2)
        nex += 1
        if candel:
            qd = heapq.heappop(candel)
        else:
            break
    else:
        nex += 1
print(ans1)

Buggy submission (verdict: Runtime Error):
import heapq
N,K = map(int,input().split())
td = [list(map(int,input().split())) for i in range(N)]
td.sort(key = lambda x:-x[1])
sumn = [[] for i in range(N)]
for i in range(N):
    heapq.heapify(sumn[i])
ans = 0
kind = {}
for t,d in td[:K]:
    if t not in kind:
        kind[t] = 1
    else:
        kind[t] += 1
    heapq.heappush(sumn[t-1],d)
kinds = len(kind)
ans = sum(sum(i) for i in sumn)
ans1 = ans +kinds**2
rem = td[K:]
nex = 0
candel = []
heapq.heapify(candel)
for k,v in kind.items():
    for i in range(v-1):
        candel.append(heapq.heappop(sumn[k-1]))
qd = heapq.heappop(candel)
while K+nex < N:
    if td[K+nex][0] not in kind:
        kind[td[K+nex][0]] = 1
        kinds += 1
        ans = ans - qd + td[K+nex][1]
        ans1 = max(ans1,ans+kinds**2)
        nex += 1
        if candel:
            qd = heapq.heappop(candel)
        else:
            break
    else:
        nex += 1
print(ans1)
Problem p03161 (python)

Fixed submission:
def main():
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [0]*N
    for i in range(1,N):
        dp[i]= min(abs(h[i]-h[j])+dp[j] for j in range(max(0,i-K),i))
    print(dp[-1])
main()

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]

for i in range(1,K):
  for j in range(0,i):
    dpa = 10**4+1
    if dpa > abs(h[i]-h[i-j-1])+dp[i-j-1]:
      dpa = abs(h[i]-h[i-j-1])+dp[i-j-1]
  dp.append(dpa)


for k in range(K,N):
  for l in range(K):
    dpa = 10**4+1
    if dpa > abs(h[k]-h[k-l-1])+dp[k-l-1]:
      dpa = abs(h[k]-h[k-l-1])+dp[k-l-1]
  dp.append(dpa)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,K+1):
  for j in range(1,i):
      dpx = min(dpx, abs(h[i]-h[i-j])+dp[i-j])
  dp.append(dpx)
for k in range(K+1,N+1):
  for l in range(1,K+1):
    dpx = min(dpx, abs(h[k]-h[k-l])+dp[k-l])
  dp.append(dpx)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,K+1):
  for j in range(1,i):
      dpx = min(dpx, abs(h[i]-h[i-j])+dp[i-j])
  dp.append(dpx)
for k in range(K+1,N+1):
  for l in range(1,K+1):
    dpx = min(dpx, abs(h[i]-h[i-j])+dp[i-j])
  dp.append(dpx)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,N):
  for j in range(i):
      dpx = min(dpx, abs(h[i]-h[i-j])+dp[i-j])
  dp.append(dpx)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,N):
  for j in range(1,K+1):
      dpx = min(dpx, abs(h[i]-h[N-j])+dp[N-j])
  dp.append(dpx)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,K):
  for j in range(0,i):
      dpx = min(dpx, abs(h[i]-h[j])+dp[j])
  dp.append(dpx)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,K+1):
  for j in range(0,i):
      dpx = min(dpx, abs(h[i]-h[j])+dp[j])
  dp.append(dpx)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
dpx = 10**4+1
for i in range(1,K+1):
  for j in range(0,i):
      dpx = min(dpx, abs(h[i]-h[j]))
  dp.append(dpx)
print(dp[-1])
Problem p03162 (python)

Fixed submission:
def main():
    N = int(input())
    
    array = []
    
    for i in range(N):
        array2 = list(map(int,input().split()))
        array.append(array2)

    num = [[0,0,0] for z in range(N)]
    for m in range(3):
        num[0][m] = array[0][m]

    

    for j in range(1,N):
        
        for z in range(3):
            if z == 0:
                num[j][z] = array[j][z]+max(num[j-1][1],num[j-1][2])
                    
            if z == 1:
                num[j][z] =array[j][z]+max(num[j-1][0],num[j-1][2])
            if z == 2:
                num[j][z] =array[j][z]+max(num[j-1][1],num[j-1][0])
        
    
    print(max(num[-1]))
    
main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    dp = [0]*N
    array = []
    sum = 0
    for i in range(N):
        array2 = list(map(int,input().split()))
        array.append(array2)
    num = [[0,0,0] for z in range(N)]
    dp[0] = max(array[0][n] for n in range(3))
    for m in range(3):
        if dp[0] == array[0][m]:
            num[0][m] = 1
    
    
    for z in range(3):
        if num[0][z] == 1:
            dp[1] = max(dp[1],max(array[1][1],array[1][2])+dp[0])
            num[1][z] = 1
    

    for j in range(2,N):
        dpj = []
        for z in range(3):
            if 1 == num[j-1][z]:
                num[j][z] = 1
                dpj.append(max(array[j][1],array[j][2])+dp[j-1])
        dp[j] = max(dpj)
    
    print(dp[-1])
    
main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    dp = [0]*N
    array = []
    sum = 0
    for i in range(N):
        array2 = list(map(int,input().split()))
        array.append(array2)
    num = [[0,0,0] for z in range(N)]
    dp[0] = max(array[0][n] for n in range(3))
    for m in range(3):
        if dp[0] == array[0][m]:
            num[0][m] = 1
    
    
    for z in range(3):
        if num[0][z] == 1:
            dp[1] = max(dp[1],max(array[1][1],array[1][2])+dp[0])
            num[1][z] = 1
    
    print(num)
    for j in range(2,N):
        dpj = []
        for z in range(3):
            if 1 == num[j-1][z]:
                num[j][z] = 1
                dpj.append(max(array[j][1],array[j][2])+dp[j-1])
        dp[j] = max(dpj)
    
    print(dp[-1])
    
main()
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N,M = map(int,input().split())
XY = [[] for m in range(N)]
for l in range(M):
    x,y = map(int,input().split())
    XY[x-1].append(y-1)

dp = [-1 for k in range(N)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    c = 0
    start = XY[i]
    for s in start:
        c = max(c,search(s)+1)
    dp[i] = c
    return dp[i]

a = 0
for i in range(N):
    a = max(a,search(i))
print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
XY = [[] for i in range(N)]
for l in range(M):
    x,y = map(int,input().split())
    XY[x-1].append(y-1)

dp = [-1 for k in range(N)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    c = 0
    start = XY[i]
    for s in start:
        c = max(c,search(s)+1)
    dp[i] = c
    return dp[i]

a = 0
for i in range(N):
    a = max(a,search(i))
print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
XY = [[] for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    XY[x-1].append(y-1)

dp = [-1 for i in range(N)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    c = 0
    start = XY[i]
    for s in start:
        c = max(c,search(s)+1)
    dp[i] = c
    return dp[i]

a = 0
for i in range(N):
    a = max(a,search(i))
print(a)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
XY = [[] for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    XY[x-1].append(y-1)
print(XY)

dp = [-1 for i in range(N)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    c = 0
    start = XY[i]
    for s in start:
        c = max(c,search(s)+1)
        
    dp[i] = c
    return dp[i]

a = 0
for i in range(N):
    a = max(a,search(i))
print(a)
Problem p03231 (python)

Fixed submission:
N,M = map(int,input().split())
def gcd(a,b):
    if a >= b:
        if b == 0:
            return a
        else:
            return gcd(b,a%b)
    else:
        if a == 0:
            return b
        else:
            return gcd(a,b%a)
S = input()
T = input()
if S[0] != T[0]:
    print(-1)
else:
    flag = True
    L = int((N//gcd(N,M))*M)
    m = L//M
    n = L//N
    for i in range(max(N,M)):
        if i*m <= N-1 and i*n <= M-1:
            if S[i*m] != T[i*n]:
                flag = False
                break
    if flag:
        print(L)
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
def gcd(a,b):
    if a >= b:
        if b == 0:
            return a
        else:
            return gcd(b,a%b)
    else:
        if a == 0:
            return b
        else:
            return gcd(a,b%a)
S = input()
T = input()
if S[0] != T[0]:
    print(-1)
else:
    flag = True
    L = int((N//gcd(N,M))*M)
    m = L//M
    n = L//N
    for i in range(min(N,M)):
        if i*m <= N-1 and i*n <= M-1:
            if S[i*m*L//N] != T[i*n*L//M]:
                flag = False
                break
    if flag:
        print(L)
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
def gcd(a,b):
    if a >= b:
        if b == 0:
            return a
        else:
            return gcd(b,a%b)
    else:
        if a == 0:
            return b
        else:
            return gcd(a,b%a)
S = input()
T = input()
if S[0] != T[0]:
    print(-1)
else:
    flag = True
    if N//M >= 2:
        for i in range(M):
            x = (N*i)//M
            if T[x*(L//M)+1] != S[i*(L//N)+1]:
                flag = False
    if M//N >= 2:
        for i in range(N):
            y = (N*i)//M
            if T[i*(L//M)+1] != S[y*(L//N)+1]:
                flag = False
    if flag:
        print(int((N//gcd(N,M))*M))
    else:
        print(-1)
Problem p03239 (python)

Fixed submission:
N,T = map(int,input().split())
ct = [list(map(int,input().split())) for i in range(N)]
ct = sorted([i for i in ct if i[1]<= T])
if ct:
    print(ct[0][0])
else:
    print('TLE')

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
ct = [list(map(int,input().split())) for i in range(N)]
ct = sorted([i for i in ct if i[1]<= T])
print(ct[0][0])
Problem p03283 (python)

Fixed submission:
N,M,Q = map(int,input().split())
num = [[0 for i in range(N)] for j in range(N)]
for i in range(M):
    l,r = list(map(int,input().split()))
    l -= 1
    r -= 1
    num[l][r] += 1
for i in range(N):
    for j in range(N-1):
        num[i][j+1] += num[i][j]
for i in range(N-1,0,-1):
    for j in range(N):
        num[i-1][j] += num[i][j]
for i in range(Q):
    p,q = map(int,input().split())
    print(num[p-1][q-1])

Buggy submission (verdict: Runtime Error):
N,M,Q = map(int,input().split())
num = [[0 for i in range(N)] for j in range(N)]
lr = [list(map(int,input().split())) for i in range(M)]
for l,r in lr:
    num[l-1][r-1] += 1

for j in range(N):
    for i in range(N-1,0,-1):
        num[i-1][j] += num[i][j]
for i in range(N):
    for j in range(N-1):
        num[i][j+1] += num[i][j]
pq = [list(map(int,input().split())) for i in range(M)]
for p,q in pq:
    print(num[p-1][q-1])
Problem p03338 (python)

Fixed submission:
from collections import Counter
N = int(input())
S = input()
array = []
for i in range(1,N):
    S1 = list(S[:i])
    S2 = list(S[i:])
    S1c = Counter(S1)
    S2c = Counter(S2)
    suma = 0
    for k in S1c:
        if k in S2c:
            suma += 1
    array.append(suma)
print(max(array))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = input()
array = []
for i in range(1,N-1):
    S1 = list(S[:i])
    S2 = list(S[i:])
    S1c = Counter(S1)
    S2c = Counter(S2)
    suma = 0
    for k in S1c:
        if k in S2c:
            suma += 1
    array.append(suma)
print(max(array))
Problem p03352 (python)

Fixed submission:
X = int(input())
if X == 1:
    print(1)
else:
    maxa = 0
    for i in range(2,32):
        for j in range(2,11):
            if i**j <= X:
                maxa = max(maxa,i**j)
    print(maxa)

Buggy submission (verdict: Runtime Error):
X = int(input())
if X == 1:
    print(1)
else:
    maxa = 0
    for i in range(2,32):
        for j in range(2,11):
            if i**j <= X:
                maxa = max(maxa,i**j)
print(maxa)
Problem p03361 (python)

Fixed submission:
H,W = map(int,input().split())
mat = []
for i in range(H):
    a = list(input())
    mat.append(a)

def search(y,x):
    if mat[y][x] == '#':
        y2 = [0,0,1,-1]
        x2 = [1,-1,0,0]
        for i in range(4):
            if 0<=y+y2[i]<=H-1 and 0<=x+x2[i]<=W-1:
                if mat[y+y2[i]][x+x2[i]] == '#':
                    return True
        return False
    
    return True
ans = 'Yes'
for i in range(H):
    for j in range(W):
        if ans == 'No':
            break
        if search(i,j):
            continue
        else:
            ans = 'No'
            break
print(ans)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
mat = []
for i in range(H):
    a = list(input())
    mat.append(a)

def search(y,x):
    if mat[y][x] == '#':
        y2 = [0,0,1,-1]
        x2 = [1,-1,0,0]
        for i in range(4):
            if 0<=y+y2[i]<=H-1 and 0<=x+x2[i]<=W-1:
                if mat[y+y2[i]][x+x2[i]] == '#':
                    return True
        return False
    
    return True
ans = 'Yes'
for i in range(H):
    for j in range(W):
        if ans == 'No':
            break
        if search(j,i):
            continue
        else:
            ans = 'No'
            break
print(ans)