Harryxun/stf_run huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv().v); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }
  // M inv() const {
  //   int x, y;
  //   extgcd(this->v, MOD, x, y);
  //   return *this + M(x);
  // }

  static long long MOD;
  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    finv.assign(n + 1, fact[n].inv());
    for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
  static M extgcd(int a, int b, int* x, int* y) {
    M d(a);
    if (b) {
      d = extgcd(b, a % b, y, x);
      *y -= (a / b) * *x;
    } else {
      *x = 1, *y = 0;
    }
    return d;
  }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<int>> o(120, vector<int>(n + 1, 0));
  vector<vector<int>> x(120, vector<int>(n + 1, 0));
  for (int b = 0; b < 120; b++) {
    for (int i = 0; i < n; i++) {
      o[b][i + 1] += o[b][i];
      x[b][i + 1] += x[b][i];
      if (a[i] >> min(60, b) & 1) {
        o[b][i + 1]++;
      } else {
        x[b][i + 1]++;
      }
    }
  }
  vector<ll> v(120);
  ll nxt = 0;
  for (int b = 0; b < 120; b++) {
    ll c = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] >> min(60, b) & 1) {
        c += x[b][i];
      } else {
        c += o[b][i];
      }
    }
    v[b] = (nxt + c) % 2;
    nxt = (nxt + c) / 2;
  }
  ModInt ans = 0;
  for (int b = 119; b >= 0; b--) {
    ans *= 2;
    ans += v[b];
  }
  cout << ans << endl;
}


### FIXED CODE ###

#!/usr/bin/env python3
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
ans = 0
for b in range(60)[::-1]:
    ans <<= 1
    c = sum(a[i] >> b & 1 for i in range(n))
    ans = (ans + c * (n - c)) % MOD
print(ans)
#D
N, K = map(int,input().split())
A = list(map(int,input().split()))

now = 0
visited = [0]
visited_set = set([0])

for i in range(K):
    now = A[now] - 1
    if now in visited_set:
        roop_start = now
        break
    visited.append(now)
    visited_set.add(now)
    
ind = visited.index(roop_start)
roop = visited[ind:]

print(roop[(K-ind)%len(roop)]+1)

### FIXED CODE ###

#D
N, K = map(int,input().split())
A = list(map(int,input().split()))

now = 0
visited = [0]
visited_set = set([0])

for i in range(K):
    now = A[now] - 1
    if now in visited_set:
        break
    visited.append(now)
    visited_set.add(now)
if len(visited) == N:
    print(visited[K-1]+1)
else:    
    ind = visited.index(now)
    roop = visited[ind:]
    print(roop[(K-ind)%len(roop)]+1)
N = int(input())
Ai = [int(i) for i in input().split(" ")]
Bi = [int(i) for i in input().split(" ")]
Ci = [int(i) for i in input().split(" ")]

res = 0
res += Ai[N+1]
res += Bi[N+1]
res += Ci[N+2]

print(res)

### FIXED CODE ###

N = int(input())
Ai = [int(i) for i in input().split(" ")]
Bi = [int(i) for i in input().split(" ")]
Ci = [int(i) for i in input().split(" ")]

res = 0
pre_i = None
for i in Ai:
  res += Bi[i-1]
  if pre_i and i == pre_i+1:
    res += Ci[i-2]
  pre_i = i

print(res)
inputs = input().split()
a = int(inputs[0])
b = inputs[1]
b = 100 * int(b[0]) + 10 * int(b[1]) + int(b[2])

print(int(a * b / 100))

### FIXED CODE ###

inputs = input().split()
a = int(inputs[0])
b = inputs[1]
b = 100 * int(b[0]) + 10 * int(b[2]) + int(b[3])

