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

Fixed submission:
n, m = map(int, input().split())
nums = [list(map(int, input().split())) for _ in range(m)]

for i in range(1000):
  is_ok = True
  num_str = str(i)
  if len(num_str) != n:
    continue
  for s, c in nums:
    if num_str[s-1] != str(c):
      is_ok = False
      break
  if is_ok:
    print(num_str)
    exit(0)
print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

s_list = []
c_list = []
for _ in range(m):
  s, c = map(int, input().split())
  s_list.append(s)
  c_list.append(c)
ans = ["1"]
ans.extend(["0"]*(n-1))

if m == 1:
  if s_list[0] == 1:
    ans = [str(c_list[0])]
  else:
    ans[s_list[0]-1] = str(c_list[0])
elif c_list[0] == "0":
  ans = ["-1"]
else:
  for s, c in zip(s_list, c_list):
    if len(ans) < s:
      ans = ["-1"]
      break
    elif ans[s-1] != "0" and ans[s-1] != str(c):
      ans = ["-1"]
      break
    ans[s-1] = str(c)
print("".join(ans))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

s_list = []
c_list = []
for _ in range(m):
  s, c = map(int, input().split())
  s_list.append(s)
  c_list.append(c)
ans = ["0"]*n
if m == 1:
  if s_list[0] == 1:
    ans = [str(c_list[0])]
  else:
    ans = ["-1"]
elif c_list[0] == 0:
  ans = ["-1"]
else:
  for i, s in enumerate(s_list):
    x = c_list[i]
    if ans[s-1] != "0" and ans[s-1] != str(x):
      ans = ["-1"]
      break
    ans[s-1] = str(x)
print("".join(ans))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

s_list = []
c_list = []
for _ in range(m):
  s, c = map(int, input().split())
  s_list.append(s)
  c_list.append(c)
ans = ["0"]*n
if c_list[0] == 0:
  ans = ["-1"]
else:
  for i, s in enumerate(s_list):
    x = c_list[i]
    if ans[s-1] != "0" and ans[s-1] != str(x):
      ans = ["-1"]
      break
    ans[s-1] = str(x)
print(int("".join(ans)))
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
tmp = sum(p_list[:k])
max_num = sum(p_list[:k])
for i in range(len(p_list)-k):
  tmp = tmp - p_list[i] + p_list[i+k]
  if tmp >= max_num:
    max_num = tmp
print((max_num+k)/2)

Buggy submission (verdict: Runtime Error):
def culc_expected_value(num):
  output = 0
  if num != 1:
    for i in range(1, num+1):
      output += i/num
  else:
    output = 1
  return output
 
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
max_nums = 0
max_targets = []
for j in range(0, len(p_list)-k-1):
  targets = [p_list[j+m] for m in range(k)]
  t_sum = sum(targets)
  if t_sum >= max_nums:
    max_nums = t_sum
    max_targets = targets
# print(max_targets)

ans = 0
for t in max_targets:
  ans += culc_expected_value(t)
  # print(ans)

print(ans)
Problem p02817 (python)

Fixed submission:
a, b = input().split(' ')
print(b + a)

Buggy submission (verdict: Runtime Error):
  a, b = input().split(' ')
  print(b + a)
Problem p02848 (python)

Fixed submission:
s = int(input())
a_list = list(input())


def get_key(d, value):
    for k, v in d.items():
        if v == value:
            return k


output = []
a_dict = {1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'F', 7: 'G', 8: 'H', 9: 'I', 10: 'J', 11: 'K', 12: 'L', 13: 'M',
          14: 'N', 15: 'O', 16: 'P', 17: 'Q', 18: 'R', 19: 'S', 20: 'T', 21: 'U', 22: 'V', 23: 'W', 24: 'X', 25: 'Y',
          26: 'Z'}
for i, a in enumerate(a_list):
    n = get_key(a_dict, a)
    n += s
    if n > 26:
        if n % 26 == 0:
            n = 26
        else:
            n %= 26
    output.append(a_dict.get(n))
