akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

//#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	long long H, W, N; cin >> H >> W >> N;
	map<int, map<int, bool>> mp;
	vector<P> v(N);
	rep(i, N) {
		int a, b; cin >> a >> b;
		mp[a][b] = true;
		v[i] = P(a, b);
	}
	vector<set<P>> anses(9);
	set<P> all;
	for (P p : v) {
		int a = p.X, b = p.Y;
		rep(i, -1, 2) rep(j, -1, 2) {
			int cnt = 0;
			int p = a + i, q = b + j;
			if (p <= 1 || q <= 1 || p + 1 > H || q + 1 > W) continue;
			rep(r, -1, 2) rep(c, -1, 2) {
				cnt += mp[p + r][q + c];
			}
			anses[cnt - 1].insert({ p,q });
			all.insert({ p,q });
		}
	}
	cout << (H - 2) * (W - 2) - all.size() << endl;
	for (auto& x : anses) cout << x.size() << endl;
	system("pause");
}

Measured memory_bytes: 249716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String[] str = sc.nextLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);

		// List<String> list = Arrays.asList(sc.nextLine().split(" "));

		// int min = list.stream().mapToInt(Integer::parseInt).min().getAsInt();

		// long count = list.stream().mapToInt(Integer::parseInt).filter(i -> i > min).count();

		int b = k - 1;
		int ans = (n - 1) / b;
		if ((n - 1) % b != 0) {
			ans++;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const long double epsilon=10e-18;
double ablog(long long base, long long x){
    return (double)log(x)/ (double) log(base);
}

int main()
{
    long long n,k;
    cin>>n>>k;
    if(n==1||n==0) cout<<n;
    else if((ablog(k,n)-(int)ablog(k,n)<=epsilon)) cout<<ablog(k,n);
    else cout<<(int)ablog(k,n)+1;
}


Measured memory_bytes: 512
#include <cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 100000
char ch[3]={'J','O','I'};
char flag[20][21];
int ref[15000],rev[1<<20];
int dp[2][1<<20][2];
int main() {
	int M,N;
	scanf("%d %d",&M,&N);
	int MASK=(1<<N)-1,mask=1<<(N-1);
	int ALL=1;
	rep(i,M) {
		getchar();
		rep(j,N) {
			flag[i][j]=getchar();
			if(flag[i][j]=='?') ALL=(ALL*3)%MOD;
		}
	}
	int ID=0;
	for(int S=0;S<(1<<N);S++) {
		if(S&1) continue;
		bool ok=true;
		for(int i=0;i<N;i++) if(((S>>i)&1)&&((S>>(i+1))&1)) ok=false;
		if(ok) {
			rev[S]=ID;
			ref[ID++]=S;
		}
	}
	int X=0;
	dp[1][0][0]=1;
	rep(i,M)rep(j,N) {
		rep(k,ID)rep(J,2)dp[X][k][J]=0;
		rep(k,ID)rep(J,2) {
			int S=ref[k];
			int D=dp[1-X][k][J];
			if(D==0) continue;
			if(flag[i][j]!='?') {
				if((S&mask)&&flag[i][j]=='I') continue;
				int ns=S;
				if(J==1&&flag[i][j]=='O') ns++;
				ns<<=1;
				dp[X][rev[ns&MASK]][(j==(N-1))?0:(flag[i][j]=='J')]=
					(dp[X][rev[ns&MASK]][(j==(N-1))?0:(flag[i][j]=='J')]+D)%MOD;
			}else {
				rep(c,3) {
					char use=ch[c];
					if(use=='J') {
						int ns=S<<1;
						dp[X][rev[ns&MASK]][j!=(N-1)]=
							(dp[X][rev[ns&MASK]][j!=(N-1)]+D)%MOD;
					}else if(use=='O') {
						int ns=S;
						if(J==1)ns++;
						ns<<=1;
						dp[X][rev[ns&MASK]][0]=
							(dp[X][rev[ns&MASK]][0]+D)%MOD;
					}else {
						if(S&mask) continue;
						int ns=S<<1;
						dp[X][rev[ns&MASK]][0]=
							(dp[X][rev[ns&MASK]][0]+D)%MOD;
					}
				}
			}
		}
		X=1-X;
	}
	int res=0;
	rep(i,ID)rep(J,2)res=(res+dp[1-X][i][J])%MOD;
	printf("%d\n",(ALL-res+MOD)%MOD);
}

Measured memory_bytes: 7304
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())

