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

Fixed submission:
N = int(input())
S = input()
print(S.count('ABC'))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
ctr = 0
for i in range (N):
  if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
    ctr += 1
print(ctr)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ctr = 0
for i in range (N):
  if S(i) == 'A' and S(i+1) == 'B' and S(i+2) == 'C':
    ctr += 1
print(ctr)
Problem p02910 (python)

Fixed submission:
S = input()
A = 'Yes'
for i in range(len(S)):
    if i%2==0 and S[i] == 'L':
        A = 'No'
    elif i%2 == 1 and S[i] == 'R':
        A = 'No'
print(A)

Buggy submission (verdict: Runtime Error):
S = list(input())
for i in range (len(S)):
  if S[2i-2] == 'R' or S[2i-1]  == 'L':
    print('No')
  	quit()
print('Yes')
Problem p02921 (python)

Fixed submission:
S = list(input())
T = list(input())
ctr = 0
for i in range (3):
  if S[i] == T[i]:
    ctr += 1
print(ctr)

Buggy submission (verdict: Runtime Error):
S = list(map(input()))
T = list(map(input()))
ctr = 0
for i in range (3):
  if S[i] == T[i]:
    ctr += 1
print(ctr)
Problem p02982 (python)

Fixed submission:
N,D = map(int,input().split())
P = []
for i in range (N):
    P.append(list(map(int, input().split())))
Pi = 0
for i in range(N):
    for j in range(i+1, N):
        Di = 0
        for k in range (D):
            Di += (P[i][k]-P[j][k])**2
        if int(Di**0.5) == Di**0.5:
            Pi += 1
print(Pi)

Buggy submission (verdict: Runtime Error):
N,D = map(int,input().split())
P = []
for i in range (N):
    P.append(list(map(int, input().split())))
Pi = 0
for i in range(N):
    for j in range(i+1, N):
        Di = 0
        for k in range (D):
            Di += (P[i][k]-P[j][k])**2
        if int(Di**0.5) == dist**0.5:
            Pi += 1
print(Pi)

Buggy submission (verdict: Runtime Error):
N,D = map(int,input().split())
    P = []
    for i in range (N):
        P.append(list(map(int, input().split())))
    Pi = 0
    for i in range(N):
        for j in range(i+1, N):
            Di = 0
            for k in range (D):
                Di += (P[i][k]-P[j][k])**2
            if int(Di**0.5) == dist**0.5:
                Pi += 1
    print(Pi)
Problem p03029 (python)