answer = ''.join(output)

print(answer)

Buggy submission (verdict: Runtime Error):
s = int(input())
a_list = list(input())


def get_key(d, value):
    for k, v in d.items():
        if v == value:
            return k


output = []
a_dict = {1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'F', 7: 'G', 8: 'H', 9: 'I', 10: 'J', 11: 'K', 12: 'L', 13: 'M',
          14: 'N', 15: 'O', 16: 'P', 17: 'Q', 18: 'R', 19: 'S', 20: 'T', 21: 'U', 22: 'V', 23: 'W', 24: 'X', 25: 'Y',
          26: 'Z'}
for i, a in enumerate(a_list):
    n = get_key(a_dict, a)
    n += s
    if n > 26:
        n %= 26
    output.append(a_dict.get(n))
answer = ''.join(output)

print(answer)
Problem p02900 (python)

Fixed submission:
from fractions import gcd
import math
 
A, B = map(int, input().split())
 
N = gcd(A, B)
 
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

factor = prime(N)
print(len(factor) + 1)

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

def get_prime_numbers(n):
  prime_nums = {}
  for i in range(2, math.ceil(math.sqrt(n)) + 1):
    while n % i == 0:
      if i in prime_nums:
        prime_nums[i] += 1
      else:
        prime_nums[i] = 1
      n //= i
  if n != 1:
    if n in prime_nums:
      prime_nums[n] += 1
    else:
      prime_nums[n] = 1
  return prime_nums

a, b = map(int, input().split())
gcd_n = gcd(a, b)
prime_nums = get_prime_numbers(gcd_n)
print(len(prime_nums.keys()))

if __name__ == '__main__':
  main()
Problem p02789 (python)

Fixed submission:
N, M = map(int, input().split())

if N == M :
	print("Yes")
else :
	print("No")

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

If N==M :
	print("Yes")
else :
	print("No")
Problem p02882 (python)

Fixed submission:
import math
a,b,x=map(int,input().split())
theta=0

if x<=a**2*b/2:
	theta=math.degrees(math.atan(a*b**2/(2*x)))
else:
	theta=math.degrees(math.atan(2*(a**2*b-x)/a**3))

print(theta)

Buggy submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
theta=0

if x<=a**2*b/2:
	theta=math.degrees(math.atan(2*x/(a*b**2)))
else:
	theta=math.degrees(math.atan(a**3/(2*(a**2*b-x))))

print(90-theta)
Problem p03162 (python)

Fixed submission:
N=int(input())
a=[0]*N
b=[0]*N
c=[0]*N

for i in range(N):
	a[i],b[i],c[i]=map(int,input().split())

dp=[[0 for j in range(N)] for k in range(3)]

for l in range(N):
	if l==0:
		dp[0][l]=a[l]
		dp[1][l]=b[l]
		dp[2][l]=c[l]
	else:
		dp[0][l]=max(dp[1][l-1],dp[2][l-1])+a[l]
		dp[1][l]=max(dp[0][l-1],dp[2][l-1])+b[l]
		dp[2][l]=max(dp[0][l-1],dp[1][l-1])+c[l]

print(max(dp[0][N-1],dp[1][N-1],dp[2][N-1]))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[0]*N
b=[0]*N
c=[0]*N

for i in range(N):
	a[i],b[i],c[i]=map(int,input().split())

dp=[[0 for j in range(3)] for k in range(N)]

for l in range(N):
	if l==0:
		dp[0][l]=a[l]
		dp[1][l]=b[l]
		dp[2][l]=c[l]
	else:
		dp[0][l]=max(dp[1][l-1],dp[2][l-1])+a[l]
		dp[1][l]=max(dp[0][l-1],dp[2][l-1])+b[l]
		dp[2][l]=max(dp[0][l-1],dp[1][l-1])+c[l]

print(max(dp[0][N-1],dp[1][N-1],dp[2][N-1]))
Problem p02837 (python)