#neighbor
#0~N-1でアクセス
ngb = [[] for _ in range(N)]

#入力
#すべて-1ベースに
for _ in range(N-1):
  a,b = mi()
  a -= 1
  b -= 1
  ngb[a].append(b)
  ngb[b].append(a)

start = 0
goal = N-1

#nodes[番号][0]には探索済みならstartからの距離、未探索なら-1を格納
#nodes[番号][1]には（探索済みなら）「何番のノードから来たか(0~N-1)」を格納
nodes = [[-1, -1] for _ in range(N)]

#nodesにスタート地点を入れ、stackを初期化
nodes[start][0] = 0
nodes[start][1] = -1
stack = []
for eachngb in ngb[start]:
  stack.append(eachngb)
  nodes[eachngb][0] = 1
  nodes[eachngb][1] = start

#phase1 start->goalの最短距離を探索
while 1:
  try:
    nownode = stack.pop()
  except:
    break

  if nownode == goal:
    break

  #現在のノードとエッジで繋がるノードのうち、未探索のものをスタックに入れる
  #スタックに入れたらもう探索済みとする
  #木なので、ngb[]が空になっていることはありえない
  for eachngb in ngb[nownode]:
    if nodes[eachngb][0] == -1:
      stack.append(eachngb)
      #距離を+1して入れ、今のノード番号（どこから来たか、となる）を入れる
      nodes[eachngb][0] = nodes[nownode][0]+1
      nodes[eachngb][1] = nownode

#phase2 B, Wの根を見つける
length = nodes[goal][0] #スタートからゴールへの距離
FenRootPos = length // 2 #Fenの根がある距離
SnRootPos = FenRootPos + 1 #Snukeの根がある距離
FenRoot = -1 #Fenの根ノード番号
SnRoot = -1 #Snukeの根ノード番号

#ゴールからフェネックの根がある場所まで、順に逆走していく
nextnode = goal
#このループ内において、iは今見ているノードのスタートからの距離を表す
for i in range(length, FenRootPos-1, -1):
  nownode = nextnode
  if i == SnRootPos:
    SnRoot = nownode
  elif i == FenRootPos:
    FenRoot = nownode
  nextnode = nodes[nownode][1]

#phase3 B, Wそれぞれの根から、その木のノード数を数える
#お互いの根は探索済み(0)とすることで、重複を避ける

#まずはFen
#探索済みかどうか
ndsFen = [-1] * N
ndsFen[SnRoot] = 0
ndsFen[FenRoot] = 0
stkFen = []
stkFen.append(FenRoot)
FenCnt = 0
while 1:
  try:
    nownode = stkFen.pop()
  except:
    break

  #現在のノードとエッジで繋がるノードのうち、未探索のものをスタックに入れる
  #スタックに入れたらもう探索済みとする
  #木なので、ngb[]が空になっていることはありえない
  for eachngb in ngb[nownode]:
    if ndsFen[eachngb] == -1:
      stkFen.append(eachngb)
      #今回は距離は関係無いので、0を入れるだけでいい
      ndsFen[eachngb] = 1
      FenCnt += 1

#次はSnuke
#探索済みかどうか
ndsSn = [-1] * N
ndsSn[FenRoot] = 0
ndsSn[SnRoot] = 0
stkSn = []
stkSn.append(SnRoot)
SnCnt = 0
while 1:
  try:
    nownode = stkSn.pop()
  except:
    break

  #現在のノードとエッジで繋がるノードのうち、未探索のものをスタックに入れる
  #スタックに入れたらもう探索済みとする
  #木なので、ngb[]が空になっていることはありえない
  for eachngb in ngb[nownode]:
    if ndsSn[eachngb] == -1:
      stkSn.append(eachngb)
      #今回は距離は関係無いので、0を入れるだけでいい
      ndsSn[eachngb] = 1
      SnCnt += 1

print('Fennec' if FenCnt > SnCnt else 'Snuke')



Measured memory_bytes: 66992
use io::*;

fn main() {

    let con = read_string();
    let mut sc = Scanner::new(&con);

    let s: Vec<char> = sc.next::<String>().chars().collect();

    let mut ans: usize = 0;
    if s[0] == '1' { ans += 1; }
    if s[1] == '1' { ans += 1; }
    if s[2] == '1' { ans += 1; }

    println!("{}", ans);
}