Fixed submission:
A,P = map(int,input().split())
print((3*A+P)//2)

Buggy submission (verdict: Runtime Error):
A,P = map(int, input().split())
print(((A*3)+P))//2)
Problem p03160 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
L = [0]*N
L[1] = abs(H[1] - H[0])
for i in range (2,N):
  X = L[i-1] + abs(H[i] - H[i-1])
  Y = L[i-2] + abs(H[i] - H[i-2])
  L[i] = min(X,Y)
print(L[N-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
N += 1 ; K += 1
H = list(map(int, input().split()))
L = [0] + [1000000000]*N
for i in range (N):
  for j in range(i+1, min(i+K, N-1)):
    L[j] = min(L[j], L[i] + abs(H[j] - H[i]))
print(L[N-2])
Problem p04033 (python)

Fixed submission:
a,b = map(int, input().split())
if a > 0:
  print("Positive")
elif b<0:
  if((b-a)%2 == 0):
    print("Negative")
  else:
    print("Positive")
else:
  print("Zero")

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
L = []
for i in range (a,b+1):
  L.append(i)
P = 1
for j in L:
  P *= j
if P > 0:
  print('Positive')
elif P = 0:
  print('Zero')
else:
  print('Negetive')
Problem p04047 (python)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
L.sort()
S = 0
for i in range (1, 2*N+1, 2):
  S += L[i-1]
print(S)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))
L.sort()
S = 0
for i in range (0, 2*N+1, 2):
  S += L[i]
print(S)
Problem p02900 (python)

Fixed submission:
import sys

input = sys.stdin.readline


class AtCoder:

    def gcd(self, a, b):
        if b == 0:
            return a
        else:
            return self.gcd(b, a % b)

    def factorize(self, n):
        p = 2
        res = 1
        while p * p < n:
            if n % p == 0:
                res += 1
                while n % p == 0:
                    n /= p
            p += 1
        if n != 1:
            res += 1
        return res

    def main(self):
        A, B = map(int, input().split())

        _gcd = self.gcd(A, B)
        print(self.factorize(_gcd))


# Run main
if __name__ == '__main__':
    AtCoder().main()

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

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B = map(int, input().split())

        gcd = math.gcd(A, B)

        root_gcd = gcd ** 0.5
        p = 2
        prim_num = 1
        while p <= root_gcd or gcd > 1:
            tmp = gcd
            while True:
                if gcd % p == 0:
                    gcd /= p
                else:
                    break
            if tmp != gcd:
                prim_num += 1

            p += 1
        print(prim_num)


# Run main
if __name__ == '__main__':
    AtCoder().main()
Problem p02903 (python)

Fixed submission:
def main():
    h,w,a,b=map(int,input().split())
    Ans=[[0]*w for _ in range(h)]
    for x in range(h):
        for y in range(w):
            Ans[x][y]=int((x<b)^(y<a))
    for ans in Ans:
        print(*ans,sep='')
    return
    
if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
h,w,a,b =map(int,input().split())
for i in range(b):
    print('1'*a+'0'*(w-a))
for i in range(h-b):
    print('0'*a+'1'*(w-a))

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        H, W, A, B = map(int, input().split())

        mergin = 0
        ans = [[0] * W for _ in range(H)]
        cnt_h = 0
        check_1 = [0] * W
        check_0 = [0] * W
        for h in range(H):
            cnt_w = 0
            for w in range(W):
                if w < mergin:
                    check_0[w] += 1
                elif cnt_w < A:
                    ans[h][w] = 1
                    check_1[w] += 1
                    cnt_w += 1
                else:
                    check_0[w] += 1
            cnt_h += 1
            if cnt_h == B:
                mergin += A
                cnt_h = 0

        flag = True
        for w in range(W):
            if min(check_0[w], check_1[w]) != B:
                flag = False
        for h in range(H):
            if min(ans[h].count(0), ans[h].count(1)) != A:
                flag = False
        if flag:
            for h in range(H):
                for w in range(W):
                    print(ans[h][w], end='')
                print()
            exit()

        mergin = 0
        ans = [[0] * W for _ in range(H)]
        cnt_h = 0
        check_1 = [0] * H
        check_0 = [0] * H
        for h in range(W):
            cnt_w = 0
            for w in range(H):
                if w < mergin:
                    check_0[w] += 1
                elif cnt_w < B:
                    ans[h][w] = 1
                    check_1[w] += 1
                    cnt_w += 1
                else:
                    check_0[w] += 1
            cnt_h += 1
            if cnt_h == A:
                mergin += B
                cnt_h = 0

        flag = True
        for w in range(H):
            if min(check_0[w], check_1[w]) != A:
                flag = False
        for h in range(W):
            if min(ans[h].count(0), ans[h].count(1)) != B:
                flag = False
        if flag:
            for h in range(H):
                for w in range(W):
                    print(ans[h][w], end='')
                print()
            exit()


# Run main
if __name__ == '__main__':
    AtCoder().main()
Problem p02918 (python)

Fixed submission:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        S = input().rstrip()

        score = 0
        for i in range(N - 1):
            if S[i] == S[i + 1]:
                score += 1
        print(min(N - 1, score + 2 * K))
            

# Run main
if __name__ == '__main__':
    AtCoder().main()

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

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        S = input().rstrip()

        b = []
        before = S[0]
        cnt = 1
        for i in range(1, N):
            if before == S[i]:
                cnt += 1
                if i == N - 1:
                    b.append(cnt)
            else:
                b.append(cnt)
                cnt = 1
                before = S[i]

        for _ in range(K):
            target = None
            tmp = 0
            if len(b) == 1:
                break
            if len(b) == 2:
                b = [sum(b)]
                break
            for i in range(1, len(b) - 1):
                current = b[i - 1] + b[i] + b[i + 1]
                if current > tmp:
                    tmp = current
                    target = i
            b = b[:target - 1] + [tmp] + b[target + 2:]

        print(sum(b) - len(b))


# Run main
if __name__ == '__main__':
    AtCoder().main()
Problem p02921 (python)

Fixed submission:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()
        T = input().rstrip()

        ans = 0
        for i, s in enumerate(S):
            if s == T[i]:
                ans += 1
        print(ans)


if __name__ == '__main__':
    AtCoder().main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        A = [list(map(int, input().split())) for _ in range(N)]

        already_p = set()
        days = 0
        done = set()
        while True:
            for i, a in enumerate(A):
                if len(a) == 0:
                    done.add(i + 1)
                    continue
                if i + 1 not in already_p:
                    if a[0] not in already_p:
                        if A[a[0] - 1][0] == i + 1:
                            already_p.add(i + 1)
                            already_p.add(a[0])
                            A[a[0] - 1] = A[a[0] - 1][1:]
                            A[i] = a[1:]

            if len(done) == N:
                break

            if len(already_p) == 0:
                print(-1)
                exit()

            already_p = set()
            days += 1

        print(days)


if __name__ == '__main__':
    AtCoder().main()
Problem p02947 (python)

Fixed submission:
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


N = int(input())
s = [input() for i in range(N)]

for i, s_i in enumerate(s):
    s_l = list(s_i)
    s_l.sort()
    a = ""
    for c in s_l:
        a += c
    s[i] = a

cnt = 0
count_dict = {}
for j in range(N):
    count_dict[s[j]] = 0
for k in range(N):
    count_dict[s[k]] += 1

for v in count_dict.values():
    if v >= 2:
        # cnt += int(factorial(v)) / int(factorial(2)) / int(factorial(v - 2))
        cnt += cmb(v, 2)

print(cnt)

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

N = int(input())
s = [input() for i in range(N)]

for i, s_i in enumerate(s):
    s_l = list(s_i)
    s_l.sort()
    a = ""
    for c in s_l:
        a += c
    s[i] = a

cnt = 0
count_dict = {}
for j in range(N):
    count_dict[s[j]] = 0
for k in range(N):
    count_dict[s[k]] += 1

for v in count_dict.values():
    if v >= 2:
        cnt += int(factorial(v)) / int(factorial(2)) / int(factorial(v - 2))

print(int(cnt))

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

N = int(input())
s = [input() for i in range(N)]

for i, s_i in enumerate(s):
    s_l = list(s_i)
    s_l.sort()
    a = ""
    for c in s_l:
        a += c
    s[i] = a

cnt = 0
count_dict = {}
for j in range(N):
    count_dict[s[j]] = 0
for k in range(N):
    count_dict[s[k]] += 1

for v in count_dict.values():
    if v >= 2:
        cnt += int(factorial(v) / factorial(2) / factorial(v - 2))

print(cnt)

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

for i, s_i in enumerate(s):
    s_l = list(s_i)
    s_l.sort()
    a = ""
    for c in s_l:
        a += c
    s[i] = a

cnt = 0
count_dict = {}
for j in range(N):
    count_dict[s[j]] = 0
for k in range(N):
    count_dict[s[k]] += 1

for v in count_dict.values():
    cnt += factorial(v) / factorial(2) / factorial(v - 2)

print(cnt)
Problem p02975 (python)

Fixed submission:
a = [input() for i in range(2)]
 
N = int(a[0])
data = a[1].split(' ')
 
data = [int(i) for i in data]
 
result = []
a = 0
for i in range(N):
    a = a ^ data[i]
    
if a == 0:
    print('Yes')
    exit()
    
print('No')

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
a = list(int(i) for i in input().split())

while True:
    f = False
    for c in itertools.combinations(a, 3):
        if c[0] ^ c[2] == c[1]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[1])
                f = True
        elif c[1] ^ c[2] == c[0]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[0])
                f = True
        elif c[1] ^ c[0] == c[2]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[2])
                f = True
    if f is False:
        print("No")
        exit()

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
a = list(int(i) for i in input().split())