Fixed submission:
N = int(input())
syougen = [[] for i in range(N)]
for i in range(N):
    a_tmp = int(input())
    for j in range(a_tmp):
        [x, y] = list(map(int,input().split()))
        syougen[i].append([x-1,y])
ans = 0
for i in range(2**N):
    data = [0]*N
    for j in range(N):
        if ((i >> j) & 1):
            data[j] = 1
    flag = True
    for k in range(N):
        if data[k] == 1:
            for l in range(len(syougen[k])):
                x = syougen[k][l][0]
                y = syougen[k][l][1]
                if data[x] != y:
                    flag = False
    if flag:
        ans = max(ans,sum(data))
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
data_xy = []
for i in range(N):
    A = int(input())
    xy = []
    for i in range(A):
        [x,y] = list(map(int,input().split()))
        xy.append([x-1, y])
    data_xy.append(xy)
data_xy = np.array(data_xy,dtype=np.int64)
ans = 0
for i in range(2**N):
    p_list = np.zeros(N,dtype=np.int64)
    for j in range(N):
        if (i>>j) & 1 == 1:
            p_list[j] = 1
    flag = True
    for j in range(N):
        if p_list[j] == 1:
            for k in range(len(data_xy[j])):
                x = data_xy[j][k][0]
                y = data_xy[j][k][1]
                if p_list[x] != y:
                    flag = False
    if flag == True:
        ans = max(sum(p_list),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
data_xy = []
for i in range(N):
    A = int(input())
    xy = []
    for i in range(A):
        [x,y] = list(map(int,input().split()))
        xy.append([x-1, y])
    data_xy.append(xy)
data_xy = np.array(data_xy,dtype=np.int64)
ans = 0
for i in range(2**N):
    p_list = np.zeros(N,dtype=np.int64)
    for j in range(N):
        if (i>>j) & 1 == 1:
            p_list[j] = 1
    flag = True
    for j in range(N):
        if p_list[j] == 1:
            for k in range(len(data_xy[j])):
                x = data_xy[j][k][0]
                y = data_xy[j][k][1]
                if p_list[x] != y:
                    flag = False
    if flag == True:
        ans = max(sum(p_list),ans)
print(ans)
Problem p02838 (python)

Fixed submission:
import numpy as np
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
A = np.array(A, dtype = np.int64)
tmp = 0
for i in range(61):
    tmp_1 = np.count_nonzero(A & 1)
    tmp += ((tmp_1)*(N - tmp_1)*(2**i)) % mod
    A = A >> 1
print(tmp % mod)

Buggy submission (verdict: Runtime Error):
import numpy as np
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
A = np.array(A, dtype = np.int64)
tmp = 0
for i in range(61):
    tmp_1 = np.count_nonzero
    tmp += ((tmp_1)*(N - tmp_1)*(2**i)) % mod
    A = A >> 1
print(tmp % mod)
Problem p02900 (python)

Fixed submission:
def gcd(a,b):
    while b != 0:
        a,b = b,a%b
    return a

A,B = list(map(int,input().split()))
GCD = gcd(A,B)
CD = []
for i in range(1,int(GCD**(0.5))+1):
    if GCD % i == 0:
        CD.append(i)
        if not i == GCD//i:
            CD.append(GCD//i)
CD.sort()
ans = 1
tmp_idx = 0
CD.pop(0)
CD_old = CD[:]
while (len(CD_old)>0):
    tmp = CD_old.pop(0)
    CD_new = []
    for i in range(len(CD_old)):
        if not CD_old[i] % tmp == 0:
            CD_new.append(CD_old[i])
    ans += 1
    CD_old = CD_new
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import heapq
A,B = list(map(int,input().split()))
GCD = math.gcd(A,B)
CD = []
for i in range(1,int(GCD**(0.5))+1):
    if GCD % i == 0:
        CD.append(i)
        if not i == GCD//i:
            CD.append(GCD//i)
CD.sort()
ans = 1
tmp_idx = 0
CD.pop(0)
CD_old = CD[:]
while (len(CD_old)>0):
    tmp = CD_old.pop(0)
    CD_new = []
    for i in range(len(CD_old)):
        if not CD_old[i] % tmp == 0:
            CD_new.append(CD_old[i])
    ans += 1
    CD_old = CD_new
print(ans)
Problem p03545 (python)

Fixed submission:
s = input()
S = [0]*len(s)
for i in range(len(s)):
    S[i] = int(s[i])

# 0:-, 1:+
op = [0]*(len(S) - 1)
for i in range(2**len(op)):
    op = [0]*(len(S) - 1)
    for j in range(len(op)):
        if (i >> j & 1):
            op[j] = 1
    tmp = S[0]
    for j in range(len(op)):
        if op[j] == 0:
            tmp -= S[j+1]
        else:
            tmp += S[j+1]
    if tmp == 7:
        ans = op[:]
ans_str = s[0]
for i in range(len(S)-1):
    if ans[i] == 0:
        ans_str = ans_str + "-"
    else:
        ans_str = ans_str + "+"
    ans_str = ans_str + s[i+1]
ans_str = ans_str + "=7"
print(ans_str)

Buggy submission (verdict: Runtime Error):
s = input()
S = [0]*len(s)
for i in range(len(s)):
    S[i] = int(s[i])
# 0:-, 1:+
for i in range(2**len(op)):
    op = [0]*(len(S) - 1)
    for j in range(len(op)):
        if (i >> j & 1):
            op[j] = 1
    tmp = S[0]
    for j in range(len(op)):
        if op[j] == 0:
            tmp -= S[j+1]
        else:
            tmp += S[j+1]
    if tmp == 7:
        ans = op[:]
ans_str = s[0]
for i in range(len(S)-1):
    if ans[i] == 0:
        ans_str = ans_str + "-"
    else:
        ans_str = ans_str + "+"
    ans_str = ans_str + s[i+1]
ans_str = ans_str + "=7"
print(ans_str)
Problem p02936 (python)

Fixed submission:
N,Q = map(int, input().split())
ki = [[] for i in range(N+1)]
val = [0 for _ in range(N+1)]

for _ in range(N-1):
  a,b = map(int, input().split())
  ki[a].append(b)
  ki[b].append(a)
for _ in range(Q):
  p,x = map(int, input().split())
  val[p] += x

q = [(1,0)]
while q:
  c,p = q.pop()
  val[c] += val[p]
  for x in ki[c]:
    if x==p:
      continue
    q.append((x,c))
print(' '.join(map(str, val[1:])))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N,Q = map(int, input().split())
ki = [[] for i in range(N+1)]
val = [0 for _ in range(N+1)]
 
for _ in range(N-1):
    a,b = map(int, input().split())
    ki[a].append(b)
for _ in range(Q):
    p,x = map(int, input().split())
    val[p] += x

touched = []
def add_num(p):
  touched.append(p)
  for k in ki[p]:
    if (k!=p)&(k not in touched):
      val[k] += val[p]
      add_num(k)

add_num(1)
print(*val[1:])

Buggy submission (verdict: Runtime Error):
def search_add_num(p,x):
    for k in ki[p]:
        if k!=p:
            search_add_num(k,x)
        else:
            k_values[p] += x
N,Q = map(int, input().split())
ki = [[i] for i in range(N+1)]
k_values = [0 for _ in range(N+1)]

for _ in range(N-1):
    a,b = map(int, input().split())
    ki[a].append(b)
for _ in range(Q):
    p,x = map(int, input().split())
    search_add_num(p,x)
print(' '.join(map(str, k_values[1:])))
Problem p03085 (python)

Fixed submission:
print('ATCG'['TAGC'.find(input())])

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

n, q = map(int, input().split())
s = input()
for _ in range(q):
  first, last = map(int, input().split())
  print(s[first-1:last].count("AC"))
Problem p03455 (python)

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

if a*b%2 == 0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b = int(input())
if a*b%2 == 0:
	print("Even")
else:
  	print("Odd")
Problem p03493 (python)

Fixed submission:
str = list(input())
c = 0
for s in str:
 c += int(s)
print(c)

Buggy submission (verdict: Runtime Error):
import collections
n, k = map(int, input().split())
a = map(int, input().split())
c = collections.Counter(a)

if len(c) <= k:
  print(0)
else:
  c = c.most_common()
  print(sum(c[:k-1][0]))
Problem p03495 (python)

Fixed submission:
from collections import Counter 
n,k = map(int, input().split())
a = list(map(int, input().split()))
ct = sorted(list(Counter(a).values()), reverse=True)
print(sum(ct[k:]))

Buggy submission (verdict: Runtime Error):
import collections
n, k = map(int, input().split())
a = map(int, input().split())
c = collections.Counter(a)

if len(c) <= K:
  print(0)
else:
  c = c.most_common()
  print(sum(c[:K-1][0]))
Problem p03502 (python)

Fixed submission:
N = int(input())
temp = N
test = 0
while temp > 0:
  test += temp %10
  temp //= 10
if N % test == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
temp = N
while temp > 0:
  test += temp %10
  temp //= 10
if N % test == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
temp = N
while temp > 0:
  test += temp %10
  temp //= 10
if N % test == 0:
  print('Yes')
else:
  print('No')
Problem p03807 (python)

Fixed submission:
import sys
input()
count = 0
a_list = list(map(int, input().split()))
for a in a_list:
  count += a%2

print("YES") if count%2==0 else print("NO")

Buggy submission (verdict: Runtime Error):
import sys
sys.stdin.readline()
count = 0
a_list = list(map(int, sys.stdin.readline().split()))
for a in x_list:
  count += a%2

print("YES") if count%2==0 else print("NO")

Buggy submission (verdict: Runtime Error):
import sys
input_ = sys.stdin.readline
input_()
x_list = list(map(int, input_().split()))
for x in x_list:
  if x%2==0:
    a += 1

if a%2==0:
  print("YES")
else:
  print("NO")
Problem p03854 (python)

Fixed submission:
#C - 白昼夢 / Daydream

s = input()[::-1]

while True:
  if s[:5] == "maerd":
    s = s[5:]
  elif s[:7] == "remaerd":
    s = s[7:]
  elif s[:5] == "esare":
    s = s[5:]
  elif s[:6] == "resare":
    s = s[6:]
  else:
    break

if s == "":
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
s = input()[::-1]

while True:
  if s[:5] == "maerd":
    s = s[5:]
  elif s[:7] == "remaerd":
    s - s[7:]
  elif s[:5] == "esare":
    s = s[5:]
  elif s[:6] == "resare":
    s - s[6:]
  else:
    break

if s == "":
  print("YES")
else:
  print("NO")
Problem p03273 (python)

Fixed submission:
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i=0; i<h; i++) {
        cin >> a.at(i);
    }
    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (a.at(i).at(j) == '#') {
				row[i] = true;
				col[j] = true;
            }
        }
    }

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}    
}
Problem p03417 (python)

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