pub mod io {

    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}

Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
long long  a, b, c, i, j, k, n, m;
int main() {
	long long  minn = 10000000000000;
	scanf("%lld", &a);
	for (i = 2; i <= sqrt(a)+1; i++) {
		if (a % i == 0) {
			minn = minn < (i + a / i) ? minn : (i + a / i);
		}
	}
	if (minn == 10000000000000)
	{
		printf("%lld", a - 1);
	}
	else
	{
		printf("%lld", minn - 2);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N, Q;
    cin >> N >> Q;

    string str;
    cin >> str;

    vector<ll> numac;
    numac.push_back(0);
    int cnt = 0;
    for (int i = 0; i < N-1; i++) {
        if (str[i] == 'A' && str[i+1] == 'C') {
            cnt++;
        }
        numac.push_back(cnt);
    }

    // for (int i = 0; i < (int)numac.size(); i++) {
    //     cout << numac[i] << endl;
    // }
    // cout << endl;

    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        r--; l--;
        cout << numac[r] - numac[l] << endl;
    }


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 2036
N = int(input())
card = []
for i in range(N):
    card.append(int(input()))
card.append(0)
ans = 0
for i in range(N):
    pair = card[i] // 2
    ans += pair
    card[i] -= pair * 2
    if card[i] == 1 and card[i+1] > 0:
        card[i] -= 1
        card[i+1] -= 1
        ans += 1
print(ans)


Measured memory_bytes: 7072
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    R,C = NMI()
    sy, sx = NMI()
    gy, gx = NMI()
    board = [list(input()) for _ in range(R)]

    #座標を0始まりにする
    sx -= 1
    sy -= 1
    gx -= 1
    gy -= 1

    #移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    #すべての点をINFで初期化
    INF = 10**7
    distance = [[INF for _ in range(C)] for _ in range(R)]

    #地点を保存するqueを作成、スタート地点を入れる
    que = deque([])
    que.append((sy,sx))

    #スタート地点の距離は0
    distance[sy][sx] = 0
    
    #テレポート移動のベクトル
    tx = [-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]
    ty = [-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2]
    
    #テレポート手前の地点を保存するqueを作成
    teleque = deque([])
    

    while len(que) != 0 or len(teleque) != 0:
        

        #queが空になるまでループ
        while len(que) != 0:

            #取り出してきた状態がゴールなら探索をやめる
            pop = que.popleft()
            if pop[0]==gy and pop[1]==gx:
                print(distance[gy][gx])
                sys.exit()

            #移動4方向をループ
            for i in range(len(dx)):
                #移動した後の点をny,nxとする
                ny = pop[0]+dy[i]
                nx = pop[1]+dx[i]


                #nyが0以上R未満   nxが0以上C未満     まだ訪れたことがない
                if 0<= ny < R and 0 <= nx < C and distance[ny][nx] == INF:

                    if board[ny][nx]!='#':
                        #つまり壁ではなく移動可能でまだ行ったことがなければqueの左へ入れる
                        que.appendleft((ny,nx))
                        distance[ny][nx] = distance[pop[0]][pop[1]]


                    else:
                        teleque.append((pop[0],pop[1]))
                        #つまり壁だった場合、壁をテレポートでよけて進めるかどうか。進めれて、まだ行ったことがなければqueの右へ入れる

        while len(teleque) != 0:
            telepop = teleque.popleft()
            if telepop[0]==gy and telepop[1]==gx:
                print(distance[gy][gx]+1)
                sys.exit()


                #テレポートのループ
            for j in range(len(tx)):
                teley = telepop[0]+ty[j]
                telex = telepop[1]+tx[j]
                #print(teley,telex)
                #nyが0以上R未満   nxが0以上C未満     まだ訪れたことがない
                if 0<= teley < R and 0 <= telex < C and distance[teley][telex] == INF:
                    if board[teley][telex]!='#': #テレポート先が壁でないならqueの右へ入れる
                        que.append((teley,telex))
                        distance[teley][telex] = distance[pop[0]][pop[1]]+1 #テレポート使用回数を1回加算

    print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 129296
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long check(long long a,long long b){
    return a/b;
}
int main(){
    long long a,b,c,d; cin >> a >> b >> c >> d;
    long long tmp = LCM(max(c,d),min(c,d)),ans = 0;
    ans += check(b,c)-check(a-1,c);
    ans += check(b,d)-check(a-1,d);
    ans -= check(b,tmp)-check(a-1,tmp);
    cout << b-a+1-ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    string s, t;
    cin >> s >> t;

    vector<int> trans(26, -1), rev_trans(26, -1);
    bool flg = true;
    for (auto i = 0; i < (int)s.size(); i++) {
        if(trans[s[i] - 'a'] < 0) trans[s[i] - 'a'] = t[i] - 'a';
        else if(trans[s[i] - 'a'] != t[i] - 'a') { flg = false; break; }
        if(rev_trans[t[i] - 'a'] < 0) rev_trans[t[i] - 'a'] = s[i] - 'a';
        else if(rev_trans[t[i] - 'a'] != s[i] - 'a') { flg = false; break; }
    }

    cout << ((flg) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;

int gcd(int n, int m)
{
  if (n < m) return gcd(m, n);
  if (m == 0) return n;
  return gcd(m, n % m);
}

int main()
{
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int g = gcd(n, m);
  for (int i = 0; i < g; i++) {
    if (s.at(n / g * i) != t.at(m / g * i)) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << (long) n * m / g << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,d,x;
  cin >> n >> d >> x;
  d--;
  int ans = 0;
  rep(i, n){
    int a;
    cin >> a;
    ans += d / a + 1;
  }
  cout << ans + x << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();
            String[] L = S.Split(' ');

            int[] W = new int[N];
            for(int i=0; i<N; i++)
            {
                W[i] = int.Parse(L[i]);
            }

            int W1 = W[0];
            int W2 = W.Sum() - W[0];
            int ans = W2 - W1;
            int res;

            for(int i=1; i<N; i++)
            {
                W1 = W1 + W[i];
                W2 = W2 - W[i];
                res = W2 - W1;
                if(res < 0)
                {
                    res = res * -1;
                }
                if (res < ans)
                {
                    ans = res;
                }

            }

            Console.WriteLine(ans);
            

        }
    }
}

Measured memory_bytes: 13268
#include "iostream"
#include "vector"
#include "cmath"

using namespace std;
typedef long long ll;

int main()
{
  ll n;
  cin >> n;

  long long ans = 1;
  ll max = 1000000000LL * 1000000000LL;

  bool overflow = false;
  for (auto i = 0; i < n; i++)
  {
    long long a;
    cin >> a;

    if (a == 0)
    {
      cout << 0 << endl;
      return 0;
    }

    if (ans && ans > numeric_limits<ll>::max() / a)
    {
      overflow = true;
      continue;
    }

    ans *= a;
    if (ans > max)
    {
      overflow = true;
      continue;
    }
  }

  if (overflow)
  {
    cout << -1 << endl;
    return 0;
  }
  else
  {
    cout << ans << endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		    Scanner sc = new Scanner(System.in);

		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    int max = a;
		    if(b > max) {
		    	max = b;
		    }
		    if(c > max) {
		    	max = c;
		    }
		    System.out.println(a + b + c + max*9);
		    sc.close(); }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    long long d;
    cin>>d;
    int f=0;
    int l=s.size();
    for(long long  i=0;i<d;i++)
    {
        if(s[i]>='2'&&s[i]<='9')
        {
            f=5;
            cout<<s[i]<<endl;
            break;
        }
        if(i>=(l-1))
        {
            break;
        }
    }
    if(f==0)
    {
        cout<<"1"<<endl;
    }
return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    public class Program
    {
        static long mod = (long)Math.Pow(10, 9) + 7;

        public static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int[] ans = new int[s.Length];

            bool getL = false;
            int startIndex = 0;
            int[] mid = null;

            for (int i = 0; i < s.Length; i++)
            {
                if (!getL && s[i + 1] == 'L')
                {
                    getL = true;
                    mid = new int[2] { i, i + 1 };
                }
                else if (getL&&i+1==s.Length||getL && s[i + 1] == 'R')
                {
                    int all = i - startIndex + 1;
                    if (all % 2 == 0)
                    {
                        ans[mid[0]] = all / 2;
                        ans[mid[1]] = all / 2;
                    }
                    else
                    {
                        if ((mid[0] - startIndex) % 2 == 0)
                        {
                            ans[mid[0]] = all / 2 + 1;
                            ans[mid[1]] = all / 2;
                        }
                        else
                        {
                            ans[mid[0]] = all / 2;
                            ans[mid[1]] = all / 2 + 1;
                        }
                    }
                    startIndex = i + 1;
                    mid = null;
                    getL = false;
                }
            }

            Console.WriteLine(string.Join(" ",ans));
            Console.ReadLine();
        }
    }


}


Measured memory_bytes: 17244
public class Main {

	public static void main(String[]args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int x;
		for (int i = 1; i <= 10000; i++) {
			x = sc.nextInt();
			if (x == 0) {
				break;
			}
			System.out.println("Case " + i + ": " + x);
		}
		sc.close();
	}
}



Measured memory_bytes: 42372
#include <iostream>
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;
	int A[n][m], B[m], ans;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		cin >> B[i];
	}
	for(int i = 0; i < n; i++){
		ans = 0;
		for(int j = 0; j < m; j++){
			ans += A[i][j]*B[j];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<cstdlib>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds; 
//#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef long double ld;
typedef vector < pair < ll, ll > > vpll;
#define Boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define forn(i,n) for (ll i = 0; i < n; i++)
#define fo(i,n) for (ll i = 1; i <= n; i++)
#define fore(i,l,r) for (ll i = l; i <= r; i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define MAX 1000000007
ll power(ll a,ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fact[500009];
ll fermat_inv(ll y){return power(y,MOD-2);}
ll nCrMod(ll n, ll r){ ll p=fact[n];ll q=(fact[r]*fact[n-r])%MOD;return (p*fermat_inv(q))%MOD;} 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
const ld PI = acos(-1.0);
vector<int> g[200009];
struct query{
  int l,r,ind;
};
bool cmp(query x,query y)
{
  return x.r<=y.r;
}
ll BIT[500009]={0};
void update(ll x,ll y,ll n)
{
  for(;x<=n;x+=x&-x)
    BIT[x]+=y;
}
ll sum(ll x,ll n)
{
  ll s=0;
  for(;x>0;x-=x&-x)
    s+=BIT[x];
  return s;

}
  int main(){
      #ifndef ONLINE_JUDGE
      freopen("input.cpp","r",stdin);
      freopen("output.cpp","w",stdout);
      #endif
      Boost();
      int t;
      //cin>>t;
      t=1;
      int t1=t;
      while(t--)
      { 
        ll n,q;
        cin>>n>>q;
        ll a[n+1];
        fo(i,n)
        cin>>a[i];
        query qu[q+1];
        fo(i,q)
        {
          cin>>qu[i].l>>qu[i].r;
          qu[i].ind=i;
        }
        sort(qu+1,qu+q+1,cmp);
        ll lst[500007];
        memset(lst,-1,sizeof(lst));
        int c=1;
        ll ans[q+1];
        fo(i,n)
        {
          if(lst[a[i]]!=-1)
            update(lst[a[i]],-1,n);
          lst[a[i]]=i;
          update(lst[a[i]],1,n);
          while(c<=q&&qu[c].r==i)
          {
            ans[qu[c].ind]=sum(qu[c].r,n)-sum(qu[c].l-1,n);
            c++;
          }
        }
        fo(i,q)
        cout<<ans[i]<<endl;

      }
      return 0;
      }
  

Measured memory_bytes: 29900
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
    
  int a;
  cin >> a;
  ll ans = a + a*a + a*a*a;
  cout << ans << endl;


}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n,m,k;
int a[maxn],b[maxn];

int32_t main()
{
    IOS
    cin>>n>>m>>k;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=m;i++) cin>>b[i];
    int ans=inf;
    for (int i=1;i<=k;i++)
    {
        int x,y,c;
        cin>>x>>y>>c;
        ans=min(ans,a[x]+b[y]-c);
    }
    int minn1=inf,minn2=inf;
    for (int i=1;i<=n;i++) minn1=min(minn1,a[i]);
    for (int i=1;i<=m;i++) minn2=min(minn2,b[i]);
    cout<<min(ans,minn1+minn2)<<endl;
}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

main()
{
	IOS
	
	int a, b;
	cin >> a >> b;
	
	cout << a - (b < a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;
 
const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
 
 
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);
 
	string s;
	cin >> s;
	int n = s.size();
 
	int k;
	cin >> k;
 
	ll dp[n+1][k][2];
	memset(dp, 0, sizeof dp);
	dp[0][0][1] = 1;
	for (int i=0; i<n; i++) {
		int d = s[i]-'0';
		for (int j=0; j<k; j++) {
			dp[i+1][j][1] = dp[i][(j+d)%k][1];
			for (int c=0; c<10; c++) {
				if (c<d) dp[i+1][j][0] += dp[i][(j+c)%k][1];
				dp[i+1][j][0] += dp[i][(j+c)%k][0];
			}
			dp[i+1][j][0] %= MOD;
		}
	}

	ll ans = dp[n][0][0] + dp[n][0][1] - 1;
	cout << (ans + MOD) % MOD << nl;
 
	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int n;
    ll d,a;
    cin >> n >> d >> a;
    vector <pair<ll,ll>> ar(n);
    for(auto &i : ar)
        cin >> i.first >> i.second;
    sort(all(ar));
    ll pos;
    ll ans = 0;
    vector <ll> power(n + 1);
    ll curPower = power[0];
    for(int i = 0; i < n;){
        pos = ar[i].first + 2*d; 
        ll cntBombs = (ll)ceil(ar[i].second / (double)a);
        ans += cntBombs;
        int l = i, r = n;
        while(l < r){
            int mid = (l + r) >> 1;
            ll curPos;
            if(mid == n)
                curPos = tINF;
            else {
                curPos = ar[mid].first; 
            }
            if(curPos > pos)
                r = mid;
            else
                l = mid + 1;
        }
        ll newPower = cntBombs * a;
        curPower -= power[i];
        power[i] += newPower;
        curPower += power[i];
        power[l] -= newPower;
        if(i + 1 == n)
            break;
        for(int j = i + 1; j < n; ++j){
            curPower += power[j];
            if(ar[j].first > pos){
                i = j;
                break;
            }
            if(ar[j].second <= curPower){
                ar[j].second = 0;
                i = j + 1;
                continue;
            }
            else{
                ar[j].second -= curPower;
                i = j;
                break;
            }
        }
    }
    cout << ans << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (true) {
      int n = sc.nextInt();
      int x = sc.nextInt();
      int count = 0;
      if (n == 0 && x == 0) {
        break;
      }
      for (int i = 1; i <= n - 2; i++) {
        for (int j = i + 1; j <= n - 1; j++) {
          for (int k = j + 1; k <= n; k++) {
            int sum = i + j + k;
            if (sum == x) {
              count++;
            }
          }
        }
      }
      System.out.println(count);
    }
  }
}



