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

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

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list (map(int,input().split()))
abs_list=[]
for b in range(-max(a),max(a)):
	c=0
	for i in range(N):
		c=abs(a[i]-(b+i+1))+c	
	abs_list.append(c)		
print(min(abs_list))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list (map(int,input().split()))
abs_list=[]
for b in range(-max(a),max(a)):
	c=0
	for i in range(N):
		c=abs(a[i]-(b+i+1))+c	
	abs_list.append(c)	
print(abs_list)	
print(min(abs_list))
Problem p03775 (python)

Fixed submission:
def func(num):
    cnt=0
    while(num>0):
        num=int(num/10)
        cnt+=1
    return cnt

N=int(input())
ans=100
for i in range(1,int(N**(1/2)+1)):
    tmp=100
    if(N%i==0):
        tmp=max(func(i),func(N/i))
    ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
def func(num):
    cnt=0
    while(num>0):
        num/=10
        cnt+=1
    return cnt
N=int(input())
ans=100
for i in range(1,N**(1/2)+1):
    tmp=0
    if(N%i==0):
        tmp=max(func(i),func(N/i))
    ans=min(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, pair<T1, T2> P)
{
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream &operator<<(ostream &s, vector<T> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        if (i > 0)
        {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream &operator<<(ostream &s, vector<vector<T>> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        s << endl
          << P[i];
    }
    return s << endl;
}
template <class T>
ostream &operator<<(ostream &s, set<T> P)
{
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, map<T1, T2> P)
{
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int func(long long num){
    int cnt = 0;
    while (num > 0)
    {
        num /= 10;
        cnt++;
    }
    return cnt;
}

int main()
{
    long long  n;
    cin >> n;
    int ans = INF;
    for (int i = 1; i <= sqrt(n) + 1; i++)
    {
        int tmp=INF;
        if (n % i == 0)
        {
            tmp = max(func(i), func(n / i));
            
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}
Problem p02598 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

l = 0
r = max(A)
for _ in range(100):
    mid = (r + l + 1) // 2
    count = 0
    for log in A:
        if log > mid:
            count += (log + mid - 1) // mid - 1
    if count <= K:
        r = mid
    else:
        l = mid

print(r)

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

l = 0
r = max(A)
while l != r:
    mid = (r + l) // 2
    count = 0
    for log in A:
        if log > mid:
            count += (log - 1) // mid
    if count <= K:
        r = mid
    else:
        l = mid + 1

print(r)
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

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


N, M, K = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))
now = 0
ans = 0

while A:
    i = 0
    while A[0] > B[i]:
        i += 1
    B.insert(i, A.popleft())

for time in B:
    now += time
    if now > K:
        break
    ans += 1

print(ans)
Problem p02682 (python)

Fixed submission:
A, B, C, K = map(int, input().split())
max_score = 0

if A >= K:
  print(K)
elif A+B >= K:
  print(A)
else:
  print(2*A+B-K)

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
cards = [1]*A + [0]*B + [-1]*C

print(sum(cards[:K]))
Problem p02862 (python)

Fixed submission:
MOD = 10**9 + 7
X, Y = map(int, input().split())


def f(n):
    res = n
    for i in range(1, n):
        res *= i
        res %= MOD
    return res


def solve():
    ans = 0
    if (X + Y) % 3 == 0:
        n = (2 * X - Y) // 3
        m = (2 * Y - X) // 3
        if n == 0 or m == 0:
            ans += 1
        elif n > 0 and m > 0:
            ans += (f(n + m) * pow(f(n), MOD - 2, MOD) * pow(f(m), MOD - 2, MOD)) % MOD

    print(ans)


if __name__ == "__main__":
    solve()

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


def f(n):
    res = n
    for i in range(1, n):
        res *= i
        res %= MOD
    return res


def solve():
    ans = 0
    if (X + Y) % 3 == 0:
        n = (2 * X - Y) // 3
        m = (2 * Y - X) // 3
    if n > 0 and m > 0:
        ans += (f(n + m) * pow(f(n), MOD - 2, MOD) * pow(f(m), MOD - 2, MOD)) % MOD

    print(ans)


if __name__ == "__main__":
    solve()
Problem p02990 (python)

Fixed submission:
N, K = map(int, input().split())
MOD = 10**9+7
cmb = [[1] if i == -1 else [1] + [0]*i + [1] for i in range(-1,N)]

for i in range(2, N+1):
    for j in range(1, i):
        cmb[i][j] = cmb[i-1][j-1] + cmb[i-1][j]

for i in range(1, K+1):
    try:
        ans = cmb[N-K+1][i]
    except IndexError:
        ans = 0
    if ans:
        ans *= cmb[K-1][i-1]
    print(ans % MOD)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
MOD = 10**9+7
cmb = [[1] if i == -1 else [1] + [0]*i + [1] for i in range(-1,N-1)]

for i in range(2, N):
    for j in range(1, i):
        cmb[i][j] = cmb[i-1][j-1] + cmb[i-1][j]

for i in range(1, K+1):
    print((cmb[N-K+1][i] * cmb[K-1][i-1]) % MOD)
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)


N = int(input())
to = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a, b, = a - 1, b - 1
    to[a].append((c, b))
    to[b].append((c, a))

Q, K = map(int, input().split())
K -= 1
query = [list(map(lambda x:int(x) - 1, input().split())) for _ in range(Q)]
depth = [0] * N

def dfs(v, d, p=-1):
    depth[v] = d
    for cost, nv in to[v]:
        if nv == p:
            continue
        dfs(nv, d + cost, v)


def main():
    dfs(K, 0)
    for x, y in query:
        print(depth[x] + depth[y])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
to = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a, b, = a - 1, b - 1
    to[a].append((c, b))
    to[b].append((c, a))

Q, K = map(int, input().split())
K -= 1
query = [list(map(lambda x:int(x) - 1, input().split())) for _ in range(Q)]
depth = [0] * N


def dfs(v, d, p=-1):
    depth[v] = d
    for cost, nv in to[v]:
        if nv == p:
            continue
        dfs(nv, d + cost, v)


def main():
    dfs(K, 0)
    for x, y in query:
        print(depth[x] + depth[y])


if __name__ == "__main__":
    main()
Problem p02580 (python)

Fixed submission:
h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for i in range(m)]
hb = [0] * h
wb = [0] * w

for i in range(m):
    hb[hw[i][0]-1] += 1
    wb[hw[i][1]-1] += 1

max_h = max(hb)
max_w = max(wb)
ans = max_h + max_w
count = hb.count(max_h) * wb.count(max_w)
for i in range(m):
    if hb[hw[i][0]-1] == max_h and wb[hw[i][1]-1] == max_w:
        count -= 1
if count <= 0:
    ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for i in range(m)]
