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

Fixed submission:
n,m=map(int,input().split())
mod=10**9+7
N=10**5+1+34
p=[1]*N #assume all are primes from start 
for i in range(2,N):
    if p[i]==1:
        for j in range(2*i,N,i):
            p[j]=0
primes=[]
for i in range(2,N):
    if p[i]==1:
        primes.append(i)

#print(primes)
fact=[1]*N
for i in range(2,N):
    fact[i]=(i*fact[i-1])%mod
ifact=[1]*N
ifact[N-1]=pow(fact[N-1],mod-2,mod)
for i in range(N-2,0,-1):
    ifact[i]=((i+1)*ifact[i+1])%mod
ans=1
#print(ifact[:10])
for x in primes:
    if x>m:
        break
    cnt=0
    #print(m,end=' before\n')
    while m%x==0:
        m//=x
        cnt+=1
    if cnt==0:
        continue
#    print(x,cnt)
    #print(m,end=' after\n')
 #   print(fact[n-1+cnt],ifact[cnt],ifact[n-1])
    val=(fact[n-1+cnt]*(ifact[cnt]*ifact[n-1])%mod)%mod
  #  print(val)
    ans=(ans*val)%mod
if m>1:
    ans=(ans*n)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
N=10**5+1+20
p=[1]*N #assume all are primes from start 
for i in range(2,N):
    if p[i]==1:
        for j in range(2*i,N,i):
            p[j]=0
primes=[]
for i in range(2,N):
    if p[i]==1:
        primes.append(i)

#print(primes)
fact=[1]*N
for i in range(2,N):
    fact[i]=(i*fact[i-1])%mod
ifact=[0]*N
ifact[N-1]=pow(fact[N-1],mod-2,mod)
for i in range(N-2,0,-1):
    ifact[i]=((i+1)*ifact[i+1])%mod
ans=1
for x in primes:
    if x>m:
        break
    cnt=0
    #print(m,end=' before\n')
    while m%x==0:
        m//=x
        cnt+=1
    if cnt==0:
        continue
    #print(x,cnt)
    #print(m,end=' after\n')
    
    val=(fact[n-1+cnt]*(ifact[cnt]*ifact[n-1])%mod)%mod
    ans=(ans*val)%mod
if m>1:
    ans=(ans*n)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
N=10**5+1+20
p=[1]*N #assume all are primes from start 
for i in range(2,N):
    if p[i]==1:
        for j in range(2*i,N,i):
            p[j]=0
primes=[]
for i in range(2,N):
    if p[i]==1:
        primes.append(i)

#print(primes)
fact=[1]*N
for i in range(2,N):
    fact[i]=(i*fact[i-1])%mod
ifact=[0]*N
ifact[N-1]=pow(fact[N-1],mod-2,mod)
for i in range(N-2,0,-1):
    ifact[i]=((i+1)*ifact[i+1])%mod
ans=1
for x in primes:
    if x>m:
        break
    cnt=0
    #print(m,end=' before\n')
    while m%x==0:
        m//=x
        cnt+=1
    if cnt==0:
        continue
    #print(x,cnt)
    #print(m,end=' after\n')
    
    val=(fact[n-1+cnt]*(ifact[cnt]*ifact[n-1])%mod)%mod
    ans=(ans*val)%mod
if m>1:
    cnt=1
    val=(fact[n-1+cnt]*(ifact[cnt]*ifact[n-1])%mod)%mod
    ans=(ans*val)%mod
print(ans)
Problem p02580 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
 
H, W, M = map(int, input().split())
 
X = [0] * W
Y = [0] * H
Map = []
 
for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    Y[h] += 1
    X[w] += 1
    Map.append((h, w))
 
MX = max(X)
MY = max(Y)
ans = MX + MY
Xans = set()
Yans = set()
for i, x in enumerate(X):
    if x == MX:
        Xans.add(i)
for i, y in enumerate(Y):
    if y == MY:
        Yans.add(i)
cnt = 0
for h, w in Map:
    if h in Yans and w in Xans:
        cnt += 1
if cnt == len(Xans) * len(Yans):
    ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
 
H, W, M = map(int, input().split())
 

for _ in range(M):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    Y[h] += 1
    X[w] += 1
    Map.append((h, w))
 
MX = max(X)
MY = max(Y)
ans = MX + MY
Xans = set()
Yans = set()
for i, x in enumerate(X):
    if x == MX:
        Xans.add(i)
