Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

Fixed submission:
import math
N = int(input())
a = map(int, input().split())
A = list(a)

min = 10**10
for e in A:
    m=0 #eが2で割り切れる回数
    while e%2==0:
        e = e/2
        m+=1
    if min>m:
        min = m
print(min)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

b = []
for i in range(n):
    s = a[i]
    b.append(s)
    for j in range(i+1, n):
        s += a[j]
        b.append(s)

MAX = 40
ans = 0
for t in range(MAX, 0, -1):
    x = ans + 2 ** (t-1)
    cnt = 0
    for v in b:
        if x & v == x:
            cnt += 1
    if cnt >= k:
        ans = x

print(ans)

Fixed submission:
n, k = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

b = []
for i in range(n):
    s = a[i]
    b.append(s)
    for j in range(i+1, n):
        s += a[j]
        b.append(s)

MAX = 40
ans = 0
for t in range(MAX, 0, -1):
    x = ans + (1 << (t-1))
    cnt = 0
    for v in b:
        if x & v == x:
            cnt += 1
    if cnt >= k:
        ans = x

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = [int(v) for v in input().split()]
p = []
q = []
x = [[0] * (N+1) for i in range(N+1)]
c = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
    l, r = [int(v) for v in input().split()]
    x[l][r] += 1
for i in range(1, N+1):
    for j in range(1, N+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for i in range(Q):
    ans = 0
    for j in range(p[i], q[i]+1):
        ans += c[j][q[i]] - c[j][p[i]-1]
    print(ans)

Fixed submission:
N, M, Q = [int(v) for v in input().split()]
p = []
q = []
x = [[0] * (N+1) for i in range(N+1)]
c = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
    l, r = [int(v) for v in input().split()]
    x[l][r] += 1
for i in range(1, N+1):
    for j in range(1, N+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for i in range(Q):
    ans = 0
    for j in range(p[i], q[i]+1):
        ans += c[j][q[i]] - c[j][p[i]-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = [int(v) for v in input().split()]
L = []
R = []
p = []
q = []
for i in range(M):
    a, b = [int(v) for v in input().split()]
    L.append(a)
    R.append(b)
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for i in range(Q):
    ans = 0
    for j in range(M):
        if p[i] <= L[j] and R[j] <= q[i]:
            ans += 1
    print(ans)

Fixed submission:
N, M, Q = [int(v) for v in input().split()]
p = []
q = []
x = [[0] * (N+1) for i in range(N+1)]
c = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
    l, r = [int(v) for v in input().split()]
    x[l][r] += 1
for i in range(1, N+1):
    for j in range(1, N+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for i in range(Q):
    ans = 0
    for j in range(p[i], q[i]+1):
        ans += c[j][q[i]] - c[j][p[i]-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

a_dict = {}
for v in a:
    if v in a_dict:
        a_dict[v] += 1
    else:
        a_dict[v] = 1

can = True
if n % 2 == 0:
    possible_list = [i for i in range(1, n, 2)]
    for k, v in a_dict.items():
        if v != 2 or k not in possible_list:
            can = False
            break
else:
    possible_list = [i for i in range(0, n, 2)]
    if 0 not in a_dict:
        can = False
    elif a_dict[0] != 1:
        can = False
    else:
        a_dict[0] = 2
        for k, v in a_dict.items():
            if v != 2 or k not in possible_list:
                can = False
                break

if can:
    print(2 ** (n // 2) % (10 ** 9 + 7))
else:
    print(0)


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

a_dict = {}
for v in a:
    if v in a_dict:
        a_dict[v] += 1
    else:
        a_dict[v] = 1

can = True
if n % 2 == 0:
    possible_list = {i: True for i in range(1, n, 2)}
    for k, v in a_dict.items():
        if v != 2 or k not in possible_list:
            can = False
            break
else:
    possible_list = {i: True for i in range(0, n, 2)}
    if 0 not in a_dict:
        can = False
    elif a_dict[0] != 1:
        can = False
    else:
        a_dict[0] = 2
        for k, v in a_dict.items():
            if v != 2 or k not in possible_list:
                can = False
                break

if can:
    print(2 ** (n // 2) % (10 ** 9 + 7))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ta = []
for i in range(n):
    ta.append([int(i) for i in input().split()])

for i in range(1, n):
    tmp = ta[i][:]
    while ta[i-1][0] > ta[i][0] or ta[i-1][1] > ta[i][1]:
        ta[i][0] += tmp[0]
        ta[i][1] += tmp[1]

print(ta[-1][0] + ta[-1][1])


Fixed submission:
def round_up(x, y):
    res = x // y
    if x % y != 0:
        res += 1
    return res

n = int(input())
ta = []
for i in range(n):
    ta.append([int(i) for i in input().split()])

for i in range(1, n):
    if ta[i-1][0] > ta[i][0] or ta[i-1][1] > ta[i][1]:
        multi = max(
            round_up(ta[i-1][0], ta[i][0]),
            round_up(ta[i-1][1], ta[i][1])
        )
        ta[i][0] *= multi
        ta[i][1] *= multi

print(ta[-1][0] + ta[-1][1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
input = [int(s) for s in input().split()]
ans = 0
for i in range(N-1):
    ans = ans + input[i]*sum(input[i+1:])

print(ans%(10**9+7))

Fixed submission:
N = int(input())
input = [int(s) for s in input().split()]
ans = 0
temp=sum(input)
for i in range(N-1):
    temp=temp-input[i]
    ans = (ans + (input[i]*((temp)%(10**9+7)))%(10**9+7))%(10**9+7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
wa = 0
for i in range(N-1):
    i_wa = 0
    for m in A[i+1:]:
        i_wa += m
    wa += A[i] * i_wa 
print(wa % (10**9+7))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
wa = 0
a = 0
for l in range(N-1):
    a += A[N-l-1]
    wa += a * A[N-l-2]
print(wa % (10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
wa = 0
for i in range(N-1):
    for m in A[i+1:]:
        wa += A[i] * m
print(wa % (10**9+7))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
wa = 0
a = 0
for l in range(N-1):
    a += A[N-l-1]
    wa += a * A[N-l-2]
print(wa % (10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
wa = 0
for i in range(N-1):
    for m in A[i+1:]:
        wa += A[i] * m
answer = wa % (10**9+7)
print(answer)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
wa = 0
a = 0
for l in range(N-1):
    a += A[N-l-1]
    wa += a * A[N-l-2]
print(wa % (10**9+7))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a, b, c = map(int, input().split())

i = 0
while True:
    a_ans = divmod(a, 2)
    b_ans = divmod(b, 2)
    c_ans = divmod(c, 2)
    if a_ans[1] == 0 and b_ans[1] == 0 and c_ans[1] == 0 and a !=0 and b !=0 and c !=0:
        i += 1
        a = a_ans[0]
        b = b_ans[0]
        c = c_ans[0]
    else:
        break
print(i)

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

i = 0
per = True
while per == True:
    for index in range(n):
        num = a[index]
        ans = divmod(num, 2)
        if num == 0 or ans[1] != 0:
            per = False
            break
        a[index] = ans[0]
    if per == True:
        i += 1
print(i)

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

i = 0
while True:
    a_ans = divmod(a, 2)
    b_ans = divmod(b, 2)
    c_ans = divmod(c, 2)
    if a_ans[1] == 0 and b_ans[1] == 0 and c_ans[1] == 0:
        i += 1
        a = a_ans[0]
        b = b_ans[0]
        c = c_ans[0]
    else:
        break
print(i)

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

i = 0
per = True
while per == True:
    for index in range(n):
        num = a[index]
        ans = divmod(num, 2)
        if num == 0 or ans[1] != 0:
            per = False
            break
        a[index] = ans[0]
    if per == True:
        i += 1
print(i)
Buggy python submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
c=[list(input())for i in range(h)]
d=0
for i in range(2**h):
    for j in range(2**w):
        i=bin(i)[2:]
        j=bin(j)[2:]
        i="0"*(h-len(i))+i
        j="0"*(j-len(j))+j
        p=0
        for s in range(h):
            for t in range(w):
                if i[s]==j[t]==0 and c[s][t]=="#":
                    p+=1
        if p==k
        d+=1
print(d)

Fixed submission:
h,w,k=map(int,input().split())
c=[list(input())for i in range(h)]
d=0
for i in range(2**h):
    for j in range(2**w):
        x=bin(i)[2:]
        y=bin(j)[2:]
        x="0"*(h-len(x))+x
        y="0"*(w-len(y))+y
        p=0
        for s in range(h):
            for t in range(w):
                if x[s]==y[t]=="0" and c[s][t]=="#":
                    p+=1
        if p==k:
           d+=1
print(d)
Buggy python submission (verdict: Runtime Error):
n=int(input())
c=""
while n:
    n-=1
    c=chr(n%26+97)+c
    n//=26
print(c)

Fixed submission:
s=input()
print("A"if s==s.upper()else"a")
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
s=len(input())
c=1
m=10**9+7
p=0
a=[1]
b=[1]
for i in range(k):
    a.append(a[-1]*25%m)
    b.append(b[-1]*26%m)
for i in range(k+1):
    p=(p+a[i]*b[k-i]*c)%m
    c=(c*(s+i)*pow(i+1,m-2,m))%m
print(p)

Fixed submission:
k=int(input())
s=len(input())
c=1
m=10**9+7
p=0
a=[1]
b=[1]
for i in range(k):
    a.append(a[-1]*25%m)
    b.append(b[-1]*26%m)
for i in range(k+1):
    p=(p+a[i]*b[k-i]*c)%m
    c=(c*(s+i)*pow(i+1,m-2,m))%m
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
n,s=map(int,input().split())
a=list(map(int,input().split()))
t=[[0]*(s+1) for i in range(n+1)]
t[0][0]=1
m=998244353
for i in range(n):
    for j in range(s+1):
        t[i+1][j]=t[i][j]*2
        if j>=a[i]:
            t[i+1][j]+=t[i][j-a[i]]
        t[i+1][j]%=m
print(t[-1][-1])

Fixed submission:
n,s=map(int,input().split())
a=list(map(int,input().split()))
t=[[0]*(s+1) for i in range(n+1)]
t[0][0]=1
m=998244353
for i in range(n):
    for j in range(s+1):
        t[i+1][j]=t[i][j]*2
        if j>=a[i]:
            t[i+1][j]+=t[i][j-a[i]]
        t[i+1][j]%=m
print(t[-1][-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=[]
e=[]
for i in range(n):
    p=[0,0]
    s=input()
    for j in s:
        if j==")":
            if p[0]!=0:
                p[0]-=1
            else:
                p[1]+=1
        else:
            p[0]+=1
    if p[0]-p[1]>=0:
        d.append(p)
    else:
        e.append(p)
d=sorted(d,key=lambda x:x[1])
e=sorted(e,key=lambda x:-x[0])
s=d+e
q=0
for i,j in s:
    if q<j:
        print("No")
        exit()
    else:
        q=q-j+i
if q==0:
    print("Yes")
else:
    print("No")


Fixed submission:
s=input()
print("Yes"if s==input()[:-1]else"No")
Buggy python submission (verdict: Runtime Error):
import numpy as np
n,m,x=map(int,input().split())
a=0
b=[[np.array(list(map(int,input().split())))]for i in range(n)]
for i in range(2**n):
    c=bin(i)
    c="0"*(n-len(c))+c
    l=np.zeros(m)
    q=0
    for j in range(n):
        if c[j]=="1":
            q+=b[j][0]
            l+=b[j]
    if np.min(l)==x:
        a=min(a,q)
if a:
    print(a)

Fixed submission:
import numpy as np
n,m,x=map(int,input().split())
a=2**64
b=[np.array(list(map(int,input().split())),"i8")for i in range(n)]
for i in range(2**n):
    c=bin(i)[2:]
    c="0"*(n-len(c))+c
    l=np.zeros(m)
    q=0
    for j in range(n):
        if c[j]=="1":
            q+=b[j][0]
            l+=b[j][1:]
    if np.min(l)>=x:
        a=min(a,q)
if a==2**64:
    print(-1)
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
g=998244353
r=pow(m-1,n-1,g)
p=r
for i in range(1,k+1):
    r=(r*(n-i)*pow((m-1)*i,-1,g))%g
    p=(p+r)%g
print((m*p)%g)

Fixed submission:
n,m,k=map(int,input().split())
g=998244353
r=1
p=pow(m-1,n-1,g)
for i in range(1,k+1):
    r=(r*(n-i)*pow(i,g-2,g))%g
    p=(p+r*pow(m-1,n-1-i,g))%g
print((m*p)%g)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=[]
e=[]
for i in range(n):
    p=[0,0]
    s=input()
    for j in s:
        if j==")":
            if p[0]!=0:
                p[0]-=1
            else:
                p[1]+=1
        else:
            p[0]+=1
    if p[0]-p[1]>=0:
        d.append(p)
    else:
        e.append(p)
d=sorted(d,key=lambda x:x[1])
e=sorted(e,key=lambda x:-x[0])
s=d+e
q=0
for i,j in s:
    if q<j:
        print("No")
        exit()
    else:
        q=q-j+i
if q==0:
    print("Yes")
else:
    print("No")

Fixed submission:
n=int(input())
d=[]
e=[]
for i in range(n):
    p=[0,0]
    s=input()
    for j in s:
        if j==")":
            if p[0]!=0:
                p[0]-=1
            else:
                p[1]+=1
        else:
            p[0]+=1
    if p[0]-p[1]>=0:
        d.append(p)
    else:
        e.append(p)
d=sorted(d,key=lambda x:x[1])
e=sorted(e,key=lambda x:-x[0])
s=d+e
q=0
for i,j in s:
    if q<j:
        print("No")
        exit()
    else:
        q=q-j+i
if q==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left as bl
n=int(input())
a=list(map(int,input().split()))
t=[[]for i in range(n)]
for i in range(n-1):
    u,v=map(int,input().split())
    t[u-1].append(v-1)
    t[v-1].append(u-1)
b=[1]+[0]*(n-1)
q=[[0,[a[0]],1]]
while q:
    c,d,e=q.pop(0)
    for i in t[c]:
        s=d[::]
        g=e
        if b[i]==0:
            h=bl(d,a[i])
            if e>h:
                s[h]=a[i]
            else:
                s.append(a[i])
                g+=1
            b[i]=g
            q.append([i,s,g])
for i in range(n):
    print(b[i])


Fixed submission:
k=int(input())
a,b=map(int,input().split())
print("OK" if (a-1)//k!=b//k else"NG")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a,b=n//2,n//2+1
for i in range(m):
    print(i+1,2*m-i+(n%2==0 and 2*(m-i)>=n//2)

Fixed submission:
n,m=map(int,input().split())
for i in range(m):
    print(i+1,2*m-i+(n%2==0 and 2*(m-i)-1>=n//2))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=deque(list(input()))
p=0
for i in range(int(input())):
    a=list(map(str,input().split()))
    if len(a)==1:
        p+=1
    else:
        if p%2:
            if a[1]=="2":
                s.appendleft(a[2])
            else:
                s.append(a[2])
        else:
            if a[1]=="1":
                s.appendleft(a[2])
            else:
                s.append(a[2])
ans=""
if p%2==1:
    while s:
        ans+=s.pop()
else:
    while s:
        ans+=s.popleft()
print(ans)

Fixed submission:
from collections import deque
s=deque(list(input()))
p=0
for i in range(int(input())):
    a=list(map(str,input().split()))
    if len(a)==1:
        p^=1
    else:
        if p%2:
            if a[1]=="2":
                s.appendleft(a[2])
            else:
                s.append(a[2])
        else:
            if a[1]=="1":
                s.appendleft(a[2])
            else:
                s.append(a[2])
ans=""
if p%2==1:
    while s:
        ans+=s.pop()
else:
    while s:
        ans+=s.popleft()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
p=0
for i in range(int(input())):
    a=list(map(str,input().split()))
    if len(a)==1:
        p+=1
    else:
        if p%2:
            if a[1]=="2":
                s.insert(0,a[2])
            else:
                s.append(a[2])
        else:
            if a[1]=="1":
                s.insert(0,a[2])
            else:
                s.append(a[2])
ans=""
if p%2==1:
    for i in s[::-1]:
        ans+=i
else:
    for i in s:
        ans+=i
print(ans)

Fixed submission:
from collections import deque
s=deque(list(input()))
p=0
for i in range(int(input())):
    a=list(map(str,input().split()))
    if len(a)==1:
        p^=1
    else:
        if p%2:
            if a[1]=="2":
                s.appendleft(a[2])
            else:
                s.append(a[2])
        else:
            if a[1]=="1":
                s.appendleft(a[2])
            else:
                s.append(a[2])
ans=""
if p%2==1:
    while s:
        ans+=s.pop()
else:
    while s:
        ans+=s.popleft()
print(ans)
Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            ans+=n
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    d=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]+int(s[i])*d)%p
        a+=t[g[i]]
        t[g[i]]+=1
        d*=10
        d%=p
    print(a)


Fixed submission:
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            a+=i+1
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    d=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]+int(s[i])*d)%p
        a+=t[g[i]]
        t[g[i]]+=1
        d*=10
        d%=p
    print(a)

Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            ans+=n
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]*10+int(s[n-i-1]))%p
        a+=t[g[i]]
        t[g[i]]+=1
    print(a)

Fixed submission:
n,p=map(int,input().split())
s=input()
if p==2 or p==5:
    a=0
    for i in range(n):
        if int(s[i])%p==0:
            a+=i+1
    print(a)
else:
    a=0
    g=[0]*(n+1)
    t=[0]*p
    t[0]=1
    d=1
    for i in range(n-1,-1,-1):
        g[i]=(g[i+1]+int(s[i])*d)%p
        a+=t[g[i]]
        t[g[i]]+=1
        d*=10
        d%=p
    print(a)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
w=[i for i in range(n+1)]
s=[1]*(n+1)
g=[list(map(int,input().split()))for i in range(n)]
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=1
        else:
            w[y]=x
            s[x]+=1
for i in range(m):
    a,b=g[i][0],g[i][1]
    unite(a,b)
for i in range(1,n+1):
    w[i]=root(i)
    s[i]=s[w[i]]
for i in range(m):
    s[g[i][0]]-=1
    s[g[i][1]]-=1
for i in range(k):
    a,b=map(int,input().split())
    if w[a]==w[b]:
        s[a]-=1
        s[b]-=1
for i in range(1,n+1):s[i]-=1
print(*s[1:])

Fixed submission:
n=int(input())
print((n+1)//2)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
w=[i for i in range(n+1)]
s=[1]*(n+1)
g=[list(map(int,input().split()))for i in range(n)]
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=1
        else:
            w[y]=x
            s[x]+=1
for i in range(m):
    a,b=g[i][0],g[i][1]
    unite(a,b)
for i in range(1,n+1):
    w[i]=root(i)
    s[i]=s[w[i]]
for i in range(m):
    s[g[i][0]]-=1
    s[g[i][1]]-=1
for i in range(k):
    a,b=map(int,input().split())
    if w[a]==w[b]:
        s[a]-=1
        s[b]-=1
for i in range(1,n+1):s[i]-=1
print(*s[1:])

Fixed submission:
n,m,k=map(int,input().split())
w=[i for i in range(n+1)]
s=[1]*(n+1)
g=[list(map(int,input().split()))for i in range(m)]
def root(x):
    if w[x]==x:
        return x
    x=w[x]
    return root(w[x])
def unite(x,y):
    x=root(x)
    y=root(y)
    if x!=y:
        if s[x]<s[y]:
            w[x]=y
            s[y]+=s[x]
        else:
            w[y]=x
            s[x]+=s[y]
for i in range(m):
    a,b=g[i][0],g[i][1]
    unite(a,b)
for i in range(1,n+1):
    w[i]=root(i)
    s[i]=s[w[i]]
for i in range(m):
    s[g[i][0]]-=1
    s[g[i][1]]-=1
for i in range(k):
    a,b=map(int,input().split())
    if w[a]==w[b]:
        s[a]-=1
        s[b]-=1
for i in range(1,n+1):s[i]-=1
print(*s[1:])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
m=10**9+7
p=1
for i in range(1,n+1):p=(p*(2*n-i)*pow(i,m-2,m))%m
if k>=n:
    print(p)
else:
    c,d=1,1
    for i in range(1,k+1):c=(c*(n-i)*pow(i,m-2,m))%m
    for i in range(1,k+1):d=(d*(n-i+1)*pow(i,m-2,m))%m
    for i in range(k+1,n):
        c=(c*(n-i)*pow(i,m-2,m))%m
        d=(d*(n-i+1)*pow(i,m-2,m))%m
        p=(p-c*d)%m
    print(p)

Fixed submission:
n,k=map(int,input().split())
m=10**9+7
p=1
for i in range(1,n+1):p=(p*(2*n-i)*pow(i,m-2,m))%m
if k>=n:
    print(p)
else:
    c,d=1,1
    for i in range(1,k+1):c=(c*(n-i)*pow(i,m-2,m))%m
    for i in range(1,k+1):d=(d*(n-i+1)*pow(i,m-2,m))%m
    for i in range(k+1,n):
        c=(c*(n-i)*pow(i,m-2,m))%m
        d=(d*(n-i+1)*pow(i,m-2,m))%m
        p=(p-c*d)%m
    print(p)
Buggy python submission (verdict: Time Limit Exceeded):
k,q=map(int,input().split())
d=list(map(int,input().split()))
for i in range(q):
    n,x,m=map(int,input().split())
    l=[i%m if i%m!=0 else m for i in d]
    print(n-1-(x+((n-1)//k)*sum(l)+sum(l[:(n-1)%k]))//m+x//m)


Fixed submission:
k,q=map(int,input().split())
d=list(map(int,input().split()))
for i in range(q):
    n,x,m=map(int,input().split())
    l=[i%m if i%m!=0 else m for i in d]
    print(n-1-(x+((n-1)//k)*sum(l)+sum(l[:(n-1)%k]))//m+x//m)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_right as br
from bisect import bisect_left as bl
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
l,r=10**18,-10**18-1
while l-r>1:
    t=(l+r)//2
    p=0
    for i in a:
        if i<0:
            p+=n-bl(a,t/i)
        elif i==0:
            if t>=0:
                p+=n
        else:
            p+=br(a,t/i)
        if i**2<=t:
            p-=1
    p//=2
    if p>=k:
        l=t
    else:
        r=t
g=-float("INF")
for i in range(n):
    if a[i]<0:
        c=bl(a,l/a[i])
        if c==i:
            c+=1
        if c<n:
            g=max(g,a[c]*a[i])
    elif a[i]==0:
        g=max(g,0)
    else:
        c=br(a,l/a[i])-1
        if c==i:
            c-=1
        if c>0:
            g=max(g,a[c]*a[i])
print(g)

Fixed submission:
a=list(map(int,input().split()))
print("Yes" if len(set(a))==2 else"No")
Buggy python submission (verdict: Runtime Error):
import numpy as np
h,n=map(int,input().split())
d=sorted([list(map(int,input().split()))for i in range(n)])
p=np.array([float("INF")]*max(h+1,2*d[-1][0]+1))
p[0]=0
s=max(h+1,2*d[-1][0]+1)
for i in range(n):
    a,b=d[i][0],d[i][1]
    j=1
    while j*a<=s:
        p[j*a:]=np.minimum(p[j*a:],p[:-j*a]+j*b)
        j+=1
print(int(min(p[h:])))

Fixed submission:
h,n=map(int,input().split())
p=[float("INF")]*(h+1)
p[0]=0
for i in range(n):
    a,b=map(int,input().split())
    for j in range(h+1):
        if p[min(h,j+a)]>p[j]+b:
            p[min(j+a,h)]=p[j]+b
print(p[-1])