Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

def isleft(ox, oy, ax, ay, px, py):
    oax, oay = ax - ox, ay - oy
    opx, opy = px - ox, py - oy
    if oax * opy > oay * opx:
        return 1
    else:
        return 0

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    A, B, C, P = (x1, y1), (x2, y2), (x3, y3), (xp, yp)
    if isleft(*A, *B, *P) == isleft(*B, *C, *P) == isleft(*C, *A, *P):
        print("YES")
    else:
        print("NO")

Fixed submission:
import sys

def isleft(ox, oy, ax, ay, px, py):
    oax, oay = ax - ox, ay - oy
    opx, opy = px - ox, py - oy
    if oax * opy > oay * opx:
        return 1
    else:
        return 0

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
#    A, B, C, P = (x1, y1), (x2, y2), (x3, y3), (xp, yp)
#    if isleft(*A, *B, *P) == isleft(*B, *C, *P) == isleft(*C, *A, *P):
    if isleft(x1, y1, x2, y2, xp, yp) == isleft(x2, y2, x3, y3, xp, yp) == isleft(x3, y3, x1, y1, xp, yp):
        print("YES")
    else:
        print("NO")

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

def isleft(ox, oy, ax, ay, px, py):
    oax, oay = ax - ox, ay - oy
    opx, opy = px - ox, py - oy
    if oax * opy > oay * opx:
        return 1
    else:
        return 0

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, line.split()))
    A, B, C, P = (x1, y1), (x2, y2), (x3, y3), (xp, yp)
    if isleft(*A, *B, *P) == isleft(*B, *C, *P) == isleft(*C, *A, *P):
        print("YES")
    else:
        print("NO")

Fixed submission:
import sys

def isleft(ox, oy, ax, ay, px, py):
    oax, oay = ax - ox, ay - oy
    opx, opy = px - ox, py - oy
    if oax * opy > oay * opx:
        return 1
    else:
        return 0

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
#    A, B, C, P = (x1, y1), (x2, y2), (x3, y3), (xp, yp)
#    if isleft(*A, *B, *P) == isleft(*B, *C, *P) == isleft(*C, *A, *P):
    if isleft(x1, y1, x2, y2, xp, yp) == isleft(x2, y2, x3, y3, xp, yp) == isleft(x3, y3, x1, y1, xp, yp):
        print("YES")
    else:
        print("NO")
Buggy python submission (verdict: Runtime Error):
from math import isclose

n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    if isclose((x2 - x1) * (y4 - y3) - (x4 - x3) * (y2 - y1), 0.0):
        print("YES")
    else:
        print("NO")

Fixed submission:
n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    if abs((x2 - x1) * (y4 - y3) - (x4 - x3) * (y2 - y1)) < 1e-10:
        print("YES")
    else:
        print("NO")