for i, y in enumerate(Y):
    if y == MY:
        Yans.add(i)
cnt = 0
for h, w in Map:
    if h in Yans and w in Xans:
        cnt += 1
if cnt == len(Xans) * len(Yans):
    ans -= 1
print(ans)
Problem p02659 (python)

Fixed submission:
import decimal
A, B = map(decimal.Decimal, input().split())
print(int(A*B))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())
print((A * B) // 1)
Problem p02984 (python)

Fixed submission:
N = int(input())
A = list(map(lambda x: 2 * int(x), input().split()))

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(map(str, mounts)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = map(lambda x: 2 * int(x), input().split())

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(mounts))
Problem p02990 (python)

Fixed submission:
import math

def cmb(n, r):
  if n == r:
    return 1
  return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

N, K = list(map(int, input().split()))

for i in range(K):
  if (N-K+1) < i + 1:
    print(0)
  else:
  	C = (cmb(K-1, i) * cmb((N-K+1), i+1)) % (10 ** 9 + 7)
  	print(C)

Buggy submission (verdict: Runtime Error):
import math

def cmb(n, r):
  if r == 0 or n == r:
    return 1
  return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

N, K = list(map(int, input().split()))

for i in range(K):
  C = (cmb(K-1, i) * cmb((N-K+1), i+1)) % (10 ** 9 + 7)
  print(C)
Problem p03242 (python)

Fixed submission:
n = input()

print(n.translate(str.maketrans({'1': '9', '9': '1'})))

Buggy submission (verdict: Runtime Error):
n = raw_input()

n.translate(str.maketrans({'1': '9', '9': '1'}))
print n
Problem p03307 (python)

Fixed submission:
N = int(raw_input())
if N % 2 == 0:
  print N
else:
  print N * 2

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
if N %= 2 == 0:
  print N
else:
  print N * 2
Problem p03326 (python)

Fixed submission:
import numpy as np

(N, M) = map(int, raw_input().split())
cakes = [map(int, raw_input().split()) for i in xrange(N)]
cakes_p = np.array(sorted(cakes, key=lambda x: sum(x))[::-1])
cakes_nx = np.array(sorted(cakes, key=lambda x: sum(x) - 2 * x[0])[::-1])
cakes_ny = np.array(sorted(cakes, key=lambda x: sum(x) - 2 * x[1])[::-1])
cakes_nz = np.array(sorted(cakes, key=lambda x: sum(x) - 2 * x[2])[::-1])
cakes_list = [cakes_p, cakes_nx, cakes_ny, cakes_nz, cakes_p[::-1], cakes_nx[::-1], cakes_ny[::-1], cakes_nz[::-1]]
value = max([sum(map(abs,sum(cake[:M]))) for cake in cakes_list]) if M != 0 else 0

print value

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

(N, M) = map(int, raw_input().split())
cakes = [map(int, raw_input().split()) for i in xrange(N)]
cakes_p = np.array(sorted(cakes, key=lambda x: sum(x))[::-1])
cakes_nx = np.array(sorted(cakes, key=lambda x: sum(x) - 2 * x[0])[::-1])
cakes_ny = np.array(sorted(cakes, key=lambda x: sum(x) - 2 * x[1])[::-1])
cakes_nz = np.array(sorted(cakes, key=lambda x: sum(x) - 2 * x[2])[::-1])
cakes_list = [cakes_p, cakes_nx, cakes_ny, cakes_nz, cakes_p[::-1], cakes_nx[::-1], cakes_ny[::-1], cakes_nz[::-1]]
value = max([sum(map(abs,sum(cake[:M]))) for cake in cakes_list])

print value

Buggy submission (verdict: Runtime Error):
import numpy as np
(N, M) = map(int, raw_input().split())
cakes = [map(int, raw_input().split()) for i in xrange(N)]
cakes_x = sorted(cakes, key=lambda x: x[0])
cakes_y = sorted(cakes, key=lambda x: x[1])
cakes_z = sorted(cakes, key=lambda x: x[2])

x_min = np.array([0, 0, 0])
x_max = np.array([0, 0, 0])
y_min = np.array([0, 0, 0])
y_max = np.array([0, 0, 0])
z_min = np.array([0, 0, 0])
z_max = np.array([0, 0, 0])
for i in xrange(M):
  x_min += np.array(cakes_x[M])
  x_max += np.array(cakes_x[-M-1])
  y_min += np.array(cakes_y[M])
  y_max += np.array(cakes_y[-M-1])
  z_min += np.array(cakes_z[M])
  z_max += np.array(cakes_z[-M-1])

value = max([sum(map(abs, x_min)), sum(map(abs, x_max)), sum(map(abs, y_min)), sum(map(abs, y_max)), sum(map(abs, z_min)), sum(map(abs, z_max))]
  
print value
Problem p02793 (python)

Fixed submission:
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)
def lcm(a, b):
    return a // gcd(a, b) * b

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

l = 1
for i in a:
    l = lcm(l, i)

ans = 0
for i in a:
    ans += l // i

print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll m = 1e9 + 7;
ll powm(ll b, ll p)
{
  if (p == 0)
  return 1;
  if (p % 2 == 1)
  return b * powm(b, p - 1) % m;
  else
  {
    ll t = powm(b, p / 2);
    return t * t % m;
  }
}
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> flcm;
  vector<map<int, int>> b(n);
  for (int i = 0; i < n; i++)
  cin >> a[i];

  for (int i = 0; i < n; i++)
  {
    int t = a[i];
    for (ll j = 2; j * j <= t; j++)
    {
      while (t % j == 0)
      {
        b[i][j] += 1;
        t /= j;
      }
      if (b[i][j] > flcm[j])
      flcm[j] = b[i][j];
    }
    if (t != 1)
    {
      b[i][t]++;
      if (flcm[t] == 0)
      flcm[t] = 1;
    }
  }
  ll ans = 0;
  ll lcm = 1;
  for (auto x : flcm)
  {
    lcm = lcm * powm(x.first, x.second) % m;
  }
  for (int i = 0; i < n; i++) {
  	ans += lcm * powm(a[i], m - 2) % m;
  }
  cout << ans << endl;
}

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