hb = [0 for i in range(h)]
wb = [0 for j in range(w)]
M = [[0 for i in range(w)] for j in range(h)]

for i in range(m):
    hb[hw[i][0]-1] += 1
    wb[hw[i][1]-1] += 1
    M[hw[i][0]-1][hw[i][1]-1] = -1

max_h = max(hb)
max_w = max(wb)
ans = max_h + max_w

max_h_list = []
for i in range(h):
    if hb[i] == max_h:
        max_h_list.append(i)
max_w_list = []
for i in range(h):
    if wb[i] == max_w:
        max_w_list.append(i)

count = 0
flg = 0
for i in range(len(max_h_list)):
    for j in range(len(max_w_list)):
        if M[max_h_list[i]][max_w_list[j]] == -1:
            count += 1
        else:
            flg = 1
            break
    if flg == 1:
        break
if count == len(max_h_list) * len(max_w_list):
    ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for i in range(m)]
hb = [0 for i in range(h)]
wb = [0 for j in range(w)]
M = [[0 for i in range(w)] for j in range(h)]

for i in range(m):
    hb[hw[i][0]-1] += 1
    wb[hw[i][1]-1] += 1
    M[hw[i][0]-1][hw[i][1]-1] = -1

max_h = max(hb)
max_w = max(wb)
ans = max_h + max_w

max_h_list = []
for i in range(h):
    if hb[i] == max_h:
        max_h_list.append(i)
max_w_list = []
for i in range(h):
    if wb[i] == max_w:
        max_w_list.append(i)

count = 0
for i in range(len(max_h_list)):
    for j in range(len(max_w_list)):
        if M[max_h_list[i]][max_w_list[j]] == 0:
            break
        else:
            count += 1
            if count >= m or(i == len(max_h_list)-1 and j == len(max_w_list)-1):
                ans -= 1
                break

print(ans)
Problem p02862 (python)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
  #  print(g1[n],g2[r],g2[n-r])
    return g1[n] * g2[r] * g2[n-r] % mod

x,y = map(int,input().split())
n = (2*y-x)/3
m = (2*x-y)/3

if n < 0 or m < 0:
    print(0)
