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

Fixed submission:
from math import gcd
import sys
input = sys.stdin.readline

mod = 10**9 + 7
N = int(input())
cnt = {}
zz = 0
az = 0
bz = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A == B == 0:
        zz += 1
        continue
    if A == 0:
        az += 1
        continue
    if B == 0:
        bz += 1
        continue
    neg = False
    if A < 0:
        neg ^= True
        A *= -1
    if B < 0:
        neg ^= True
        B *= -1
    g = gcd(A, B)
    sign = -1 if neg else 1
    A //= g
    B //= g
    frac = (-sign * A, B)
    if frac not in cnt:
        cnt[frac] = 0
    cnt[frac] += 1
ans = 1
used = set()
for frac, c in cnt.items():
    if frac in used:
        continue
    A, B = frac
    sign = 1
    if A < 0:
        A *= -1
        sign = -1
    bad = (B * -sign, A)
    if bad in cnt:
        b = cnt[bad]
        ans = ans * (pow(2, c, mod) + pow(2, b, mod) - 1) % mod
        used.add(bad)
    else:
        ans = ans * pow(2, c) % mod
ans = ans * (pow(2, az, mod) + pow(2, bz, mod) - 1) % mod
print((ans + zz - 1) % mod)

Buggy submission (verdict: Runtime Error):
from math import gcd
import sys
input = sys.stdin.readline

mod = 10**9 + 7
N = int(input())
cnt = {}
for i in range(N):
    A, B = map(int, input().split())
    neg = False
    if A < 0:
        neg ^= True
        A *= -1
    if B < 0:
        neg ^= True
        B *= -1
    g = gcd(A, B)
    sign = -1 if neg else 1
    A //= g
    B //= g
    frac = (-sign * A, B)
    if frac not in cnt:
        cnt[frac] = 0
    cnt[frac] += 1
ans = 1
used = set()
for frac, c in cnt.items():
    if frac in used:
        continue
    A, B = frac
    sign = 1
    if A < 0:
        A *= -1
        sign = -1
    bad = (B * -sign, A)
    if bad in cnt:
        b = cnt[bad]
        ans = ans * (pow(2, c, mod) + pow(2, b, mod) - 1) % mod
        used.add(bad)
    else:
        ans = ans * 2 % mod
print((ans - 1) % mod)

Buggy submission (verdict: Runtime Error):
from math import gcd
import sys
input = sys.stdin.readline

mod = 10**9 + 7
N = int(input())
cnt = {}
for i in range(N):
    A, B = map(int, input().split())
    neg = False
    if A < 0:
        neg ^= True
        A *= -1
    if B < 0:
        neg ^= True
        B *= -1
    g = gcd(A, B)
    sign = -1 if neg else 1
    A //= g
    B //= g
    frac = (-sign * A, B)
    if frac not in cnt:
        cnt[frac] = 0
    cnt[frac] += 1
ans = 1
used = set()
for frac, c in cnt.items():
    if frac in used:
        continue
    A, B = frac
    sign = 1
    if A < 0:
        A *= -1
        sign = -1
    bad = (B * -sign, A)
    if bad in cnt:
        b = cnt[bad]
        ans = ans * (pow(2, c, mod) + pow(2, b, mod) - 1) % mod
        used.add(bad)
    else:
        ans = ans * 2 % mod
print((ans - 1) % mod)
Problem p02757 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N, P = map(int, input().split())
S = list(map(int, list(input().rstrip())))
ans = 0
if P == 2 or P == 5:
    for i in range(N):
        if S[i] % P == 0:
            ans += i + 1
else:
    U = [0] * (N+1)
    count = [0] * P
    count[0] = 1
    factor = 10
    for i in range(N)[::-1]:
        U[i] = (S[i] * factor + U[i+1]) % P
        factor = factor * 10 % P
        ans += count[U[i]]
        count[U[i]] += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int N, P;
    cin >> N >> P;
    string S;
    cin >> S;
    ll count[P];
    memset(count, 0, sizeof(count));
    ll ncount[P];
    ll ans = 0;
    rep(i, N) {
        int d = S.at(i) - '0';
        count[0]++;
        memset(ncount, 0, sizeof(ncount));
        rep(j, P) {
            int nj = (j * 10 + d) % P;
            ncount[nj] += count[j];
        }
        rep(j, P) count[j] = ncount[j];
        ans += count[0];
    }
    cout << ans << endl;
}
Problem p02851 (python)