if n>=2 and m>=2:
    print(n*m - (n-2)*2 - (m-2)*2 - 4)
elif n==1 and m==1:
    print(1)
elif n==1 and m>=2:
    print(m-2)
else:
    print(n-2)

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

int main() {
  long long n, m;
  cin >> n >> m;

  if (n>=2 && m>=2) {
      cout << n*m - (n-2)*2 - (m-2)*2 - 4 << endl;
  }
  else if (n==1 && m==1) {
      cout << 1 << endl;
  }
  else if (n==1 && m>=2) {
      cout << m-2 << endl;
  }
  else {
      cout << n-2 << endl;
  }
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;

  if (n>=2 && m>=2) {
      cout << n*m - (n-2)*2 - (m-2)*2 - 4 << endl;
  }
  else if (n==1 && m==1) {
      cout << 1 << endl;
  }
  else if (n==1 && m>=2) {
      cout << m-2 << endl;
  }
  else {
      cout << n-2 << endl;
  }
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;

  if (n>=2 && m>=2) {
      cout << n*m - (n-2)*2 - (m-2)*2 - 4 << endl;
  }
  else if (n==1 && m==1) {
      cout << 1 << endl;
  }
  else if (n==1 && m>=2) {
      cout << m-2 << endl;
  }
  else {
      cout << n-2 << endl;
  }
}
Problem p03068 (python)

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

