Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort()

def bisec(i,k): #ギリギリokなj<=j_を探す
    ci = i
    ck = k
    i+=1
    k-=1
    j = (i+k)//2
    while k-i>1:
        if l[ci]+l[j]>l[ck]:
            k = j
            j = (i+k)//2
        else:
            i = j+1
            j = (i+k)//2
    if l[ci]+l[i]>l[ck]:
        return i
    elif l[ci]+l[i+1]>l[ck]:
        return i+1
    else:
        return -1

for i in range(n):
#     for j in range(i+1,n):  i<j<kでl[i]+l[j]>l[k]を満たすものを二分探索
    for k in range(i+2,n):
        j = bisec(i,k)
        if j>=0:
            ans += k-j
print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort()

def bisec(i,k): #ギリギリokなj<=j_を探す
    ci = i
    ck = k
    i+=1
    k-=1
    j = int((i+k)/2)
    while k-i>1:
        if l[ci]+l[j]>l[ck]:
            k = j
            j = int((i+k)/2)
        else:
            i = j+1
            j = int((i+k)/2)
    if l[ci]+l[i]>l[ck]:
        return True,i
    elif l[ci]+l[i+1]>l[ck]:
        return True,i+1
    else:
        return False,-1

for i in range(n):
    for k in range(i+2,n):
        f,j = bisec(i,k)
        if f:
            ans += k-j
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort()
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i]+l[j]>l[k]:
                ans += 1
            else:
                break
print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort()

def bisec(i,k): #ギリギリokなj<=j_を探す
    ci = i
    ck = k
    i+=1
    k-=1
    j = int((i+k)/2)
    while k-i>1:
        if l[ci]+l[j]>l[ck]:
            k = j
            j = int((i+k)/2)
        else:
            i = j+1
            j = int((i+k)/2)
    if l[ci]+l[i]>l[ck]:
        return True,i
    elif l[ci]+l[i+1]>l[ck]:
        return True,i+1
    else:
        return False,-1

for i in range(n):
    for k in range(i+2,n):
        f,j = bisec(i,k)
        if f:
            ans += k-j
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort()
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i]+l[j]>l[k]:
                ans += 1
            else:
                break
print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort()

def bisec(i,k): #ギリギリokなj<=j_を探す
    ci = i
    ck = k
    i+=1
    k-=1
    j = int((i+k)/2)
    while k-i>1:
        if l[ci]+l[j]>l[ck]:
            k = j
            j = int((i+k)/2)
        else:
            i = j+1
            j = int((i+k)/2)
    if l[ci]+l[i]>l[ck]:
        return True,i
    elif l[ci]+l[i+1]>l[ck]:
        return True,i+1
    else:
        return False,-1

for i in range(n):
    for k in range(i+2,n):
        f,j = bisec(i,k)
        if f:
            ans += k-j
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
judge(n,l)

def judge(n,l):
    for i in range(n):
        for j in range(j):
            s = 0
            if(j!=i):
                s += l[j]
            if(s>l[i]):
                print('No')
                return
    print('Yes')
    return

Fixed submission:
def judge(n,l):
    for i in range(n):
        s = 0
        for j in range(n):
            if(j!=i):
                s += l[j]
        if(s<=l[i]):
            print('No')
            return
    print('Yes')
    return

n = int(input())
l = list(map(int,input().split()))
judge(n,l)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
dp_ = [-1]*n

def dp(i):
    if dp_[i]!=-1:
        return dp_[i]
    if i == 0:
        dp_[i] = 0
    elif i == 1:
        dp_[i] = abs(h[1]-h[0])
    else:
        dp_[i] = min(dp(i-2)+abs(h[i]-h[i-2]),dp(i-1)+abs(h[i]-h[i-1]))
    return dp_[i]

print(dp(n-1))
print(dp(n-1))

Fixed submission:
import sys
sys.setrecursionlimit(100000) 

n = int(input())
h = list(map(int,input().split()))
dp_ = [-1]*n

def dp(i):
    if dp_[i]!=-1:
        return dp_[i]
    if i == 0:
        dp_[i] = 0
    elif i == 1:
        dp_[i] = abs(h[1]-h[0])
    else:
        dp_[i] = min(dp(i-2)+abs(h[i]-h[i-2]),dp(i-1)+abs(h[i]-h[i-1]))
    return dp_[i]

