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

Fixed submission:
n,X,m=map(int,input().split())
if m==1:
    print(0)
else:
    x=[0]*m
    y=[0]*m
    y[0]=X
    z=[0]*(m+1)
    z[X]+=1
    for i in range(1,m):
        x[i]=(i**2)%m
    for i in range(1,m):
        y[i]=x[y[i-1]]
        z[y[i]]+=1
        if z[y[i]]==2:
            e=i
            q=y[i]
            break
    for i in range(len(y)):
        if y[i]==q:
            b=i
            break
    l=y[b:e]
    L=len(l)
    s=sum(l)
    #print(x)
    #print(y)
    #print(z)
    #print(b,e)
    #print(l)
    #print(sum(y[:b]))
    #print(((n-b)//L)*s)
    #print(sum(l[:(n-b)%L]))
    if n>=b:
        ans=sum(y[:b])+((n-b)//L)*s+sum(l[:(n-b)%L])
    else:
        ans=sum(y[:n])
    print(ans)

Buggy submission (verdict: Runtime Error):
n,X,m=map(int,input().split())
x=[0]*m
y=[0]*m
y[0]=X
z=[0]*(m+1)
z[X]+=1
for i in range(1,m):
    x[i]=(i**2)%m
for i in range(1,m):
    y[i]=x[y[i-1]]
    z[y[i]]+=1
    if z[y[i]]==2:
        e=i
        q=y[i]
        break
for i in range(len(y)):
    if y[i]==q:
        b=i
        break
l=y[b:e]
L=len(l)
s=sum(l)
#print(x)
#print(y)
#print(z)
#print(b,e)
#print(l)
#print(sum(y[:b]))
#print(((n-b)//L)*s)
#print(sum(l[:(n-b)%L]))
if n>=b:
    ans=sum(y[:b])+((n-b)//L)*s+sum(l[:(n-b)%L])
else:
    ans=sum(y[:n])
if m!=1:
    print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,X,m=map(int,input().split())
x=[0]*m
y=[0]*m
y[0]=X
z=[0]*(m+1)
z[X]+=1
for i in range(1,m):
    x[i]=(i**2)%m
for i in range(1,m+1):
    y[i]=x[y[i-1]]
    z[y[i]]+=1
    if z[y[i]]==2:
        e=i
        q=y[i]
        break
for i in range(len(y)):
    if y[i]==q:
        b=i
        break
l=y[b:e]
L=len(l)
s=sum(l)
#print(x)
#print(y)
#print(z)
#print(b,e)
#print(l)
#print(sum(y[:b]))
#print(((n-b)//L)*s)
#print(sum(l[:(n-b)%L]))
if n>=b:
    ans=sum(y[:b])+((n-b)//L)*s+sum(l[:(n-b)%L])
else:
    ans=sum(y[:n])
print(ans)

Buggy submission (verdict: Runtime Error):
n,X,m=map(int,input().split())
x=[0]*m
y=[0]*m
y[0]=X
z=[0]*(m+1)
z[X]+=1
for i in range(1,m):
    x[i]=(i**2)%m
for i in range(1,m+1):
    y[i]=x[y[i-1]]
    z[y[i]]+=1
    if z[y[i]]==2:
        e=i
        q=y[i]
        break
for i in range(len(y)):
    if y[i]==q:
        b=i
        break
l=y[b:e]
L=len(l)
s=sum(l)
#print(x)
#print(y)
#print(z)
#print(b,e)
#print(l)
#print(sum(y[:b]))
#print(((n-b)//L)*s)
#print(sum(l[:(n-b)%L]))
ans=sum(y[:b])+((n-b)//L)*s+sum(l[:(n-b)%L])
if n==1:
    print(X)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,X,m=map(int,input().split())
x=[0]*m
y=[0]*m
y[0]=X
z=[0]*(m+1)
z[X]+=1
for i in range(1,m):
    x[i]=(i**2)%m
for i in range(1,m+1):
    y[i]=x[y[i-1]]
    z[y[i]]+=1
    if z[y[i]]==2:
        e=i
        q=y[i]
        break
for i in range(len(y)):
    if y[i]==q:
        b=i
        break
l=y[b:e]
L=len(l)
s=sum(l)
#print(x)
#print(y)
#print(z)
#print(b,e)
#print(l)
#print(sum(y[:b]))
#print(((n-b)//L)*s)
#print(sum(l[:(n-b)%L]))
ans=sum(y[:b])+((n-b)//L)*s+sum(l[:(n-b)%L])
print(ans)
Problem p03221 (python)

Fixed submission:
n,m=map(int,input().split())
x=[]
y=[]
for i in range(m):
    a,b=map(int,input().split())
    x.append([a,b,i])
x.sort()
s=1
for i in range(m):
    c=x[i][0]
    a=6-len(str(x[i][0]))
    b=["0"]*a
    for j in range(len(str(x[i][0]))):
        b.append(str(x[i][0])[j])
    x[i][0]="".join(b)
    a=6-len(str(s))
    b=["0"]*a
    for j in range(len(str(s))):
        b.append(str(s)[j])
    x[i].append("".join(b))
    if i<m-1:
        if c==x[i+1][0]:
            s+=1
        else:
            s=1
for i in range(m):
    y.append([x[i][2],x[i][0],x[i][3]])
y.sort()
for i in range(m):
    print(y[i][1]+y[i][2])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[]
y=[]
for i in range(m):
    a,b=map(int,input().split())
    x.append([a,b,i])
x.sort()
s=1
for i in range(m):
    c=x[i][0]
    if len(str(x[i][0]))<6:
        a=6-len(str(x[i][0]))
        b=["0"]*a
        for j in range(len(str(x[i][0]))):
            b.append(str(x[i][0])[j])
        x[i][0]="".join(b)
    if len(str(s))<6:
        a=6-len(str(s))
        b=["0"]*a
        for j in range(len(str(s))):
            b.append(str(s)[j])
        x[i].append("".join(b))
    if i<m-1:
        if c==x[i+1][0]:
            s+=1
        else:
            s=1
for i in range(m):
    y.append([x[i][2],x[i][0],x[i][3]])
y.sort()
for i in range(m):
    print(y[i][1]+y[i][2])
Problem p02546 (python)

Fixed submission:
s = input()
if s[-1] == "s":
    print(s+"es")
else:
    print(s+"s")

Buggy submission (verdict: Runtime Error):
n, x, m = map(int, input().split())
a = [x]
if n == 1:
    print(x)
    exit()
for i in range(n-1):
    ad = (a[-1]**2) % m
    if ad in a:
        roop_s = a.index(ad)
        roop_e = len(a)
        break
    else:
        a.append(ad)
    if i == n-2:
        print(sum(a))
        exit()
roop_t = (n-roop_s) // (roop_e - roop_s)
left = n - roop_t*(roop_e - roop_s) - roop_s
ans = sum(a[:roop_s]) + roop_t*sum(a[roop_s : roop_e]) + sum(a[roop_s:roop_s+left])
print(ans)
Problem p02550 (python)

Fixed submission:
n, x, m = map(int, input().split())
a = [x]
if n == 1:
    print(x)
    exit()
for i in range(n-1):
    ad = (a[-1]**2) % m
    if ad in a:
        roop_s = a.index(ad)
        roop_e = len(a)
        break
    else:
        a.append(ad)
    if i == n-2:
        print(sum(a))
        exit()
roop_t = (n-roop_s) // (roop_e - roop_s)
left = n - roop_t*(roop_e - roop_s) - roop_s
ans = sum(a[:roop_s]) + roop_t*sum(a[roop_s : roop_e]) + sum(a[roop_s:roop_s+left])
print(ans)

Buggy submission (verdict: Runtime Error):
n, x, m = map(int, input().split())
a = [x]
for i in range(n-1):
    ad = (a[-1]**2) % m
    if ad in a:
        roop_s = a.index(ad)
        roop_e = len(a)
        break
    else:
        a.append(ad)
    if i == n-2:
        print(sum(a))
        exit()
roop_t = (n-roop_s) // (roop_e - roop_s)
left = n - roop_t*(roop_e - roop_s) - roop_s
ans = sum(a[:roop_s]) + roop_t*sum(a[roop_s : roop_e]) + sum(a[roop_s:roop_s+left])
print(ans)
Problem p02735 (python)

Fixed submission:
h, w = map(int, input().split())
hw = [input() for _ in range(h)]
dp = [[1000]*w for _ in range(h)]
if hw[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(h):
    for j in range(w):
        if i > 0:
            if hw[i][j] == "#" and hw[i-1][j] == ".":
                dp[i][j] = min(dp[i][j], dp[i-1][j] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i-1][j])
        if j > 0:
            if hw[i][j] == "#" and hw[i][j-1] == ".":
                dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i][j-1])

print(dp[h-1][w-1])

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
hw = [input() for _ in range(h)]
dp = [[1000]*w for _ in range(h)]
if hw[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(w):
    for j in range(h):
        if i > 0:
            if hw[i][j] == "#" and hw[i-1][j] == ".":
                dp[i][j] = min(dp[i][j], dp[i-1][j] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i-1][j])
        if j > 0:
            if hw[i][j] == "#" and hw[i][j-1] == ".":
                dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i][j-1])

print(dp[h-1][w-1])

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
hw = [input() for _ in range(h)]
dp = [[1000]*w for _ in range(h)]
if hw[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(w):
    for j in range(h):
        if i > 0:
            if hw[i][j] == "#" and hw[i-1][j] == ".":
                dp[i][j] = min(dp[i][j], dp[i-1][j] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i-1][j])
        if j > 0:
            if hw[i][j] == "#" and hw[i][j-1] == ".":
                dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i][j-1])