Fixed submission:
import numpy as np
from collections import defaultdict

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))

B = (np.add.accumulate(A) - np.arange(N+1)) % K

counter = defaultdict(int)
ans = 0

for j in range(N+1):
    if j - K >= 0:
        counter[B[j-K]] -= 1
    ans += counter[B[j]]
    counter[B[j]] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))

B = (np.add.accumulate(A) - np.arange(N+1)) % K

count = [0] * K
ans = 0

for j in range(N+1):
    if j - K >= 0:
        count[B[j-K]] -= 1
    ans += count[B[j]]
    count[B[j]] += 1

print(ans)
Problem p02879 (python)

Fixed submission:
A, B = map(int, input().split())
if A > 9 or B > 9:
    print(-1)
else:
    print(A * B)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

l = 0
r = max(a * f for a, f in zip(A, F)) + 1

while l < r:
    m = (l + r) // 2
    if sum(max(a - m // f, 0) for a, f in zip(A, F)) <= K:
        r = m
    else:
        l = m + 1

print(r)
Problem p02948 (python)

Fixed submission:
from heapq import heappush, heappop

N, M = map(int, input().split())
salary = [[] for i in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    if A <= M:
        salary[A].append(B)
queue = []
ans = 0

for i in range(1, M+1):
    for s in salary[i]:
        heappush(queue, -s)
    if queue:
        ans += -heappop(queue)

print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop

N, M = map(int, input().split())
salary = [[] for i in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    salary[A].append(B)
queue = []
ans = 0

for i in range(1, M+1):
    for s in salary[i]:
        heappush(queue, -s)
    if queue:
        ans += -heappop(queue)

print(ans)
Problem p03003 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
mod = 10**9 + 7

dp = [[0] * (M+1) for _ in range(N+1)]
for i in range(N+1):
    for j in range(M+1):
        if i == 0 or j == 0:
            dp[i][j] = 1
        elif S[i-1] == T[j-1]:
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod
        else:
            dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod
print(dp[-1][-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
mod = 10**9 + 7

memo = [[0] * M for _ in range(N)]
def dfs(i, j):
    if i < 0 or j < 0:
        return 1
    if memo[i][j] != 0:
        return memo[i][j]
    if S[i] == T[j]:
        memo[i][j] = (dfs(i-1, j) + dfs(i, j-1)) % mod
    else:
        memo[i][j] = (dfs(i-1, j) + dfs(i, j-1) - dfs(i-1, j-1)) % mod
    return memo[i][j]

print(dfs(N-1, M-1))
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
BC = [list(map(int, input().split())) for i in range(M)]
BC = sorted(BC, key=lambda x: -x[1])
i = 0
for B, C in BC:
    for _ in range(B):
        if i < N and A[i] < C:
            A[i] = C
            i += 1
        else:
            print(sum(A))
            exit()
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
BC = [list(map(int, input().split())) for i in range(M)]
BC = sorted(BC, key=lambda x: -x[1])
i = 0
for B, C in BC:
    for _ in range(B):
        if A[i] < C:
            A[i] = C
            i += 1
        else:
            print(sum(A))
            exit()
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
BC = [list(map(int, input().split())) for i in range(M)]
BC = sorted(BC, key=lambda x: -x[1])
i = 0
for B, C in BC:
    for _ in range(B):
        if A[i] < C:
            A[i] = C
            i += 1
        else:
            print(sum(A))
            exit()
Problem p03332 (python)

Fixed submission:
from fractions import gcd

N, A, B, K = map(int, input().split())
if K == 0:
    print(1)
    exit()
c = gcd(A, B)
if K % c != 0:
    print(0)
    exit()
A //= c; B //= c; K //= c
mod = 998244353

fact = [1] * (N+1)
fact_inv = [1] * (N+1)
for i in range(1, N+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[N] = pow(fact[N], mod-2, mod)
for i in range(1, N+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod
comb = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n-k] % mod

ans = 0
for x in range(N+1):
    y, r = divmod(K - A * x, B)
    if r != 0:
        continue
    if 0 <= y <= N:
        ans = (ans + comb(N, x) * comb(N, y)) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd

N, A, B, K = map(int, input().split())
if K == 0:
    print(1)
    exit()
c = gcd(A, B)
if K % c != 0:
    print(0)
    exit()
A //= c; B //= c; K //= c
mod = 998244353

fact = [1] * (N+1)
fact_inv = [1] * (N+1)
for i in range(1, N+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[N] = pow(fact[N], mod-2, mod)
for i in range(1, N+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod


ans = 0
for x in range(N+1):
    if (K - A * x) % B != 0:
        continue
    y = (K - A * x) // B
    tmp = 0
    for g in range(max(0, x + y - N), min(x, y, N)+1):
        r = x - g
        b = y - g
        if r < 0 or b < 0:
            break
        tmp = (tmp + fact_inv[r] * fact_inv[b] * fact_inv[g] * fact_inv[N - r - g - b]) % mod
    ans = (ans + tmp) % mod
ans = ans * fact[N] % mod
print(ans)
Problem p02578 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input()))
s = a[0]
ans = 0
for i in range(1,n):
  ans += max(0,a[i]-s)
  s = max(s,a[i])
print(ans)
Problem p02594 (python)

Fixed submission:
x=int(input())
if x>=30:print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
ok=10**10
ng=1
for i in range(40):
    chk=(ok+ng)//2
    cnt=0
    for j in range(n):
        cnt+=(a[j]+chk-1)//chk-1
    if cnt > k:
        ng = chk
    else:
        ok = chk
print(ok)
Problem p02629 (python)

Fixed submission:
n=int(input())
ans=""
def re(n,ans):
    if n<=26:
        return ans+chr(n+96)
    rem=(n-1)%26
    div=(n-1)//26
    return re(div,ans+chr(rem+97))
print(re(n,"")[::-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=""
while n>26:
    rem=n%26
    if rem==0:
        ans+="z"
        n=(n//26-26)*26
        continue
    n//=26
    ans+=chr(rem+96)
ans+=chr(n+96)
print(ans[::-1])
Problem p02659 (python)

Fixed submission:
a,b=map(float,input().split())
a=int(a)
b*=10**15
b=int(b)
print((a*b)//10**15)

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b.replace('.','')
b=int(b)
print((a*b)//100)
Problem p02759 (python)

Fixed submission:
n=int(input())
print((n+1)//2)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
n,m,k=map(int,input().split())
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
 
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    def getsize(self, x):
        return self.size[self.root(x)]
uf=UnionFind(n)
ans=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    uf.merge(a-1,b-1)
    ans[a-1]-=1;ans[b-1]-=1
for i in range(k):
    c,d=map(int,input().split())
    if uf.issame(c-1,d-1):
        ans[c-1]-=1;ans[d-1]-=1
for i in range(n):
    ans[i]=uf.getsize(i)+ans[i]-1
print(*ans)
Problem p02762 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n,m,k=map(int,input().split())
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
 
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    def getsize(self, x):
        return self.size[self.root(x)]
uf=UnionFind(n)
ans=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    uf.merge(a-1,b-1)
    ans[a-1]-=1;ans[b-1]-=1
for i in range(k):
    c,d=map(int,input().split())
    if uf.issame(c-1,d-1):
        ans[c-1]-=1;ans[d-1]-=1
for i in range(n):
    ans[i]=uf.getsize(i)+ans[i]-1
print(*ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
 
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    def getsize(self, x):
        return self.size[self.root(x)]
uf=UnionFind(n)
ans=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    uf.merge(a-1,b-1)
    ans[a-1]-=1;ans[b-1]-=1
for i in range(k):
    c,d=map(int,input().split())
    if uf.issame(c-1,d-1):
        ans[c-1]-=1;ans[d-1]-=1
for i in range(n):
    ans[i]=uf.getsize(i)+ans[i]-1
print(*ans)
Problem p02862 (python)

Fixed submission:
x,y=map(int,input().split())
MOD = 10**9+7
if (x+y)%3!=0:print(0);exit()
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
f_mod=[1]*(10**6)
f_mod_inverse=[1]*(10**6)
for i in range(1,10**6):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i)%MOD
cnt=(x+y)//3
dif=abs(x-y)
ele=(cnt-dif)//2
print(comb_mod(cnt,ele))

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
MOD = 10**9+7

def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
f_mod=[1]*(n+1)
f_mod_inverse=[1]*(n+1)
for i in range(1,n+1):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i)%MOD

if x+y%3!=0:print(0)
else:
  n=(x+y)//3
  dif=abs(x-y)
  ele=(n-dif)//2
  print(comb_mod(n,ele))
Problem p02863 (python)

Fixed submission:
import sys
input=sys.stdin.readline
n,t=map(int,input().split())
dp=[[0 for i in range(t)] for j in range(n+1)]
food=[list(map(int,input().split())) for i in range(n)]
foodmax=[0]*n
food.sort(key=lambda x:x[1],reverse=True)
food.sort(key=lambda x:x[0])
foodmax[-1]=food[-1][1]
for i in range(n-1)[::-1]:
  foodmax[i]=max(foodmax[i+1],food[i][1])
foodmax+=[0]
for i in range(n):
  for j in range(t):
    if j<food[i][0]:
      dp[i+1][j]=dp[i][j]
    else:
      dp[i+1][j]=max(dp[i][j],dp[i][j-food[i][0]]+food[i][1])
      
ans=0
for i in range(n):
  if ans<dp[i+1][t-1]+foodmax[i+1]:
    ans=dp[i+1][t-1]+foodmax[i+1]
print(ans)

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
dp=[[[0,0] for i in range(t)] for j in range(n+1)]
food=[list(map(int,input().split())) for i in range(n)]
foodmax=[0]*n
food.sort(key=lambda x:x[1],reverse=True)
food.sort(key=lambda x:x[0])
foodmax[-1]=food[-1][1]
for i in range(n-1)[::-1]:
  foodmax[i]=max(foodmax[i+1],food[i][1])
for i in range(n):
  for j in range(t):
    if j<food[i][0]:
      dp[i+1][j]=dp[i][j]
    else:
      dp[i+1][j][0]=max(dp[i][j][0],dp[i][j-food[i][0]][0]+food[i][1])
      if dp[i][j][0]>=dp[i][j-food[i][0]][0]+food[i][1]:
        dp[i+1][j][1]=dp[i][j][1]
      else:
        dp[i+1][j][1]=i
ans=0
for i in range(n+1):
  if ans<dp[i][t-1][0]+foodmax[dp[i][t-1][1]+1]:
    ans=dp[i][t-1][0]+foodmax[dp[i][t-1][1]+1]
print(ans)
Problem p02891 (python)

Fixed submission:
s=input()
k=int(input())
a=set(s)
if len(a)==1:print(k*len(s)//2)
else:
  V=[]
  unit=0
  for i in s:
    if len(V)==0 or V[-1][0]!=i:
      V.append([i,1])
    else:
      V[-1][1] += 1
  for i in V:
    unit+=i[1]//2
  ans=unit*k
  if s[0]==s[-1]:
    ans=ans-(V[0][1]//2+V[-1][1]//2-(V[0][1]+V[-1][1])//2)*(k-1)
  print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
a=set(s)
if len(a)==1:print(k*len(s)//2)
else:
  V=[]
  unit=0
  for i in s:
	if len(V)==0 or V[-1][0]!=i:
		V.append([i,1])
	else:
		V[-1][1] += 1
  for i in V:
    unit+=i[1]//2
  ans=unit*k
  if s[0]==s[-1]:
    ans=ans-(V[0][1]//2+V[-1][1]//2-(V[0][1]+V[-1][1])//2)*(k-1)
  print(ans)
Problem p02912 (python)

Fixed submission:
import sys
import heapq
sys.setrecursionlimit(100002)
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]=-a[i]
heapq.heapify(a)
for i in range(m):
  heapq.heappushpop(a,-(-a[0]//2))
print(-sum(a))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100002)
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
    max(a)//=2
print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100002)
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
r=[0]
a.sort(reverse=True)
for i in range(m):
    d=a.pop(0)
    if r[-1]>=d:
        r[-1]//=2
        r.append(d)
        r.sort()
    else:
        d//=2
        r.append(d)
        r.sort()
print(sum(a)+sum(r))
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
print(s if a>=3200 else"red")

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
sys.setrecursionlimit(500000)
input=sys.stdin.readline
n,q=map(int,input().split())
edge=[[] for i in range(n)]
cost=[0]*n
for i in range(n-1):
  p,s=map(int,input().split())
  p-=1;s-=1
  edge[p].append(s)
  edge[s].append(p)
for i in range(q):
  x,c=map(int,input().split())
  x-=1
  cost[x]+=c
visited=[False]*n
queue=deque([0])
visited[0]=True
while len(queue)!=0:
  a=queue.popleft()
  for i in edge[a]:
    if visited[i]==True:continue
    queue.append(i)
    visited[i]=True
    cost[i]+=cost[a]
for i in range(n):
  cost[i]=str(cost[i])
print(" ".join(cost))
Problem p02951 (python)

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

Buggy submission (verdict: Runtime Error):
a=input()
l=len(a)
a=int(a)
if a==100000:
  print(90909)
elif 99999>=a>=10000:
  print(909+a-9999)
elif 9999>=a>=1000:
  print(909)
elif 999>=a>=100:
  print(9+a-99)
elif 99>=a>=10:
  print(9)
else:
  print(a)
Problem p03003 (python)

Fixed submission:
n,m=map(int,input().split())
mod=10**9+7
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0 for i in range(m+1)] for i in range(n+1)]
sum=[[0 for i in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,m+1):
    if s[i-1]==t[j-1]:
      dp[i][j]=(sum[i-1][j-1]+1)%mod
    else:dp[i][j]=0
    sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod
print((sum[-1][-1]+1)%mod)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0 for i in range(n+1)] for i in range(m+1)]
sum=[[0 for i in range(n+1)] for i in range(m+1)]
for i in range(1,n+1):
  for j in range(1,m+1):
    if s[i-1]==t[j-1]:
      dp[i][j]=(sum[i-1][j-1]+1)%mod
    else:dp[i][j]=0
    sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod
print(sum[-1][-1]%mod)
Problem p03012 (python)

Fixed submission:
n=int(input())
b=list(map(int,input().split()))
ans=sum(b)
ansl=[]
for i in range(n-1,0,-1):
  ans-=2*b[i]
  ansl.append(abs(ans))
print(min(ansl))

Buggy submission (verdict: Runtime Error):
=int(input())
a=list(map(int,input().split()))
ans=sum(a)
for i in range (n):
  if ans>abs(ans-2*a[i]):
    ans=ans-2*a[i]
print(abs(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=sum(a)n=int(input())
a=list(map(int,input().split()))
ans=sum(a)
for i in
for i in range (n):
  if ans>abs(ans-2*a[i]):
    ans=abs(ans-2*a[i])
print(ans)
Problem p03013 (python)

Fixed submission:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
arr=[1,2]
arr=arr+[0]*(n-2)
danger=[int(input()) for _ in range(m)]
if danger==[]:
  pass
elif danger[0]==1:
  arr[0]=0
  arr[1]=1
for i in range(m):
  arr[danger[i]-1]=-1
for i in range(n):
  if arr[i]==-1:
    arr[i]=0
  elif i==0 or i==1:
    continue 
  else:
    arr[i]=(arr[i-1]+arr[i-2])%(10**9+7)
print(arr[n-1]%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
arr=[1,2]
arr=arr+[0]*(n-2)
danger=[int(input()) for _ in range(m)]
if danger[0]==1:
  arr[0]=0
  arr[1]=1
for i in range(m):
  arr[danger[i]-1]=-1
for i in range(n):
  if arr[i]==-1:
    arr[i]=0
  elif i==0 or i==1:
    continue 
  else:
    arr[i]=(arr[i-1]+arr[i-2])%(10**9+7)
print(arr[n-1]%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
out=[]
for i in range(m):
  out.append(int(input()))
dp=[0 for i in range(n)]
dp[0]=1
dp[1]=2
if 1 in out:
  dp[0]=0
  if 2 in out:
    dp[1]=0
  else:
    dp[1]=1
elif 2 in out:
  dp[1]=0
for i in range(2,n):
  if (i+1) in out:
    continue
  else:
    dp[i]=dp[i-1]+dp[i-2]
print (dp[n-1]%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
out=[]
for i in range(m):
  out.append(int(input()))
def stairs(n):
  memo=["a"]*n
  def count(n):
    if n in out:
      return 0
    elif n<=2:
      return n
    else memo[n-1]!="a":
      return memo[n-1]%(10e9+7)
    return (memo[n-2]+memo[n-3])%(10e9+7)
  return count(n)
print(stairs(n)%(10e9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
out=[]
for i in range(m):
  out.append(int(input())
from functools import lru_cache

@lru_cache(maxsize=10**5)
def fib_memoized(n):
    if n < 2:
        return n
    elif n in out:
        return 0
    else:
        return fib(n - 1) + fib(n - 2)
print(fib_memorized(n))