while True:
    for c in itertools.combinations(a, 3):
        if c[0] ^ c[2] == c[1]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[1])
        elif c[1] ^ c[2] == c[0]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[0])
        elif c[0] ^ c[1] == c[2]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[2])
    else:
        print("No")
        exit()

Buggy submission (verdict: Runtime Error):
while True:
    for c in itertools.combinations(a, 3):
        if c[0] ^ c[2] == c[1]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[1])
                break
        elif c[1] ^ c[2] == c[0]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[0])
                break
        elif c[0] ^ c[1] == c[2]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[2])
                break
        else:
            print("No")
            exit()

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
a = list(int(i) for i in input().split())

while True:
    for c in itertools.combinations(a, 3):
        if c[0] ^ c[2] == c[1]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[1])
        elif c[1] ^ c[2] == c[0]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[0])
        elif c[0] ^ c[1] == c[2]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[2])
    print("No")
    exit()
Problem p02995 (python)

Fixed submission:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, D = map(int, input().split())

        def gcd(a, b):
            while b:
                a, b = b, a % b
            return a

        def lcm(a, b):
            return a * b // gcd(a, b)

        def f(x):
            return x - (x // C + x // D - x // lcm(C, D))

        print(f(B) - f(A - 1))


# Run main
if __name__ == '__main__':
    AtCoder().main()

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = (int(i) for i in input().split())

if C == D:
    duplicate = C
elif C > D and C % D == 0:
    duplicate = C
elif D > C and D % C == 0:
    duplicate = D
else:
    duplicate = C * D // math.gcd(C, D)

cCnt = (B - A) // C
dCnt = (B - A) // D
duplicateCnt = (B - A) // duplicate

print(B - A - cCnt - dCnt + duplicateCnt)
Problem p03005 (python)

Fixed submission:
s = input().split()

n = int(s[0])
k = int(s[1])

if k==1 :
    print(0)
else:
    print(n-k)

Buggy submission (verdict: Runtime Error):
s = input().split()

n = s[0]
k = s[1]

if n ==1 :
    print(0)
else:
    print(n-k)

Buggy submission (verdict: Runtime Error):
input = input().split()

n = s[0]
k = s[1]

if n ==1 :
    print(0)
else:
    print(n-k)
Problem p03068 (python)

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

kc = S[K - 1]
ans = ''
for c in S:
  if c != kc:
    ans += '*'
  else:
    ans += c

print(ans)

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

kc = S[K]
ans = ''
for c in S:
  if c != kc:
    ans += '*'
  else:
    ans += c

print(ans)

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

S = list(S)
c = S[K]
for i in range(N):
  if S[i] != c:
    S[i] = '*'

print(str.join('', S))

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

c = S[K]
for i in range(N):
  if S[i] != c:
    S[i] = '*'

print(S)

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

c = S[K]
for i in range(N):
  if S[i] !== c:
    S[i] = '*'

print(S)
Problem p03240 (python)

Fixed submission:
N = int(input())

info = []
for _ in range(N):
    x, y, h = map(int, input().split())
    info.append([h, x, y])

info.sort(reverse=True)

for c_x in range(101):
    for c_y in range(101):
        H = info[0][0] + abs(info[0][1] - c_x) + abs(info[0][2] - c_y)
        flag = True
        for i in range(1, N):
            if info[i][0] != max(H - abs(info[i][1] - c_x) - abs(info[i][2] - c_y), 0):
                flag = False
                break

        if flag:
            print(*[c_x, c_y, H])
            exit()

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

info = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        info.append([h, x, y])

info.sort(reverse=True)

for c_x in range(101):
    for c_y in range(101):
        H = info[0][0] + abs(info[0][1] - c_x) + abs(info[0][2] - c_y)
        flag = True
        for i in range(1, N):
            if info[i][0] != H - abs(info[i][1] - c_x) - abs(info[i][2] - c_y):
                flag = False
                break

        if flag:
            print(*[c_x, c_y, H])
            exit()
Problem p03292 (python)

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

ans = 0
for i in range(1,3):
  ans += A[i] - A[i-1]
print(ans)

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

ans = 0
for i in range(1,3):
  ans += a[i] - a[i-1]
print(ans)
Problem p03624 (python)

Fixed submission:
import string

S = set(list(input()))

for c in string.ascii_lowercase:
  if c not in S:
    print(c)
    exit()

print('None')

Buggy submission (verdict: Runtime Error):
S = set(list(input()))

for c in string.ascii_lowercase:
  if c not in S:
    print(c)
    exit()

print('None')
Problem p03760 (python)

Fixed submission:
O = input()
E = input()

ans = ''
for i in range(len(O) -1):
  ans += O[i] + E[i]

if len(O) - len(E) == 0:
  ans += O[-1] + E[-1]
else:
  ans += O[-1]
  
print(ans)

Buggy submission (verdict: Runtime Error):
O = input()
E = input()

ans = ''
for i in range(len(O) -1):
  ans += O[i] + E(i)

if len(O) - len(E) == 0:
  ans += O[-1] + E[-1]
else:
  ans += O[-1]
  
print(ans)
Problem p03860 (python)

Fixed submission:
contest_name = [word for word in input().split()]
 
print('A' + contest_name[1][0] + 'C')

Buggy submission (verdict: Runtime Error):
contest_name = [word for word in input.split()]
 
print('A' + contest_name[1][0] + 'C')

Buggy submission (verdict: Runtime Error):
contest_name = input.split()

print('A' + contest_name[1][0] + 'C')
Problem p04044 (python)

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]

