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

import sys

sys.setrecursionlimit(1000000000)

ap=a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
bp=cp=dp=ep=fp=0
i=0
def idou(a,b,c,d,e,f,ap,bp,cp,dp,ep,fp):
    global i
    if a==fp:
        return i
    else:
        i+=1
        if ep != 0:
            if ep>=f:
                ep-=f
                fp+=f
            else:
                fp+=ep
                ep=0
        if dp != 0:
            if dp>=e:
                dp-=e
                ep+=e
            else:
                ep+=dp
                dp=0
        if cp != 0:
            if cp>=d:
                cp-=d
                dp+=d
            else:
                dp+=cp
                cp=0
        if bp != 0:
            if bp>=c:
                bp-=c
                cp+=c
            else:
                cp+=bp
                bp=0
        if ap != 0:
            if ap>=b:
                ap-=b
                bp=bp+b
            else:
                bp+=ap
                ap=0
        idou(a,b,c,d,e,f,ap,bp,cp,dp,ep,fp)
idou(a,b,c,d,e,f,ap,bp,cp,dp,ep,fp)
print(i)

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
 
print((a-1) // min(b,c,d,e,f) + 5)
### BUGGY CODE ###

N = int(input())

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

X = [0]*N

for i in range(N):
    for j in range(N):
        if j+i < N:
            tmp_A = (-1)**(j+i)*A[j+i-N]
        else:
            tmp_A = (-1)**(j+i)*A[j+i-N]
        X[i] += tmp_A
    if i % 2 != 0:
        X[i] *= -1
print(" ".join(map(str, X)))

### FIXED CODE ###

N = int(input())

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

X = [0]*N

for i in range(N):
    X[0] += (-1)**(i)*A[i]

for j in range(0,N-1):
    X[j+1] = 2 * (A[j] - int(X[j]/2))

print(" ".join(map(str, X)))
### BUGGY CODE ###

N = int(input())

arr = []

count = 0

def sort_str(s):
    return "".join(sorted(list(s)))


sorted_str_arr = []
for i in range(N):
    sorted_str_arr.append(sort_str(str(input())))

for i in range(N):
    for j in range(i+1, N):
        if sorted_str_arr[i] == sorted_str_arr[j]:
            count += 1

print(count)


### FIXED CODE ###

N = int(input())

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

m = {}

def sort_str(s):
    return "".join(sorted(list(s)))

for i in range(N):
    s = str(input())
    ss = sort_str(s)

    if ss in m:
        m[ss] += 1
    else:
        m[ss] = 1


count = 0

for c in m.values():
    if c > 1:
        count += cmb(c, 2)

print(count)
### BUGGY CODE ###

N = int(input())

count = 0
for A in range(1, N+1):
    for B in range(1, N+1):
        if str(A)[-1]==str(B)[0] and str(B)[-1]==str(A)[0]:
            count +=1
print(count)

### FIXED CODE ###

N = int(input())

cnt = [[0]*10 for i in range(10)]
# 先頭がi, 末尾がjであるような数の個数を計算
for n in range(1, N+1):
    n = str(n)
    i = int(n[0])
    j = int(n[-1])
    cnt[i][j] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j]*cnt[j][i]

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

import sys

sys.setrecursionlimit(10 ** 5)

MOD = 998244353


def solve(A, B, C, D):
    cache = {}

    def numWays(rows, cols):
        if rows == A and cols == B:
            return 1

        key = rows * 4096 + cols
        if key not in cache:

            assert rows >= A and cols >= B
            ways = 0
            if rows > A:
                ways += cols * numWays(rows - 1, cols) % MOD
            if cols > B:
                ways += rows * numWays(rows, cols - 1) % MOD

            if rows > A and cols > B:
                ways -= (cols - 1) * (rows - 1) * numWays(rows - 1, cols - 1) % MOD
            cache[key] = ways % MOD
        return cache[key]

    return numWays(C, D) % MOD


A, B, C, D = [int(x) for x in input().split()]
print(solve(A, B, C, D))


### FIXED CODE ###

MOD = 998244353


