Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

class Dice:
    def __init__(self, men):
        self.men = men

    def throw(self, direction):
        if direction == "E":
            pmen = men[:]
            men[0] = pmen[3]
            men[1] = pmen[1]
            men[2] = pmen[0]
            men[3] = pmen[5]
            men[4] = pmen[4]
            men[5] = pmen[2]
        elif direction == "W":
            pmen = men[:]
            men[0] = pmen[2]
            men[1] = pmen[1]
            men[2] = pmen[5]
            men[3] = pmen[0]
            men[4] = pmen[4]
            men[5] = pmen[3]
        elif direction == "S":
            pmen = men[:]
            men[0] = pmen[4]
            men[1] = pmen[0]
            men[2] = pmen[2]
            men[3] = pmen[3]
            men[4] = pmen[5]
            men[5] = pmen[1]
        elif direction == "N":
            pmen = men[:]
            men[0] = pmen[1]
            men[1] = pmen[5]
            men[2] = pmen[2]
            men[3] = pmen[3]
            men[4] = pmen[0]
            men[5] = pmen[4]


    def printUe(self):
        print (self.men)[0]

    def printMigi(self):
        print (self.men)[2]

    def printMen(self):
        print self.men


men = map(int, (raw_input()).split(" "))
d = Dice(men)

q = int(raw_input())

for i in range(q):
    Q = map(int, (raw_input()).split(" "))
    print Q
    if(d.men[2] == Q[1] or d.men[3] == Q[1]):
        while(d.men[1] != Q[1]):
            d.throw("E")
    else:
        while(d.men[1] != Q[1]):
            d.throw("S")

    while(d.men[0] != Q[0]):
        d.throw("E")

    d.printMigi()

### FIXED CODE ###

class Dice:
    def __init__(self, men):
        self.men = men

    def throw(self, direction):
        if direction == "E":
            pmen = men[:]
            men[0] = pmen[3]
            men[1] = pmen[1]
            men[2] = pmen[0]
            men[3] = pmen[5]
            men[4] = pmen[4]
            men[5] = pmen[2]
        elif direction == "W":
            pmen = men[:]
            men[0] = pmen[2]
            men[1] = pmen[1]
            men[2] = pmen[5]
            men[3] = pmen[0]
            men[4] = pmen[4]
            men[5] = pmen[3]
        elif direction == "S":
            pmen = men[:]
            men[0] = pmen[4]
            men[1] = pmen[0]
            men[2] = pmen[2]
            men[3] = pmen[3]
            men[4] = pmen[5]
            men[5] = pmen[1]
        elif direction == "N":
            pmen = men[:]
            men[0] = pmen[1]
            men[1] = pmen[5]
            men[2] = pmen[2]
            men[3] = pmen[3]
            men[4] = pmen[0]
            men[5] = pmen[4]


    def printUe(self):
        print (self.men)[0]

    def printMigi(self):
        print (self.men)[2]

    def printMen(self):
        print self.men


men = map(int, (raw_input()).split(" "))
d = Dice(men)

q = int(raw_input())

for i in range(q):
    Q = map(int, (raw_input()).split(" "))
    if(d.men[2] == Q[1] or d.men[3] == Q[1]):
        d.throw("E")

    while(d.men[1] != Q[1]):
        d.throw("S")

    while(d.men[0] != Q[0]):
        d.throw("E")

    d.printMigi()
### BUGGY CODE ###


from fractions import gcd
from functools import reduce