def lcm(a, b):
    return a // gcd(a, b) * b

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

l = 1
for i in a:
    l = lcm(l, i)

ans = 0
for i in a:
    ans += l // i

print(ans % 1000000007)
Problem p02572 (python)

Fixed submission:
n = int(input())
mod = 10**9+ 7
a = list(map(int,input().split()))
ans = (sum(a)%mod)**2 - sum([x**2%mod for x in a])
ans *= 5*10**8+4
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
mod = 10**9+ 7
a = list(map(int,input().split()))
ans = (sum(a)%mod)**2 - (sum[x**2 for x in a]%mod)
ans *= 5*10**8+4
ans %= mod
print(ans)
Problem p02763 (python)

Fixed submission:
class Binary_Indexed_Tree:
    def __init__(self, n):
        self.size = n
        self.tree = [0 for _ in range(n+1)]

    # a[i]にxを加算(1 <= i <= n) 1-indexed
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & (-i)

    # a[1] から a[t] までの合計を得る (1 <= t <= n)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & (-i)

        return s

alpha_small_dict = {chr(i):i-97 for i in range(97, 97+26)} #辞書ver
n = int(input())
S = input()
data = [[0 for i in range(n)] for j in range(26)]

bit = [Binary_Indexed_Tree(n) for i in range(26)]
for i,x in enumerate(S):
    bit[alpha_small_dict[x]].add(i+1,1)
    data[alpha_small_dict[x]][i] = 1
q = int(input())
for i in range(q):
    x,y,z = input().split()
    x,y = int(x),int(y)
    #print(x,y,z)
    if x == 1:
        num = alpha_small_dict[z]
        for j in range(26):
            if data[j][y-1] == 1:
                data[j][y-1] = 0
                bit[j].add(y,-1)
                break
        data[num][y-1] = 1
        bit[num].add(y,1)
    else:
        z = int(z)
        ans = 0
        for j in range(26):
            if bit[j].sum(z)-bit[j].sum(y-1) >= 1:
                ans += 1
        print(ans)

Buggy submission (verdict: Runtime Error):
class Binary_Indexed_Tree:
    def __init__(self, n):
        self.size = n
        self.tree = [0 for _ in range(n+1)]

    # a[i]にxを加算(1 <= i <= n) 1-indexed
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & (-i)

    # a[1] から a[t] までの合計を得る (1 <= t <= n)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & (-i)

        return s