print(dp(n-1))

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
dp_ = [-1]*n

def dp(i):
    if dp_[i]!=-1:
        return dp_[i]
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[1]-h[0])
    else:
        return min(dp(i-2)+abs(h[i]-h[i-2]),dp(i-1)+abs(h[i]-h[i-1]))

print(dp(n-1))

Fixed submission:
import sys
sys.setrecursionlimit(100000) 

n = int(input())
h = list(map(int,input().split()))
dp_ = [-1]*n

def dp(i):
    if dp_[i]!=-1:
        return dp_[i]
    if i == 0:
        dp_[i] = 0
    elif i == 1:
        dp_[i] = abs(h[1]-h[0])
    else:
        dp_[i] = min(dp(i-2)+abs(h[i]-h[i-2]),dp(i-1)+abs(h[i]-h[i-1]))
    return dp_[i]

print(dp(n-1))

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

def dp(i):
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[1]-h[0])
    else:
        return min(dp(i-2)+abs(h[i]-h[i-2]),dp(i-1)+abs(h[i]-h[i-1]))

print(dp(n-1))

Fixed submission:
import sys
sys.setrecursionlimit(100000) 

n = int(input())
h = list(map(int,input().split()))
dp_ = [-1]*n

def dp(i):
    if dp_[i]!=-1:
        return dp_[i]
    if i == 0:
        dp_[i] = 0
    elif i == 1:
        dp_[i] = abs(h[1]-h[0])
    else:
        dp_[i] = min(dp(i-2)+abs(h[i]-h[i-2]),dp(i-1)+abs(h[i]-h[i-1]))
    return dp_[i]

print(dp(n-1))
Buggy python submission (verdict: Time Limit Exceeded):
#B
n,k = list(map(int,input().split()))
h = list(map(int,input().split()))

cost = [float('inf')]*n
for i in range(n):
    if i == 0:
        cost[i] = 0
        continue    
    for j in range(1,k+1):
        if i-j>=0:
            cost[i] = min(cost[i],cost[i-j]+abs(h[i]-h[i-j]))
print(cost[n-1])

Fixed submission:
#B
n,k = list(map(int,input().split()))
h = list(map(int,input().split()))

dp = [float('inf')]*n
for i in range(n):
    if i == 0:
        dp[i] = 0
        continue    
    for j in range(1,k+1):
        if i-j>=0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
#B
n,k = list(map(int,input().split()))
h = list(map(int,input().split()))

cost = [1000000]*n
for i in range(n):
    if i == 0:
        cost[i] = 0
        continue    
    for j in range(1:k+1):
        if i-j>=0:
            cost[i] = min(cost[i],cost[i-j]+abs(h[i]-h[i-j]))
print(cost[n-1])

Fixed submission:
#B
n,k = list(map(int,input().split()))
h = list(map(int,input().split()))

dp = [float('inf')]*n
for i in range(n):
    if i == 0:
        dp[i] = 0
        continue    
    for j in range(1,k+1):
        if i-j>=0:
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
#D
n,W = list(map(int,input().split()))
w = [0]*n
v = [0]*n
for i in range(n):
    w[i],v[i] = list(map(int,input().split()))
    
dp = [[0 for i in range(W+1)] for j in range(n)]
for i in range(n): #品物iまで
    for j in range(W+1):
        if j == 0:
            dp[i][j] = 0
            continue
        if j-w[i] >= 0:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]] + v[i])
        else:
            dp[i][j] = dp[i-1][j]
print(max([dp[i][W]for i in range(n)]))

Fixed submission:
#D
n,W = list(map(int,input().split()))
w = [0]*n
v = [0]*n
for i in range(n):
    w[i],v[i] = list(map(int,input().split()))
    
dp = [[0 for i in range(W+1)] for j in range(n)]
for i in range(n): #品物iまで
    for j in range(W+1):
        if j == 0:
            dp[i][j] = 0
            continue
        if j-w[i] >= 0:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]] + v[i])
        else:
            dp[i][j] = dp[i-1][j]
print(max([dp[i][W]for i in range(n)]))
Buggy python submission (verdict: Time Limit Exceeded):
#E
n,W = list(map(int,input().split()))
w = [0]*(n+1)
v = [0]*(n+1)
for i in range(1,n+1):
    w[i],v[i]=list(map(int,input().split()))
V = n*max(v)

