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

Fixed submission:
import numpy as np
import math

rotate = int(input())

x = 0
y = 1
heading = 90

count = 1

while True:
    heading += rotate
    x += np.cos(np.deg2rad(heading))
    y += np.sin(np.deg2rad(heading))
    count += 1
    #print('heading', heading)
    #print('x : ', x)
    #print('y : ', y)

    if math.isclose(x, 0.0,abs_tol=0.000001) and math.isclose(y, 0.0,abs_tol=0.0000001):
        break

print(count)

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

rotate = int(input()) 

x = 0
y = 1
heading = 0

count = 1

while x != 0 and y != 0:
  heading += rotate
  x += cos(np.deg2rad(heading))
  y += sin(np.deg2rad(heading))
  count++
  
print(count)
Problem p02633 (python)

Fixed submission:
import math

x = int(input())
g = math.gcd(x,360)
print(360//g)

Buggy submission (verdict: Runtime Error):
import math

x = int(input())
g = math.gdc(x,360)
print(360//g)

Buggy submission (verdict: Runtime Error):
x = int(input())
if 360%x==0:
  print(360//x)
else:
  orint(360)
Problem p03307 (python)

Fixed submission:
n = int(input())
if n%2==0:
  print(n)
else:
  print(2*n)

Buggy submission (verdict: Runtime Error):
import math

n=int(input())
print(2*n//int(math.gcd(2,n)))

Buggy submission (verdict: Runtime Error):
import math

n=int(input())
print(2*n//math.gcd(2,n))
Problem p03315 (python)

Fixed submission:
s=input()
p=0; m=0
for i in range(0,4):
  if s[i]=='+':
    p += 1
  else:
    m += 1
print(p-m)

Buggy submission (verdict: Runtime Error):
s=input()
p=0; m=0
for i in range(0,4)
  if s[i]=='+':
    p += 1
  else:
    m += 1
print(p-m)

Buggy submission (verdict: Runtime Error):
s=input()
p=0; m=0
for i in range(0,len(s))
  if s[i]=='+':
    p += 1
  else:
    m += 1
print(p-m)

Buggy submission (verdict: Runtime Error):
s=input()
p=0; m=0
for i in range(0,len(s))
  if s[i]='+':
    p += 1
  else:
    m += 1
print(p-m)
Problem p02633 (python)

Fixed submission:
x = int(input())
for i in range(1, 361):
  if 360*i % x == 0:
    print(360*i//x)
    break
else:
  print(360)

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int,input().split())
dp = [[0 for j in range(d+1)] for i in range(c+1)]
for i in range(a, c+1):
  for j in range(b, d+1):
    if i == a and j == b:
      dp[i][j] = 1
      continue
    dp[i][j] = (dp[i-1][j] * j + dp[i][j-1] * i - dp[i-1][j-1] * (i-1) * (j-1) ) % 998244353
    dp[i][j] += 998244353
    dp[i][j] %= 998244353
print(dp[c][d])

Buggy submission (verdict: Runtime Error):
x = int(input())
for i in range(1, 361):
  if 360*i % x === 0:
    print(360*i//x)
    break
else:
  print(360)
Problem p02659 (python)

Fixed submission:
A, B = input().split()
A = int(A)
x,y = B.split('.')
B = 100*int(x)+int(y)

print(A*B//100)

Buggy submission (verdict: Runtime Error):
A, B = map(float, input().split())

print(int((A*(B*100)/100))
Problem p02859 (python)

Fixed submission:
r = int(input())
S=r*r
print(int(S))

Buggy submission (verdict: Runtime Error):
#Beginner COnetst 145 /2019/11/16
#Probrem A
#import math
from operator import mul
from functools import reduce

DEBUG = 0

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def calc(x,y):
    if (x*2-y)%3 != 0 or (y*2-x)%3 != 0: return 0
    m = (x*2-y)//3
    n = (y*2-x)//3
    if m <= 0 or n <= 0:return 0
    return combinations_count(m+n,m)

X,Y = list(map(int, input().split()))

if DEBUG:print(X,Y)

print(calc(X,Y)%(10**9+7))

Buggy submission (verdict: Runtime Error):
r = int(input())
S=r*r
print(f'{S}')

Buggy submission (verdict: Runtime Error):
r = int(input())
S=r**2
print(f'{S}')
Problem p02723 (python)

Fixed submission:
s=input()
if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input()
if s[2]==s[3] and s[4]==s[5]:
          print("Yes")
else:
          print("No"
Problem p02679 (python)

Fixed submission:
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
zeros = 0
a_zeros = 0
b_zeros = 0
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    if not any((a, b)):
        zeros += 1
        continue
    if not a:
        a_zeros += 1
        continue
    if not b:
        b_zeros += 1
        continue
    g = gcd(a, b) * (a // abs(a))
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for k, v in counts.items():
    a, b = v
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
total = (total * (pow(2, a_zeros, MOD) + pow(2, b_zeros, MOD) - 1)) % MOD
print((total + zeros + MOD - 1) % MOD)

Buggy submission (verdict: Runtime Error):
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    g = gcd(a, b) * (a // abs(a) if a else 1)
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for a, b in counts.values():
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
print((total + MOD - 1) % MOD)

Buggy submission (verdict: Runtime Error):
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    g = gcd(a, b) * (a // abs(a))
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for a, b in counts.values():
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
print((total + MOD - 1) % MOD)
Problem p02685 (python)

Fixed submission:
MOD = 998244353
FACT_MAX = 2 * 10 ** 5
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD
N, M, K = map(int, input().split())
total = 0
for k in range(K + 1):
    total = (total + comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
print(total)

Buggy submission (verdict: Runtime Error):
MOD = 998244353
FACT_MAX = 2 * 10 ** 5
fact = [(f := 1 if not i else (f := f * i % MOD)) for i in range(FACT_MAX)]
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD
N, M, K = map(int, input().split())
total = 0
for k in range(K + 1):
    total = (total + comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
print(total)
Problem p02781 (python)

Fixed submission:
from scipy.misc import comb

N = input()
K = int(input())

L = len(N)

if N.count("0") > L - K:
    integer = int(N)
    N = str(integer - integer % 10 - 1)

L = len(N)

if L < K or N[0] == "-":
    print(0)
    quit()

M = ["0"] * L
count = 0
for i in range(L):
    count += bool(int(N[i]))
    M[i] = N[i]
    if count == K:
        M = "".join(M)
        break

index = 0
ans = 0
count = 0
while index < L:
    if int(M[index]):
        count += 1
        n = L - index - 1
        k = K - count + 1
        digit = int(M[index]) - (count != K)
        ans += comb(n, k, exact=True) * 9 ** k + \
               digit * comb(n, k - 1, exact=True) * 9 ** (k - 1)
    index += 1

print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb

N = input()
K = int(input())

L = len(N)

if N.count("0") > L - K:
    integer = int(N)
    N = str(integer - integer % 10 - 1)

L = len(N)

if L < K:
    print(0)
    quit()

M = ["0"] * L
count = 0
for i in range(L):
    count += bool(int(N[i]))
    M[i] = N[i]
    if count == K:
        M = "".join(M)
        break

index = 0
ans = 0
while index < L:
    if int(M[index]):
        n = L - index - 1
        k = K - index
        digit = (int(M[index]) - 1)
        ans += comb(n, k, exact=True) * 9 ** k + \
               digit * comb(n, k - 1, exact=True) * 9 ** (k - 1)
    index += 1

print(ans + 1)

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb

N = input()
K = int(input())

L = len(N)

if N.count("0") > L - K:
    integer = int(N)
    N = str(integer - integer % 10 - 1)

M = ["0"] * L
count = 0

for i in range(L):
    count += bool(int(N[i]))
    M[i] = N[i]
    if count == K:
        M = "".join(M)
        break

index = 0
ans = 0
while index < L:
    if int(M[index]):
        n = L - index - 1
        k = K - index
        digit = (int(M[index]) - 1)
        ans += comb(n, k, exact=True) * 9 ** k + \
               digit * comb(n, k - 1, exact=True) * 9 ** (k - 1)
    index += 1

print(ans + 1)
Problem p02793 (python)

Fixed submission:
import sys
from fractions import gcd

input = sys.stdin.buffer.readline

LARGE = 10 ** 9 + 7

def lcm(x, y):
    return (x * y) // gcd(x, y)

input()
A = list(map(int, input().split()))

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

total = 0
for a in A:
    total += l // a

print(total % LARGE)

Buggy submission (verdict: Runtime Error):
import numpy as np
from fractions import gcd
from functools import reduce

LARGE_INT = 10 ** 9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

input()
A = list(map(int, input().split()))
lcm = lcm_list(A)

total = 0
for a in A:
    total += lcm // a % LARGE_INT
    total %= LARGE_INT
print(total)
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))

Buggy submission (verdict: Runtime Error):
from math import gcd
a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))
Problem p02833 (python)

Fixed submission:
N = int(input())
if N % 2 == 0:
    total = 0
    temp = (N // 2) // 5
    total += temp
    while temp:
        temp //= 5
        total += temp
    print(total)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import numpy as np
from math import log
N = int(input())
if N % 2:
    print(0)
    quit()
print(((N // 2) // np.array([5**i for i in range(1, int(log(N // 2, 5)) + 1)], np.int64)).sum())
Problem p02881 (python)

Fixed submission:
num = int(input())
print(min(i + num // i - 2 for i in range(1, int(num ** (1 / 2)) + 1) if not num % i))

Buggy submission (verdict: Runtime Error):
num = int(input())
print(min(i + num // i - 2 for i in range(1, int(num ** (1 / 2))) if not num % i))
Problem p02990 (python)

Fixed submission:
MOD = 10 ** 9 + 7
FACT_MAX = 2001
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return 0 if n < r else fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD

N, K = map(int, input().split())
for i in range(1, K + 1):
    print(comb(N - K + 1, i) * comb(K - 1, i - 1) % MOD)

Buggy submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7
FACT_MAX = 2000
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD

N, K = map(int, input().split())
for i in range(1, K + 1):
    print(comb(N - K + 1, i) * comb(K - 1, i - 1) % MOD)
Problem p03015 (python)

Fixed submission:
MOD = 10 ** 9 + 7
L = input()
N = len(L)
total = 0
one_count = 0
pow2, pow3 = [1], [1]
p2, p3 = 1, 1
for i in range(N):
    p2 = p2 * 2 % MOD
    p3 = p3 * 3 % MOD
    pow2.append(p2)
    pow3.append(p3)
for i in range(N):
    if L[i] == "1":
        total = (total + pow2[one_count] * pow3[N - i - 1]) % MOD
        one_count += 1
print((total + pow2[one_count] * pow3[N - i - 1]) % MOD)

Buggy submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7
p3 = [1] * N
for i in range(1, N):
    p3[i] = p3[i - 1] * 3 % MOD
L = input()
N = len(L)
p2 = 1
total = 0
for i in range(N):
    if L[i] == "1":
        total = (total + p2 * p3[N - i - 1]) % MOD
        p2 = p2 * 2 % MOD
print((total + p2 * p3[N - i - 1]) % MOD)
Problem p03745 (python)

Fixed submission:
n = input()
iter_ = iter(list(map(int, input().rstrip("\n").split())))
ans = 0

last = next(iter_)
try:
    while True:
        ans += 1
        now = next(iter_)
        while now == last:
            now = next(iter_)
        laststate = (last < now)
        state = laststate
        while state == laststate:
            last = now
            now = next(iter_)
            while now == last:
                now = next(iter_)
            state = (last < now)
        last = now
except StopIteration:
    print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
iter_ = iter(list(map(int, input().rstrip("\n").split())))
ans = 0

last = next(iter_)
try:
    while True:
        ans += 1
        now = next(iter_)
        while now == last:
            now = next(iter_)
        laststate = (last < now)
        state = laststate
        print(f"out: {last}, {now}")
        while state == laststate:
            last = now
            now = next(iter_)
            while now == last:
                now = next(iter_)
            state = (last < now)
            print(f"in: {last}, {now}")
        last = now
except StopIteration:
    print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
iter_ = iter(list(map(int, input().rstrip("\n").split())))
ans = 0

last = next(iter_)
try:
    while True:
        ans += 1
        now = next(iter_)
        while now == last:
            now = next(iter_)
        laststate = (last < now)
        state = laststate
        print(f"out: {last}, {now}")
        while state == laststate:
            last = now
            now = next(iter_)
            while now == last:
                now = next(iter_)
            state = (last < now)
            print(f"in: {last}, {now}")
        last = now
except StopIteration:
    print(ans)
Problem p03834 (python)

Fixed submission:
print(input().replace(",", " "))

Buggy submission (verdict: Runtime Error):
k, s = map(int, input().rstrip("\n").split())
print(sum([x + y + z == s for x in range(k + 1) for y in range(k + 1) for z in range(k + 1)]))

Buggy submission (verdict: Runtime Error):
k, s = map(int, input().rstrip("\n").split())
print(sum([x + y + z == s for x in range(k + 1) for y in range(k + 1) for z in range(k + 1)]))
Problem p03835 (python)

Fixed submission:
k, s = map(int, input().rstrip("\n").split())
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        if x + y > s:
            x = k + 1
            y = k + 1
            continue
        count += (s <= x + y + k)

print(count)

Buggy submission (verdict: Runtime Error):
for x in range(k + 1):
    for y in range(k + 1):
        if x + y > s:
            break
        for z in range(k + 1):
            count += (x + y + z == s)

print(count)
Problem p02951 (python)

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

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c - a + b, 0) << endl;
}
Problem p03011 (python)

Fixed submission:
a,b,c = map(int,input().split())
print(min(a+b,b+c,c+a))

Buggy submission (verdict: Runtime Error):
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;

#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=a:i<n;i--)

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min({ a + b,b + c,c + a }) << endl;
}
Problem p03045 (python)

Fixed submission:
def find(x):
    if root[x] == x:
        return x
    else:
        root[x] = find(root[x])
        return root[x]

def same(x,y):
    return find(x) == find(y)

def unite(x,y):
    x = find(x)
    y = find(y)
    if rank[x] == rank[y]:
        root[y] = x
        rank[x] += 1
    elif rank[x] > rank[y]:
        root[y] = x
    elif rank[x] < rank[y]:
        root[x] = y
    
n,m = map(int, input().split())
root = [i for i in range(n)]
rank = [0 for i in range(n)]

for i in range(m):
    x, y, z = [int(i)-1 for i in input().split()]
    if not same(x,y):
        unite(x,y)
    
for i in range(n):
    find(i)

print(len(list(set(root))))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.root = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.root[a] == a:
            return a
        else:
            self.root[a] = self.root(self.root[a])
            return self.root[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.root[ra] = rb
        else:
            self.root[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1

uf = UnionFind(N)
for x,y,z in src:
    x,y = x-1,y-1
    uf.unite(x,y)
print(N - uf.count)
Problem p03075 (python)

Fixed submission:
A = [int(input()) for i in range(5)]
A.sort()
k = int(input())
if A[-1]-A[0] <= k:
	print("Yay!")
else:
	print(":(")

Buggy submission (verdict: Runtime Error):
A = [input() for i in range(5)]
k = int(input())
if A[-1]-A[0] <= k:
	print('Yay!')
else:
	print(':(')
Problem p02766 (python)

Fixed submission:
import numpy as np
n , k = map(int,input().strip().split())
n = np.base_repr(n, base=k)
print(len(n))

Buggy submission (verdict: Runtime Error):

n , k = map(int,input().strip().split())
if k == 2:
    n = bin(n)[2:]
    print(len(n))
elif k==8:
    n = oct(n)[2:]
    print(len(n))
elif k == 3:
    n = np.base_repr(n, base=3)
    print(len(n))
elif k == 4:
    n = np.base_repr(n, base=4)
    print(len(n))
elif k == 5:
    n = np.base_repr(n, base=5)
    print(len(n))
elif k == 6:
    n = np.base_repr(n, base=6)
    print(len(n))
elif k == 7:
    n = np.base_repr(n, base=7)
    print(len(n))
elif k == 9:
    n = np.base_repr(n, base=9)
    print(len(n))

else:
    print(len(n))

Buggy submission (verdict: Runtime Error):
import numpy as np
n , k = map(int,input().strip().split())
if k == 2:
    n = bin(n)[2:]
    print(len(n))
elif k==8:
    n = oct(n)[2:]
    print(len(n))
elif k == 3:
    n = np.base_repr(n, base=3)
    print(len(n))
elif k == 4:
    n = np.base_repr(n, base=4)
    print(len(n))
elif k == 5:
    n = np.base_repr(n, base=5)
    print(len(n))
elif k == 6:
    n = np.base_repr(n, base=6)
    print(len(n))
elif k == 7:
    n = np.base_repr(n, base=7)
    print(len(n))
elif k == 9:
    n = np.base_repr(n, base=9)
    print(len(n))

else:
    print(len(n))

Buggy submission (verdict: Runtime Error):
import numpy as np
n , k = map(int,input().strip().split())
if k == 2:
    n = bin(n)[2:]
    print(len(n))
elif k==8:
    n = oct(n)[2:]
    print(len(n))
elif k == 3:
    n = np.base_repr(n, base=3)
    print(len(n))
elif k == 10:
    print(len(n))
Problem p02689 (python)

Fixed submission:
n, m = map(int, input().split())
Hs = input().split()
Hs = [int(ele) for ele in Hs]

res = [1 for i in range(n) ]
for i in range(m):
    con = input().split()
    con = [int(ele) for ele in con]
    
    id1 = con[0] - 1
    id2 = con[1] - 1
    
    if res[id1] == 1:
        res[id1] = int(Hs[id2] < Hs[id1])
    if res[id2] ==1:
        res[id2] = int(Hs[id1] < Hs[id2])

print(sum(res))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
Hs = input().split()
Hs = [int(ele) for ele in Hs]

import numpy as np

gra = np.zeros(shape=(n, n))

for i in range(m):
    con = input().split()
    con = [int(ele) for ele in con]
    con.sort()
    id1 = con[0] - 1
    id2 = con[1] - 1
    
    if Hs[id2] == Hs[id1]:
        gra[id1, id2] = 100
        gra[id2, id1] = 100
    else:    
        gra[id1, id2] = Hs[id2] - Hs[id1]
        gra[id2, id1] = Hs[id1] - Hs[id2]

res = np.all(gra <= 0, axis=1)

print(sum(res))
Problem p03631 (python)

Fixed submission:
print(("Yes","No")[len(set(input()[::2]))-1])

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(-a+b-c+d+2)
Problem p03776 (python)

Fixed submission:
n,a,b = map(int,input().split())
vs = sorted([int(v) for v in input().split()],reverse=True)
print(sum(vs[:a])/a)
binom = [1]
for k in range(vs.count(vs[a-1])):
    binom = [x+y for (x, y) in zip(binom+[0],[0]+binom)]
if vs[a-1] == vs[0]:
    print(sum(binom[a:b+1]))
else:
    print(binom[a-vs.index(vs[a-1])])

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
vs = sorted([int(v) for v in input().split()],reverse=True)
print(sum(vs[:a])/a)
binom = [1]
for k in range(vs.count(vs[a-1])):
    binom = [x+y for (x, y) in zip(binom+[0],[0]+binom)]
if vs[a-1] == vs[0]:
    print(sum(binom[a:b+1]))
else:
    print(binom[vs.index(vs[a-1])])
Problem p02762 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import Counter
N, M, K = map(int, input().split())
friend = [[] for _ in range(N)]
block = [[] for _ in range(N)]

for _ in range(M):
	a, b = map(int, input().split())
	friend[a - 1].append(b - 1)
	friend[b - 1].append(a - 1)
	
for _ in range(K):
	c, d = map(int, input().split())
	block[c - 1].append(d - 1)
	block[d - 1].append(c - 1)
	
# 同じ連結成分にラベルを振る（まだラベルを振っていない = -1 で初期化）
label = [-1] * N

cnt_label_num = 0

for i in range(N):
	if label[i] != -1: continue # もう振ってあったら飛ばす
	
	# 振ってなかったら幅優先でラベルを振る
	Q = [i]
	while Q:
		cur = Q.pop()
		if label[cur] != -1: continue
		label[cur] = cnt_label_num
		for adj in friend[cur]:
			if label[adj] != -1: continue
			Q.append(adj)
	
	cnt_label_num += 1
	
# お友達候補計算
cnt = Counter(label)
for i in range(N):
	friend_candidate = cnt[label[i]] - 1 # 同じグラフにいる人
	friend_candidate -= len(friend[i]) # 元から友達を引く
	# blockしている人が同じグラフにいるときはその分引く
	for block_man in block[i]:
		if label[i] == label[block_man]:
			friend_candidate -= 1
	print(friend_candidate, end = " ")

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
friend = [[] for _ in range(N)]
block = [[] for _ in range(N)]
ans = [0] * N

for _ in range(M):
	a, b = map(int, input().split())
	friend[a - 1].append(b - 1)
	friend[b - 1].append(a - 1)
	
for _ in range(K):
	c, d = map(int, input().split())
	block[c - 1].append(d - 1)
	block[d - 1].append(c - 1)
	

def dfs(start, i):
	global visited
	global friend
	global block
	global ans
	visited[i] = 1
	for adj in friend[i]:
		if visited[adj]: continue
		if not adj in friend[start] and not adj in block[start]:
			ans[start] += 1
		dfs(start, adj)
		
	
for i in range(N):
	visited = [0] * N
	dfs(i, i)
	
print(*ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
friend = [[] for _ in range(N)]
block = [[] for _ in range(N)]
ans = [0] * N

for _ in range(M):
	a, b = map(int, input().split())
	friend[a - 1].append(b - 1)
	friend[b - 1].append(a - 1)
	
for _ in range(K):
	c, d = map(int, input().split())
	block[c - 1].append(d - 1)
	block[d - 1].append(c - 1)
	

def dfs(start, i):
	visited[i] = 1
	for adj in friend[i]:
		if visited[adj]: continue
		if not adj in friend[start] and not adj in block[start]:
			ans[start] += 1
		dfs(start, adj)
		
	
for i in range(N):
	visited = [0] * N
	dfs(i, i)
	
print(*ans)