class RangeUpdate:
    def __init__(self, n):
        self.p = Binary_Indexed_Tree(n + 1)
        self.q = Binary_Indexed_Tree(n + 1)

    # a[s] から a[t] まで一律xを加算 (1 <= s <= t <= n)
    def add(self, s, t, x):
        t += 1
        self.p.add(s, -x * s)
        self.p.add(t, x * t)
        self.q.add(s, x)
        self.q.add(t, -x)

    # a[s] から a[t] までの合計を得る (1 <= s <= t <= n)
    def sum(self, s, t):
        t += 1
        return self.p.sum(t) + self.q.sum(t) * t - self.p.sum(s) - self.q.sum(s) * s

alpha_small_dict = {chr(i):i-97 for i in range(97, 97+26)} #辞書ver
n = int(input())
S = input()
data = [[0 for i in range(n)] for j in range(26)]

bit = [RangeUpdate(n) for i in range(26)]
for i,x in enumerate(S):
    bit[alpha_small_dict[x]].add(i+1,i+1,1)
    data[i][alpha_small_dict[x]] = 1
q = int(input())
for i in range(q):
    x,y,z = input().split()
    x,y = int(x),int(y)
    #print(x,y,z)
    if x == 1:
        num = alpha_small_dict[z]
        for j in range(26):
            if data[j][y-1] == 1:
                data[j][y-1] = 0
                bit[j].add(y,y,-1)
                break
        data[num][y-1] = 1
        bit[num].add(y,y,1)
    else:
        z = int(z)
        ans = 0
        for j in range(26):
            if bit[j].sum(y,z) >= 1:
                ans += 1
        print(ans)
Problem p02781 (python)

Fixed submission:
n = input()
k = int(input())
m = len(n)
if k == 1:
    print(int(n[0])+9*(m-1))
elif k == 2:
    if m<2:ans = 0
    else:
        ans = 81*(m-1)*(m-2)//2+(int(n[0])-1)*(m-1)*9
        for i in range(1,m):
            if int(n[i]) != 0:
                ans += (m-i-1)*9+int(n[i])
                break
    print(ans)
else:
    if m<3:ans = 0
    else:
        ans = (m-1)*(m-2)*(m-3)//6*9**3 + (int(n[0])-1)*(m-1)*(m-2)//2*81
        for i in range(1,m):
            if int(n[i])!=0:
                ans += (m-i-1)*(m-i-2)//2*81+(int(n[i])-1)*(m-i-1)*9
                break
        for j in range(i+1,m):
            if int(n[j]) != 0:
                ans += (m-j-1)*9+int(n[j])
                break
    print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
k = int(input())
m = len(n)
if k == 1:
    print(int(n[0])+9*(m-1))
elif k == 2:
    if m<2:ans = 0
    else:
        ans = 81*(m-1)*(m-2)//2
        ans += (int(n[0])-1)*(m-1)*9+int(n[1])+(m-2)*9
    print(ans)
else:
    if m<3:ans = 0
    else:
        ans1 = (m-1)*(m-2)*(m-3)//6*9**3
        ans2=(int(n[0])-1)*(m-1)*(m-2)//2*81
        ans3 =(m-2)*(m-3)//2*81
        ans = ans1+ans2+ans3
        if int(n[1]) > 0:
            ans += (int(n[1])-1)*(m-2)*9 + (m-3)*9+int(n[3])
    print(ans)
Problem p02879 (python)

Fixed submission:
a,b = map(int,input().split())
if a <10 and b < 10:
    print(a*b)
else:
    print(-1)

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()
ok = max(a)*max(f)
ng = -1

while ok-ng > 1:
    mid = (ok+ng)//2
    t = 0
    for i in range(n):
        t += max(0,a[i]-int(mid/f[i]))
    if t > k:
        ng = mid
    else:
        ok = mid

print(ok)
Problem p02891 (python)

Fixed submission:
s = input()
k = int(input())
n = len(s)

a = 1
data = []
for i in range(n-1):
    if s[i] == s[i+1]:
        a += 1
    else:
        data.append(a)
        a = 1
data.append(a)

ans = 0

if s[0] != s[-1]:
    for d in data:
        ans += d//2
    ans *= k
elif len(data) == 1:
    ans = n*k//2
else:
    for i in range(1,len(data)-1):
        ans += data[i]//2
    ans *= k
    ans += data[0]//2 + data[-1]//2 + (data[0] + data[-1])//2 * (k-1)

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
n = len(s)