Buggy python submission (verdict: Runtime Error):
paper = [[0 for _ in range(14)] for _ in range(14)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

while True:
    try:
        x, y, s = map(int, input().split())
    except EOFError:
        break
    x += 2
    y += 2
    paper[x][y] += 1
    for i in range(4):
        paper[x + dx[i]][y + dy[i]] += 1
    if s >= 2:
        for i in range(4):
            paper[x + dx[i] + dx[(i + 1) % 4]][y + dy[i] + dy[(i + 1) % 4]] += 1
    if s >= 3:
        for i in range(4):
            paper[x + 2 * dx[i]][y + 2 * dy[i]] += 1

paper = paper[2:12]
for i in range(10):
    paper[i] = paper[i][2:12]
print(sum(paper[i].count(0) for i in range(10)))
print(max(paper[i][j] for i in range(10) for j in range(10)))

Fixed submission:
paper = [[0 for _ in range(10)] for _ in range(10)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def paint(x, y):
    if 0 <= x <= 9 and 0 <= y <= 9:
        paper[x][y] += 1

while True:
    try:
        x, y, s = map(int, input().split(","))
    except EOFError:
        break
    if x == y == s == -1:
        break
    paint(x, y)
    for i in range(4):
        paint(x + dx[i], y + dy[i])
    if s >= 2:
        for i in range(4):
            paint(x + dx[i] + dx[(i + 1) % 4], y + dy[i] + dy[(i + 1) % 4])
    if s >= 3:
        for i in range(4):
            paint(x + 2 * dx[i], y + 2 * dy[i])

print(sum(paper[i].count(0) for i in range(10)))
print(max(paper[i][j] for i in range(10) for j in range(10)))
Buggy python submission (verdict: Runtime Error):
while True:
    n = int(input())
    if n == 0:
        break
    pre = ""
    post = ""
    for _ in range(n):
        l = map(str, input().split())
        pre += l[0]
        post += l[1]
    m = int(input())
    data = ""
    for _ in range(m):
        data += input()
    print(data.translate(str.maketrans(pre, post)))

Fixed submission:
while True:
    n = int(input())
    if n == 0:
        break
    pre = ""
    post = ""
    for _ in range(n):
        l = input().strip().split()
        pre += l[0]
        post += l[1]
    m = int(input())
    data = ""
    for _ in range(m):
        data += input().strip()
    print(data.translate(str.maketrans(pre, post)))
Buggy python submission (verdict: Runtime Error):
def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

x, y = map(int, input().split())
print(gcd(x, y)

Fixed submission:
def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

x, y = map(int, input().split())
print(gcd(x, y))
Buggy python submission (verdict: Runtime Error):
from collections import deque
queue = deque([])
n = int(input())
for _ in range(n):
    command = input()
    if command == "deleteFirst":
        _ = queue.popleft()
    elif command == "deleteLast":
        _ = queue.pop()
    elif "delete" in command:
        queue.remove(command[-1])
    else:
        queue.appendleft(command[-1])
print(" ".join(queue))

Fixed submission:
from collections import deque
queue = deque([])
n = int(input())
for _ in range(n):
    command = input()
    if command == "deleteFirst":
        _ = queue.popleft()
    elif command == "deleteLast":
        _ = queue.pop()
    elif "delete" in command:
        _, x = command.split()
        try:
            queue.remove(x)
        except ValueError:
            pass
    else:
        _, x = command.split()
        queue.appendleft(x)
print(" ".join(queue))

Buggy python submission (verdict: Runtime Error):
from collections import deque
queue = deque([])
n = int(input())
for _ in range(n):
    command = input()
    if command == "deleteFirst":
        _ = queue.popleft()
    elif command == "deleteLast":
        _ = queue.pop()
    elif "delete" in command:
        _, x = command.split()
        queue.remove(x)
    else:
        _, x = command.split()
        queue.appendleft(x)
print(" ".join(queue))

Fixed submission:
from collections import deque
queue = deque([])
n = int(input())
for _ in range(n):
    command = input()
    if command == "deleteFirst":
        _ = queue.popleft()
    elif command == "deleteLast":
        _ = queue.pop()
    elif "delete" in command:
        _, x = command.split()
        try:
            queue.remove(x)
        except ValueError:
            pass
    else:
        _, x = command.split()
        queue.appendleft(x)
print(" ".join(queue))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations as C

n = int(input())
A = list(map(int, input().split()))
q = int(input())
query = list(map(int, input().split()))

def check(m):
    for r in range(1, n + 1):
        for sub in C(A, r):
            if sum(sub) == m:
                return True
    return False

for m in query:
    if check(m):
        print("yes")
    else:
        print("no")

Fixed submission:
from functools import lru_cache

n = int(input())
A = sorted(list(map(int, input().split())))
q = int(input())
query = list(map(int, input().split()))

@lru_cache(maxsize=None)
def solve(i, m):
    if m == 0:
        return True
    elif i >= n or m < A[i]:
        return False
    else:
        return solve(i + 1, m - A[i]) or solve(i + 1, m)

for m in query:
    if solve(0, m):
        print("yes")
    else:
        print("no")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
q = int(input())
query = list(map(int, input().split()))

def solve(i, m):
    if m == 0:
        return True
    elif m < 0 or i >= n:
        return False
    else:
        return solve(i + 1, m) or solve(i + 1, m - A[i])

for m in query:
    if solve(0, m):
        print("yes")
    else:
        print("no")

Fixed submission:
from functools import lru_cache

n = int(input())
A = sorted(list(map(int, input().split())))
q = int(input())
query = list(map(int, input().split()))

@lru_cache(maxsize=None)
def solve(i, m):
    if m == 0:
        return True
    elif i >= n or m < A[i]:
        return False
    else:
        return solve(i + 1, m - A[i]) or solve(i + 1, m)

for m in query:
    if solve(0, m):
        print("yes")
    else:
        print("no")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = sorted(list(map(int, input().split())))
q = int(input())
query = list(map(int, input().split()))

def solve(i, m):
    if m == 0:
        return True
    elif i >= n or m < A[i]:
        return False
    else:
        return solve(i + 1, m) or solve(i + 1, m - A[i])

for m in query:
    if solve(0, m):
        print("yes")
    else:
        print("no")

Fixed submission:
from functools import lru_cache

n = int(input())
A = sorted(list(map(int, input().split())))
q = int(input())
query = list(map(int, input().split()))

@lru_cache(maxsize=None)
def solve(i, m):
    if m == 0:
        return True
    elif i >= n or m < A[i]:
        return False
    else:
        return solve(i + 1, m - A[i]) or solve(i + 1, m)

for m in query:
    if solve(0, m):
        print("yes")
    else:
        print("no")
Buggy python submission (verdict: Time Limit Exceeded):
cnt = 0

def merge(A, l, m, r):
    n1, n2 = m - l, r - m
    L = [A[l + i] for i in range(n1)]
    R = [A[m + i] for i in range(n2)]
    L.append(10 ** 10)
    R.append(10 ** 10)
    i, j = 0, 0
    global cnt
    for k in range(l, r):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, l, r):
    if r - l > 1:
        m = (l + r) // 2
        mergeSort(A, l, m)
        mergeSort(A, m, r)
        merge(A, l, m, r)

n = int(input())
A = list(map(int, input().split()))
mergeSort(A, 0, n)
print(" ".join(list(map(str, A))))
print(cnt)

Fixed submission:
def merge(A, l, m, r):
    L = A[l:m] + [10 ** 9 + 1]
    R = A[m:r] + [10 ** 9 + 1]
    i, j = 0, 0
    for k in range(l, r):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global cnt
    cnt += r - l

def mergeSort(A, l, r):
    if r - l > 1:
        m = (l + r) // 2
        mergeSort(A, l, m)
        mergeSort(A, m, r)
        merge(A, l, m, r)

n = int(input())
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, n)
print(" ".join(list(map(str, A))))
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
def merge(A, l, m, r):
    n1, n2 = m - l, r - m
    L = [A[l + i] for i in range(n1)] + [10 ** 10]
    R = [A[m + i] for i in range(n2)] + [10 ** 10]
    i, j = 0, 0
    for k in range(l, r):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global cnt
    cnt += r - l

def mergeSort(A, l, r):
    if r - l > 1:
        m = (l + r) // 2
        mergeSort(A, l, m)
        mergeSort(A, m, r)
        merge(A, l, m, r)

n = int(input())
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, n)
print(" ".join(list(map(str, A))))
print(cnt)