dp = [[float('inf') for i in range(V+1)] for j in range(n+1)]
#i番目(1:n)の品物までを使って価値の総和がjになるようなときの重さの最小値
dp[0][0] = 0
for i in range(1,n+1):
    for j in range(V+1): #価値
        if j-v[i]>=0:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i]]+w[i])
        else:
            dp[i][j] = dp[i-1][j]
# for i in range(n+1):
#     print(dp[i])
print(max([j for j in range(V+1) if dp[n][j]<=W]))

Fixed submission:
#E
n,W = list(map(int,input().split()))
w = [0]*(n+1)
v = [0]*(n+1)
for i in range(1,n+1):
    w[i],v[i]=list(map(int,input().split()))
V = n*max(v)

dp = [[float('inf') for i in range(V+1)] for j in range(n+1)]
#i番目(1:n)の品物までを使って価値の総和がjになるようなときの重さの最小値
dp[0][0] = 0
for i in range(1,n+1):
    for j in range(V+1): #価値
        if j-v[i]>=0:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i]]+w[i])
        else:
            dp[i][j] = dp[i-1][j]
# for i in range(n+1):
#     print(dp[i])
print(max([j for j in range(V+1) if dp[n][j]<=W]))
Buggy python submission (verdict: Runtime Error):
#ABC106C
s=input()
k=int(input())
cnt=0
while(s[cnt]=='1'):
    cnt+=1
if(k-1<=cnt):
    print('1')
else:
    print(s[cnt])

Fixed submission:
#ABC106C
s=input()
k=int(input())
cnt=0
while(s[cnt]=='1' and cnt!=len(s)-1):
    cnt+=1
if(k-1<cnt):
    print('1')
else:
    print(s[cnt])
Buggy python submission (verdict: Runtime Error):
if r < 1200:
    print('ABC')
elif r < 2800:
    print('ARC')
else:
    print('AGC')

Fixed submission:
r = int(input())
if r < 1200:
    print('ABC')
elif r < 2800:
    print('ARC')
else:
    print('AGC')
Buggy python submission (verdict: Runtime Error):
s = input()
if s[0] == 'A' and s[2,-1].count('C') == 1 and s[1:].replace('C').islower():
    print('AC')
else:
    print('WA')

Fixed submission:
s = input()
if s[0] == 'A' and s[2:-1].count('C') == 1 and s[1:].replace('C','').islower():
    print('AC')
else:
    print('WA')
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
k=k%n
al=list(map(int,input().split()))
pos=0
for val in range(len(al)):
   al[val]-=1
while(k!=0):
  i=pos
  pos=al[i]
  k-=1
print(pos+1)


Fixed submission:
s1=str(input())
s2=str(input())
if (len(s2)-len(s1)!=1):
  print('No')
Flag='Yes'
for val in range(len(s1)):
  if(s1[val]!=s2[val]):
    Flag='No'
print(Flag)

Buggy python submission (verdict: Runtime Error):
s1=str(input())
s2=str(input())
if (len(s2)-len(s1)!=1):
  print('No')
Flag='Yes'
for val in range(len(s1)):
  if(s1[val]=!s2[val]):
    Flag='No'
print(Flag)

Fixed submission:
s1=str(input())
s2=str(input())
if (len(s2)-len(s1)!=1):
  print('No')
Flag='Yes'
for val in range(len(s1)):
  if(s1[val]!=s2[val]):
    Flag='No'
print(Flag)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k=map(int,input().split())
sums=0
while(k!=0):
  if(a!=0):
    a-=1
    k-=1
    sums+=1
  elif(b!=0):
    b-=1
    k-=1
  else:
    c-=1
    k-=1
    sums-=1
print(sums)

Fixed submission:
a,b,c,k=map(int,input().split())
if(a>k):
  print(k)
elif(a+b>k):
  print(a)
else:
  print(a+(a+b-k))
Buggy python submission (verdict: Time Limit Exceeded):
#Frog2
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
dp={1.0:0}
for val3 in range(2,n+1):
    dp[val3]=float(1e9)
for val in range(2,n+1):
    for val2 in range(1,min(val,k+1)):
        dp[val]=min(dp[val],dp[val-val2]+abs(h[int(val)]-h[int(val-val2)]))
print(dp[n])
        

Fixed submission:
#Frog2
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
dp={1.0:0}
for val3 in range(2,n+1):
    dp[val3]=float(1e9)