elif int(n) != n or int(m) != m:
    print(0)
else:
    n = int(n)
    m = int(m)
    mod = 10**9+7 #出力の制限
    N = n+m
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    
    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
    ans = cmb(n+m,n,mod)
    print(ans)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
  #  print(g1[n],g2[r],g2[n-r])
    return g1[n] * g2[r] * g2[n-r] % mod

x,y = map(int,input().split())
n = (2*y-x)/3
m = (2*x-y)/3

if n <= 0 or m <= 0:
    print(0)
elif int(n) != n or int(m) != m:
    print(0)
else:
    mod = 10**9+7 #出力の制限
    N = n+m
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    
    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
    ans = cmb(n+m,n,mod)
    print(ans)
Problem p03317 (python)

Fixed submission:
NK = input()
Ain = input()
s = NK.index(" ")

N = int(NK[0:s])
K = int(NK[s+1:len(NK)+1])
n = N-1
k = K-1
a = int(n/k)
if n%k != 0:
    a += 1
print(a)

Buggy submission (verdict: Runtime Error):
NK = input()
Ain = input()
N = int(NK[0:1])
K = int(NK[2:3])
n = N-1
k = K-1
a = int(n/k)
if n%k > 0:
    a += 1
print(a)
Problem p02577 (python)

Fixed submission:
def main():
    N = map(int, input())
    if sum(N) % 9 == 0:
        return "Yes"
    else:
        return "No"

if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
  N = int(input())
  print("Yes" if N % 9 == 0 else "No")

Buggy submission (verdict: Runtime Error):
  N = int(input())
  return "Yes" if N % 9 == 0 else "No"
Problem p02623 (python)

Fixed submission:
def main():
    N, M, K = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    
    if a[0] > K and b[0] > K:
        return 0

    a2=[0]
    for i in a:a2.append(a2[-1]+i)
    b2=[0]
    for i in b:b2.append(b2[-1]+i)
    ans = 0
    j = M
    
    for i in range(N + 1):
        if a2[i] > K:
            break
        while b2[j] > K - a2[i]:
            j -= 1
        ans = max(ans, i + j)    
    return ans

if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
def main():
    N, M, K = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    
    if a[0] > K and b[0] > K:
        return 0

    a2=[0]
    for i in a:a2.append(a2[-1]+i)
    b2=[0]
    for i in b:b2.append(b2[-1]+i)
    ans = 0
    j = M
    
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i + j)    
    return ans

if __name__ == '__main__':
    print(main())
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):
import numpy as np


from collections import deque
class Graph:
    edges = {}

    def append_edge(self, sv, ev, weight = 1):
        if sv in self.edges:
            self.edges[sv].append((ev, weight))
        else:
            self.edges[sv] = [(ev, weight)]

    def bfs(self, sv):
        dist = np.full(len(self.edges.keys()), -1)
        q = deque([])   # キュー
        q.append(sv)
        dist[sv] = 0
        connect_vtxs = []
        while len(q) > 0:
            p = q.popleft()     # キュー取りだし（先頭）
            connect_vtxs.append(p)
            for (ev, w) in self.edges[p]:
                if dist[ev] != -1:
                    continue
                q.append(ev)    # キュー追加
                dist[ev] = dist[p] + 1
        return dist, connect_vtxs

N, X, Y = list(map(int, input().split()))
g = Graph()
for i in range(N - 1):
    g.append_edge(i, i + 1)
    g.append_edge(i + 1, i)
g.append_edge(X - 1, Y - 1)
g.append_edge(Y - 1, X - 1)
dist_cnt = np.zeros(N)
for sv in range(N):
    dist, connect_vtxs = g.bfs(sv)
    for j in range(dist.shape[0]):
        if dist[j] == -1: continue
        dist_cnt[dist[j]] += 1

for i in range(N-1):
    print(int(dist_cnt[i+1]/2))
Problem p02777 (python)

Fixed submission:
S, T = list(input().split())
A, B = list(map(int, input().split()))
U = input()
dict = {}
dict[S] = A
dict[T] = B
dict[U] -= 1
print(dict[S], dict[T])

Buggy submission (verdict: Runtime Error):
S, T = list(input().split())
A, B = list(map(int, input().split()))
U = input()
dict = {}
dict[S] = A
dict[T] = B
dict[U] -= 1
print(f"{dict[S]} {dict[T]}")
Problem p02688 (python)

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

judge = [True] * n
for i in range(k):
    j = int(input())
    A = list(map(int,input().split()))
    for a in A:
        judge[a-1] = False