print(a * b // 100)
#!/usr/bin/env python3
import sys


def solve(n: int, m: int, A: "List[int]", B: "List[int]"):
    par = [i for i in range(n)]
    nums = [1] * n
    def get_root(a):
        if par[a] == a:
            return a
        root = get_root(par[a])
        par[a] = root
        return par[a]
    def merge(a, b):
        root_a = get_root(a)
        root_b = get_root(b)
        if root_a == root_b:
            return 0
        else:
            ret = nums[root_a] * nums[root_b]
            group = nums[root_a] + nums[root_b]
            par[root_a] = root_b
            nums[root_b] = group
            return ret

    con = 0
    ret = []
    pairs = n * (n - 1) // 2
    ret.append(pairs - con)
    for i in range(m - 1):
        idx = m - i - 1
        a = A[idx] - 1
        b = B[idx] - 1
        con += merge(a, b)
        ret.append(pairs - con)
    ret.reverse()
    for c in ret:
        print(c)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(100001)


def solve(n: int, m: int, A: "List[int]", B: "List[int]"):
    par = [i for i in range(n)]
    nums = [1] * n
    def get_root(a):
        if par[a] == a:
            return a
        root = get_root(par[a])
        par[a] = root
        return par[a]
    def merge(a, b):
        root_a = get_root(a)
        root_b = get_root(b)
        if root_a == root_b:
            return 0
        else:
            ret = nums[root_a] * nums[root_b]
            group = nums[root_a] + nums[root_b]
            par[root_a] = root_b
            nums[root_b] = group
            return ret

    con = 0
    ret = []
    pairs = n * (n - 1) // 2
    ret.append(pairs - con)
    for i in range(m - 1):
        idx = m - i - 1
        a = A[idx] - 1
        b = B[idx] - 1
        con += merge(a, b)
        ret.append(pairs - con)
    ret.reverse()
    for c in ret:
        print(c)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()
N=int(input())
*A,=map(int,input().split())

count1=0
i=0
while True:
    count1+=A[i]
    i+=1
    ans1=count1-sum(A[i:])
    if ans1>=0 and ans1<=i:
        break


A=A[::-1]
count2=0
j=0
while True:
    count2+=A[j]
    j+=1
    ans2=count2-sum(A[j:])
    if ans2>=0 and ans2<=j:
        break

print(min(ans1,ans2))

### FIXED CODE ###

N=int(input())
*A,=map(int,input().split())
S=sum(A)

count1=0
count2=[0]*N
i=0
while i<N:
    count1+=A[i]
    count2[i]=abs(S-2*count1)
    i+=1

print(min(count2))
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
a = IR(n)

# N個のボタンがあり、今1個のボタンが光っている。
# ボタンは1~Nまで番号があり、iが光っているときに押すと、iの光が消え、aiが光る。
# 光っていないボタンを押しても反応しない。
# ボタン１が光っている状態で開始、ボタン2が光っている状態で終了したい。
# そのようなことが不可能であれば－1、可能であれば最小回数を出力

#　普通にシミュレートしたらよい。
#　n回ボタン押したうえで、2にたどり着かなかったらどこかで同じボタンを2回押していることになる。

count = 0
cur = 1

while count < n:
    count += 1
    cur = a[cur-1]
    if cur == 2:
        print(count)
        return
print(-1)

### FIXED CODE ###

import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
a = IR(n)

# N個のボタンがあり、今1個のボタンが光っている。
# ボタンは1~Nまで番号があり、iが光っているときに押すと、iの光が消え、aiが光る。
# 光っていないボタンを押しても反応しない。
# ボタン１が光っている状態で開始、ボタン2が光っている状態で終了したい。
# そのようなことが不可能であれば－1、可能であれば最小回数を出力

#　普通にシミュレートしたらよい。
#　n回ボタン押したうえで、2にたどり着かなかったらどこかで同じボタンを2回押していることになる。

count = 0
cur = 1

while count < n:
    count += 1
    cur = a[cur-1]
    if cur == 2:
        print(count)
        sys.exit()
print(-1)
X, N = map(int, input().split())
p_list = list(map(int, input().split()))
all_list = range(1, 101)

not_p_list = list(set(all_list)-set(p_list))
ans_list = []

for i in not_p_list:
    j = abs(i - X)
    ans_list.append(j)

# print(ans_list)

ans = min(ans_list)
minus_ans = -1 * ans

#print(ans, minus_ans)

if (minus_ans + X) in not_p_list:
    print(minus_ans + X)
else:
    print(ans + X)


### FIXED CODE ###

X, N = map(int, input().split())
p_list = list(map(int, input().split()))
all_list = range(0, 151)

not_p_list = list(set(all_list)-set(p_list))
ans_list = []

if N == 0:
    print(X)
else:
    for i in not_p_list:
        j = abs(i - X)
        ans_list.append(j)

    # print(ans_list)

    ans = min(ans_list)
    minus_ans = -1 * ans

    #print(ans, minus_ans)

    if (minus_ans + X) in not_p_list:
        print(minus_ans + X)
    else:
        print(ans + X)
from sys import stdin
N,X=[int(x) for x in stdin.readline().rstrip().split()]
burger_set=["P"]
for i in range(N):
    new_burger="B"+burger_set[0]+"P"+burger_set[0]+"B"
    burger_set.append(new_burger)
    del burger_set[0]
print(burger_set[0].count('P'))

### FIXED CODE ###

from sys import stdin
N, X = [int(x) for x in stdin.readline().rstrip().split()]

heights = [1]
putties = [1]
for _ in range(N):
    heights.append(heights[-1] * 2 + 3)
    putties.append(putties[-1] * 2 + 1)


def solve(n, x):
    if n == 0 and x == 1:
        return 1
    elif x == 1:
        return 0
    elif 1 < x <= 1+heights[n-1]:
        return solve(n-1, x-1)
    elif x == 2+heights[n-1]:
        return 1+putties[n-1]
    elif 2+heights[n-1] < x <= 2+2*heights[n-1]:
        return putties[n-1]+1+solve(n-1,x-2-heights[n-1]) 
    elif x == 3+2*heights[n-1]:
        return 2*putties[n-1]+1
print(solve(N, X))
n=int(input())
ans=0
for i in n:
  if i%2==1:
    ans+=1
print(ans/n)

### FIXED CODE ###

x = int(input())
f = x // 2
print((x-f)/x)
def main():
    import sys
    import bisect
    from itertools import accumulate

    n = int(input())
    a = list(map(int, sys.stdin.readline().split()))

    b = list(accumulate(a))
    l = b[-1]
    i = bisect.bisect_left(b, l // 2)
    ans = min(abs(l - 2 * b[i]), abs(l - 2 * b[i + 1]))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    from itertools import accumulate

    n = int(input())
    a = list(map(int, sys.stdin.readline().split()))

    b = list(accumulate(a))
    diff = b[-1]
    total = b[-1]
    for x in b:
        diff = min(diff, abs(total - 2 * x))
    print(diff)

if __name__ == '__main__':
     main()
n = int(input())
    A = list(map(int, input().split()))
    max_a = max(A)
    m = set()
    checked = set()
    duplicated = set()

    for a in A:
        if a in checked:
            duplicated.add(a)
            continue

        i = 2
        while a*i <= max_a:
            m.add(a*i)
            i += 1

        checked.add(a)

    ans = 0
    for a in A:
        if a in duplicated: continue

        if a not in m:
            ans += 1
    
    print(ans)
 
resolve()

### FIXED CODE ###

def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    max_a = max(A)
    m = set()
    checked = set()
    duplicated = set()

    for a in A:
        if a in checked:
            duplicated.add(a)
            continue

        i = 2
        while a*i <= max_a:
            m.add(a*i)
            i += 1

        checked.add(a)

    ans = 0
    for a in A:
        if a in duplicated: continue

        if a not in m:
            ans += 1
    
    print(ans)
 
resolve()
_=input()
A=eval('*'.join(input().split()))
print(-1 if A>10**18 else A)

### FIXED CODE ###

_=input()
A=sorted(list(map(int,input().split())))
B=1
for a in A:
    B*=a
    if B>10**18:
        B=-1
        break
print(B)
N=int(input())
b=list(map(int,input().split()))
a=[0]*N
for i in range(N):
    z = N-i-1
    while z <= N-1:
        a[N-1-i] += b[z]
        z=(z+1)*2-1
print(sum(a))
if sum(a) != 0:
    s = ''
    for i in a:
        s += str(i) + ' ' if i != 0 else ''
print(s.rstrip())


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*N
    l2=[]
    ans=0
    for i,x in enumerate(reversed(a)):
        z=N-i
        c=0
        for j in range(2,N//z+1):
            c+=l[z*j-1]
        if c%2!=x:
            l[N-1-i]+=1
            ans+=1
            l2.append(N-i)
    print(ans)
    print(*l2)

if __name__ == '__main__':
    main()
from fractions import gcd
n = int(input())
times = [int(input()) for _ in range(n)]

if n == 1:
    print(times[0])
else:
    prev_lcm = times[0]
    for t in times[1:]:
        tmp = gcd(prev_lcm, t)
        lcm = int(prev_lcm * t / tmp)
        prev_lcm = lcm
    print(lcm)


### FIXED CODE ###

from fractions import gcd
n = int(input())
times = [int(input()) for _ in range(n)]

if n == 1:
    print(times[0])
else:
    prev_lcm = times[0]
    for t in times[1:]:
        tmp = gcd(prev_lcm, t)
        lcm = prev_lcm * (t // tmp)
        prev_lcm = lcm
    print(lcm)
import sys
from itertools import permutations

n, c = map(int, sys.stdin.readline().split())
d = [[int(x) for x in sys.stdin.readline().split()] for _ in range(c)]
grid = [[int(x) - 1 for x in sys.stdin.readline().split()] for _ in range(n)]

cost = [[0] * 3 for _ in range(c)]
for i in range(n):
  for j in range(n):
    k = (i + j) % 3
    for l in range(c):
      cost[k][l] += d[grid[i][j]][l]
  
def main():
  res = []
  for i, j, k in permutations(range(c), 3):
    res.append(cost[0][i] + cost[1][j] + cost[2][k])
  print(min(res))

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
import numpy as np 
from itertools import permutations

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, C = I[:2]
cost = I[2:2+C**2].reshape(C, C)
color = I[2+C**2:].reshape(n, n) - 1

def main():
    mod_3 = (np.arange(1, n+1)[:, None] + np.arange(1, n+1)) % 3
    c0 = np.bincount(color[mod_3 == 0], minlength=C)
    c1 = np.bincount(color[mod_3 == 1], minlength=C)
    c2 = np.bincount(color[mod_3 == 2], minlength=C)

    ans = float('inf')
    for i, j, k in permutations(range(C), 3):
        res = np.sum(c0 * cost[:, i])
        res += np.sum(c1 * cost[:, j])
        res += np.sum(c2 * cost[:, k])
        ans = min(ans, res)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)
H, W = map(int, input().split())
s_list = []
for i in range(H):
    s = list(input())
    s_list.append(s)

dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1
mod = 10 ** 9 + 7
for i in range(H):
    for j in range(W):
        if s_list[i][j] == "#":
            continue
        if i + 1 < H and s_list[i + 1][j] == ".":
            dp[i + 1][j] += dp[i][j] % mod
        if j + 1 < W and s_list[i][j + 1] == ".":
            dp[i][j + 1] += dp[i][j] % mod
print(dp[H - 1][W - 1] % mod)



### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 8)

N, M = map(int, input().split())
graph = [dict() for _ in range(N)]

for i in range(M):
    x, y = map(int, input().split())
    graph[y - 1][x - 1] = 1

dp = [0 for _ in range(N)]


def dfs(u):
    if dp[u] != 0:
        return dp[u]
    max_dis = 0
    for f in graph[u].keys():
        if max_dis < dfs(f) + 1:
            max_dis = dfs(f) + 1

    dp[u] = max_dis
    return dp[u]


for i in range(N):
    dfs(i)
print(max(dp))
n, k = map(int, input())

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

### FIXED CODE ###

n, k = map(int, input().split())

if (n-1)%(k-1)==0:
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1)+1)
s = int(input())
a = list(map(int,input().split()))
ans = [s]

while True:
  if s%2 ==0:
    s = s//2
  else:
    s = 3s + 1

  if s in ans:
        break
  else:
        ans.append(s)
      
print(len(ans)+1)

### FIXED CODE ###

s = int(input())
ans = [s]
 
while True:
  if s%2 ==0:
    s = s//2
  else:
    s = 3*s + 1
 
  if s in ans:
        break
  else:
        ans.append(s)
      
print(len(ans)+1)
x = map(int, input().split())
x[0] = -1*x[0]
print(sum(x))

### FIXED CODE ###

x = list(map(int, input().split()))
x[0] = -1*x[0]
print(max(sum(x), 0))
N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
d=[[] for _ in range(N)] # 隣接リスト
e=[ set() for _ in range(N)] #その頂点につながる辺に存在する色のリスト
maxi=0
for i in range(N-1):
    a[i],b[i] = map(int,input().split())
    d[a[i]-1].append(b[i]-1)
    d[b[i]-1].append(a[i]-1)
    
for j in d:
    maxi=max(maxi,len(j))  #最大の色数が確定する
for i in range(N-1):
    pos=set([i+1 for i in range(maxi)])
    pos= pos- e[a[i]-1] -e[b[i]-1]
    col=pos.pop()
    c[i]=col
    e[a[i]-1].add(col)
    e[b[i]-1].add(col)
   
print(maxi)
for color in c:
    print(color)


### FIXED CODE ###

from collections import deque

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[set() for _ in range(N)] # 使用している色
d=[set() for _ in range(N)] # 隣接リスト
e=[ False for _ in range(N)] #訪問ずみかどうか
f=[0]*N  #答え
for i in range(N-1):
    a[i],b[i] = map(int,input().split())
    d[a[i]-1].add(b[i]-1)
    d[b[i]-1].add(a[i]-1)

maxi=max([len(d[i]) for i in range(N-1)])
print(maxi)
#print("c:",c)
#print("d",d)
#print("e",e)

#x=0としてBFSする

v=deque([0])
e[0]=True
color=1

while v:
  p = v.popleft()
  for q in d[p]:
    if e[q]==False:
      while color in c[p]:
        color +=1
        if color>maxi:
          color=1
      c[p].add(color)
      c[q].add(color)
      f[q]=color
      e[q]=True
      v.append(q)
      
for i in range(N-1):
  print( f[b[i]-1])
a,b,c = map(int(),input().split())
sum = a+b+c

if sum >= 22:
    print('bust')
else:
    print('win')


### FIXED CODE ###

a,b,c = map(int,input().split())
sum = a+b+c

if sum >= 22:
    print('bust')
else:
    print('win')
s = list(input())
print(s[:4] + ' ' + s[4:])

### FIXED CODE ###

s = input()
print(s[:4] + ' ' + s[4:])
from bisect import *

N,M,K,*f = map(int, open(0).read().split())
A = f[:N]
B = f[N:]
a_read = 0
b_read = 0
csa = [0]
for i in range(N):
    csa.append(csa[i]+A[i])
csb = [0]
for i in range(M):
    csb.append(csb[i]+B[i])
for i in range(N+M):
    if a_read == N:
        bs = bisect_right(csb,K-csa[N])
        b_read = bs - 1
        break
    elif b_read == M:
        bs = bisect_right(csa,K-csb[M])
        b_read = bs - 1
        break
    else:
        if A[a_read] < B[b_read]:
            bs = bisect_right(csa,min(csa[a_read]+B[b_read],K-csb[b_read]))
            if bs <= a_read:
                break
            else:
                a_read = bs - 1
        elif A[a_read] > B[b_read]:
            bs = bisect_right(csb,min(csb[b_read]+A[a_read],K-csa[a_read]))
            if bs <= b_read:
                break
            else:
                b_read = bs - 1
        else:
            if K - csa[a_read] - csb[b_read] >= A[a_read]:
                for j in range(1,N+M):
                    if A[a_read+j] < B[a_read+j]:
                        if K - csa[a_read+j-1] - csb[b_read] >= A[a_read+j]:
                            a_read += j
                            break
                        else:
                            a_read += j - 1
                            break
                    elif A[a_read+j] > B[a_read+j]:
                        if K - csa[a_read] - csb[b_read+j-1] >= B[a_read+j]:
                            b_read += j
                            break
                        else:
                            b_read += j - 1
                            break
                    else:
                        if K - csa[a_read+j-1] - csb[b_read] < A[a_read+j]:
                            a_read += j - 1
                            break
            else:
                break
print(a_read+b_read)

### FIXED CODE ###

from bisect import *

N,M,K,*f = map(int, open(0).read().split())
A = f[:N]
B = f[N:]
csa = [0]
ans = 0
for i in range(N):
    csa.append(csa[i]+A[i])
csb = [0]
for i in range(M):
    csb.append(csb[i]+B[i])
for i in range(N+1):
    if csa[i] <= K:
        bs = bisect_right(csb,K-csa[i])
        ans = max(ans,i+bs-1)
    else:
        break
print(ans)
N, K = map(int, input().split())
A = list(map(int, input().split()))

S = []
for l in range(0, N):
  temp = 0
  for r in range(l, N):
    temp += A[r]
    S.append(temp)

max_s = max(S)
n = max_s.bit_length()
S_temp = [S.copy(), []]
s_idx = 0
for i in range(n-1, -1, -1):
  c = 0
  for s in S_temp[s_idx]:
    if (s >> i) & 1:
      S_temp[s_idx-1].append(s)
      c += 1
  if c == K:
    ans = S_temp[s_idx-1][0]
    for _s in S_temp[s_idx-1]:
      ans &= _s
    print(ans)
    quit()
  if c > K:
    S_temp[s_idx] = []
    s_idx = not s_idx
  else:
    S_temp[s_idx-1] = []

ans = S_temp[s_idx][0]
for _s in S_temp[s_idx][:K]:
  ans &= _s

print(ans)

### FIXED CODE ###

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

S = []
for l in range(0, N):
  temp = 0
  for r in range(l, N):
    temp += A[r]
    S.append(temp)

max_s = max(S)
n = max_s.bit_length()
S_temp = [S, []]
s_idx = 0
for i in range(n-1, -1, -1):
  c = 0
  for s in S_temp[s_idx]:
    if (s >> i) & 1:
      S_temp[s_idx-1].append(s)
      c += 1
  if c == K:
    ans = S_temp[s_idx-1][0]
    for _s in S_temp[s_idx-1]:
      ans &= _s
    print(ans)
    quit()
  if c > K:
    S_temp[s_idx] = []
    s_idx = not s_idx
  else:
    S_temp[s_idx-1] = []

ans = S_temp[s_idx][0]
for _s in S_temp[s_idx][:K]:
  ans &= _s

print(ans)
solved_flag = False
if B==1:
    ans = 0
    solved_flag = True
else:
    if B <= N:
        x = B-1
    else:
        x = N

if not solved_flag:
    ans = math.floor(A*x/B) - A*math.floor(x/B)
print(ans)

### FIXED CODE ###

import math

A, B, N = map(int, input().split())

solved_flag = False
if B==1:
    ans = 0
    solved_flag = True
else:
    if B <= N:
        x = B-1
    else:
        x = N

if not solved_flag:
    ans = math.floor(A*x/B) - A*math.floor(x/B)
print(ans)
N=input()
s=list(map(int,input().split(' ')))
if len(set(s))==4:
    print('Four')
else:
    print('Three')

### FIXED CODE ###

N=input()
s=len(set(list(input().split(' '))))
if s==4:
    print('Four')
else:
    print('Three')