for val in range(2,n+1):
    for val2 in range(1,min(val,k+1)):
        dp[val]=min(dp[val],dp[val-val2]+abs(h[int(val)]-h[int(val-val2)]))
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
#Frog2
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
dp={1:0}
for val3 in range(2,n+1):
    dp[val3]=int(1e9+9)
for val in range(2,n+1):
    for val2 in range(1,min(val,k+1)):
        dp[val]=min(dp[val],dp[val-val2]+abs(h[val]-h[val-val2]))
print(dp[n])
        

Fixed submission:
#Frog2
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
dp={1.0:0}
for val3 in range(2,n+1):
    dp[val3]=float(1e9)
for val in range(2,n+1):
    for val2 in range(1,min(val,k+1)):
        dp[val]=min(dp[val],dp[val-val2]+abs(h[int(val)]-h[int(val-val2)]))
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
#Frog2
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
dp={1:0}
for val3 in range(2,n+1):
    dp[val3]=int(1e9)
for val in range(2,n+1):
    for val2 in range(1,min(val,k+1)):
        dp[val]=min(dp[val],dp[val-val2]+abs(h[val]-h[val-val2]))
print(dp[n])
        

Fixed submission:
#Frog2
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
dp={1.0:0}
for val3 in range(2,n+1):
    dp[val3]=float(1e9)
for val in range(2,n+1):
    for val2 in range(1,min(val,k+1)):
        dp[val]=min(dp[val],dp[val-val2]+abs(h[int(val)]-h[int(val-val2)]))
print(dp[n])
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
l = [1,a[0]]
tp = a[0]-1
while True:  
  if a[tp] not in l: 
    l.append(a[tp])
    tp = a[tp] -1
  else:
    l.append(a[tp])
    break
    
last = l[-1]

loop = len(l[l.index(last):-1])
first = l.index(last)
if len(l)>k:
  print(l[k])
  exit()
k -=first
k %=loop
if k==0:
  k+=loop
print(l[k+first])

Fixed submission:
s = input()
t = input()

if t[:-1]==s:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
fizzbuzz = [i for i in range(n+1) if i%5!=0 and i%3!=0]
print(sum(fizzbuss))

Fixed submission:
n = int(input())
fizzbuzz = [i for i in range(n+1) if i%5!=0 and i%3!=0]
print(sum(fizzbuzz))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
n = int(input())


sum = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            tmp = math.gcd(i,j)
            tmp2 = math.gcd(j,k)
            tmp3 = math.gcd(tmp,tmp2)
            sum += tmp3
print(sum)

Fixed submission:
import math
from functools import reduce
n = int(input())
 
 
sum = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            tmp = math.gcd(i,j)
            tmp2 = math.gcd(j,k)
            tmp3 = math.gcd(tmp,tmp2)
            sum += tmp3
print(sum)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
Ai = list(map(int,input().split()))

sum = 0
cnt = 0

for i in Ai:
	sum += i

sorted = Ai.sort(reverse=True)

if sorted[m-1] >= sum/(4*m):
  print("Yes")
else:
  print("No")
  


Fixed submission:
n,m = map(int,input().split())
Ai = list(map(int,input().split()))

sum = 0

for i in Ai:
	sum += i

S = sorted(Ai,reverse=True)

if S[m-1] >= sum/(4*m):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
numList = list(map(int,input().split()))

for i in numList:
	sum += i

for _ in numList:
  if _ > sum/(4*m):
    continue
  else:
    print("No")
    exit
    
print("Yes")

Fixed submission:
n,m = map(int,input().split())
Ai = list(map(int,input().split()))

sum = 0

for i in Ai:
	sum += i

S = sorted(Ai,reverse=True)

if S[m-1] >= sum/(4*m):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
numList = list(map(int,input().split()))

for i in numList:
	sum += i

if sum > 1/(4*m):
  print("Yes")
else:
  print("No")


Fixed submission:
n,m = map(int,input().split())
Ai = list(map(int,input().split()))

sum = 0

for i in Ai:
	sum += i

S = sorted(Ai,reverse=True)

if S[m-1] >= sum/(4*m):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
numList = list(map(int,input().split()))

y = 0
n = 0

for i in len(nunList):
  if  i > 1/(4*m):
    y +=1
  else:
    n +=1
    