print(dp[h-1][w-1])
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
dp = [0] * n
for i in a:
    dp[i-1] = -1
if n == 1:
    if dp[0] == 0:
        print(1)
        exit()
    elif dp[0] == -1:
        print(0)
        exit()
if dp[1] >= 0 and dp[0] >= 0:
    dp[0] = 1
    dp[1] = 2
elif dp[1] == -1 and dp[0] >= 0:
    dp[0] = 1
elif dp[1] >= 0 and dp[0] == -1:
    dp[1] = 1
else:
    print(0)
    exit()
for j in range(2, n):
    if dp[j] >= 0:
        if dp[j-1] >= 0 and dp[j-2] >= 0:
            dp[j] = dp[j-1] + dp[j-2]
        elif dp[j-1] == -1 and dp[j-2] >= 0:
            dp[j] = dp[j-2]
        elif dp[j-1] >= 0 and dp[j-2] == -1:
            dp[j] = dp[j-1]
        else:
            print(0)
            exit()
print(dp[n-1] % (10**9+7))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
dp = [0] * n
for i in a:
    dp[i-1] = -1
if dp[1] >= 0 and dp[0] >= 0:
    dp[0] = 1
    dp[1] = 2
elif dp[1] == -1 and dp[0] >= 0:
    dp[0] = 1