Fixed submission:
def merge(A, l, m, r):
    L = A[l:m] + [10 ** 9 + 1]
    R = A[m:r] + [10 ** 9 + 1]
    i, j = 0, 0
    for k in range(l, r):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global cnt
    cnt += r - l

def mergeSort(A, l, r):
    if r - l > 1:
        m = (l + r) // 2
        mergeSort(A, l, m)
        mergeSort(A, m, r)
        merge(A, l, m, r)

n = int(input())
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, n)
print(" ".join(list(map(str, A))))
print(cnt)
Buggy python submission (verdict: Runtime Error):
x = input()
print(x ** 3)

Fixed submission:
x = int(input())
print(x ** 3)
Buggy python submission (verdict: Runtime Error):
l = input().split
a, b = list(map(int, l))
print(a * b, 2 * (a + b))

Fixed submission:
l = input().split()
a, b = list(map(int, l))
print(a * b, 2 * (a + b))
Buggy python submission (verdict: Runtime Error):
from math import pi as p

a = int(input())
s = round(p * (a ** 2), 11)
l = round(2 * p * a, 11)
print(s, l)

Fixed submission:
from math import pi

a = float(input())
s = round(pi * (a ** 2), 11)
l = round(2 * pi * a, 11)
print(s, l)

Buggy python submission (verdict: Runtime Error):
from math import pi