print(judge.count(True))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k = map(int,input().split())
l = np.zeros((n,k))
for i in range(k):
    d = int(input())
    tmp = list(map(int,input().split()))
    for j in tmp:
        l[j-1][d-1] = 1
print(len(l[np.all(l < 1,axis=1),:]))
Problem p02689 (python)

Fixed submission:
n,m = map(int,input().split())
h = list(map(int,input().split()))
judge = [True] * n

for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] == h[b-1]:
        judge[a-1],judge[b-1] =False, False
    elif h[a-1] > h[b-1]:
        judge[b-1] = False
    else:
        judge[a-1] = False

print(judge.count(True))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
h = list(map(int,input().split())
judge = [True] * n

for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] >= h[b-1]:
        judge[b-1] = False
    else:
        judge[a-1] = False
        
print(judge.count(True))
Problem p02693 (python)

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

def main():
    for i in range(a,b+1):
        if i % k == 0:
            print('OK')
            return
    print('NG')

main()

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

for i in range(a,b+1):
    if i % k == 0:
        print('OK')
        sys.exit()
print('NG')
Problem p02629 (python)

Fixed submission:
n=int(input(""))
a=[]
t=0
c=0
for i in range(11):
    t=n
    c=i+1
    n-=26**(i+1)
    if(n<=0):
        break
for i in range(c):
    a+=[n%26]
    n=int(n/26)
b=[]
for i in range(c):
    b+=[a[n-1-i]]
s=""
for i in b:
    if (i==1):
        s+="a"
    elif(i==2):
        s+="b"
    elif(i==3):
        s+="c"
    elif(i==4):
        s+="d"
    elif(i==5):
        s+="e"
    elif(i==6):
        s+="f"
    elif(i==7):
        s+="g"
    elif(i==8):
        s+="h"
    elif(i==9):
        s+="i"
    elif(i==10):
        s+="j"
    elif(i==11):
        s+="k"
    elif(i==12):
        s+="l"
    elif(i==13):
        s+="m"
    elif(i==14):
        s+="n"
    elif(i==15):
        s+="o"
    elif(i==16):
        s+="p"
    elif(i==17):
        s+="q"
    elif(i==18):
        s+="r"
    elif(i==19):
        s+="s"
    elif(i==20):
        s+="t"
    elif(i==21):
        s+="u"
    elif(i==22):
        s+="v"
    elif(i==23):
        s+="w"
    elif(i==24):
        s+="x"
    elif(i==25):
        s+="y"
    elif(i==0):
        s+="z"

print(s)

Buggy submission (verdict: Runtime Error):
n=int(input(""))
a=[]
t=0
c=0
for i in range(11):
    t=n
    c=i+1
    n-=26**(i+1)
    if(n<0):
        break
for i in range(c):
    a+=[n%26]
    n=int(n/26)
b=[]
for i in range(c):
    b+=[a[n-1-i]]
s=""
for i in b:
    if (i==1):
        s+="a"
    elif(i==2):
        s+="b"
    elif(i==3):
        s+="c"
    elif(i==4):
        s+="d"
    elif(i==5):
        s+="e"
    elif(i==6):
        s+="f"
    elif(i==7):
        s+="g"
    elif(i==8):
        s+="h"
    elif(i==9):
        s+="i"
    elif(i==10):
        s+="j"
    elif(i==11):
        s+="k"
    elif(i==12):
        s+="l"
    elif(i==13):
        s+="m"
    elif(i==14):
        s+="n"
    elif(i==15):
        s+="o"
    elif(i==16):
        s+="p"
    elif(i==17):
        s+="q"
    elif(i==18):
        s+="r"
    elif(i==19):
        s+="s"
    elif(i==20):
        s+="t"
    elif(i==21):
        s+="u"
    elif(i==22):
        s+="v"
    elif(i==23):
        s+="w"
    elif(i==24):
        s+="x"
    elif(i==25):
        s+="y"
    elif(i==0):
        s+="z"

print(s)
Problem p02659 (python)

Fixed submission:
c=input("").split(" ")
a=int(c[0])

e=100*int(c[1][0])+10*int(c[1][2])+int(c[1][3])

d=int(a*e)
s=str(d)
if (len(s)<3):
    f="0"
else:
    f=s[:len(s)-2]

print(f)

Buggy submission (verdict: Runtime Error):
c=input("").split(" ")
a=int(c[0])

e=100*int(c[0][0])+int(c[0][1])*10+int(c[0][2])