Measured memory_bytes: 27044
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  int ans = 0;
  int cnt = 1;
  a.push_back(inf);
  REP(i,n+1) {
    if(a[i] != a[i-1]) {
      ans += cnt%2 != 0;
      cnt = 0;
    }
    cnt++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
    unsigned long long N, A, B;

    // input
    scanf("%llu %llu %llu", &N, &A, &B);

    unsigned long long set = N / (A + B);
    unsigned long long blueBall = A * set;

    unsigned long long mod = N % (A + B);
    if (mod >= A) {
        blueBall += A;
    } else {
        blueBall += mod;
    }

    // output
    printf("%llu\n", blueBall);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;

int a, b, c;

int main(){
    cin >> a >> b >> c;
    if ((c > a+b) && (long long) 4*a*b < (long long)(c-a-b)*(c-a-b)) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
S = int(input())

if S == 1 or S ==2:
  print(0)
elif S == 3 or S == 4 or S == 5:
  print(1)
else:
  #初期化
  dp = [0]*S
  dp[2] = 1
  dp[3] = 1
  dp[4] = 1
  dp_S = 0
  #dp
  for i in range(5,S):
    dp_S += dp[i-3] 
    dp[i] = 1+dp_S

  print(dp[S-1]%1000000007)

Measured memory_bytes: 9152
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10**9 + 7
x = (k*(k+1)//2)%mod
y = (k*(k-1)//2)%mod

r = 0
for i in range(n):
    right = sum(a[i] > j for j in a[i:])
    left = sum(a[i] > j for j in a[:i+1])
    r = (r+((right*x) + (left*y))%mod)%mod
print(r)

Measured memory_bytes: 74772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  int n_size = N.size();
  char one = N.at(n_size-1);
  
  if(one == '3'){
  	cout<<"bon"<<endl;
  }else if(one == '0' || one== '1' || one== '6' || one== '8' ){
  	cout<<"pon"<<endl;
  }else{
  cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
ll dp[10001];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h, n, i, prev = 0, j;
    cin>>h>>n;
    for(i=1; i<=h; i++) {
    	dp[i] = 1e16;
    }
    vector<pair<ll, ll>> v(n);
    for(i=0; i<n; i++) {
    	cin>>v[i].ss>>v[i].ff;
    }
    for(i = 1 ; i <= h; i++) {
    	for(j=0; j<n; j++) {
    		if( i - v[j].ss <= 0) {
    			dp[i] = min(dp[i], v[j].ff);
    		} else {
    			dp[i] = min(dp[i], dp[i - v[j].ss] + v[j].ff);
    		}
    	}
    }
    cout<<dp[h]<<"\n";
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

signed main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> l(n);
    for(int i = 0;i < n;i ++) cin >> l.at(i);
    sort(l.begin(),l.end());

    int ans = 0;
    for(int i = 0;i < n;i ++){
        for(int j = i+1;j < n;j ++){
            auto itr1 = upper_bound(l.begin(),l.end(),l.at(i)+l.at(j)-1);
            int k = itr1 - l.begin()-1;

            ans += k - j;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    const char Wh = '.';
    const char Bl = '#';
    const char Sp = ' ';

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = int.Parse(spl[1]);

        var pR = new List<int>();
        var pL = new List<int>();

        spl = input.ReadLine().Split(' ');
        for (int i = 0; i < n; i++) {
            var x = int.Parse(spl[i]);
            if (x < 0) {
                pL.Add(Math.Abs(x));
            } else if(x > 0) {
                pR.Add(Math.Abs(x));
            } else {
                k--;
                if (k == 0) return 0;
            }
        }

        pR.Sort();
        pL.Sort();

        long min = int.MaxValue;

        var p1 = pR;
        var p2 = pL;
        for (int i=0; i< p1.Count; i++) {
            var cost = p1[i];

            if((i+1) < k) {
                var j = k - (i + 1) - 1;
                if(j < p2.Count) {
                    cost += p2[j] * 2;
                } else {
                    continue;
                }
            }

            min = Math.Min(min, cost);
        }

        p1 = pL;
        p2 = pR;
        for (int i = 0; i < p1.Count; i++) {
            var cost = p1[i];

            if ((i + 1) < k) {
                var j = k - (i + 1) - 1;
                if (j < p2.Count) {
                    cost += p2[j] * 2;
                } else {
                    continue;
                }
            }

            min = Math.Min(min, cost);
        }

        return min;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 21216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

vector<vector<int> > dp(5005, vector<int>(5005));
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  for (int i = n - 2; i >= 0; --i) for (int j = n - 1; j >= i + 1; --j) {
    if (s[i] == s[j]) {
      dp[i][j] = min(dp[i + 1][j + 1] + 1, j - i);
    } else {

    }
  }
  int ans = 0;
  rep(i, n) rep3(j, i + 1, n) chmax(ans, dp[i][j]);
  cout << ans << endl;
  // rep(i, n) { rep(j, n) cerr << dp[i][j] << " "; cerr << endl; }
}


Measured memory_bytes: 101692
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, fib[50];

signed main(){
    fib[0] = 1;
    fib[1] = 1;
    for(int i = 2; i < 45; i++){
        fib[i] = fib[i - 1] + fib[i - 2];
    }
    cin >> N;
    cout << fib[N] << endl;


    return 0;
}

/*

*/


Measured memory_bytes: 3112
#include <bits/stdc++.h>

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005;
int n, q, to[26][MX];
string s;
char t[MX], d[MX];

int f (int i) {
	int j = 0;

	while (0 <= i && i < n && to[s[i] - 'A'][j] != -1) {
		j = to[s[i] - 'A'][j];
		if (d[j] == 'L') i--;
		else i++;
		j++;
	}

	if (i < 0) return -1;
	if (i >= n) return 1;
	return 0;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(to, -1, sizeof(to));
	
	cin >> n >> q >> s;
	forn (i, q) {
		cin >> t[i] >> d[i];
		to[t[i] - 'A'][i] = i;
	}

	for (int i = q - 1; i >= 0; i--)
		forn (j, 26)
			if (to[j][i] == -1)
				to[j][i] = to[j][i + 1];

	int res = n;

	int i = 0, j = n - 1, rep = 20;
	while (rep--) {
		int m = (i + j + 1) / 2;
		if (f(m) == -1) i = m;
		else j = m;
	}
	if (f(i) == -1) res -= i + 1;

	i = 0, j = n - 1, rep = 20;
	while (rep--) {
		int m = (i + j) / 2;
		if (f(m) == 1) j = m;
		else i = m;
	}
	if (f(j) == 1) res -= n - j;

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 21328
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n, m, b[100001], ans[100001];

signed main()
{

 	FLASH

 	cin>>n>>m;
 	ans[0] = 1;
 	fr(i, 1, m + 1){
 		int x;
 		cin>>x;
 		b[x] = 1;
 	}

 	ans[1] = !b[1];
 	fr(i, 2, n + 1){
 		ans[i] = (!b[i - 1])*ans[i - 1] + (!b[i - 2])*ans[i - 2];
 		ans[i] %= mod;
 	}

 	cout<<ans[n];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int mod = 1e9 + 7;


int n;
int dp[25][1<<22];
int mat[25][25];


ll int kil(int idx, int mask)
{
  if(idx == n)
  {
    if( __builtin_popcount(mask) == n)
      return 1;
    return 0;
  }

  if(dp[idx][mask] != -1)
    return dp[idx][mask];

  dp[idx][mask] = 0;
  for(int j=0;j<n;j++)
  {
    if(mat[idx][j] &&  (mask & (1<<j)) == 0)
      dp[idx][mask] = (dp[idx][mask] + kil(idx+1, mask | (1<<j))) % mod;
  }

  return dp[idx][mask];
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  memset(dp, -1, sizeof dp);
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin>>mat[i][j];

  cout<<kil(0, 0)<<endl;

  return 0;
}


Measured memory_bytes: 409856
#include<bits/stdc++.h>
using namespace std;

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll n,k;cin>>n>>k;
  vector<int> a(n);
  int i;
  rep(i,n)cin>>a[i];
  rep(i,n)a[i]--;
  vector<int> fvisit(n,-1);
  fvisit[0]=0;
  int times=0;
  int now=0;
  while(times<k)
  {
    times++;
    now=a[now];
    if(fvisit[now]!=-1)
    {
      break;
    }
    else
    {
      fvisit[now]=times;
    }
  }
  if(times==k)
  {
    cout<<now+1<<endl;
  }
  else
  {
    ll loop=times-fvisit[now];
    ll left=k-fvisit[now];
    left%=loop;
    while(left>0)
    {
      now=a[now];
      left--;
    }
    cout<<now+1<<endl;
  }
}

Measured memory_bytes: 4840
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (a, b, t) = parse_line!(i32, i32, i32);
    let mut num = 0;
    let mut tmp = a;
    while tmp <= t {
        num += b;
        tmp += a;
    }
    println!("{}", num);
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
	val (n, a, b) = readLine()!!.split(" ").map{ it.toInt() }
	val arr = LongArray(n)
	for (i in 0..(n - 1)) {
		val num = readLine()!!.toLong()
		arr[i] = num
	}
	val base = b.toLong()
	val diff = (a - b).toLong()
	var l = 0L
	var r = 1000000000L
	while (r - l > 1) {
		val mid = (l + r) / 2
		if (judge(mid, base, diff, arr)) {
			r = mid
		} else {
			l = mid
		}
	}
	println(r)
}

fun judge(k: Long, base: Long, diff: Long, arr: LongArray): Boolean {
	var sum = 0L
	for (v in arr) {
		val times = (v - base * k + diff - 1) / diff 
		if (times > 0) {
			sum += times
		}
	}
	return sum <= k
}

Measured memory_bytes: 43036
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

vector<int> input;
int N;

ll solve(int siz){
	deque<ll> P,Q;
	rep(i,N)P.push_back(input[i]);
	if(siz>0){
		Q.push_back(P.front());
		P.pop_front();
	}else{
		Q.push_back(P.back());
		P.pop_back();
	}
	// show(Q);
	while(!P.empty()){
		if(siz > 0){
			if(P.size()<2){
				ll t = P.back(); P.pop_back();
				if(abs(Q.front()-t) > abs(Q.back()-t)){
					Q.push_front(t);
				}else{
					Q.push_back(t);
				}
				break;
			}
			ll mb = P.back(); P.pop_back();
			ll lb = P.back(); P.pop_back();
			Q.push_front(mb);
			Q.push_back(lb);
		}else{
			if(P.size()<2){
				ll t = P.back(); P.pop_back();
				if(abs(Q.front()-t) > abs(Q.back()-t)){
					Q.push_front(t);
				}else{
					Q.push_back(t);
				}
				break;
			}
			ll ms = P.front(); P.pop_front();
			ll ls = P.front(); P.pop_front();
			Q.push_front(ms);
			Q.push_back(ls);
		}
		siz *= -1;
	}
	// show(Q);
	ll ans = 0;
	ll bf = Q.front();
	Q.pop_front();
	while(!Q.empty()){
		ans += abs(bf-Q.front());
		bf = Q.front();
		Q.pop_front();
	}
	return ans;
}

int main(){
	cin>>N;
	input.resize(N);
	rep(i,N)cin>>input[i];
	sort(all(input));
	ll ans_a = solve(1);
	ll ans_b = solve(-1);
	cout<<max(ans_a, ans_b)<<endl;
	return 0;
}

Measured memory_bytes: 1536