a = int(input())
s = round(math.pi * (a ** 2), 11)
l = round(2 * math.pi * a, 11)
print(s, l)

Fixed submission:
from math import pi

a = float(input())
s = round(pi * (a ** 2), 11)
l = round(2 * pi * a, 11)
print(s, l)

Buggy python submission (verdict: Runtime Error):
from math import pi

a = int(input())
s = round(pi * (a ** 2), 11)
l = round(2 * pi * a, 11)
print(s, l)

Fixed submission:
from math import pi

a = float(input())
s = round(pi * (a ** 2), 11)
l = round(2 * pi * a, 11)
print(s, l)
Buggy python submission (verdict: Runtime Error):
dummy = input()
print(' '.join(input().split().reverse()))

Fixed submission:
dummy = input()
print(' '.join(input().split()[::-1]))
Buggy python submission (verdict: Runtime Error):
Suits = ['S', 'H', 'C', 'D']
Taro = []
Missing = []
n = input()
for i in range(n):
    Taro.append(input())
for j in range(52):
    card = Suits[j//13] + ' ' + str(j % 13 + 1)
    if card not in Taro:
        Missing.append(card)
print('\n'.join(Missing))

Fixed submission:
Suits = ['S', 'H', 'C', 'D']
Taro = []
Missing = []
n = int(input())
for i in range(n):
    Taro.append(input())
for j in range(52):
    card = Suits[j//13] + ' ' + str(j % 13 + 1)
    if card not in Taro:
        Missing.append(card)
if Missing != []:
    print('\n'.join(Missing))
Buggy python submission (verdict: Runtime Error):
Residents = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    b, f, r, v = list(map(int, input().split()))
    Residents[b-1][f-1][r-1] += v
for k in range(4):
    for j in range(3):
        print(' '.join(Residents[k][j]))
    if k == 3:
        break
    print('####################')

Fixed submission:
Residents = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    b, f, r, v = list(map(int, input().split()))
    Residents[b-1][f-1][r-1] += v
for k in range(4):
    for j in range(3):
        print(' '+' '.join(map(str, Residents[k][j])))
    if k == 3:
        break
    print('####################')
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m = list(map(int, input().split()))
a = [[0] for i in range(n)]
v = [[0] for j in range(m)]
for i in range(n):
    a[i][:] = list(map(int, input().split()))
for j in range(m):
    v[j][0] = int(input())
A = np.matrix(a)
V = np.matrix(v)
B = A * V
for i in range(n):
    print(B[i][0])

Fixed submission:
n, m = list(map(int, input().split()))
A = []
V = []
B = []
for i in range(n):
    A.append(list(map(int, input().split())))
for j in range(m):
    V.append([int(input())])
for i in range(n):
    B.append([0])
    for j in range(m):
            B[i][0] += A[i][j] * V[j][0]
for i in range(n):
    print(B[i][0])
Buggy python submission (verdict: Runtime Error):
print(swapcase(input()))

Fixed submission:
print(input().swapcase())
Buggy python submission (verdict: Runtime Error):
import sys

Target = ""
for line in sys.stdin.readlines:
    Target += line.rstrip("\r\n")
for i in range(26):
    print(chr(i + 97), ":", Target.count(chr(i + 97)))

Fixed submission:
import sys

Target = ""
for line in sys.stdin:
    Target += line
for i in range(26):
    print(chr(i + 97), ":", Target.lower().count(chr(i + 97)))
Buggy python submission (verdict: Runtime Error):
x = raw_input()
print x ** 2

Fixed submission:
x = int(raw_input())
print x ** 3

Buggy python submission (verdict: Runtime Error):
x = raw_input()
print x ** 3

Fixed submission:
x = int(raw_input())
print x ** 3

Buggy python submission (verdict: Runtime Error):
x = raw_input()
print x ** 3

Fixed submission:
x = int(raw_input())
print x ** 3

Buggy python submission (verdict: Runtime Error):
x = raw_input()
print x ** 3

Fixed submission:
x = int(raw_input())
print x ** 3
Buggy python submission (verdict: Runtime Error):
a,b = raw_input.split.map
print a*b

Fixed submission:
a,b = map(int, raw_input().split())
print a*b, 2*(a+b)
Buggy python submission (verdict: Runtime Error):
while True:
    a, b = map(int, input().split())
    print(len(str(a + b)))

Fixed submission:
import fileinput
for line in fileinput.input():
    a, b = map(int, line.split())
    print(len(str(a + b)))

Buggy python submission (verdict: Runtime Error):
while True:
    a, b = map(int, input().split())
    print(len(str(a + b)))

Fixed submission:
import fileinput
for line in fileinput.input():
    a, b = map(int, line.split())
    print(len(str(a + b)))

Buggy python submission (verdict: Runtime Error):
while 1:
    a, b = map(int, input().split())
    c = a + b
    c = str(c)
    print(len(c))
    

Fixed submission:
import fileinput
for line in fileinput.input():
    a, b = map(int, line.split())
    print(len(str(a + b)))

Buggy python submission (verdict: Runtime Error):
import sys
while 1:
    a, b = map(int, sys.stdin.readline().split())
    c = a + b
    c = str(c)
    print(len(c))

Fixed submission:
import fileinput
for line in fileinput.input():
    a, b = map(int, line.split())
    print(len(str(a + b)))
Buggy python submission (verdict: Runtime Error):
import fileinput
import math
for line in fileinput.input():
    a, b = map(int, line.split())
    gcd = math.gcd(a, b)
    lcm = a * b // gcd
    print(gcd, lcm)

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

import fileinput
import math
for line in fileinput.input():
    a, b = map(int, line.split())
    g = gcd(a, b)
    lcm = a * b // g
    print(g, lcm)

Buggy python submission (verdict: Runtime Error):
import fileinput
import math
for line in fileinput.input():
    if line == "\n":
        break
    else:
        a, b = map(int, line.split())
        g = math.gcd(a, b)
        lcm = a * b // g
        print(g, lcm)

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

import fileinput
import math
for line in fileinput.input():
    a, b = map(int, line.split())
    g = gcd(a, b)
    lcm = a * b // g
    print(g, lcm)
Buggy python submission (verdict: Runtime Error):
import fileinput
for line in fileinput.input():
    a = line.split()
    b = input().split()
    hit = 0
    blow = 0
    for i in range(4):
        for j in range(4):
            if a[i] == b[j]:
                if i == j:
                    hit += 1
                else:
                    blow += 1
    print(hit, blow)

Fixed submission:
import sys
for line in sys.stdin:
    hit = 0
    blow = 0
    if line == "\n":
        break
    A = line.split()
    B = [n for n in input().split()]
    for i in B:
        if i in A:
            if A.index(i) == B.index(i):
                hit += 1
            else:
                blow += 1
    print(hit, blow)

Buggy python submission (verdict: Runtime Error):
import fileinput
for line in fileinput.input():
    a = line.split()
    b = input().split()
    hit = 0
    blow = 0
    for i in range(4):
        for j in range(4):
            if a[i] == b[j]:
                if i == j:
                    hit += 1
                else:
                    blow += 1
    print(hit, blow)

Fixed submission:
import sys
for line in sys.stdin:
    hit = 0
    blow = 0
    if line == "\n":
        break
    A = line.split()
    B = [n for n in input().split()]
    for i in B:
        if i in A:
            if A.index(i) == B.index(i):
                hit += 1
            else:
                blow += 1
    print(hit, blow)
Buggy python submission (verdict: Runtime Error):
week = {"1": "Thursday", "2": "Friday", "3": "Saturday", "4": "Sunday", "5": "Monday", "6": "Tuesday", "7": "Wednesday"}
month = {"1": 0, "2": 31, "3": 60, "4": 91, "5": 121, "6": 152, "7": 182, "8": 213, "9": 244, "10": 274, "11": 305, "12": 335}
m, d = input().split()
while m != "0":
    days = month[m] + int(d)
    print(week[str(days % 7)])
    m, d = input().split()

Fixed submission:
while True:
    m, d = map(int, input().split())
    if m == d == 0:
        break
    dim = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 182, 8: 213, 9: 244, 10: 274, 11: 305, 12: 335}
    ds = dim[m] + d -1
    print({0:'Thursday', 1:'Friday', 2:'Saturday', 3:'Sunday', 4:'Monday', 5:'Tuesday', 6:'Wednesday'}[ds % 7])

Buggy python submission (verdict: Runtime Error):
week = {"1": "Thursday", "2": "Friday", "3": "Saturday", "4": "Sunday", "5": "Monday", "6": "Tuesday", "7": "Wednesday"}
month = {"1": 0, "2": 31, "3": 60, "4": 91, "5": 121, "6": 152, "7": 182, "8": 213, "9": 244, "10": 274, "11": 305, "12": 335}
m, d = input().split()
while m != "0":
    days = month[m] + int(d)
    print(week[str(days % 7)])
    m, d = input().split()

Fixed submission:
while True:
    m, d = map(int, input().split())
    if m == d == 0:
        break
    dim = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 182, 8: 213, 9: 244, 10: 274, 11: 305, 12: 335}
    ds = dim[m] + d -1
    print({0:'Thursday', 1:'Friday', 2:'Saturday', 3:'Sunday', 4:'Monday', 5:'Tuesday', 6:'Wednesday'}[ds % 7])