c = S[K-1]

print("".join([v if v == c else "*" for v in S]))

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

c = S[K]

print("".join([v if v == c else "*" for v in S]))
Problem p03149 (python)

Fixed submission:
print("YES" if "".join(sorted(input().split())) == "1479" else "NO")

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

if sum(A) < sum(B) : 
    print(-1)
else :
    diff=[A[i] - B[i] for i in range(len(A))]
    pos=sorted([x for x in diff if x > 0])
    neg=[x for x in diff if x < 0]
    nes=sum(neg)
    if nes >= 0 :
        print(0)
    else:
        items = 0
        total_pos = 0
        for p in reversed(pos):
            items += 1
            total_pos += p
            if(total_pos + nes >= 0) :
                print(items + len(neg))
                break
Problem p03599 (python)

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

W = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))
S = [max([c*C + d*D for c in range(int((E*w / 100) / C) + 1) for d in range(int((E*w / 100) / D) + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]
print(100*A if W[I] == 0 else W[I] + S[I], S[I])

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

W = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))
S = [max([c*C + d*D for c in range(int((E*w / 100) / C) + 1) for d in range(int((E*w / 100) / D) + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]
print(A[0] if W[I] == 0 else W[I] + S[I], S[I])

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

W = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))
S = [max([c*C + d*D for c in range((E*w / 100) / C + 1) for d in range((E*w / 100) / D + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]
print(W[I] + S[I], S[I])
Problem p04048 (python)

Fixed submission:
def gcd(a, b):
        while a != b:
                if a == 0:
                        return b
                elif b == 0:
                        return a
                if a > b :
                        a %= b
                else:
                        b %= a
        return a

N, X=map(int, input().split())

print(3*(N - gcd(N, X)))

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

N, X=map(int, input().split())

print(3*(N - gcd(N, X)))
Problem p02761 (python)

Fixed submission:
N, M = [int(i) for i in input().split(" ")]
conds = []
for _ in range(M):
    conds.append([int(i) for i in input().split(" ")])

exists = True
A = [None for _ in range(N)]
for s, c in conds:
    idx = s-1
    if A[idx] != None and A[idx] != c:
        exists = False
        break
    A[idx] = c


def check():
    if not exists:
        return [-1]

    if N == 1:
        if A[0] == None:
            return [0]
        else:
            return A
    else:
        if A[0] == 0:
            return [-1]

    for i in range(N):
        if A[i] == None:
            A[i] = -float("infinity")

    base = [1] + [0] * (N-1)
    res = []
    for i in range(N):
        res.append(max(A[i], base[i]))
    return res


print("".join(str(x) for x in check()))

Buggy submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split(" ")]
conds = []
for _ in range(M):
    conds.append([int(i) for i in input().split(" ")])

exists = True
A = [None for _ in range(N)]
for s, c in conds:
    idx = s-1
    if A[idx] != None and A[idx] != c:
        exists = False
        break
    A[idx] = c


def check():
    if not exists:
        return [-1]

    if N == 1:
        if A[0] == None:
            return [0]
        else:
            return A
    else:
        if A[0] == 0:
            return [-1]

    for i in range(N):
        if A[i] == None:
            A[i] = -float("infinity")

    base = [1] + [0] * (N-1)
    res = []
    for i in range(N):
        res[i] = max(A[i], base[i])
    return res


print("".join(str(x) for x in check()))