print(*sorted(S), sep='')

Buggy submission (verdict: Runtime Error):
N, L = input().split()
S = [input() for i in range(N)]

print(*sorted(S), sep='')
Problem p02609 (python)

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


n=int(input())
X=str(input())

number=0
for i in range(n):
    if X[i]=='1':
        number+=1



def culc(x):
    bin_x=str(bin(x)[2:])
    one=0
    for i in range(len(bin_x)):
        if bin_x[i]=='1':
            one+=1
    return x%one
        



#dp[i](0<=i<=number)
dp=[-1]*(number+1)
dp[0]=0
def rec(x):
    if dp[x]>=0:
        return dp[x]
    else:
        dp[x]=rec(culc(x))+1
        return dp[x]



if number==0:
    for i in range(n):
        print(1)
    sys.exit()



base1=0
for i in range(n):
    if X[i]=='1':
        base1=(base1+pow(2,n-i-1,number+1))%(number+1)

if number==1:
    for i in range(n):
        if X[i]=='1':
            print(0)
        else:
            temp=(base1+pow(2,n-i-1,number+1))%(number+1)
            ans=rec(temp)+1
            print(ans)
    sys.exit()



base2=0
for i in range(n):
    if X[i]=='1':
        base2=(base2+pow(2,n-i-1,number-1))%(number-1)