if y > m:
  print("Yes")
else:
  print("No")

Fixed submission:
n,m = map(int,input().split())
Ai = list(map(int,input().split()))

sum = 0

for i in Ai:
	sum += i

S = sorted(Ai,reverse=True)

if S[m-1] >= sum/(4*m):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
numList = list(map(int,input().split()))

y = 0
n = 0

for i in len(nunList):
  if numList > 1/(4*m):
    y +=1
  else:
    n +=1
    
if y > m:
  print("Yes")
else:
  print("No")
   
  

Fixed submission:
n,m = map(int,input().split())
Ai = list(map(int,input().split()))

sum = 0

for i in Ai:
	sum += i

S = sorted(Ai,reverse=True)

if S[m-1] >= sum/(4*m):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
num = 0
while True:
	num = n-k
    if num < 0:
      print(abs(num))

Fixed submission:
n,k = map(int,input().split())

d = n//k

n = n - d*k

if abs(n-k)>n:
  print(n)
else:
  print(abs(n-k))
Buggy python submission (verdict: Runtime Error):
import sys
A,B = map(int,input().split())
if A<13:
  print(-1)
  sys.exit()
last = 2000

for i in range(last):
  mA = int(i*0.08)
  mB = int(i*0.10)
  print(mA,mB,i)

  
  if mA==A and mB==B:
    print("match")
    print(i)
    break
  if i==last-1:
    print("-1")

Fixed submission:
s = input()
if s=="AAA" or s=="BBB":
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
bingo = []
b = []

for i in range(3):
  tmp = list(map(int,input().split()))
  bingo.append(tmp)

n = int(input())

while True:
  try:
    b.append(int(input()))
  except EOFError:
    break

lis1 = [bingo[0][0],bingo[0][1],bingo[0][2]]
lis2 = [bingo[1][0],bingo[1][1],bingo[1][2]]
lis3 = [bingo[2][0],bingo[2][1],bingo[2][2]]

lis4 = [bingo[0][0],bingo[1][0],bingo[2][0]]
lis5 = [bingo[0][1],bingo[1][1],bingo[2][1]]
lis6 = [bingo[0][2],bingo[1][2],bingo[2][2]]

lis7 = [bingo[0][0],bingo[1][1],bingo[2][2]]
lis8 = [bingo[0][2],bingo[1][1],bingo[2][0]]


print(allList)
for i in allList:
  cnt = 0
  for _ in range(3):
    if i[_] in b:
      cnt +=1
  if cnt ==3:
    print("Yes")
    exit()
print("No")

Fixed submission:
bingo = []
b = []

for i in range(3):
  tmp = list(map(int,input().split()))
  bingo.append(tmp)

n = int(input())

while True:
  try:
    b.append(int(input()))
  except EOFError:
    break

lis1 = [bingo[0][0],bingo[0][1],bingo[0][2]]
lis2 = [bingo[1][0],bingo[1][1],bingo[1][2]]
lis3 = [bingo[2][0],bingo[2][1],bingo[2][2]]

lis4 = [bingo[0][0],bingo[1][0],bingo[2][0]]
lis5 = [bingo[0][1],bingo[1][1],bingo[2][1]]
lis6 = [bingo[0][2],bingo[1][2],bingo[2][2]]

lis7 = [bingo[0][0],bingo[1][1],bingo[2][2]]
lis8 = [bingo[0][2],bingo[1][1],bingo[2][0]]

allList = [lis1,lis2,lis3,lis4,lis5,lis6,lis7,lis8]

for i in allList:
  cnt = 0
  for _ in range(3):
    if i[_] in b:
      cnt +=1
  if cnt ==3:
    print("Yes")
    exit()
print("No")
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = []
c = []
while True:
  try:
    tmp = list(map(int,input().split()))
    s.append(tmp[0])
    c.append(tmp[1])
  except EOFError:
    break
  
for i in range(10**(n-1)-1,10**n):
  cnt =0
  tmp = str(i)
  for _ in range(len(c)):
    if tmp[s[_]-1]==str(c[_]):
      cnt +=1
  if cnt == len(c):
    print(i)
    exit()
print("-1")

Fixed submission:
n,m = map(int,input().split())
s = []
c = []
while True:
  try:
    tmp = list(map(int,input().split()))
    s.append(tmp[0])
    c.append(tmp[1])
  except EOFError:
    break
