Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
n = int(input())
a = list(map(int,input().split()))
for i in range(len(a)):
  o = 0
  b = a[:]
  del b[i]
  c = collections.Counter(b)
  for i in c.values():
    if i-2<1:
      r=1
    else:
      r=i-2
    o += (math.factorial(i) // math.factorial(r)//2)
  print(int(o))
  


Fixed submission:
from collections import Counter
def comb(x):
    return x*(x-1)//2
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
b = 0
for i in c.values():
    b+=comb(i)
for k in range(n):
    print(b-c[a[k]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
from scipy.misc import comb
n = int(input())
a = list(map(int,input().split()))
for i in range(len(a)):
  o = 0
  b = a[:]
  del b[i]
  c = collections.Counter(b)
  n = len(set(b))
  for i in c.values():
    o += comb(i,2,exact=True)
  print(o)
  

Fixed submission:
from collections import Counter
def comb(x):
    return x*(x-1)//2
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
b = 0
for i in c.values():
    b+=comb(i)
for k in range(n):
    print(b-c[a[k]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import itertools
n = int(input())
a = list(map(int,input().split()))
for i in range(len(a)):
  o = 0
  b = a[:]
  del b[i]
  c = collections.Counter(b)
  for i in c.values():
    o += len(list(itertools.permutations([ii for ii in range(i)], 2)))/2
  print(int(o))
  

Fixed submission:
from collections import Counter
def comb(x):
    return x*(x-1)//2
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
b = 0
for i in c.values():
    b+=comb(i)
for k in range(n):
    print(b-c[a[k]]+1)
Buggy python submission (verdict: Runtime Error):
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = [min(a)+min(b)]
for t in c:
    p.append((p,a[t[0]-1]+b[t[1]-1]-t[2])
print(min(p))

Fixed submission:
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = min(a)+min(b)
for t in c:
    p = min(p,a[t[0]-1]+b[t[1]-1]-t[2])
print(p)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = []
x = 0
p.append(min(a)+min(b))
for ka,ai in enumerate(a):
    for kb,bi in enumerate(b):
        for t in c:
            if t[0]==ka+1 and t[1]==kb+1:
                x = t[2]
                p.append(ai+bi-x)
print(min(p))

Fixed submission:
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = min(a)+min(b)
for t in c:
    p = min(p,a[t[0]-1]+b[t[1]-1]-t[2])
print(p)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = []
x = 0
for ka,ai in enumerate(a):
    for kb,bi in enumerate(b):
        for t in c:
            if t[0]==ka+1 and t[1]==kb+1:
                x = t[2]
            p.append(ai+bi-x)
print(min(p))

Fixed submission:
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = min(a)+min(b)
for t in c:
    p = min(p,a[t[0]-1]+b[t[1]-1]-t[2])
print(p)
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
qaws = ""
c = 0
while(N > len(qaws)):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws[:N].count("B"))

Fixed submission:
s = list(input())
i = len(set(s))
if i == 1:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
qaws = ""
while(N > len(qaws)):
  qaws += ("B"*A)
  qaws += ("R"*B)
print(qaws[:N].count("B"))

Fixed submission:
n,a,b=map(int,input().split())
ans = n//(a+b)*a
r = n%(a+b)
print(min(r,a)+ans)

Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
qaws = ""
while(N > len(qaws)):
  qaws += ("B"*A)
  qaws += ("R"*B)
print(qaws[:N].count("B")

Fixed submission:
n,a,b=map(int,input().split())
ans = n//(a+b)*a
r = n%(a+b)
print(min(r,a)+ans)

Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
qaws = ""
c = 0
while(N > len(qaws)):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws[:N].count("B"))

Fixed submission:
n,a,b=map(int,input().split())
ans = n//(a+b)*a
r = n%(a+b)
print(min(r,a)+ans)

Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
ab = A+B

qaws = ""
c = 0
while(N >= c):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws[:N].count("B"))

Fixed submission:
n,a,b=map(int,input().split())
ans = n//(a+b)*a
r = n%(a+b)
print(min(r,a)+ans)

Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
ab = A+B

qaws = ""
c = 0
while(N >= c):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws)
print(qaws[:N].count("B"))

Fixed submission:
n,a,b=map(int,input().split())
ans = n//(a+b)*a
r = n%(a+b)
print(min(r,a)+ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
f = False
# Falseだと左が先頭
for _ in range(q):
    t = input().split()
    if t[0]=="1":
        f = not f
    elif t[0]=="2":
        if f:
            t[2]=t[2][::-1]
            if t[1]=="1":
                s = s+t[2]
            elif t[1]=="2":
                s = t[2]+s
        else:
            if t[1]=="1":
                s = t[2]+s
            elif t[1]=="2":
                s = s+t[2]
if f:
    print(s[::-1])
else:
    print(s)

Fixed submission:
from collections import deque
s = deque(input())
q = int(input())
f = False
# Falseだと左が先頭
for _ in range(q):
    t = input().split()
    if t[0]=="1":
        f = not f
    elif t[0]=="2":
        t[2]=list(t[2])
        if f:
            t[2]=t[2][::-1]
            if t[1]=="1":
                s.extend(t[2])
            elif t[1]=="2":
                s.extendleft(t[2])
        else:
            if t[1]=="1":
                s.extendleft(t[2])
            elif t[1]=="2":
                s.extend(t[2])
if f:
    print("".join(s)[::-1])
else:
    print("".join(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for _ in range(q):
    t = input().split()
    if t[0]=="1":
        s=s[::-1]
    elif t[0]=="2":
        if t[1]=="1":
            s = t[2]+s
        elif t[1]=="2":
            s = s+t[2]
print(s)

Fixed submission:
from collections import deque
s = deque(input())
q = int(input())
f = False
# Falseだと左が先頭
for _ in range(q):
    t = input().split()
    if t[0]=="1":
        f = not f
    elif t[0]=="2":
        t[2]=list(t[2])
        if f:
            t[2]=t[2][::-1]
            if t[1]=="1":
                s.extend(t[2])
            elif t[1]=="2":
                s.extendleft(t[2])
        else:
            if t[1]=="1":
                s.extendleft(t[2])
            elif t[1]=="2":
                s.extend(t[2])
if f:
    print("".join(s)[::-1])
else:
    print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import exit
n = int(input())
a = list(map(int, input().split()))
b = "APPROVED"
while b == "APPROVED":
  for i in a:
    if i % 2 == 0:
      if (i % 3 == 0 or i % 5 == 0):
        b = "APPROVED"
      else:
        print("DENIED")
        exit()
  
print(b)

Fixed submission:
from sys import exit
n = int(input())
a = list(map(int, input().split()))
b = "APPROVED"
while b == "APPROVED":
  for i in a:
    if i % 2 == 0:
      if (i % 3 == 0 or i % 5 == 0):
        b = "APPROVED"
      else:
        print("DENIED")
        exit()
  break
print(b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = "APPROVED"
while b == "APPROVED":
  for i in a:
    if i % 2 == 0:
      if (i % 3 == 0 or i % 5 == 0):
        b = "APPROVED"
      else:
        b = "DENIED"
        break
print(b)

Fixed submission:
from sys import exit
n = int(input())
a = list(map(int, input().split()))
b = "APPROVED"
while b == "APPROVED":
  for i in a:
    if i % 2 == 0:
      if (i % 3 == 0 or i % 5 == 0):
        b = "APPROVED"
      else:
        print("DENIED")
        exit()
  break
print(b)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
for i in range(n-k+1):
    x = 0
    for j in p[i:i+k]:
        z = 0
        for a in range(1,j+1):
            z+=a*(1/j)
        x+=z
    ans = max(x,ans)
print(ans)

Fixed submission:
import collections
s = int(input())
a = list(map(str, input().split()))
n = {}
for i in a:
  n.setdefault(i, 0)
for i in a:
  n[i] += 1
x = 0
for i in n.values():
  if x <= i:
    x = i
if x == 1:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
for i in range(n-k+1):
    x = 0
    for j in p[i:i+k]:
        z = 0
        for a in range(1,j+1):
            z+=a*(1/j)
        x+=z
    ans = max(x,ans)
print(ans)

Fixed submission:
n,k = map(int,input().split())
p = [0]
a = list(map(int,input().split()))
a = [(1+i)/2 for i in a]
p.extend(a)
s = [0]*(n+1)
for i in range(n):
    s[i+1]=s[i]+p[i+1]
ans = 0
for i in range(n-k+1):
    ans = max(ans,s[i+k]-s[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
for i in range(n-k+1):
    x = 0
    for j in p[i:i+k]:
        z = 0
        for a in range(1,j+1):
            z+=a*(1/j)
        x+=z
    ans = max(x,ans)
print(ans)

Fixed submission:
n,k = map(int,input().split())
p = [0]
a = list(map(int,input().split()))
a = [(1+i)/2 for i in a]
p.extend(a)
s = [0]*(n+1)
for i in range(n):
    s[i+1]=s[i]+p[i+1]
ans = 0
for i in range(n-k+1):
    ans = max(ans,s[i+k]-s[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
if N == M:
  print(Yes)
elif N != M:
  print(No)

Fixed submission:
N, M = map(int, input().split())
if N == M:
  print("Yes")
elif N != M:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if s=="WA":
      if d[p]:
        pass
      else:
        WA+=1
    elif s=="AC":
      if d[p]:
        pass
      else:
        d[p]=True
        ac+=1
  else:
    if s=="WA":
      d[p]=False
      wa+=1
    else:
      d[p]=True
      ac+=1
print(ac,wa)

Fixed submission:
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if d[p][1]:
      pass
    else:
      if s=="WA":
          d[p][0]+=1
      elif s=="AC":
          d[p][1]=True
          ac+=1
          wa+=d[p][0]
  else:
    if s=="WA":
      d[p]=[1,False]
    elif s=="AC":
      d[p]=[0,True]
      ac+=1
print(ac,wa)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
up = [input().split() for i in range(m)]

wa,ac = 0,0
if m==0:
    print(0,0)
else:
    k = [[] for i in range(2)]
    f=0
    temp=up[0]
    for t in up:
        if not temp[0]==t[0]:
            f+=1
        k[f].append(t)
        temp=t
    temp = False
    for qrs in k:
        for qr in qrs:
            if qr[1] == "WA":
                wa+=1
            elif qr[1] == "AC" and not temp:
                ac+=1
                break
    print(ac,wa)


Fixed submission:
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if d[p][1]:
      pass
    else:
      if s=="WA":
          d[p][0]+=1
      elif s=="AC":
          d[p][1]=True
          ac+=1
          wa+=d[p][0]
  else:
    if s=="WA":
      d[p]=[1,False]
    elif s=="AC":
      d[p]=[0,True]
      ac+=1
print(ac,wa)

Buggy python submission (verdict: Runtime Error):
up = [input().split() for i in range(m)]

wa,ac = 0,0
if m==0:
    print(0,0)
else:
    k = [[] for i in range(2)]
    f=0
    temp=up[0]
    for t in up:
        if not temp[0]==t[0]:
            f+=1
        k[f].append(t)
        temp=t
    temp = False
    for qrs in k:
        for qr in qrs:
            if qr[1] == "WA":
                wa+=1
            elif qr[1] == "AC" and not temp:
                ac+=1
                break
    print(ac,wa)


Fixed submission:
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if d[p][1]:
      pass
    else:
      if s=="WA":
          d[p][0]+=1
      elif s=="AC":
          d[p][1]=True
          ac+=1
          wa+=d[p][0]
  else:
    if s=="WA":
      d[p]=[1,False]
    elif s=="AC":
      d[p]=[0,True]
      ac+=1
print(ac,wa)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split(" "))

for i in range(k):
  if (a+b) == 0:
    break
  if a >= 1:
    a -= 1
  else:
    b -= 1
print(a, b)

Fixed submission:
from sys import exit
a, b, k = map(int, input().split(" "))


if (a+b) <= k:
    print(0,0)
    exit()
    
a -= k

if a <= 0:
    b += a
    a = 0
print(a, b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
for i in range(1000):
    i = str(i).zfill(3)
    ind = 0
    a = 0
    for ij in i:
        while(ind < len(s)):
            if s[ind] == ij:
                a += 1
                ind += 1
                break
            ind += 1
    ans += a == 3
print(ans)


Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(1000):
    i = str(i).zfill(3)
    ind = 0
    a = 0
    for ij in i:
        while(ind < len(s)):
            if s[ind] == ij:
                a += 1
                ind += 1
                break
            ind += 1
    ans += a == 3
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

l = []
for i in range(1, 10):
    for j in range(1, 10):
        l.append(i * j)

if N in l:
    print('Yes')
else:
    print('No')

Fixed submission:
A, B = map(int, input().split())

if A >= 10 or B >= 10:
    print(-1)
else:
    print(A*B)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans=[str(a.index(i)+1) for i in range(1,n+1)]
print(" ".join(ans))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans=[0]*n
for k,i in enumerate(a):
    ans[i-1]=str(k+1)
print(" ".join(ans))
Buggy python submission (verdict: Runtime Error):
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[n];
    int b[n-1]; rep(i,n-1) cin >> b[i];

    a[0] = b[0];
    a[n-1] = b[n-2];
    for (int i = 1; i<(n-1); i++) {
        a[i] = min(b[i-1],b[i]);
    }
    ll ans = 0;
    rep(i,n) ans += a[i];
    cout << ans << "\n";
}

Fixed submission:
n = int(input())
b = list(map(int,input().split()))
a = [0]*n
a[0] = b[0]
a[-1] = b[-1]
for i in range(1,n-1):
    a[i] = min(b[i-1],b[i])
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
from numba import njit

@njit(cache=True)
def f(n):
    #n = 10**9
    ans = 0
    for i,j in zip(range(1,n),range(2,n+1)):
        #print(i,j)
        ans += i%j
    return ans

if __name__ == "__main__":
    n = int(input())
    r = f(n)
    print(r)

Fixed submission:
#n = 10**9
n = int(input())
ans = 0
print(((n-1)*(1+n-1)//2))
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
c = [0] * n
l = {}
for i in range(n - 1):
    a, b = map(int, input().split())
    l[b] = a
for i in range(q):
    p, x = map(int, input().split())
    c[p - 1] += x
for i in range(2, n + 1):
    c[i - 1] += c[l[i] - 1]
print(*c)


Fixed submission:
from collections import defaultdict, deque
import sys
sys.setrecursionlimit(10**9)


N, Q = map(int, input().split())
count = [0] * N
parent = defaultdict(int)
t = [[] for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    t[a - 1].append(b)
    t[b - 1].append(a)

for i in range(Q):
    p, x = map(int, input().split())
    count[p - 1] += x


f = [False] * N
q = deque([1])
while(q):
    n = q.popleft()
    f[n-1] = True
    for i in t[n-1]:
        if f[i-1]:
            continue
        q.append(i)
        count[i-1]+=count[n-1]
        f[i-1] = True
#for i in range(1, N):
#    count[i] += count[parent[i + 1] - 1]
#print(parent)
print(*count)
Buggy python submission (verdict: Time Limit Exceeded):
#import itertools
import math
n=int(input())
s = [str(sorted(list(input()))) for i in range(n)]
l=[]
for si in set(s):
    l.append(s.count(si))
ans=0
for i in l:
    if i>=2:
        #x=len(list(itertools.combinations(range(i),2)))
        x = (math.factorial(i) // (math.factorial(i - 2) * math.factorial(2)))
        ans+=x
print(ans)

Fixed submission:
import math
from collections import Counter
n=int(input())
s = [str(sorted(list(input()))) for i in range(n)]
c = Counter(s)
#l=[]
#for si in set(s):
#    l.append(s.count(si))
ans=0
for i in c.values():
    if i>=2:
        x = (math.factorial(i) // (math.factorial(i - 2) * math.factorial(2)))
        ans+=x
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n= int(input())
s = [str(sorted(list(input()))) for i in range(n)]
l=[]
for si in set(s):
  x=0
  for sj in s:
    if si==sj:
      x+=1
  l.append(x)
ans=0
for i in l:
  x=len(list(itertools.combinations(range(i),2)))
  ans+=x
print(ans)

Fixed submission:
import math
from collections import Counter
n=int(input())
s = [str(sorted(list(input()))) for i in range(n)]
c = Counter(s)
#l=[]
#for si in set(s):
#    l.append(s.count(si))
ans=0
for i in c.values():
    if i>=2:
        x = (math.factorial(i) // (math.factorial(i - 2) * math.factorial(2)))
        ans+=x
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    print(h)
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = hi
print(ans)


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = h[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
f=True
for i in range(max(a,b)):
  if abs(a-i)==abs(b-i):
    print(i)
    f=False
    break
if f:
  print("IMPOSSIBLE")

Fixed submission:
a,b = map(int,input().split())
f=True
if a%2 == b%2:
  print((a+b)//2)
else:
  print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input(),split())
f=True
for i in range(max(a,b)):
  if abs(a-i)==abs(b-i):
    print(i)
    f=False
    break
if f:
  print("IMPOSSIBLE")

Fixed submission:
a,b = map(int,input().split())
f=True
if a%2 == b%2:
  print((a+b)//2)
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    t = a[:]
    t.pop(i)
    print(max(t))

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a,reverse=True)

for i in range(n):
    if a[i]==b[0]:
        print(b[1])
    else:
        print(b[0])
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if b > n*a:
  print(a*c)
elif b < a*a:
  print(b)
else:
  print(b)


Fixed submission:
n,a,b = map(int,input().split())
if b > n*a:
  print(a*n)
elif b < a*a:
  print(b)
else:
  print(b)
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
ans = 500000000000000000000000000000000000000000000000000
for j in range(l+1,r+1):
    for i in range(l,j):
        ans = min(ans,(i*j)%2019)
print(ans)


Fixed submission:
l,r = map(int,input().split())
ans = 10**10
for i in range(l,r+1):
    for j in range(i+1,r+1):
        x = (i*j)%2019
        if x==0:
            ans = 0
            break
        else:
            ans=min(ans,x)
    else:
        continue
    break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int,input().split()))
d.sort()
ans=0
for k in range(1,d[-1]+1):
    abc=[k>i for i in d]
    arc=[k<=i for i in d]
    if sum(arc)==sum(abc):
        ans+=1
print(ans)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[n//2]-d[(n//2)-1])
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
l = list(map(int,input().split()))
m = 0
a = 0
while(a<=x):
    a+=l.pop(0)
    m+=1
print(m)

Fixed submission:
n,x = map(int,input().split())
l = list(map(int,input().split()))
m = 1
a = 0
for i in l:
    a+=i
    if a<=x:
        m+=1
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
g = [tuple(map(int,input().split())) for i in range(m)]
ans=0
for i in range(1,n+1):
  if all([t[0]<=i and i<=t[1] for t in g]):
    ans+=1
print(ans)

Fixed submission:
n,m = map(int,input().split())
l = []
r = []
for i in range(m):
  t = tuple(map(int,input().split()))
  l.append(t[0])
  r.append(t[1])
l,r=max(l),min(r)
if l<=r:
  print(abs(l-r)+1)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil

R, G, B, n = map(int, input().split())
rm = ceil(n / R)
gm = ceil(n / G)
bm = ceil(n / B)
ans = 0
for r in range(rm+1):
    for g in range(gm+1):
        x = n-(r*R+g*G)
        if x >= 0:
            ans += (x%B == 0)

print(ans)


Fixed submission:
from math import ceil

R, G, B, n = map(int, input().split())
rm = ceil(n / R)
gm = ceil(n / G)
bm = ceil(n / B)
ans = 0
for r in range(rm+1):
    for g in range(gm+1):
        x = n-(r*R+g*G)
        if x >= 0:
            ans += (x%B == 0)

print(ans)
Buggy python submission (verdict: Runtime Error):
print(max([len(s) for s in "".join(["1" if s in ["A","C","G","T"] else " " for s in input()]).split()]))

Fixed submission:
a="".join(["1" if s in ["A","C","G","T"] else "0" for s in input()])
ans=[len(s) for s in a.split("0")]
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
h = list(map(int,input().split()))
INF = 10**9
dp = [INF]*n
dp[0] = 0

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(
            dp[i],
            dp[j]+abs(h[i]-h[j])
        )
print(dp[-1])


Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
INF = 10**9
dp = [INF]*n
dp[0] = 0

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(
            dp[i],
            dp[j]+abs(h[i]-h[j])
        )
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,w = map(int,input().split())
wv = [tuple(map(int,input().split())) for i in range(n)]

dp = [[0]*(w+10) for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j-wv[i][0] >= 0:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j-wv[i][0]]+wv[i][1])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])

print(max(dp[-1]))


Fixed submission:
n,w = map(int,input().split())
wv = [tuple(map(int,input().split())) for i in range(n)]

dp = [[0]*(w+10) for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j-wv[i][0] >= 0:
            dp[i+1][j] = max(dp[i+1][j],dp[i][j-wv[i][0]]+wv[i][1])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])

print(max(dp[-1]))