def solve(A, B, C, D):
    numWays = [[None for c in range(D + 1)] for r in range(C + 1)]

    numWays[A][B] = 1

    for rows in range(A, C + 1):
        for cols in range(B, D + 1):
            if rows == A and cols == B:
                continue
            ways = 0
            if rows > A:
                ways += cols * numWays[rows - 1][cols] % MOD
            if cols > B:
                ways += rows * numWays[rows][cols - 1] % MOD
            if rows > A and cols > B:
                ways -= (cols - 1) * (rows - 1) * numWays[rows - 1][cols - 1] % MOD
            numWays[rows][cols] = ways % MOD

    return numWays[C][D] % MOD


A, B, C, D = [int(x) for x in input().split()]
print(solve(A, B, C, D))
### BUGGY CODE ###

import fractions

mod = 10 ** 9 + 7
def modpow(a, x):
    if a == 0:
        return 0
    if x == 0:
        return 1
    elif x % 2 == 0:
        return modpow((a * a) % mod, x // 2) % mod
    else:
        return (modpow((a * a) % mod , x // 2) % mod * a) % mod


def factorization(x):
    ans = []
    i = 2
    in_x = x
    while i <= x:
        count = 0
        while x % i == 0:
            x = x // i
            count += 1
        if count > 0:
            ans.append((i, count))
        i += 1
    return ans


N = int(input())
A = list(map(int, input().split(" ")))
primes = {}
for a in A:
    factors = factorization(a)
    for f in factors:
        if f[0] in primes:
            primes[f[0]] = max(primes[f[0]], f[1])
        else:
            primes[f[0]] = f[1]

lcm = 1
for p in primes:
    lcm *= modpow(p, primes[p])
    lcm %= mod


ans = 0
for a in A:
    ans += (lcm * modpow(a, mod - 2)) % mod
    ans %= mod
print(ans)

### FIXED CODE ###

import sys
import fractions
input = sys.stdin.readline


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

lcm = 1
for a in A:
    lcm = a // fractions.gcd(a, lcm) * lcm

ans = 0
for a in A:
    ans += lcm // a

print(ans % mod)
### BUGGY CODE ###

#coding:utf-8
import re

if __name__ == "__main__":
    patterns = ["dream", "dreamer", "erase" ,"eraser"]
    S = input()

    end = False

    while not(end):
        flag = False
        for pattern in patterns:
            if flag == False:
                if re.search(pattern+"$",S):
                    S = re.sub(pattern+"$","",S)
                    flag = True
            elif flag == True:
                break
        else:
            if flag == False:
                print("NO")
                end = True

        if not(S):
            print("YES")
            end = True

### FIXED CODE ###

#coding:utf-8
import re

if __name__ == "__main__":
    patterns = ["dream", "dreamer", "erase" ,"eraser"]
    S = input()

    while True:
        flag = False
        if S[-5:] == "dream":
            S = S[:-5]
            flag = True
        if S[-7:] == "dreamer":
            S = S[:-7]
            flag = True
        if S[-5:] == "erase":
            S = S[:-5]
            flag = True
        if S[-6:] == "eraser":
            S = S[:-6]
            flag = True

        if flag == False:
            print("NO")
            break

        if S == "":
            print("YES")
            break
### BUGGY CODE ###

# coding: utf-8

n,m,q = list(map(int,input().split()))
M = [ list(map(int,input().split())) for i in range(m) ]
Q = [ list(map(int,input().split())) for i in range(q) ]

count = [0]*q

for i in range(q):
    for j in range(m):
        if Q[i][0] <= M[j][0] and M[j][1] <= Q[i][1]:
            count[i] += 1

for i in range(q):
    print(count[i])

### FIXED CODE ###

# coding: utf-8

n,m,q = list(map(int,input().split()))
M = [ list(map(int,input().split())) for i in range(m) ]
Q = [ list(map(int,input().split())) for i in range(q) ]

LR = [[0]*(n+1) for _ in range(n+1)]

for m in M:
    LR[m[0]-1][m[1]] += 1 

for l in range(n,-1,-1):
    for r in range(0,n,1):
        LR[l-1][r+1] = LR[l-1][r+1] + LR[l-1][r] + LR[l][r+1] - LR[l][r]

for q in Q:
    print(LR[q[0]-1][q[1]])
### BUGGY CODE ###

N=int(input())
P=[]
ans=0
for i in range(N):
  P.append(i + 1)
for i in range(N - 1):
  ans += P[i] % (i + 2)
print(ans)

### FIXED CODE ###

N=int(input())
print((N+1) * (N // 2) - N if N%2==0 else (N+1) * (N // 2) + int(N/2+1) - N)
### BUGGY CODE ###

n = int(input())
s = [''.join(sorted(input())) for i in range(n)]


cnt = 0
set_list = set(s)
for i in set_list:
    num = s.count(i)
    tmp = num * (num - 1) / 2
    cnt += tmp

print(int(cnt))


### FIXED CODE ###

n = int(input())
s = [''.join(sorted(input())) for i in range(n)]

cnt = 0
dic = {}
for i in s:
    dic.setdefault(i, 0)
    cnt += dic[i]
    dic[i] += 1

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

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = [list(map(int, input().split())) for i in range(N)]

    now = [0] * N
    day = 0
    gamed_day = [-1] * N
    while True:
        had_game = False
        all_finish = True
        for i in range(N):
            if now[i] < N-1 and gamed_day[i] != day:
                all_finish = False
                want = a[i][now[i]] - 1
                if gamed_day[want] != day:# 今日試合していない
                    if a[want][now[want]] - 1 == i:# 相手の試合相手が自分
                        now[want] += 1
                        now[i] += 1
                        gamed_day[i] = day
                        gamed_day[want] = day
                        had_game = True
                        # print(day+1, i+1, want+1)
        if all_finish:
            if had_game:
                print(day+1)
            else:
                print(day)
            break
        if not had_game:
            print(-1)
            break
        day += 1
    # print(now)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import time
def main():
    N = int(input())
    a = [list(map(int, input().split())) for i in range(N)]
    start = time.time()
    now = [0] * N
    day = 0
    gamed_day = [-1] * N
    finished = 0
    while True:
        if time.time() - start > 1.6:
            print((N*(N-1))//2)
            break
        had_game = False
        all_finish = True
        for i in range(N-1, -1, -1):
            if now[i] < N-1 and gamed_day[i] != day:
                all_finish = False
                want = a[i][now[i]] - 1
                if gamed_day[want] != day:# 今日試合していない
                    if a[want][now[want]] - 1 == i:# 相手の試合相手が自分
                        now[want] += 1
                        now[i] += 1
                        if now[want] >= N-1:
                            finished += 1
                        if now[i] >= N-1:
                            finished += 1
                        gamed_day[i] = day
                        gamed_day[want] = day
                        had_game = True
                        # print(day+1, i+1, want+1)
        if all_finish or finished == N:
            if had_game:
                print(day+1)
            else:
                print(day)
            break
        if not had_game:
            print(-1)
            break
        day += 1
    # print(now)

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

N = int(input())
X = input()

d = [0 for _ in range(N)]
for i in range(1, N):
    v = i % bin(i)[2:].count("1")
    d[i] = d[v] + 1
   
for i in range(N):
    if X[i] == "0":
        x = X[:i] + "1" + X[i+1:]
    else:
        x = X[:i] + "0" + X[i+1:]
        
    val = int(x, 2)
    if val == 0:
        print(0)
    else:
        print(d[val % x.count("1")] + 1)


### FIXED CODE ###

N = int(input())
X = input()

a = int(X, 2)
b = X.count("1")

if b > 1:
    a1 = a % (b-1)
else:
    a1 = 0
a0 = a % (b+1)

for i in range(N):
    if X[i] == "1":
        if b == 1:
            print(0)
            continue
        t = (a1 - pow(2, N-1-i, b-1)) % (b-1)
    else:
        t = (a0 + pow(2, N-1-i, b+1)) % (b+1)
    
    ans = 1
    while t > 0:
        t %= bin(t).count("1")
        ans += 1
    print(ans)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc127/tasks/abc127_e

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math

# Calculate count of combination
def combination(n, r):
    if r == 0:
        return 1
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        if a % (i + 1):
            a //= (i + 1)
        else:
            b *= (i + 1)
    return a // b


def main():
    MOD = 10**9 + 7
    N, M, K = map(int, input().split())

    com = combination(N * M - 2, K - 2)
    # print(com)
    com = com % MOD
    # print(com)

    ans = 0
    for i in range(N*M-1):
        for j in range(i + 1, N*M):
            # print('{} {}'.format(i, j))
            iy = i // M
            ix = i % M

            jy = j // M
            jx = j % M
            ans += (abs(iy - jy) + abs(ix - jx)) * com
            ans = ans % MOD

    print(ans)



if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://atcoder.jp/contests/abc127/tasks/abc127_e

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math

# Calculate count of combination
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


def combination(n, r):
    if r == 0:
        return 1
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        if a % (i + 1):
            a //= (i + 1)
        else:
            b *= (i + 1)
    return a // b


def main():
    MOD = 10**9 + 7
    N, M, K = map(int, input().split())

    pattern = cmb(N * M - 2, K - 2)
    # print(com)
    pattern = pattern % MOD
    # print(com)

    ans = 0

    for dx in range(1, M):
        ans += dx * (M - dx) * pattern * (N * N)
        ans = ans % MOD

    # y
    for dy in range(1, N):
        ans += dy * (N - dy) * pattern * (M * M)
        ans = ans % MOD

    ans = ans % MOD
    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

#!/usr/bin/env python3
n = int(input()) 
l = sorted(list(map(int, input().split())))
[print(l.count(i)) for i in range(1, n+1)]
    

### FIXED CODE ###

#!/usr/bin/env python3
import collections
n = int(input()) 
l = sorted(list(map(int, input().split())))
c = collections.Counter(l)
[print(c[i]) for i in range(1, n+1)]
### BUGGY CODE ###

import sys
import heapq
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = [[0 for i in range(3 * n)] for j in range(3 * n)]
for i in range(m):
    u, v = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    graph[u][n+v] = 1
    graph[u+n][2*n+v] = 1
    graph[u + 2 * n][v] = 1
s, t = [int(i) for i in sys.stdin.readline().split()]
s -= 1
t -= 1

que = [(0,s)]
already = set()
flg = False
while que:
    cost, cur = heapq.heappop(que)
    already.add(cur)
    if cur == t:
        flg = True
        break
    for i, _next in enumerate(graph[cur]):
        if _next == 0:
            continue
        if i in already:
            continue
        heapq.heappush(que, (cost + 1, i))
if not flg:
    cost = -1
else:
    cost //= 3

print(cost)

### FIXED CODE ###

import sys
INF = 10 ** 9
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {j:[] for j in range(3 * n)}
for i in range(m):
    u, v = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    graph[u].append(n+v)
    graph[u+n].append(2*n+v)
    graph[u + 2 * n].append(v)
s, t = [int(i) for i in sys.stdin.readline().split()]
s -= 1
t -= 1

que = [s]
flg = False
already = set()
dist = [INF for i in range(3 * n)]
dist[s] = 0
while que:
    cur= que[0]
    que.pop(0)
    for i in graph[cur]:
        if i not in already:
            if i == t:
                res = dist[cur] + 1
                que.clear()
                flg = True
                break
            que.append(i)
            dist[i] = dist[cur] + 1
            already.add(i)
if not flg:
    res = -1
else:
    res //= 3

print(res)
### BUGGY CODE ###

#!/usr/bin/env python3

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
bc_list = []

for _ in range(M):
    b, c = list(map(int, input().split()))
    bc_list.append((b, c))

now_list = sorted(a_list)

for bc in bc_list:
    b, c = bc
    now_list = [c if x < c and i < b else x for i, x in enumerate(now_list)]
    now_list = sorted(now_list)

ans = sum(now_list)
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import bisect
import numpy as np

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
bc_list = []

for i in range(M):
    try:
        b, c = list(map(int, input().split()))
        bc_list.append((b, c))
    except:
        M = i

bc_list = sorted(bc_list, key=lambda x: x[1], reverse=True)
a_list = sorted(a_list)

fix_list = []
s = 0
b, c = bc_list[0]
bc_index = 0
now_b, now_c = 0, c

for i, a in enumerate(a_list):
    # a = a_list[i]
    if now_b >= b:
        bc_index += 1
        if bc_index >= len(bc_list):
            # TODO: 残りを足す
            fix_list.append(a)
            s += a
            continue
        now_b = 0
        b, c = bc_list[bc_index]

    if a < c:
        fix_list.append(c)
        s += c
    else:
        fix_list.append(a)
        s += a
    now_b += 1

ans = s
print(ans)
### BUGGY CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import defaultdict, deque
    n, m = map(int, readline().split())
    edge = defaultdict(list)
    for _ in range(m):
        a, b = map(int, readline().split())
        edge[a].append(b)
        edge[b].append(a)

    mat = []
    q = int(readline())
    for _ in range(q):
        mat.append(list(map(int, readline().split())))

    paint = [[0, -1] for _ in range(n + 1)]
    for v, d, c in mat[::-1]:
        if d == 0 and paint[v] == -1:
            paint[v][0] = c
            paint[v][1] = 0
        else:
            que = deque()
            que.append((v, d, c))
            while que:
                cur, rem, color = que.popleft()
                if paint[cur][0] == 0:
                    paint[cur][0] = color
                    paint[cur][1] = rem
                if rem > 0:
                    n_rem = rem - 1
                    for nx in edge[cur]:
                        if paint[nx][1] >= n_rem:
                            pass
                        else:
                            que.append((nx, n_rem, color))

    for i in range(1, n + 1):
        print(paint[i][0])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import defaultdict, deque
    n, m = map(int, readline().split())
    edge = defaultdict(list)
    for _ in range(m):
        a, b = map(int, readline().split())
        edge[a].append(b)
        edge[b].append(a)

    q = int(readline())
    mat = [[] for _ in range(q)]

    for i in range(q):
        mat[i] = list(map(int, readline().split()))

    dp = [[0] * 11 for _ in range(n + 1)]

    for v, d, c in mat[::-1]:
        if dp[v][d] != 0:
            continue
        que = deque()
        que.append((v, d, c))
        while que:
            cur, dist, color = que.popleft()
            for i in range(dist, -1, -1):
                if dp[cur][i] == 0:
                    dp[cur][i] = color
                else:
                    break
            if dist > 0:
                for nx in edge[cur]:
                    if dp[nx][dist - 1] != 0:
                        continue
                    else:
                        que.append((nx, dist - 1, color))

    for i in range(1, n + 1):
        print(dp[i][0])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import itertools
from functools import lru_cache

@lru_cache(maxsize=10000000)
def f(x):
    return (max(x) - min(x))

def resolve():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    A = map(int, input().split())

    c_list = itertools.combinations(A, K)

    fx = map(f, c_list)
    total = sum(fx)
    total = total % MOD
    print(total)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

import math
from functools import lru_cache
from operator import mul
from functools import reduce


def resolve():
    import sys
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()
    B = A[::-1]

    @lru_cache(maxsize=None)
    def combinations_count__(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

    @lru_cache(maxsize=None)
    def combinations_count____(n, r):
        r = min(r, n - r)
        numer = reduce(mul, range(n, n - r, -1), 1)
        denom = reduce(mul, range(1, r + 1), 1)
        return numer // denom

    def combinations_count_(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

    def modinv(a, mod=10**9+7):
        return pow(a, mod-2, mod)

    def combinations_count(n, r, mod=10**9+7):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n-r)
        return fact[n] * factinv[r] * factinv[n-r] % mod
    
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

    sum = 0
    for i in range(K-1, N):
        sum += combinations_count(i, K-1) * A[i] % MOD - combinations_count(i, K-1) * B[i] % MOD

    print(sum % MOD)


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

#答え
T=input()

#考えられる要素数total
total=2**T.count("?")
#?の個数
num=T.count("?")

ans=0
ans_str=""
for i in range(total):
    T_trans=""
    #変換後のT
    trans=[]
    #このリストにそって、?をPかDに変換する
    #ここで1がP、0がDとし、格納していく
    ptn = bin(i)[2:].rjust(num, "0")
    for j in range(num):
        if ptn[j]==1:
            trans.append(1)
        else:
            trans.append(0)
    
    for k in T:
        if k=="?":
            if trans[0]==1:
                T_trans+="P"
                del trans[0]
            else:
                T_trans+="D"
                del trans[0]
        else:
            T_trans+=k
    
    n=T_trans.count("D")+T_trans.count("PD")
    if ans<=n:
        ans_str=T_trans
        ans=n
    
print(ans_str)

### FIXED CODE ###

T=input()
T_trans=""
for i in T:
    if i=="?":
        T_trans+="D"
    else:
        T_trans+=i
print(T_trans)
### BUGGY CODE ###

K=int(input())
A,B=list(map(int,input().split()))
c=K
while c<=B:
  if c>=A and c<=B:
    print("OK")
    break
else:
  print("NG")

### FIXED CODE ###

K=int(input())
A,B=list(map(int,input().split()))
c=K
while c<=B:
  if c>=A and c<=B:
    print("OK")
    break
  else:
    c += K
else:
  print("NG")