a = 1
data = []
for i in range(n-1):
    if s[i] == s[i+1]:
        a += 1
    else:
        data.append(a)
        a = 1
data.append(a)

ans = 0

if s[0] != s[-1]:
    for d in data:
        ans += d//2
    ans *= k
elif len(data) == 1:
    ans = n*k//2
else:
    for i in range(1,n-1):
        ans += data[i]//2
    ans *= k
    ans += data[0]//2 + data[-1]//2 + (data[0] + data[-1])//2 * (k-1)

print(ans)
Problem p02925 (python)

Fixed submission:
import time
start = time.time()
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
s = [0 for i in range(n)] #それぞれ何試合目か
ans = 0
need = n*(n-1)//2
while need:
    c = [0 for i in range(n)] #今日試合をするかどうか
    ans += 1
    for first in range(n):
        if c[first] == 0 and s[first] < n-1:
            second = a[first][s[first]]-1 # firstが対戦したい相手
            second_num = s[second] # #secondの対戦番号
            if c[second] == 0 and a[second][second_num]-1 == first:
                c[first] = 1
                c[second] = 1
                s[first] += 1
                s[second] += 1
                need -= 1
    if sum(c) == 0:
        print(-1)
        exit()
    now = time.time()-start
    if now > 1.8:
        print(n*(n-1)//2)
        exit()
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

n = int(input())
a = [list(map(lambda x:int(x)-1,input().split())) + [-1] for _ in range(n)] + [0]

l,day = [0]*n,[0]*n

que = deque([i for i in range(n)])

while que:
    u = que.popleft()
    v = a[u][l[u]]
    if a[v][l[v]] == u:
        day[u] = max(day[u],day[v]) + 1
        day[v] = day[u]
        l[u] += 1
        l[v] += 1
        que.append(u)
        que.append(v)

if any(x != n-1 for x in l):
    print(-1)
    exit()

print(max(day))

Buggy submission (verdict: Runtime Error):
from collections import deque

n = int(input())
a = [list(map(lambda x:int(x)-1,input().split())) for _ in range(n)]

l,day = [0]*n,[0]*n

que = deque([i for i in range(n)])

while que:
    u = que.popleft()
    v = a[u][l[u]]
    if a[v][l[v]] == u:
        day[u] = max(day[u],day[v]) + 1
        l[u] += 1
        l[v] += 1
        que.append(u)
        que.append(v)

if any(x != n-1 for x in l):
    print(-1)
    exit()

print(max(day))
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
MOD = 10**9 + 7
dp = [0 for i in range(n+1)]
t = [True for _ in range(n+1)]
for i in range(m):
    a = int(input())
    t[a] = False

dp[0] = 1
for now in range(n):
    for next in range(now+1,min(n+1,now+3)):
        if t[next]:
            dp[next] += dp[now]
            dp[next] %= MOD

print(dp[n])

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

q = [1,2]
append = q.append
for i in range(10**5+10):
    if i >= 2:
        t = q[i-1]+q[i-2]
        t%= MOD
        append(t)
ans = 1
a_pre = 0
for i in range(m+1):
    if i == m:
        if a_now == n-1:
            print(0)
            exit()
        else:
            ans *= q[n-a_now-2]
            ans %=MOD
            break
    if i>0:
        a_pre = a_now
    a_now = int(input())
    if i == 0:
        if a_now != 1:
            ans*=q[a_now-2]
            ans%=MOD
    if i>0:
        if a_pre + 1 == a_now:
            print(0)
            exit()
        else:
            if a_now-a_pre-3!=-1:
                ans*=q[a_now-a_pre-3]
            ans %=MOD

print(ans)
Problem p03017 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
n,a,b,c,d = map(int,input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
truth = [[0 for i in range(n)],[0 for j in range(n)]]

def solve(now,dest):
    for i in  range(now,dest):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True
if c < d:
    if solve(a,c) and solve(b,d):
        print('Yes')
    else:
        print('No')

else:
    q = False
    for i in range(b,d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            q = True
            break
    if q and solve(a,c) and solve(b,d):
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
n,a,b,c,d = map(int,input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
truth = [[0 for i in range(n)],[0 for j in range(n)]]

def solve(now,dest):
    for i in  range(now,dest):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True
if c < d:
    if solve(a,c,0) and solve(b,d,1):
        print('Yes')
    else:
        print('No')

else:
    q = False
    for i in range(b,d):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            q = True
            break
        if s[i-1] == '#' and s[i] == '#':
            print('No')
            exit()
    if q and solve(a,c,0) and solve(b,d,1):
        print('Yes')
    else:
        print('No')
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
n = int(input())
data = [[] for i in range(n)]
for i in range(n-1):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    data[a].append([b,c])
    data[b].append([a,c])

dist = [-1 for i in range(n)]
q,k = map(int,input().split())
k -= 1
dist[k] = 0

def dfs(now,pre,d):
    dist[now] = d
    for p,q in data[now]:
        if p == pre:
            continue
        dfs(p,now,d+q)

dfs(k,-1,0)

for i in range(q):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    print(dist[x]+dist[y])

Buggy submission (verdict: Runtime Error):
n = int(input())
data = [[] for i in range(n)]
for i in range(n-1):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    data[a].append([b,c])
    data[b].append([a,c])

dist = [-1 for i in range(n)]
q,k = map(int,input().split())
k -= 1
dist[k] = 0

def dfs(now,pre,d):
    dist[now] = d
    for p,q in data[now]:
        if p == pre:
            continue
        dfs(p,now,d+q)

dfs(k,-1,0)

for i in range(q):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    print(dist[x]+dist[y])
Problem p03776 (python)

Fixed submission:
def combination(n, r):  # nCrを求める
    r = min(n - r, r)
    result = 1
    for i in range(n, n - r, -1):
        result *= i
    for i in range(1, r + 1):
        result //= i
    return result


n,a,b = map(int,input().split())
v = list(map(int,input().split()))
v.sort(reverse=True)
ans1 = sum(v[:a])/a
num1 = v[:a].count(v[a-1])
num2 = v[a:n].count(v[a-1])

ans2 = 0
if v[0] == v[a]:
    for i in range(a,n):
        if v[i] == v[a-1]:
            idx = i + 1
    for i in range(a,min(b,idx) + 1):
        ans2 += combination(num1 + num2, i)
else:
    ans2 = combination(num1 + num2,num1)

print(ans1)
print(ans2)

Buggy submission (verdict: Runtime Error):
def combination(n, r):  # nCrを求める
    r = min(n - r, r)
    result = 1
    for i in range(n, n - r, -1):
        result *= i
    for i in range(1, r + 1):
        result //= i
    return result


n,a,b = map(int,input().split())
v = list(map(int,input().split()))
v.sort(reverse=True)
ans1 = v[:a]/a
num1 = v[:a].count(v[a-1])
num2 = v[a:n].count(v[a-1])

ans2 = 0
if v[0] == v[a]:
    for i in range(a,n):
        if v[i] == v[a-1]:
            idx = i + 1
    for i in range(a,min(b,idx) + 1):
        ans2 += combination(num1 + num2, i)
else:
    ans2 = combination(num1 + num2,num1)
    
print(ans1)
print(ans2)
Problem p03803 (python)

Fixed submission:
a,b=map(int,input().split())
if a==1:
    if b==1:
        print('Draw')
    else:
        print('Alice')
else:
    if b==1:
        print('Bob')
    else:
        if a>b:
            print('Alice')
        elif a==b:
            print('Draw')
        else:
            print('Bob')

Buggy submission (verdict: Runtime Error):
a.b=map(int,input().split())
if a==1:
    if b==1:
        print('Draw')
    else:
        print('Alice')
else:
    if b==1:
        print('Bob')
    else:
        if a>b:
            print('Alice')
        elif a==b:
            print('Draw')
        else:
            print('Bob')
Problem p02879 (python)

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

if a[0] < 10 and a[1] < 10:
  print(a[0] * a[1])
else:
  print(-1)

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

if a[0] < 10 && a[1] < 10:
  print(a[0] * a[1])
else:
  print(-1)
Problem p02880 (python)

Fixed submission:
import math
a = int(input())
flag = False
i = 1

while i <= math.sqrt(a):
  b = divmod(a,i)
  if b[0] < 10 and b[1] == 0:
    flag = True
  i+=1
    
if flag:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import math
a = int(input())
flag = False
i = 0

while i <= math.sqrt(a):
  b = divmod(a)
  if b[0] < 10 and b[1] == 0:
    flag = True
  else:
    i+=1
    
if flag:
  print("Yes")
else:
  print("No")
Problem p02759 (python)

Fixed submission:
from math import ceil, floor

n = int(input())
print(ceil(n/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
print(ceil(n/2))