d=int(int(a*e)/100)
print(d)
Problem p02661 (python)

Fixed submission:
n=int(input(""))
a=[]
b=[]
for i in range(n):
    cc=input("").split(" ")
    a+=[int(cc[0])]
    b+=[int(cc[1])]
s=0
a.sort()
b.sort()
if (n%2==0):
    s=(a[int(n/2)]+a[int(n/2)-1]-b[int(n/2)]-b[int(n/2)-1])
else:
    s=a[int((n-1)/2)]-b[int((n-1)/2)]
print(int(-s+1))

Buggy submission (verdict: Runtime Error):
n=int(input(""))
a=[]
b=[]
for i in range(n):
    cc=input("").split(" ")
    a+=[int(cc[0])]
    b+=[int(cc[1])]
s=0
a.sort()
b.sort()
if (n%2==0):
    s=(a[n/2]+a[n/2-1]-b[n/2]-b[n/2-1])/2
else:
    s=a[int((n-1)/2)]-b[int((n-1)/2)]
print(-s+1)

Buggy submission (verdict: Runtime Error):
n=int(input(""))
a=[]
b=[]
for i in range(n):
    cc=input("").split(" ")
    a+=[int(cc[0])]
    b+=[int(cc[1])]
s=0
a.sort()
b.sort()
if (n%2==0):
    s=(a[n/2]+a[n/2-1]-b[n/2]-b[n/2-1])/2
else:
    s=a[int((n+1)/2)]-b[int((n+1)/2)]
print(-s+1)

Buggy submission (verdict: Runtime Error):
n=int(input(""))
a=[]
b=[]
for i in range(n):
    cc=input("").split(" ")
    a+=[int(cc[i])]
    b+=[int(cc[i])]
s=0
a.sort()
b.sort()
if (n%2==0):
    s=(a[n/2]+a[n/2-1]-b[n/2]-b[n/2-1])/2
else:
    s=a[(n+1)/2]-b[(n+1)/2]
print(s+1)
Problem p02689 (python)

Fixed submission:
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
greatest = [0] * N
for m in range(0, M):
  A, B = [int(s)-1 for s in input().split()]
  greatest[A] = max(greatest[A], heights[B])
  greatest[B] = max(greatest[B], heights[A])
    
count = 0
for i in range(0, N):
    count += heights[i] > greatest[i]
    
print(count)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = [int(s)-1 for s in input.split()]
  if heights[A] >= heights[B]:
    good[B] = False
  elif heights[A] <= heights[B]:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = map(int, input().split())
  if heights[A - 1] > heights[B - 1]:
    good[B] = False
  elif heights[A - 1] < heights[B - 1]:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = map(int, input().split())
  if heights[A] > heights[B]:
    good[B] = False
  elif heights[A] < heights[B]:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

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

good = [True] * N
for m in range(0, M):
  A, B = map(int, input.split())
  if A > B:
    good[B] = False
  elif A < B:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count++
    
print(count)
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = [int(s) for s in input().split()]
 
largest = B // K * K
 
print("OK" if largest >= A else "NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = [int(s) for s in input().split()]
 
largest = B // K * K

print("OK" if largest >= a else "NG")
Problem p02699 (python)

Fixed submission:
S, W = [int(s) for s in input().split()]
if W >= S:
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
S, W = [int(s) for s in input.split()]
if W >= S:
  print("unsafe")
else:
  print("safe")
Problem p02701 (python)

Fixed submission:
N = int(input())
items = set()
for n in range(0, N):
  items.add(input())
print(len(items))

Buggy submission (verdict: Runtime Error):
N = int(input())
items = set()
for i in range(0, N):
  items.add(input())
return len(items)
Problem p02729 (python)

Fixed submission:
import math
e,o = map(int,input().split())
if e < 2:
    e_cases = 0
else:
    e_cases = math.factorial(e)/math.factorial(e-2)/2
if o < 2:
    o_cases = 0
else:
    o_cases = math.factorial(o)/math.factorial(o-2)/2
print(int(e_cases+o_cases))

Buggy submission (verdict: Runtime Error):
import math
N = (int(input()))
items = list(map(int,input().split()))
for i in range(len(items)):    
    rest = items[:i] + items[i+1:]
    rest_unique = sorted(set(rest))
    out = 0
    for j in rest_unique:
        cnt = sum([1 for x in rest if x == j])
        if cnt >= 2:
            out = out + math.factorial(cnt)/math.factorial(cnt-2)/2
    print(int(out))