if n == 1 and all(i == 0 for i in c):
  print(0)
  exit()
for i in range(10**(n-1),10**n):
  cnt =0
  tmp = str(i)
  for _ in range(len(c)):
    if tmp[s[_]-1]==str(c[_]):
      cnt +=1
  if cnt == len(c):
    print(i)
    exit()
print("-1")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))

p = [0]+p

ansList =[]
for i in range(1,n+1):
  if min(p[1:i+1])==p[i]:
    ansList.append(p[i])
    
print(len(ansList))

Fixed submission:
n = int(input())
p = list(map(int,input().split()))

MIN = 10**10
cnt =0
for i in p:
  if i<=MIN:
    MIN = i
    cnt +=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))

p = [0]+p

ansList =[]
for i in range(1,n+1):
  if min(p[1:i+1])==p[i]:
    ansList.append(p[i])
    
print(len(ansList))

Fixed submission:
n = int(input())
p = list(map(int,input().split()))

MIN = 10**10
cnt =0
for i in p:
  if i<=MIN:
    MIN = i
    cnt +=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import  numpy as np
n,k,q = map(int,input().split())
a = []
while True:
  try:
    a.append(int(input()))
  except:
    break

score = np.ones(n)*k

for i in range(q):
  score -=1
  score[a[i]-1] += 1

for i in score:
  if i>=1:
    print("Yes")
  else:
    print("No")


Fixed submission:
n,k,q = map(int,input().split())
a = []
while True:
  try:
    a.append(int(input()))
  except:
    break

score = [k-q]*n

for i in range(q):
  score[a[i]-1] +=1

for i in score:
  if i>=1:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import  numpy as np
n,k,q = map(int,input().split())
a = []
while True:
  try:
    a.append(int(input()))
  except:
    break

score = np.ones(n)*k

for i in range(q):
  score -=1
  score[a[i]-1] += 1

for i in score:
  if i>=1:
    print("Yes")
  else:
    print("No")


Fixed submission:
n,k,q = map(int,input().split())
a = []
while True:
  try:
    a.append(int(input()))
  except:
    break

score = [k-q]*n

for i in range(q):
  score[a[i]-1] +=1

for i in score:
  if i>=1:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))
h.append(10**10)
ans = 0

for i in range(n):
  cnt = 0
  for j in range(i,n):
    if h[j]>=h[j+1]:
      cnt +=1
    else:
      if cnt > ans:
        ans = cnt
      break

print(ans)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
h = h[::-1]
h.append(10**10)
cnt = 0
L = []
for i in range(n):
  L.append(cnt)
  if h[i+1]>=h[i]:
    cnt +=1
  else:
    cnt =0
print(max(L))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))
h.append(10**10)
counter = []

for i in range(n):
  cnt = 0
  for j in range(i,n):
    if h[j]>=h[j+1]:
      cnt +=1
    else:
      counter.append(cnt)
      break

ans = max(counter)
print(ans)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
h = h[::-1]
h.append(10**10)
cnt = 0
L = []
for i in range(n):
  L.append(cnt)
  if h[i+1]>=h[i]:
    cnt +=1
  else:
    cnt =0
print(max(L))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
while True:
  try:
    a.append(int(input()))
  except:
    break

for i in range(n):
  tmp = a[i]
  a[i]=0
  print(max(a))
  a[i]=tmp

Fixed submission:
n = int(input())
a = []
while True:
  try:
    a.append(int(input()))
  except:
    break

A = sorted(a,reverse=True)

MAX = A[0]
SMAX = A[1]

for i in range(n):
  if a[i]==MAX:
    print(SMAX)
  else:
    print(MAX)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
l = []
r = []

while True:
  try:
    tl,tr = map(int,input().split())
    l.append(tl)
    r.append(tr)
  except:
    break

l = sorted(l)
r = sorted(r)
cnt = 0
for i in range(1,n+1):
  if i>=max(l) and i<=min(r):
    cnt +=1
    
print(cnt)
    

Fixed submission:
n,m = map(int,input().split())
l = []
r = []

while True:
  try:
    tl,tr = map(int,input().split())
    l.append(tl)
    r.append(tr)
  except:
    break

R = min(r)
L = max(l)
cnt = 0
for i in range(1,n+1):
  if i>=L and i<=R:
    cnt +=1
    
print(cnt)