def main():
    lcm = lambda a, b: a * b // gcd(a, b)
    mod = 10 ** 9 + 7

    N, *A = map(int, open(0).read().split())

    L = reduce(lcm, A)

    ans = 0
    for a in A:
        ans = (ans + L // a) % mod

    print(ans)

main()

### FIXED CODE ###

from fractions import gcd
from functools import reduce

def main():
    lcm = lambda a, b: a * b // gcd(a, b)
    mod = 10 ** 9 + 7

    N, *A = map(int, open(0).read().split())

    L = reduce(lcm, A)
    print(sum(L // a for a in A) % mod)

main()
### BUGGY CODE ###

def main():
    s = list(input())
    s = s[::-1]

    l = [[] for i in range(673)]
    l[0].append(0)
    ten = 1
    mod = 673
    now = 0
    for i in range(len(s)):
        now = (now+int(s[i])*ten)%mod
        l[now].append(i+1)
        ten *= 10
        ten %= mod
    ans = 0
    for i in l:
        if len(i) >= 2:
            for j in range(len(i)-1):
                for k in range(j+1,len(i)):
                    a = sum(list(map(int,s[i[j]:i[k]])))
                    if a %3 == 0:
                        ans += 1
    print(ans)
if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    s = list(input())
    s = s[::-1]

    l = [[[] for j in range(3)] for i in range(673)]
    l[0][0].append(0)
    mo = 0
    ten = 1
    mod = 673
    now = 0
    ans = 0
    for i in range(len(s)):
        a = int(s[i])*ten
        mo = (mo+a)%3
        now = (now+a)%mod
        if l[now][mo]:
            ans += len(l[now][mo])
        l[now][mo].append(i+1)
        ten *= 10
        ten %= 2019
    print(ans)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###


from collections import deque
def resolve():
    drc4 = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + drc4]

    H, W = map(int, input().split())
    sy, sx = map(lambda x: int(x) - 1, input().split())
    gy, gx = map(lambda x: int(x) - 1, input().split())
    G = [input() for _ in range(H)]

    INF = 10 ** 12
    ans = [[INF] * W for _ in range(H)]

    q = deque()
    q.append((sy, sx, 0))
    ans[sy][sx] = 0

    while q:
        sy, sx, cost = q.popleft()
        for dy, dx in drc4:
            ny, nx = dy + sy, dx + sx
            if 0 <= ny < H and 0 <= nx < W and G[ny][nx] == "." and ans[ny][nx] > cost:
                ans[ny][nx] = cost
                q.append((ny, nx, cost))

        for dy8, dx8 in warp:
            ny8, nx8 = dy8 + sy, dx8 + sx
            if 0 <= ny8 < H and 0 <= nx8 < W and G[ny8][nx8] == "." and ans[ny8][nx8] > cost + 1:
                ans[ny8][nx8] = cost + 1
                q.append((ny8, nx8, cost + 1))

    res = ans[gy][gx] if ans[gy][gx] < INF else -1
    print(res)


if __name__ == "__main__":
    resolve()

### FIXED CODE ###


from collections import deque
def resolve():
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    maze = [input() for _ in range(H)]

    INF = 10 ** 12
    path = [[INF] * W for _ in range(H)]

    q = deque()
    path[Ch][Cw] = 0
    q.append((Ch, Cw, 0))

    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    while q:
        x, y, s = q.popleft()
        for dx, dy in walk:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
                path[nx][ny] = s
                q.appendleft((nx, ny, s))
        for dx, dy in warp:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
                path[nx][ny] = s + 1
                q.append((nx, ny, s + 1))

    ans = path[Dh][Dw] if path[Dh][Dw] < INF else -1
    print(ans)


if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

n=int(input())
S=str(input())
r=S.count('R')
g=S.count('G')
b=S.count('B')
cnt=r*g*b
for i in range(n):
    for a in range(1,n):
        j=i+a
        k=j+a
        if k<n:
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                cnt-=1
        elif k==n-1:
            break
print(cnt)

### FIXED CODE ###

n=int(input())
S=str(input())
r=S.count('R')
g=S.count('G')
b=S.count('B')
cnt=r*g*b
for i in range(n):
    for a in range(1,n):
        j=i+a
        k=j+a
        if k>=n:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            cnt-=1

print(cnt)
### BUGGY CODE ###

from collections import Counter

n, m = map(int, input().split())
a = Counter(list(map(int, input().split())))

for i in range(m):
    b, c = map(int, input().split())
    for value in sorted(list(a.keys())):
        if value >= c:
            break
        if a[value] > 0:
            if a[value] >= b:
                a[value] -= b
                a[c] += b
                b = 0
            else:
                b -= a[value]
                a[c] += a[value]
                a[value] = 0
        if a[value] == 0:
            del a[value]
        if b == 0:
            break
    
ans = 0
for i in a.keys():
    ans += i * a[i]
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
cb = []
for i in range(m):
    b, c = map(int, input().split())
    cb.append([c, b])
cb.sort(reverse=True)

now = 0
for i in range(n):
    if a[i] < cb[now][0] and cb[now][1] > 0:
        a[i] = cb[now][0]
        cb[now][1] -= 1
    if cb[now][1] == 0:
        now += 1
    if now >= len(cb):
        break
print(sum(a))
### BUGGY CODE ###

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    s = sum(a)
    cand = [s]
    for i in range(2, int(s ** 0.5) + 1):
        if s % i == 0:
            cand.append(i)
            cand.append(s // i)
    cand.sort(reverse=True)

    for c in cand:
        arr = [[a[i] % c, a[i] % c - c] for i in range(n)]
        min_sum = sum([ai[1] for ai in arr])
        if (0 - min_sum) // c <= n:
            for i in range(1 << n):
                tmp = [0] * 2
                for j in range(n):
                    if i & (1 << j):
                        tmp[0] += arr[j][0]
                    else:
                        tmp[1] += arr[j][1]
                if sum(tmp) == 0 and tmp[0] <= k:
                    print(c)
                    exit()
    print(1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


### FIXED CODE ###

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    s = sum(a)
    cand = [s]
    for i in range(2, int(s ** 0.5) + 1):
        if s % i == 0:
            cand.append(i)
            cand.append(s // i)
    cand.sort(reverse=True)

    for c in cand:
        arr = [a[i] % c for i in range(n)]
        arr.sort()
        sum_r = [0] * n
        sum_r[0] = arr[0]
        for i in range(1, n):
            sum_r[i] = sum_r[i - 1] + arr[i]
        for i in range(n - 1):
            if sum_r[i] <= k:
                sum_l = c * (n - i - 1) - sum_r[-1] + sum_r[i]
                if sum_r[i] == sum_l:
                    print(c)
                    exit()

    print(1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline
from numba import njit
import numpy as np
INF = 10**18

@njit
def solve(N, costX, costY):
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = np.minimum(cx, cy).sum()
        ans[M] = min(ans[M], cost)

    return ans

def sol():
    N = int(input())
    XYP = [tuple(map(int, input().split())) for _ in range(N)]
    XYP.sort(key=lambda xyp: xyp[2], reverse=False)

    X = [x for x, _, _ in XYP]
    Y = [y for _, y, _ in XYP]

    def calcCost(AP, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i, (a, p) in enumerate(AP):
                cost = abs(a)
                for z in useA:
                    cost = min(cost, abs(a - z))
                ret[state][i] = cost * p
        return ret

    costX = calcCost([(x, p) for x, _, p in XYP], X)
    costY = calcCost([(y, p) for _, y, p in XYP], Y)

    ans = solve(N, costX, costY)
    print(*ans, sep='\n')

sol()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from numba import njit
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in range(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()
### BUGGY CODE ###

def change(s):
    ans = []
    for i in s:
        if i== "0":
            ans.append("1")
        else:
            ans.append("0")
    return "".join(ans)

n = int(input())
s = input()
MOD = 998244353

a = [0] * (n+1)
for i in range(1, n + 1):
    if n % i == 0:
        a[i] += int(s[0:i], 2)
        for j in range(n // i):
            if j % 2 == 0:
                if int(s[0:i]) < int(s[j*i:(j+1)*i]):
                    a[i] += 1
                    break
                if int(s[0:i]) > int(s[j*i:(j+1)*i]):
                    break
            else:
                if int(change(s[0:i])) < int(s[j*i:(j+1)*i]):
                    a[i] += 1
                    break      
                if int(change(s[0:i])) > int(s[j*i:(j+1)*i]):
                    break 
        else:
            a[i] += 1
            
for i in range(1, n + 1):
    for j in range(2*i, n + 1, i):
        if n % j == 0:
            a[j] -= a[i]

# b: 有効周期
b = []
ans = 0
for i in range(1, n+1):
    if n % i == 0:
        if (n // i) % 2 == 1: 
                b.append(i)

for i in range(1, n+1):
    if n % i == 0:
        for tmp in b:
            if tmp % i == 0:
                ans += a[i] * 2*tmp
                ans %= MOD
                break
          
print(ans % MOD)



### FIXED CODE ###

def change(s):
    ans = []
    for i in s:
        if i== "0":
            ans.append("1")
        else:
            ans.append("0")
    return "".join(ans)

n = int(input())
s = input()
MOD = 998244353

# 重複込みで数える
a = [0] * (n+1)
for i in range(1, n + 1):
    if n % i == 0:
        a[i] += int(s[0:i], 2)
        a[i] %= MOD
        si = int(s[0:i])
        change_si = int(change(s[0:i]))
        for j in range(n // i):
            if j % 2 == 0:
                if si < int(s[j*i:(j+1)*i]):
                    a[i] += 1
                    break
                if si > int(s[j*i:(j+1)*i]):
                    break
            else:
                if change_si < int(s[j*i:(j+1)*i]):
                    a[i] += 1
                    break      
                if change_si > int(s[j*i:(j+1)*i]):
                    break 
        else:
            a[i] += 1

# 約数包除で重複を除く
for i in range(1, n + 1):
    for j in range(2*i, n + 1, i):
        if n % j == 0:
            a[j] -= a[i]

# b:有効周期
b = []
ans = 0
for i in range(1, n+1):
    if n % i == 0:
        if (n // i) % 2 == 1: 
                b.append(i)

#周期の重みを足し合わせる
for i in range(1, n+1):
    if n % i == 0:
        for tmp in b:
            if tmp % i == 0:
                ans += a[i] * 2*tmp
                ans %= MOD
                break
          
print(ans % MOD)
### BUGGY CODE ###

import numpy as np
s=input()
t=input()
a=len(s)
b=len(t)
dp=np.full((a+1,b+1),0,dtype=int)
for i in range(a):
  for j in range(b):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
res=''
while a!=0 and b!=0:
  if dp[a][b]==dp[a-1][b]:
    a-=1
  elif dp[a][b]==dp[a][b-1]:
    b-=1
  else:
    a-=1
    b-=1
    res=s[a]+res
print(res)

### FIXED CODE ###

import numpy as np
S = np.array([ord(i)-97 for i in input()], dtype=int)
T = np.array([ord(i)-97 for i in input()], dtype=int)
Ns = len(S)
Nt = len(T)
equal = np.equal.outer(S, T).astype(int)
 
dp = [np.zeros(Nt + 1, dtype=int)]
for i in range(Ns):
    x = dp[-1].copy()
    newDP = x.copy()
    newDP[1:] = np.maximum(x[:-1] + equal[i], newDP[1:])
    np.maximum.accumulate(newDP, out=newDP)
    dp.append(newDP)
 
 
ans = ""
i, j = Ns, Nt
while i > 0 and j > 0:
    if S[i-1] == T[j-1]:
        ans += chr(S[i-1]+97)
        i -= 1
        j -= 1
        continue
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    else:
        j -= 1
 
print(ans[::-1])
### BUGGY CODE ###

N = int(input())

A = list(map(int, input().split()))

ans = 1
for x in A:
  ans *= x
  if ans < 0:
    print(-1)
    exit()

if ans > 1000000000000000000:
  print(-1)
  exit()


print(ans)


### FIXED CODE ###

N = int(input())

A = list(map(int, input().split()))

ans = 1
keta = 0
if 0 in A:
  print(0)
  exit()

for x in A:
  ans *= x
  keta += len(str(x))
  if ans > 1000000000000000000:
    print(-1)
    exit()

print(ans)
### BUGGY CODE ###

def resolve():
    '''
    code here
    '''
    import collections
    H, W = [int(item) for item in input().split()]
    grid = [[item for item in input()] for _ in range(H)]

    fp = [[-1 for _ in range(W)] for _ in range(H)]

    que = collections.deque()
    next_y_x = [[0, 1], [1, 0], [-1, 0], [0, -1]]
    

    for i in range(H):
        for j in range(W):
            if grid[i][j] == '#':
                que.append([i, j, 0])
                fp[i][j] = 0




    while que:
        temp = que.popleft()

        for dy, dx in next_y_x:
            ny = temp[0] + dy
            nx = temp[1] + dx

            if 0 <= ny <= H-1 and 0 <= nx <= W-1:
                if fp[ny][nx] == -1:
                    que.append([ny, nx, temp[2]+1])
                    fp[ny][nx] = temp[2] + 1

    temp_max_list = []
    for line in fp:
        temp_max_list.append(max(line))

    print(max(temp_max_list))



if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    import collections
    H, W = [int(item) for item in input().split()]
    grid = [[item for item in input()] for _ in range(H)]

    fp = [[-1 for _ in range(W)] for _ in range(H)]

    que = collections.deque()
    next_y_x = [[0, 1], [1, 0], [-1, 0], [0, -1]]
    

    for i in range(H):
        for j in range(W):
            if grid[i][j] == '#':
                que.append([i, j, 0])
                fp[i][j] = 0




    while que:
        temp = que.popleft()

        for dy, dx in next_y_x:
            ny = temp[0] + dy
            nx = temp[1] + dx

            if 0 <= ny <= H-1 and 0 <= nx <= W-1:
                if fp[ny][nx] == -1:
                    que.append([ny, nx, temp[2]+1])
                    fp[ny][nx] = temp[2] + 1

    temp_max_list = []
    for line in fp:
        temp_max_list.append(max(line))

    print(max(temp_max_list))



if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

n = int(input())
s = 0
while n > 0:
    r = n % 10
    s += r
    s %= 9
    n //= 10
if s % 9 == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = int(input())
ln = list(str(n))
from collections import Counter
nc = dict(Counter(ln))
s = 0
if n != 0:
    for i in range(1, 10):
        if str(i) in nc:
            s += i * nc[str(i)]
if s % 9 == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

# damedatta
def binsearch(l, r, fn):
    while r - l > 1:
        m = (l + r) // 2
        if fn(m):
            l = m
        else:
            r = m
    return l
def main():
    X, Y, Z, K = map(int, input().split())
    D = sorted(map(int, input().split()), reverse=True)
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A = sorted((i + j for i in B for j in C), reverse=True)
    def calc(x):
        t = 0
        ii = len(D) - 1
        for i in A:
            while ii >= 0 and D[ii] + i < x:
                ii -= 1
            t += ii + 1
            if t >= K:
                return True
            else:
                return False
    l = binsearch(D[-1] + A[-1], D[0] + A[0], calc)
    ii = len(D) - 1
    rl = []
    for i in A:
        while ii >= 0 and D[ii] + i < l:
            ii -= 1
        if ii < 0:
            break
        rl.extend([i + j for j in D[:ii+1]])
    rl.sort(reverse=True)
    print('\n'.join(str(i) for i in rl[:K]))
main()


### FIXED CODE ###

# damedatta
def binsearch(l, r, fn):
    while r - l > 1:
        m = (l + r) // 2
        if fn(m):
            l = m
        else:
            r = m
    return l
def main():
    X, Y, Z, K = map(int, input().split())
    D = sorted(map(int, input().split()), reverse=True)
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A = sorted((i + j for i in B for j in C), reverse=True)
    def calc(x):
        t = 0
        ii = len(D) - 1
        for i in A:
            while ii >= 0 and D[ii] + i < x:
                ii -= 1
            t += ii + 1
            if t >= K:
                return True
            if ii < 0:
                return False
        return t >= K
    l = binsearch(D[-1] + A[-1], D[0] + A[0]+1, calc)
    ii = len(D) - 1
    rl = []
    for i in A:
        while ii >= 0 and D[ii] + i < l + 1:
            ii -= 1
        if ii < 0:
            break
        rl.extend(i + j for j in D[:ii+1])
    rl.sort(reverse=True)
    rl += [l] * (K - len(rl))
    print('\n'.join(str(i) for i in rl))
main()