elif dp[1] >= 0 and dp[0] == -1:
    dp[1] = 1
else:
    print(0)
    exit()
for j in range(2, n):
    if dp[j] >= 0:
        if dp[j-1] >= 0 and dp[j-2] >= 0:
            dp[j] = dp[j-1] + dp[j-2]
        elif dp[j-1] == -1 and dp[j-2] >= 0:
            dp[j] = dp[j-2]
        elif dp[j-1] >= 0 and dp[j-2] == -1:
            dp[j] = dp[j-1]
        else:
            print(0)
            exit()
print(dp[n-1] % (10**9+7))
Problem p02629 (python)

Fixed submission:
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
N=int(input())
print(num2alpha(N).lower())

Buggy submission (verdict: Runtime Error):
def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC=[]
for i in range(Q):
    BC.append(list(map(int,input().split())))
for i in BC:
    if i[0] in A:
        indexlist=my_index_multi(A,i[0])
        for j in indexlist:
            A[j]=i[1]
    print(sum(A))

Buggy submission (verdict: Runtime Error):
def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC=[]
for i in range(Q):
    BC.append(list(map(int,input().split())))
for i in BC:
    if i[0] in A:
        indexlist=my_index_multi(A,i[0])
        for j in indexlist:
            A[j]=i[1]
    print(sum(A))
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):
N,M,K=map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sum_A=0
sum_B=0
for i in range(min(N,M)):
    sum_A +=A[i]
    sum_B +=B[i]
    if sum_A>K:
        del A[i:]
    if sum_B>K:
        del B[i:]
    if sum_A>K and sum_A>K:
        break
