Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
data = [list(map(int, input().split())) for i in range(3)]

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = data[0][0] - a1
            b2 = data[0][1] - a1
            b3 = data[0][2] - a1

            if (
                b1 + a2 == data[1][0]
                and b2 + a2 == data[1][1]
                and b3 + a2 == data[1][2]
                and b1 + a3 == data[2][0]
                and b2 + a3 == data[2][1]
                and b3 + a3 == data[2][2]
            ):
                print("Yes")
                exit(1)

print("No")

Fixed submission:
data = [list(map(int, input().split())) for i in range(3)]

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = data[0][0] - a1
            b2 = data[0][1] - a1
            b3 = data[0][2] - a1

            if (
                b1 + a2 == data[1][0]
                and b2 + a2 == data[1][1]
                and b3 + a2 == data[1][2]
                and b1 + a3 == data[2][0]
                and b2 + a3 == data[2][1]
                and b3 + a3 == data[2][2]
            ):
                print("Yes")
                exit(0)

print("No")
Buggy python submission (verdict: Runtime Error):
import sys

N = int(input())
D = list(map(int, sys.stdin.readline().rsplit()))
M = int(input())
T = list(map(int, sys.stdin.readline().rsplit()))

q = [0] * (10 ** 9 + 1)
for d in D:
    q[d] += 1

for t in T:
    if q[t] > 0:
        q[t] -= 1
    else:
        print("NO")
        exit()

print("YES")


Fixed submission:
import sys
from collections import defaultdict

N = int(input())
D = list(map(int, sys.stdin.readline().rsplit()))
M = int(input())
T = list(map(int, sys.stdin.readline().rsplit()))
q = defaultdict(int)

for d in D:
    q[d] += 1

for t in T:
    if q[t] > 0:
        q[t] -= 1
    else:
        print("NO")
        exit()

print("YES")

Buggy python submission (verdict: Runtime Error):
import sys

N = int(input())
D = list(map(int, sys.stdin.readline().rsplit()))
M = int(input())
T = list(map(int, sys.stdin.readline().rsplit()))

q = [0] * (max(D) + 1)
for d in D:
    q[d] += 1

for t in T:
    if q[t] > 0:
        q[t] -= 1
    else:
        print("NO")
        exit()

print("YES")


Fixed submission:
import sys
from collections import defaultdict

N = int(input())
D = list(map(int, sys.stdin.readline().rsplit()))
M = int(input())
T = list(map(int, sys.stdin.readline().rsplit()))
q = defaultdict(int)

for d in D:
    q[d] += 1

for t in T:
    if q[t] > 0:
        q[t] -= 1
    else:
        print("NO")
        exit()

print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D, E, F = map(int, input().split())