for i in range(n):
    #base1
    if X[i]=='0':
        temp=(base1+pow(2,n-i-1,number+1))%(number+1)
        ans=rec(temp)+1
        print(ans)
    #base2
    if X[i]=='1':
        temp=(base2-pow(2,n-i-1,number-1))%(number-1)
        ans=rec(temp)+1
        print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)


n=int(input())
X=str(input())

number=0
for i in range(n):
    if X[i]=='1':
        number+=1

base1=0
for i in range(n):
    if X[i]=='1':
        base1=(base1+pow(2,n-i-1,number+1))%(number+1)


base2=0
for i in range(n):
    if X[i]=='1':
        base2=(base2+pow(2,n-i-1,number-1))%(number-1)



def culc(x):
    bin_x=str(bin(x)[2:])
    one=0
    for i in range(len(bin_x)):
        if bin_x[i]=='1':
            one+=1
    return x%one
        



#dp[i](0<=i<=number)
dp=[-1]*(number+1)
dp[0]=0
def rec(x):
    if dp[x]>=0:
        return dp[x]
    else:
        dp[x]=rec(culc(x))+1
        return dp[x]





for i in range(n):
    #base1
    if X[i]=='0':
        temp=(base1+pow(2,n-i-1,number+1))%(number+1)
        ans=rec(temp)+1
        print(ans)
    #base2
    if X[i]=='1':
        temp=(base2-pow(2,n-i-1,number-1))%(number-1)
        ans=rec(temp)+1
        print(ans)
Problem p02618 (python)

Fixed submission:
d=int(input())
C=list(map(int,input().split()))
S=[]
for i in range(d):
    S.append(list(map(int,input().split())))


last=[0]*26

for i in range(d):
    s=-1
    for j in range(26):
        temp=S[i][j]+C[j]*(i+1-last[j])
        if temp>s:
            s=temp
            index=j
    last[index]=i+1
    print(index+1)

Buggy submission (verdict: Runtime Error):
d=int(input())
C=list(map(int,input().split()))
S=[]
for i in range(d):
    S.append(list(map(int,input().split())))
T=[]
for i in range(d):
    t=int(input())-1
    T.append(t)


Last=[0]*26

ans=0
for i in range(d):
    t=T[i]
    temp=S[i][t]
    for j in range(26):
        if j==t:
            Last[j]=i+1
        else:
            temp-=C[j]*(i+1-Last[j])
    ans+=temp
    print(ans)