while sum(A)+sum(B)>K:
    if A[-1]>B[-1]:
        del A[-1]
    elif A[-1]<B[-1]:
        del B[-1]
    elif A[-1] == B[-1]:
        del A[-1]
        del B[-1]
        if sum(A)+sum(B)<=K:
            A.append(1)
print(len(A)+len(B))
Problem p02578 (python)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
ma = 0
ans = 0
for i in a:
    ma = max(ma, i)
    ans += (ma - i)
print(ans)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t, n, ma = -1;
    ll ans = 0;
    cin >> n;
    while(n--){
        cin >> t;
        ma = max(ma, t);
        ans += (ma - t);
    }
    cout << ans;
    return 0;
}
Problem p02549 (python)

Fixed submission:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod = 998244353
INF = 10**18
eps = 10**-7

n,k = map(int,readline().split())
LR = [list(map(int,readline().split())) for i in range(k)]



dp = [0]*(2*n+10)

imos = [0]*(2*n+10)
dp[1] = 1
for i in range(1,n+1):
    imos[i] = (imos[i-1]+imos[i])%mod
    dp[i] = (dp[i]+imos[i])%mod
    for (l,r) in LR:
        imos[i+l] += dp[i]
        imos[i+r+1] -= dp[i]

print(dp[n])

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod = 998244353
INF = 10**18
eps = 10**-7

n,k = map(int,readline().split())
LR = [list(map(int,readline().split())) for i in range(k)]



dp = [0]*(2*n+1)

imos = [0]*(2*n+1)
dp[1] = 1
for i in range(1,n+1):
    imos[i] = (imos[i-1]+imos[i])%mod
    dp[i] = (dp[i]+imos[i])%mod
    for (l,r) in LR:
        imos[i+l] += dp[i]
        imos[i+r+1] -= dp[i]

print(dp[n])
Problem p02550 (python)

Fixed submission:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod = 998244353
INF = 10**18
eps = 10**-7

n,x,m = map(int,readline().split())

if n == 1:
    print(x)
    exit()

if n < 10**7:
    a = [0]*n
    a[0] = x
    for i in range(n-1):
        a[i+1] = a[i]**2%m
    print(sum(a))
    exit()



a = [0]*(m+10)
a[0] = x

for i in range(m+5):
    a[i+1] = a[i]**2%m

idx = [-1]*m

for i in range(m+5):
    if (idx[a[i]] == -1):
        idx[a[i]] = i
    else:
        idxx = idx[a[i]]
        now = i
        break