Buggy python submission (verdict: Runtime Error):
week = {1: "Thursday", 2: "Friday", 3: "Saturday", 4: "Sunday", 5: "Monday", 6: "Tuesday", 7: "Wednesday"}
month = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 182, 8: 213, 9: 244, 10: 274, 11: 305, 12: 335}
m, d = map(int, input().split())
while m:
    days = month[m] + d
    print(week[days % 7])
    m, d = map(int, input().split())

Fixed submission:
while True:
    m, d = map(int, input().split())
    if m == d == 0:
        break
    dim = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 182, 8: 213, 9: 244, 10: 274, 11: 305, 12: 335}
    ds = dim[m] + d -1
    print({0:'Thursday', 1:'Friday', 2:'Saturday', 3:'Sunday', 4:'Monday', 5:'Tuesday', 6:'Wednesday'}[ds % 7])

Buggy python submission (verdict: Runtime Error):
week = {1: "Thursday", 2: "Friday", 3: "Saturday", 4: "Sunday", 5: "Monday", 6: "Tuesday", 7: "Wednesday"}
month = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 182, 8: 213, 9: 244, 10: 274, 11: 305, 12: 335}
while True:
    m, d = map(int, input().split())
    if m == 0:
        break
    days = month[m] + d
    print(week[days % 7])

Fixed submission:
while True:
    m, d = map(int, input().split())
    if m == d == 0:
        break
    dim = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 182, 8: 213, 9: 244, 10: 274, 11: 305, 12: 335}
    ds = dim[m] + d -1
    print({0:'Thursday', 1:'Friday', 2:'Saturday', 3:'Sunday', 4:'Monday', 5:'Tuesday', 6:'Wednesday'}[ds % 7])