memo = {}
memo.update(density=0, sugerwater=0, suger=0)
for a in range(F//(100*A) + 1):
    for b in range(F//(100*B) + 1):
        for c in range(E*(A*a + B*b)//C + 1):
            for d in range(E*(A*a + B*b)//D + 1):
                # print(100*(A*a + B*b) + C*c + D*d)
                if 100 * (A * a + B * b) + C * c + D * d <= F and C * c + D * d <= E * (A * a + B * b) and (100 * (A * a + B * b) + C * c + D * d) != 0:
                    dens_tmp = 100*(C*c + D*d)/(100*(A*a + B*b) + C*c + D*d)
                    if dens_tmp >= memo['density']:
                        memo.update(density=dens_tmp, sugerwater=100 *
                                    (A * a + B * b) + C * c + D * d, suger=C * c + D * d)

print(memo['sugerwater'], memo['suger'])

Fixed submission:
A, B, C, D, E, F = map(int, input().split())

memo = {}
memo.update(density=0, sugerwater=0, suger=0)
for a in range(F//(100*A) + 1):
    for b in range(F//(100*B) + 1):
        for c in range(E*(A*a + B*b)//C + 1):
            for d in range(E*(A*a + B*b)//D + 1):
                # print(100*(A*a + B*b) + C*c + D*d)
                if 100 * (A * a + B * b) + C * c + D * d <= F and C * c + D * d <= E * (A * a + B * b) and (100 * (A * a + B * b) + C * c + D * d) != 0:
                    dens_tmp = 100*(C*c + D*d)/(100*(A*a + B*b) + C*c + D*d)
                    if dens_tmp >= memo['density']:
                        memo.update(density=dens_tmp, sugerwater=100 *
                                    (A * a + B * b) + C * c + D * d, suger=C * c + D * d)

print(memo['sugerwater'], memo['suger'])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

for g in G[N - 1]:
    if g in G[0]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")


Fixed submission:
N, M = map(int, input().split())
G = [set() for i in range(N + 1)]

for i in range(M):
    a, b = map(int, input().split())
    G[a].add(b)
    G[b].add(a)

for a in G[1]:
    if a in G[N]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

now = 0
count = 0
while True:
    if now == 0 and count != 0:
        print(-1)
        break

    if now == 1:
        print(count)
        break

    now = A[now] - 1
    count += 1


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

now = 0
count = 0
while True:
    if count >= N:
        print(-1)
        break

    if now == 1:
        print(count)
        break

    now = A[now] - 1
    count += 1

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

now = 0
count = 0
while True:
    if now == 0 and count != 0:
        print(-1)
        break

    if now == 1:
        print(count)
        break

    now = A[now] - 1
    count += 1


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

now = 0
count = 0
while True:
    if count >= N:
        print(-1)
        break

    if now == 1:
        print(count)
        break

    now = A[now] - 1
    count += 1

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

now = 0
count = 0
while True:
    count += 1
    if A[now] == 1:
        print(-1)
        break

    if A[now] == 2:
        print(count)
        break

    now = A[now] - 1


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

now = 0
count = 0
while True:
    if count >= N:
        print(-1)
        break

    if now == 1:
        print(count)
        break

    now = A[now] - 1
    count += 1
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
t = list(map(int, input().split()))

res = 0
for i in range(N - 1):
    res += min(T, t[i + 1] - t[i])

if t[-2] + T <= t[-1]:
    res += T 

print(res)


Fixed submission:
N, T = map(int, input().split())
t = list(map(int, input().split()))

res = 0
for i in range(N - 1):
    res += min(T, t[i + 1] - t[i])

res += T

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

res = 1000000000
for bit in range(2 ** N):
    b = [int(bin(bit)[i + 2]) for i in range(len(bin(bit)) - 2)]
    if b.count(1) >= K:
    	b.reverse()
        b_index = -1
        height = 0
        cnt = 0
        while True:
            sub = 0
            if 1 in b[b_index + 1:]:
                b_index = b[b_index + 1:].index(1) + b_index + 1
            else:
                break

            if A[b_index] - height <= 0:
                sub += height - A[b_index] + 1
                cnt += sub
                height = A[b_index] + sub
            else:
                height = A[b_index]

        res = min(res, cnt)

print(res)

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

res = 10 ** 15

for bit in range(2 ** N):
    cnt = 0
    for i in range(N):
        if (bit >> i) & 1:
            cnt += 1

    if cnt < K:
        continue

    cost = 0
    height = 0
    for i in range(0, N):
        if (bit >> i) & 1 and height >= A[i]:
            cost += height - A[i] + 1
            height += 1
        elif height < A[i]:
            height = A[i]

    res = min(res, cost)

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
M = 10 ** 9 + 7

res = 1
for i in range(1, N + 1):
    res *= i

print(res % M)

Fixed submission:
import math
n = int(input())
print(math.factorial(n) % (10**9 + 7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
M = 10 ** 9 + 7

res = 1
for i in range(1, N + 1):
    res *= i

print(res % M)

Fixed submission:
import math
n = int(input())
print(math.factorial(n) % (10**9 + 7))
Buggy python submission (verdict: Runtime Error):
from itertools import permutations

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

res = 0
for P in permutations(range(N), N):
    if P[0] != 0:
        continue
    for i in range(N - 1):
        if P[i + 1] not in G[P[i]]:
            break
    else:
        res += 1

print(res)


Fixed submission:
import itertools as it

N, M = map(int, input().split())
ab = tuple(set(map(int, input().split())) for _ in range(M))

P = it.permutations(range(1, N + 1), N)

res = 0
for p in P:
    if p[0] == 1:
        for i in range(N - 1):
            if not(set({p[i], p[i + 1]}) in ab):
                break
        else:
            res += 1

print(res)

Buggy python submission (verdict: Runtime Error):
from itertools import permutations

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

res = 0
for P in permutations(range(N), N):
    if P[0] != 0:
        continue
    for i in range(N - 1):
        if P[i + 1] not in G[P[i]]:
            break
    else:
        res += 1

print(res)


Fixed submission:
import itertools as it

N, M = map(int, input().split())
ab = tuple(set(map(int, input().split())) for _ in range(M))

P = it.permutations(range(1, N + 1), N)

res = 0
for p in P:
    if p[0] == 1:
        for i in range(N - 1):
            if not(set({p[i], p[i + 1]}) in ab):
                break
        else:
            res += 1

print(res)
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())

if x % a == 0:
    print((b - a + 1) // x + 1)
else:
    print((b - a + 1) // x)


Fixed submission:
a, b, x = map(int, input().split())
print(b//x - (a - 1)//x)
Buggy python submission (verdict: Runtime Error):
S = list(input())
K = int(input())

l = 0
for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= K:
        S[i] = 'a'
        K -= ord('z') - ord(s) + 1
    else:
        l = i
else:
    if K > 0:
        S[l] = chr(ord(S[l]) + K)

print("".join(S))


Fixed submission:
S = list(input())
K = int(input())

for i, s in enumerate(S):
    if s == "a":
        pass
    elif ord('z') - ord(s) + 1 <= K:
        S[i] = 'a'
        K -= ord('z') - ord(s) + 1

K %= 26
S[-1] = chr((ord(S[-1]) - ord('a') + K) % 26 + ord('a'))

print("".join(S))

Buggy python submission (verdict: Runtime Error):
S = list(input())
K = int(input())

for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= K:
        S[i] = 'a'
        K -= ord('z') - ord(s) + 1
else:
    if K > 0:
        S[-1] = chr(ord(S[-1]) + K)

print("".join(S))


Fixed submission:
S = list(input())
K = int(input())

for i, s in enumerate(S):
    if s == "a":
        pass
    elif ord('z') - ord(s) + 1 <= K:
        S[i] = 'a'
        K -= ord('z') - ord(s) + 1

K %= 26
S[-1] = chr((ord(S[-1]) - ord('a') + K) % 26 + ord('a'))

print("".join(S))
Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
B *= 2
if A < B:
    print('0')
else:
    print(A - B)

Fixed submission:
a = list(map(int, input().split()))
A = a[0]
B = a[1]
if A <= B * 2:
    print(0)
else:
    print(A - B * 2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

l = []
ans = 1
z = False
l = input().split(' ')
for x in l:
  x = int(x)
  if x == 0:
    print(0)
    exit(0)
for i in range(n):
  x = int(l[i])
  ans *= x
  if ans > 1e18:
    ans = -1

print(ans)

Fixed submission:
n = int(input())

l = []
ans = 1
z = False
l = input().split(' ')
for x in l:
  x = int(x)
  if x == 0:
    print(0)
    exit(0)
for i in range(n):
  x = int(l[i])
  ans *= x
  if ans > 1e18:
    ans = -1
    break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

l = []
ans = 1
l = input().split(' ')
for i in range(n):
  x = int(l[i])
  ans *= x

if ans > 1e18:
  ans = -1
print(ans)

Fixed submission:
n = int(input())

l = []
ans = 1
z = False
l = input().split(' ')
for x in l:
  x = int(x)
  if x == 0:
    print(0)
    exit(0)
for i in range(n):
  x = int(l[i])
  ans *= x
  if ans > 1e18:
    ans = -1
    break

print(ans)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

void printArray(vector<int> arr) {
	for (int a: arr) cout << a << " ";
	cout << '\n';
}

int a[100001];

int main() {
	std::ios_base::sync_with_stdio(false);
	int n, q;
	cin >> n;
	map<int, int> count;
	ll sum = 0;
	for (int i = 0; i<n; i++) {
		cin >> a[i];
		sum += a[i];
		if (count.find(a[i]) == count.end()) count[a[i]] = 1;
		else count[a[i]]++;
	} 
	cin >> q;
	for (int _=0; _<q; _++) {
		int b,c,temp;
		cin >> b >> c;
		if (count.find(b) != count.end()) {
			temp = count[b];
			count.erase(b);
			sum = sum - b*temp + c*temp;
			if (count.find(c) == count.end()) count[c] = temp;
			else count[c] += temp;
		}
		cout << sum << '\n';
	}
	
}	



Fixed submission:
n = int(input())
count = {}
s = 0
a = [int(c) for c in input().split()]
for val in a:
	s += val
	if (val not in count): count[val] = 1
	else: count[val] += 1

q = int(input())
for _ in range(q):
	b, c = [int(c) for c in input().split()]
	if (b in count):
		temp = count[b]
		count.pop(b)
		s = s + c*temp - b*temp 
		if (c not in count): count[c] = temp 
		else: count[c] += temp
	print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt = 0
for a in range(1,n):
    cnt += (n-1)//a
print(cnt)n = int(input())
cnt = 0
for a in range(1,n):
    cnt += (n-1)//a
print(cnt)

Fixed submission:
n = int(input())
cnt = 0
for a in range(1,n):
    cnt += (n-1)//a
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import math

def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
    
def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num

n = int(input())
cnt = 0
for i in range(1, n):
    k = n-i
    cnt += search_divisor_num_1(k)
print(cnt)



Fixed submission:
n = int(input())
cnt = 0
for a in range(1,n):
    cnt += (n-1)//a
print(cnt)

Buggy python submission (verdict: Runtime Error):
from sympy import divisors
n = int(input())

cnt = 0
for i in range(1, n):
    k = n-i
    cnt += len(divisors(k))
print(cnt)


Fixed submission:
n = int(input())
cnt = 0
for a in range(1,n):
    cnt += (n-1)//a
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())

cnt = 0
cnt2 = 0
for i in range(1, n):
    k = n-i
    for j in range(1, int(math.sqrt(k+1))+1):
        if k%j == 0:
            if j == math.sqrt(k):
                cnt2 += 1
            else:
                cnt += 1

print(int(cnt*2)+cnt2)

Fixed submission:
n = int(input())
cnt = 0
for a in range(1,n):
    cnt += (n-1)//a
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
stn = input()
m = stn.count('R')

for i in range(N+1):
    white_l = stn.count('W', 0, i)
    red_r = stn.count('R', i, N)
    if red_r >= white_l:
        m = min(m, red_r)
    else:
        m = min(m, white_l)

print(m)

Fixed submission:
N = int(input())
stn = input()
m = stn.count('R')
r = m
w = 0
for i in range(N):
    if stn[i]=='R':
        r -= 1
    else:
        w += 1

    m = min(m, max(r,w))

print(m)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
score = 1
for i in range(k-1, n-1):
    if int(score) < int(score*a[i+1]/a[i-k+1]):
        print('Yes')
    else:
        print('No')
    score = score*a[i+1]/a[i-k+1]

Fixed submission:
n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
for i in range(k, n):
    score = 1
    if score < score*a[i]/a[i-k]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
score = 1
for i in range(k):
    score *= a[i]
for i in range(k-1, n-1):
    if int(score) < int(score*a[i+1]/a[i-k+1]):
        print('Yes')
    else:
        print('No')
    score = score*a[i+1]/a[i-k+1]

Fixed submission:
n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
for i in range(k, n):
    score = 1
    if score < score*a[i]/a[i-k]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
H, W, K = map(int, input().split(' '))
C = []*H
ans=0
for i in range(H):
    C[i] = list(input())
for paint_h in range(2**H):
    for paint_w in range(2**W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (paint_h<<i)&1==0 and (paint_w<<j)&1==0:
                    if C[i][j] == '#':
                        cnt+=1
        if cnt==K:
            ans+=1
print(ans)

Fixed submission:
H, W, K = map(int, input().split(' '))
C = []*H
ans=0
C = [list(input()) for _ in range(H)]
for paint_h in range(2**H):
    for paint_w in range(2**W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (paint_h>>i)&1==0 and (paint_w>>j)&1==0:
                    if C[i][j] == '#':
                        cnt+=1
        if cnt==K:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())

for a in range(1, int(math.sqrt(n))):
    if n%a == 0:
        b = n//a
        ans = len(str(b))
print(ans)

Fixed submission:
import math
n = int(input())
if n < 10:
    print(1)
else:
    a = 0
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            a = i
    b = n//a
    j = 1
    while True:
        m = b / (10**j)
        if m>=1 and m<10:
            ans = j+1
            break
        j+=1

    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
a = 0
for i in range(1, int(math.sqrt(n))+1):
    if n % i == 0:
        a = i
b = n//a
j = 1
while True:
    m = b / (10**j)
    if m>=1 and m<10:
        ans = j+1
        break
    j+=1

print(ans)

Fixed submission:
import math
n = int(input())
if n < 10:
    print(1)
else:
    a = 0
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            a = i
    b = n//a
    j = 1
    while True:
        m = b / (10**j)
        if m>=1 and m<10:
            ans = j+1
            break
        j+=1

    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
ans = 0
for i in range(1, int(math.sqrt(n))+1):
    if n % i == 0:
        j = 1
        while True:
            m = (n//i)/(10**j)
            if m>=1 and m<10:
                ans = j+1
                break
            j+=1
print(ans)

Fixed submission:
import math
n = int(input())
if n < 10:
    print(1)
else:
    a = 0
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            a = i
    b = n//a
    j = 1
    while True:
        m = b / (10**j)
        if m>=1 and m<10:
            ans = j+1
            break
        j+=1

    print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
if s[0] != "1":
    print(int(s[0]))
else:
    count = 0
    i = 0
    while s[i] == "1":
        count += 1
        i += 1
    if k <= count:
        print(1)
    else:
        print(int(s[i]))

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

if s[0] != "1":
    print(int(s[0]))
else:
    count = 0
    i = 0
    if len(set(s)) == 1:
        print(1)
    else:
        while s[i] == "1":
            count += 1
            i += 1
        if k <= count:
            print(1)
        else:
            print(int(s[i]))
Buggy python submission (verdict: Runtime Error):
import math

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

b = [a[i]-(i+1) for i in range(n)]

s = sum(b)
N = len(b)
mean = math.floor(s / N)
meanb = mean+1

t = sum([abs(b[i]-mean) for i in b])
u = sum([abs(b[i]-meanb) for i in b])

print(min(t,u))

Fixed submission:
import math
import statistics

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

b = [a[i]-(i+1) for i in range(n)]
median = statistics.median(b)

med1 = math.floor(median)
med2 = med1+1

t = sum([abs(i-med1) for i in b])
u = sum([abs(i-med2) for i in b])

print(min(t,u))
Buggy python submission (verdict: Runtime Error):
a,b = [int i for i in input().split()]
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Fixed submission:
a,b = [int(i) for i in input().split()]
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Fixed submission:
a,b = [int(i) for i in input().split()]
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")