d = sum(a[idxx:now])
l = now-idxx
ans = sum(a[:idxx])
n -= idxx
ans += d*(n//l)
n = n%l
ans += sum(a[idxx:idxx+n])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod = 998244353
INF = 10**18
eps = 10**-7

n,x,m = map(int,readline().split())

if n == 1:
    print(x)
    exit()

if n < 10**7:
    a = [0]*n
    a[0] = x
    for i in range(n-1):
        a[i+1] = a[i]**2%m
    print(sum(a))
    exit()

a = [0]*m
a[0] = x

for i in range(m-1):
    a[i+1] = a[i]**2%m

idx = [-1]*m

for i in range(m):
    if (idx[a[i]] == -1):
        idx[a[i]] = i
    else:
        idxx = idx[a[i]]
        now = i
        break

d = sum(a[idxx:now])
l = now-idxx
ans = sum(a[:idxx])
n -= idxx
ans += d*(n//l)
n = n%l
ans += sum(a[idxx:idxx+n])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod = 998244353
INF = 10**18
eps = 10**-7

n,x,m = map(int,readline().split())

if n < 10**7:
    a = [0]*n
    a[0] = x
    for i in range(n-1):
        a[i+1] = a[i]**2%m
    print(sum(a))
    exit()

a = [0]*m
a[0] = x

for i in range(m-1):
    a[i+1] = a[i]**2%m

idx = [-1]*m

for i in range(m):
    if (idx[a[i]] == -1):
        idx[a[i]] = i
    else:
        idxx = idx[a[i]]
        now = i
        break

d = sum(a[idxx:now])
l = now-idxx
ans = sum(a[:idxx])
n -= idxx
ans += d*(n//l)
n = n%l
ans += sum(a[idxx:idxx+n])
print(ans)
Problem p02725 (python)

Fixed submission:
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = a[0] + k - a[-1]
for i in range(n-1):
  ans = max(ans, a[i+1]-a[i])
print(k-ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = a[0] + k - a[-1]
for i in range(n-1):
  ans = max(ans, a[i+1]-a[i])
print(k-ans)
Problem p02769 (python)

Fixed submission:
def modinv(a,m):
    return pow(a,m-2,m)


n,k = map(int,input().split())
P = 10**9+7



if n-1 <= k:
    N = n + min(n-1,k)
    ans = 1
    for i in range(1,n):
        ans = ans*(N+1-i)*modinv(i,P)%P

else:
    ans = 1
    nCl = 1
    n1Cl = 1
    for l in range(1,k+1):
        nCl = nCl*(n+1-l)*modinv(l,P)%P
        n1Cl = n1Cl*(n-l)*modinv(l,P)%P
        ans = (ans+nCl*n1Cl)%P

print(ans)

Buggy submission (verdict: Runtime Error):
def modinv(a,m):
    return pow(a,m-2,m)


n,k = map(int,input().split())
P = 10**9+7

if n-1 <= k:

    ans = 1
    for i in range(1,n):
        ans = ans*(N+1-i)*modinv(i,P)%P

else:
    ans = 0
    nCl = 1
    n1Cl = 1
    for l in range(1,k+1):
        nCl = nCl*(n+1-l)*modinv(l,P)%P
        n1Cl = n1Cl*(n-l)*modinv(l,P)%P
        ans = (ans+nCl*n1Cl)%P

print((ans+1)%P)

Buggy submission (verdict: Runtime Error):
def modinv(a,m):
    return pow(a,m-2,m)


n,k = map(int,input().split())
P = 10**9+7

if n-1 <= k:

    ans = 1
    for i in range(1,n):
        ans = ans*(N+1-i)*modinv(i,P)%P

else:
    ans = 0
    nCl = 1
    n1Cl = 1
    for l in range(1,k+1):
        nCl = nCl*(n+1-l)*modinv(l,P)%P
        n1Cl = n1Cl*(n-l)*modinv(l,P)%P
        ans = (ans+nCl*n1Cl)%P

print((ans+1)%P)
Problem p02793 (python)

Fixed submission:
#a,bの最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

#べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い)
def modinv2(a,m):
    return pow(a,m-2,m)


N = int(input())
A = list(map(int,input().split()))
P = 10**9+7

if N == 1:
    ans = 1

else:

    A.sort()

    inv = modinv2(A[0],P)
    g = A[0]
    invlist = []
    seki = A[0]%P

    for i in range(1,N):
        inv = (inv+modinv2(A[i],P))%P
        seki = seki*A[i]%P

    g = gcd(A[0],A[1])
    l = A[0]//g*A[1]
    cc = modinv2(g,P)
    for i in range(2,N):
        g = gcd(l,A[i])
        l = l//g*A[i]
        cc = cc*modinv2(g,P)%P

    ans = (inv*seki%P)*cc%P

print(ans)

Buggy submission (verdict: Runtime Error):
#a,bの最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

#べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い)
def modinv2(a,m):
    return pow(a,m-2,m)


N = int(input())
A = list(map(int,input().split()))
P = 10**9+7

A.sort()

inv = modinv2(A[0],P)
g = A[0]
invlist = []
seki = A[0]%P

for i in range(1,N):
    inv = (inv+modinv2(A[i],P))%P
    seki = seki*A[i]%P

g = gcd(A[0],A[1])
l = A[0]//g*A[1]
cc = modinv2(g,P)
for i in range(2,N):
    g = gcd(l,A[i])
    l = l//g*A[i]
    cc = cc*modinv2(g,P)%P

ans = (inv*seki%P)*cc%P

print(ans)
Problem p02847 (python)

Fixed submission:
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
S = input()
if S == 'SUN':
    print(7)
elif S = 'MON':
    print(6)
elif S = 'TUE':
    print(5)
elif S = 'WED':
    print(4)
elif S = 'THU':
    print(3)
elif S = 'FRI':
    print(2)
else:
    print(1)
Problem p02879 (python)

Fixed submission:
A,B=map(int,input().split())
if 1<=A<=9 and 1<=B<=9:
    print(A*B)
else:
    print(-1)

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    int a,b; cin >> a >> b;
    if (a >= 10 || b >= 10) cout << -1 << endl;
    else cout << a*b << endl;
    return 0;
}
Problem p02897 (python)

Fixed submission:
N=int(input())

if N%2==0:
  print(1/2)

else:
  print((N+1)/(2*N))

Buggy submission (verdict: Runtime Error):
N=int(input())
 
li=list(map(int,input().split()))
 
ans=sorted(range(N), key=lambda a: li[a])
 
for n in range(N):
  ans[n]+=1
      
print(*ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
 
li=list(map(int,input().split()))
 
ans=sorted(range(N), key=lambda k: li[k])
 
for n in range(N):
  ans[n]+=1
      
print(*ans)

Buggy submission (verdict: Runtime Error):
N=int(input())

if N%2==0:
  print(1/2)

else:
  print((n+1)/(2*n))
Problem p03326 (python)

Fixed submission:
n,m = map(int,input().split())
xyz = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(8):
    s = []
    for j in range(n):
        a = 0
        for k in range(3):
            if i>>k&1:
                a += xyz[j][k]
            else:
                a -= xyz[j][k]
        s.append(a)
    s.sort()
    ans = max(ans,sum(s[n-m:]))
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
xyz = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(8):
    s = [0 for i in range(n)]
    for j in range(n):
        a = 0
        for k in range(3):
            if i>>k&1:
                a += xyz[j][k]
            else:
                a -= xyz[j][k]
        s[i] = a
    s.sort()
    ans = max(ans,sum(s[n-m:]))
print(ans)
Problem p03634 (python)

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

N = int(input())

vertex = [{} for _ in range(N)]

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

Q,K = map(int,input().split())

d = [0 for i in range(N)]

def dfs(v1,v2):
    d[v2] = d[v1] + vertex[v1][v2]
    for v in vertex[v2]:
        if v == v1:
            continue
        dfs(v2,v)

for v in vertex[K-1].keys():
    dfs(K-1,v)

for q in range(Q):
    x,y = map(int,input().split())
    print(d[x-1] + d[y-1])

Buggy submission (verdict: Runtime Error):
N = int(input())

vertex = [{} for _ in range(N)]

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

Q,K = map(int,input().split())

d = [0 for i in range(N)]

def dfs(v1,v2):
    d[v2] = d[v1] + vertex[v1][v2]
    for v in vertex[v2]:
        if v == v1:
            continue
        dfs(v2,v)

for v in vertex[K-1].keys():
    dfs(K-1,v)

for q in range(Q):
    x,y = map(int,input().split())
    print(d[x-1] + d[y-1])
Problem p03705 (python)

Fixed submission:
N,A,B=map(int,input().split())
if A==B:
  print(1)
else:
  if N==1:
    print(0)
  else:
    if A<B:
      print((N-2)*(B-A)+1)
    else:
      print(0)

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
if A==B:
  print(1)
else:
  if N==1:
    ptint(0)
  else:
    if A<B:
      print((N-2)*(B-A)+1)
    else:
      print(0)
Problem p03774 (python)

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

student=[list(map(int,input().split())) for n in range(N)]

check=[list(map(int,input().split())) for m in range(M)]

for n in range(N):
  man=400000001
  for m in range(M):
    dis=abs(student[n][0]-check[m][0])+abs(student[n][1]-check[m][1])
    point=m+1
    if dis<man:
      man=dis
      ans=point
  print(ans)

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

student=[list(map(int,input().split())) for n in range(N)]

check=[list(map(int,input().split())) for m in range(M)]

for n in range(N):
  man=200000001
  for m in range(M):
    dis=abs(student[n][0]-check[m][0])+abs(student[n][1]-check[m][1])
    point=m+1
    if dis<man:
      man=dis
      ans=point
  print(ans)

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

student=[list(map(int,input().split())) for n in range(N)]

check=[list(map(int,input().split())) for m in range(M)]

for n in range(N):
  man=100000001
  for m in range(M):
    dis=abs(student[n][0]-check[m][0])+abs(student[n][1]-check[m][1])
    point=m+1
    if dis<man:
      man=dis
      ans=point
  print(ans)
Problem p03834 (python)

Fixed submission:
s=input().split(',')
print(s[0],s[1],s[2])

Buggy submission (verdict: Runtime Error):
s=input().split(,)
print(s[0],s[1],s[2])