akhauriyash/Code-Regression huggingface dataset:
S = int(input())
MOD = 10**9 + 7
pattern = S//3
ans = 0
factorial = [1] * 10000
for i in range(1,10000):
  factorial[i] = factorial[i-1] * i
  factorial[i] = factorial[i] % MOD
  

for i in range(1, pattern+1):
  x = S - (3 * i)
  y = i - 1
  ans += factorial[x + y] % MOD * pow(factorial[x], MOD-2, MOD) % MOD * pow(factorial[y],MOD-2, MOD)
  ans %= MOD
print(ans%MOD)

Measured memory_bytes: 63804
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		long[] X = new long[N];
		long[] Y = new long[N];

		Y[0] = -A[0];
		X[0] = A[0];
		for (int i = 1; i < N - 1; i++) {
			long x1 = X[i-1];
			long y1 = Y[i-1];
			Y[i] = Math.max(-A[i] + x1, A[i] + y1);
			X[i] = Math.max(A[i] + x1, -A[i] + y1);
		}
		long x = A[N-1] + X[N-2];
		long y = -A[N-1] + Y[N-2];

		System.out.println(Math.max(x, y));
	}
}


Measured memory_bytes: 50076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min(b/a, c) << endl;
}

Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
py=[list(map(int,input().split())) for i in range(m)]
for i in range(m):
    py[i].append(i)

py.sort()
anslst=[""]*m
dic=defaultdict(int)

for i in range(m):
    p,y,index=py[i]
    dic[p]+=1
    pnum=str(p)
    pnum="0"*(6-len(pnum))+pnum
    ynum=str(dic[p])
    ynum="0"*(6-len(ynum))+ynum
    anslst[index]=pnum+ynum
for i in range(m):
    print(anslst[i])

Measured memory_bytes: 102716
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;

using ll = long long;

struct point
{
	ll x, y;
};

double dist(point a, point b, int rr)
{
	auto ret = sqrtl((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) - rr;
	if (ret < 0)return 0.0;
	return (double)ret;
}

struct circle
{
	point center;
	ll radius;
};
circle cc[1234];
ll n;
struct edge
{
	ll to;
	double cost;
};
vector<edge>graph[1234];
double memo[1234];
double dijkstra()
{
	fill(memo, memo + 1234, 1e18);
	memo[0] = 0.0;
	priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>>que;
	que.push({ 0.0,0 });
	while (!que.empty())
	{
		auto pp = que.top();
		que.pop();
		int nowv = pp.second;
		if (memo[nowv] < pp.first)continue;
		for (auto ed : graph[nowv])
		{
			if (memo[ed.to] > memo[nowv] + ed.cost)
			{
				memo[ed.to] = memo[nowv] + ed.cost;
				que.push({ memo[ed.to],ed.to });
			}
		}
	}
	return memo[n + 1];
}

int main(void)
{
	ll xs, ys, xt, yt;
	scanf("%lld %lld %lld %lld", &xs, &ys, &xt, &yt);
	scanf("%lld", &n);
	cc[0] = { {xs,ys},0 };
	cc[n + 1] = { {xt,yt},0 };
	for (int i = 0; i < n; ++i)
	{
		ll x, y, r;
		scanf("%lld %lld %lld", &x, &y, &r);
		cc[i + 1] = { {x,y},r };
	}
	for (int i = 0; i <= n + 1; ++i)
	{
		for (int j = 0; j <= n + 1; ++j)
		{
			if (i == j)continue;
			double cost = dist(cc[i].center, cc[j].center, cc[i].radius + cc[j].radius);
			graph[i].push_back({ j,cost });
			//graph[j].push_back({ i,cost });
		}
	}
	double ans = dijkstra();
	printf("%.12lf\n", ans);
	return 0;
}


Measured memory_bytes: 20592
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n, m = [int(x) for x in input().split()]
    d = defaultdict(int)
    for i in range(n):
        s = input()
        for e in s:
            d[e] += 1
    odd = 0
    q = 0
    for c in d:
        odd += d[c] % 2
        q += d[c] // 4
    if n % 2 and m % 2:
        if odd == 1 and q * 4 >= (n * m - (n + m - 1)):
            print("Yes")
        else:
            print("No")
    elif n % 2 != m % 2:
        ev = n
        if m % 2 == 0: ev = m
        if q * 4 < n * m - ev or odd:
            print("No")
        else:
            print("Yes")
    else:
        if q * 4 != n * m:
            print("No")
        else:
            print("Yes")


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
a b a
d c d
a b a
"""


Measured memory_bytes: 9932
// AtCoder Beginner Contest 088 - Problem C: Takahashi's Information (https://abc088.contest.atcoder.jp/tasks/abc088_c)
#include <bits/stdc++.h>

using namespace std;

int M[3][3];

bool bf(int a1, int b1)
{
    int as[] { a1, M[1][0] - b1, M[2][0] - b1 };
    int bs[] { b1, M[0][1] - a1, M[0][2] - a1 };

    for (int i = 0; i < 3; ++i) 
        for (int j = 0; j < 3; ++j)
            if (M[i][j] != (as[i] + bs[j]))
                return false;

    return true;
}

int main()
{
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> M[i][j];

    for (int a1 = -100; a1 <= 100; ++a1)
    {
        int b1 = M[0][0] - a1;

        if (bf(a1, b1))
        {
            cout << "Yes\n";
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            String x = in.next();
            int pre[] = new int[x.length() + 1];
            for (int i = 1; i < x.length(); i++) {
                if (x.charAt(i) == 'C' && x.charAt(i - 1) == 'A') {
                    pre[i + 1] = pre[i] + 1;
                } else {
                    pre[i + 1] = pre[i];
                }
            }
//        for(int i=0;i<=x.length();i++){
//            out.print(pre[i] + " ");
//        }
//        out.println();
            while (q-- > 0) {
                int l = in.nextInt();
                int r = in.nextInt();
                out.println(pre[r] - pre[l]);
            }


        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 41828
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n[]={1,3,1,2,1,2,1,1,2,1,2,1};
  int a,b;
  cin>>a>>b;
  if(n[a-1]==n[b-1])
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())

using namespace std;

int main() {

	int i, j, k;
	int a, b;
	cin >> a >> b;
	if ((a % 3 == 0) | (b % 3 == 0) | (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

using namespace std;
int main()
{
	long long a,b;
	char c;
	cin>>a;
	while((c=getchar())!=EOF&&c^'+'&&c^'-');
	cin>>b;
	if(c=='+')
		cout<<a+b;
	else if(c=='-')
		cout<<a-b;
    return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

int t[5 * maxn], a[maxn], lazy[5 * maxn];

int doit(int a, int b) {
    return a + b;
}

void build(int start, int end, int index = 1) {
    if (start == end) {
        t[index] = 0;
        return;
    }

    int mid = start + end >> 1;
    build(start, mid, index << 1);
    build(mid + 1, end, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

int query(int start, int end, int l, int r, int index = 1) {
    //Invalid range
    if (r < start or l > end)
        return 0;

    //In range
    if (l <= start and end <= r) {
        return t[index];
    }

    int mid = start + end >> 1;
    return doit(query(start, mid, l, r, index << 1), query(mid + 1, end, l, r, index << 1 | 1));
}

void pUpdate(int start, int end, int point, int val, int index = 1) {
    if (start == end) {
        t[index] += val;
        return;
    }

    int mid = start + end >> 1;
    if (point <= mid)
        pUpdate(start, mid, point, val, index << 1);
    else
        pUpdate(mid + 1, end, point, val, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void rangeUpdate(int start, int end, int l, int r, int val, int index) {

}

void solve() {
    int n, q;
    cin >> n >> q;

    build(0, n - 1, 1);

    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;

        int x, y;
        cin >> x >> y;

        if (a == 0) {
            pUpdate(0, n - 1, x - 1, y, 1);
        } else {
            cout << query(0, n - 1, x - 1, y - 1, 1) << endl;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 5240
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String inStr = input.nextLine();
        char inX = inStr.charAt(0);
        char inY = inStr.charAt(2);
        if(inX < inY){
            System.out.println("<");
        }
        else if(inX > inY){
            System.out.println(">");
        }
        else{
            System.out.println("=");
        }
    }
}

Measured memory_bytes: 23636
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
#include <numeric>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long int ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	ll a[100] = {};
	ll b[100] = {};
	ll c[100] = {};
	ll d[100] = {};

	//ll v[3] = {};
	//ll *c, *s, *n;
	string S,T,U[52];
	ll count = 0;
	ll count2 = 0;
	ll sum = 0;
	ll min = 100000000000000;
	ll max = 0;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	
	
	//char p;


	

	

	//cin >> S;
	
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);

	
	cin >>N >> M;
	rep(i, 0, N) {
		cin >> a[i] >> b[i];
	}
	
	rep(i, 0, M) {
		cin >> c[i] >> d[i];
	}
	
	rep(i, 0, N) {

		rep(j, 0, M) {
			
			if (min > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				count = j + 1;
				min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			}

		}
		cout << count << endl;
		count = 0;
		min = 100000000000000;


	}
		
	
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	

	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	return 0;

}

ll gcd(ll a, ll b) {
	
	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y/b*x;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  
  int x,a,b;
  
  cin >> x >> a >> b;

  if (abs(x-a) < abs(x-b)) {
    cout << "A" << endl;    
  } else {
    cout << "B" << endl;
  }

  return 0;
}



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

int main() {
  int n;cin >> n;
  int a[n];
  int b[n];
  int c[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
  }
  for(int i = 0; i < n; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }
  int ans = 0;
  int temp = 100;
  for(int i = 0; i < n; i++){
    ans += b[a[i]];
    if(temp+1 == a[i]){
      ans += c[temp];
    }
    temp = a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
use std::collections::HashMap;

fn main() {
    proconio::input! {
        n: usize,
        a: [i32; n],
    }
    let mut ans: i64 = 0;
    let mut map = HashMap::new();
    for i in 0..n {
        if map.contains_key(&(i as i32 - a[i])) {
            ans += map[&(i as i32 - a[i])] as i64;
        }
        *map.entry(i as i32 + a[i]).or_insert(0) += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 7888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define umap unordered_map
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main(){
  int n;
  cin>>n;
  
  vector<int> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  
  sort(all(a));
  sort(all(c));
  
  ll ans=0;
  rep(i,n){
    auto x=lb(all(a),b[i]);
    auto y=ub(all(c),b[i]);
    ans+=(ll)(x-a.begin())*(c.end()-y); 
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 1408
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = input()
a = list(map(lambda x:int(x)-1, list(a)))
b = [0 if i % 2 == 0 else i for i in a]
cnt = 0
for i in range(n):
    if b[i] % 2:
        if (n-1) & i == i:
            cnt += 1
if cnt % 2:
    print(1)
else:
    if 1 in b:
        print(0)
    else:
        c = [i // 2 if i % 2 == 0 else i for i in a]
        cnt = 0
        for i in range(n):
            if c[i] % 2:
                if (n-1) & i == i:
                    cnt += 1
        if cnt % 2:
            print(2)
        else:
            print(0)

Measured memory_bytes: 148224
using System;
using System.Collections.Generic;

namespace _0009 {

	public static class Program {

		public static void Main() {
			var cache = new Dictionary<int, bool>();

			string input;
			while (!string.IsNullOrEmpty(input = Console.ReadLine())) {
				var x = int.Parse(input);
				var count = 0;

				for (int i = 2; i <= x; i++) {
					bool prime = false;
					if (cache.ContainsKey(i)) {
						prime = cache[i];
					} else {
						prime = IsPrime(i);
						cache.Add(i, prime);
					}

					if (prime) {
						count++;
					}
				}

				Console.WriteLine(count);
			}
		}

		private static bool IsPrime(int x) {
			if (x == 2) {
				return true;
			}
			if (x < 2 || x % 2 == 0) {
				return false;
			}

			for (int i = 3; i <= Math.Sqrt(x); i += 2) {
				if (x % i == 0) {
					return false;
				}
			}

			return true;
		}

	}

}

Measured memory_bytes: 54408
#include <iostream>
#include <vector>
#include <cassert>

typedef size_t baumkuchen_size_t;
typedef int index_t;

std::vector<baumkuchen_size_t> pieces;
baumkuchen_size_t whole_size; // SUM OF SIZE OF PIECES
baumkuchen_size_t max_size;   // MAX SIZE OF THE SMALLEST PIECE


inline void reguralize(index_t *x)
{
    if ((*x) < 0)
        (*x) += pieces.size();
    (*x) %= pieces.size();
}


inline void progress_idx(
    index_t &idx,
    baumkuchen_size_t &size_prev,
    baumkuchen_size_t &size_curr)
{
    size_prev += pieces.at(idx);
    size_curr -= pieces.at(idx);
    ++idx;
    reguralize(&idx);
}


inline void regress_idx(
    index_t &idx,
    baumkuchen_size_t &size_prev,
    baumkuchen_size_t &size_curr)
{
    --idx;
    reguralize(&idx);
    size_prev -= pieces.at(idx);
    size_curr += pieces.at(idx);
}


inline void update(baumkuchen_size_t input, baumkuchen_size_t *target)
{
    if (input > (*target))
        (*target) = input;
}


int main()
{
    // READ INPUTS
    {
        int num;
        std::cin >> num;
        pieces.assign(num, 0);

        for (int i = 0; i < num; ++i)
        {
            std::cin >> pieces[i];
            whole_size += pieces.at(i);
        }
        max_size = whole_size / 3;
    }
    
    index_t idx1(0), idx2(1), idx3(2); // BEGIN INDEX OF EACH BAUMKUCHEN PIECE
    baumkuchen_size_t
        size1(pieces.at(idx1)),            // SIZE OF 1ST BAUMKUCHEN PIECE
        size2(pieces.at(idx2)),            // SIZE OF 2ND BAUMKUCHEN PIECE
        size3(whole_size - size1 - size2); // SIZE OF 3RD BAUMKUCHEN PIECE
    baumkuchen_size_t out(0); // RETURN VALUE

    /* PRESUME THAT THE FIRST PIECE IS SMALLEST. */

    //std::cerr << "num = " << pieces.size() << std::endl;
    //std::cerr << "sum = " << whole_size << std::endl;
    //std::cerr << "max = " << max_size << std::endl;
    
    for (int i = 0; i < pieces.size(); ++i)
    {        
        while (size1 <= max_size)
        {
            // CHECK WHETHER size1 CAN BE SMALLEST
            
            if (size1 <= size2 and size1 <= size3)
                update(size1, &out);

            while (size1 > size2 or size1 > size3)
            {
                // NOTE: size2 & size3 CANNOT BE EQUAL HERE.
                
                bool was_larger(size2 > size3);
                assert(size2 != size3);

                (size2 > size3) ?
                    regress_idx(idx3, size2, size3) :
                    progress_idx(idx3, size2, size3);

                if (size1 <= size2 and size1 <= size3)
                    update(size1, &out);

                if ((size2 > size3) != was_larger)
                    break;
            }
            
            progress_idx(idx2, size1, size2);
        }

        progress_idx(idx1, size3, size1);
        while (size1 > max_size)
            regress_idx(idx2, size1, size2);
    }
    
    //std::cerr << "out = " << out << std::endl;
    std::cout << out << std::endl;
    
    return 0;
}

Measured memory_bytes: 1796
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int n, x;
    int count = 0;

    while (true)
    {
        cin >> n >> x;
        count = 0;
        if (n + x == 0)
            break;

        for (int i = 1; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                for (int k = j + 1; k <= n; k++)
                {
                    if (i + j + k == x)
                        count++;
                }
            }
        }

        cout << count << endl;
    }

    return 0;
}


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

int main() {
int n;
string text;
cin >> n >> text;
bool flag = true;
if(text.size()%2==1){cout << "No" << endl;
return 0;}
for(int i=0;i<n/2;i++){
    if(text.at(i)==text.at(i+n/2))continue;
    else {flag = false;
    break;}
}
if(flag)cout << "Yes" <<endl;
else cout << "No" <<endl;}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int w,a,b;cin>>w>>a>>b;
  a<b && b-(a+w)>=0 ? cout<<b-(a+w)<<endl : a>b && a-(b+w)>=0 ? cout<<a-(b+w)<<endl : cout<<0<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<list>
#include<sstream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%2==0)
	cout<<n;
	if(n%2==1)
	cout<<2*n;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

int main() {
	int N;
	cin >> N;
	cout << max(N / 2, (N + 1) / 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  string s; cin >> s;
  bool f = true;
  if ( s[2] >= '2' || (s[3] == '9' &&  s[5] == '1') ||
       ( s[5] == '0' && s[6] >= '5' ) ) f = false;
if( f) cout << "Heisei" << endl;
else cout << "TBD" << endl;

  return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n,m;
double p[20][20];
double dp[20][1<<16];

int main(void){
	cin >> m >> n;
	rep(i,m)rep(j,n) cin >> p[j][i];
	rep(mask,1<<m) dp[n][mask]=1.0;

	for(int i=n-1;i>=0;--i){
		for(int mask=(1<<m)-1;mask>=0;--mask){
			rep(j,m){
				if(mask&(1<<j)) continue;
				double cur=1.0,res=0.0;
				int nmask=mask|(1<<j);
				range(ni,i,n){
					double pp=cur*(1.0-p[ni][j]);
					res+=pp*dp[ni][nmask];
					cur*=p[ni][j];
				}
				res+=cur;
				dp[i][mask]=max(dp[i][mask],res);
			}
		}
	}
	cout.precision(20);
	cout << fixed << dp[0][0]  << endl;
	return 0;
}

Measured memory_bytes: 11532
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  string s;
  cin >> s;

  if (s == "SUN") cout << 7 << endl;
  if (s == "MON") cout << 6 << endl;
  if (s == "TUE") cout << 5 << endl;
  if (s == "WED") cout << 4 << endl;
  if (s == "THU") cout << 3 << endl;
  if (s == "FRI") cout << 2 << endl;
  if (s == "SAT") cout << 1 << endl;

  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static int H;
        static int W;
        static int[,] chocolate;
        static int[,] cusum;

        static void Main(string[] args)
        {
            //[summary]B - String Palindrome
            var S = Console.ReadLine();

            if (IsStrongPalindrome(S))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool IsStrongPalindrome(string S)
        {
            if (IsPalindrome(S))
            {
                var n = S.Length / 2;

                if (IsPalindrome(S.Substring(0, n)))
                {
                    if (IsPalindrome(S.Substring(n + 1, n)))
                    {
                        return true;
                    }
                }
            }

            return false;
        }

        static bool IsPalindrome(string s)
        {
            var reverse = String.Join("", s.Reverse());

            if (s == reverse)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b, ans;

int main() {
	cin >> a >> b;
	incII(i, a, b) {
		string s, t;
		s = t = to_string(i);
		reverse(ALL(t));
		if(s == t) { ans++; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
d = int(input())
x = [a,b,c]
max_value = max(x)
index = x.index(max_value)

for i in range(d):
    max_value = max_value * 2

x[index] = max_value
sum = 0
for value in x:
    sum += value
print(sum)

Measured memory_bytes: 3064
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b; cin >> a >> b;
    
    if(a<b) swap(a,b);
    
    cout << a*b/GCD(a, b) << endl;
    
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(A)

for i in range(M):
  max_value = heapq.heappop(A)*(-1)
  heapq.heappush(A, (max_value//2)*(-1))
  
print((-1)*sum(A))

Measured memory_bytes: 14180
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int> > out(2);
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        out[i%2].push_back(a);
    }
    int rev = (n+1)%2;
    reverse(out[rev].begin(), out[rev].end());
    copy(out[1-rev].begin(), out[1-rev].end(), back_inserter(out[rev]));
    for(int i=0; i<n-1; i++){
        cout << out[rev][i] << " ";
    }
    cout << out[rev][n-1] << endl;
    return 0;
}


Measured memory_bytes: 3568
def solve(N, values):
    while len(values) > 1:
        values.sort()
        x = values.pop(0)
        y = values.pop(0)
        values.append((x + y) / 2)
    return values[0]


N = int(input())
values = [int(v) for v in input().split()]
ans = solve(N, values)
print(ans)

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << res << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	FOR(i, 0, n - 1) {
		cin >> h[i];
	}
	sort(ALL(h));
	ll res = 0;
	FOR(i, 0, n - 1 - k) {
		res += h[i];
	}
	pv(res)
	return(0);
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

class Program {

    static int Main(string[] args) {
        List<string[]> list = new List<string[]>();

        string v = Console.ReadLine();
        int n = int.Parse(v);

        for (int i = 0; i < n; i++) {
            string a = Console.ReadLine();
            string b = Console.ReadLine();

            list.Add(new string[] { a, b });
        }

        for (int i = 0; i < list.Count; i++) {
            if ((list[i][0].Length > 80) || (list[i][1].Length > 80)) {
                Console.WriteLine("overflow");
                continue;
            }

            AddValue(list[i][0], list[i][1]);
        }

        return 0;
    }

    static void AddValue(string a, string b) {
        int len = Math.Max(a.Length, b.Length);
        a = a.PadLeft(len, '0');
        b = b.PadLeft(len, '0');

        string c = "";
        int up = 0;
        for (int i = len - 1; i >= 0; i--) {
            int add = int.Parse(a.Substring(i, 1)) + int.Parse(b.Substring(i, 1)) + up;
            if (add >= 10) { up = 1; add = add % 10; }
            else { up = 0; }

            c = add.ToString() + c;
        }

        if (up > 0) { c = "1" + c; }

        if (c.Length > 80) {
            Console.WriteLine("overflow");
        }
        else {
            Console.WriteLine(c);
        }
    }
}

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

using namespace std;

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

	long double s = 1.;

	vector<long long> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	if(*min_element(a.begin(), a.end()) == 0) {
		cout << 0 << '\n';
		exit(0);
	}

	long long ans = 1;
	bool ok = true;

	for(int i = 0; i < n; ++i) {
		s = s * a[i];
		ans = ans * a[i];
		if(s > 1e18) {
			ok = false;
		}
	}

	if(!ok) {
		cout << -1 << '\n';
	} else {
		cout << ans << '\n';
	}

	return 0;
}

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<int> a(N);rep(i,N)cin >> a[i];
    map<int,int> m;
    int sub = 0;

    rep(i,N){
        if(1 <= a[i] && a[i] <= 399)m[0]++;
        if(400 <= a[i] && a[i] <= 799)m[1]++;
        if(800 <= a[i] && a[i] <= 1199)m[2]++;
        if(1200 <= a[i] && a[i] <= 1599)m[3]++;
        if(1600 <= a[i] && a[i] <= 1999)m[4]++;
        if(2000 <= a[i] && a[i] <= 2399)m[5]++;
        if(2400 <= a[i] && a[i] <= 2799)m[6]++;
        if(2800 <= a[i] && a[i] <= 3199)m[7]++;
        if(3200 <= a[i])sub++;
    }

    int mi = m.size();
    int ma = mi + sub;

    if(sub > 0 && mi == 0){
        mi = 1;
        ma = sub;
    }
    cout << mi << " " << ma << endl;
}

Measured memory_bytes: 256
// 作者：杨成瑞先生
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        long k = sc.nextLong(), a = sc.nextLong(), b = sc.nextLong();

        long biscuits = 1;

        if(b - a <= 2) {
            biscuits += k;
        }
        else {
            biscuits += a - 1;
            k -= a - 1;

            biscuits += k / 2 * (b - a);
            k %= 2;
            biscuits += k;
        }

        pw.println(biscuits);
        pw.close();
	}

}

Measured memory_bytes: 23380
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}

struct Node {
	int Number;
	int Level;
	vector<int> connected{ vector<int>() };
	bool operator<(const Node& n) { return Number < n.Number; }
};

void get_level(vector<Node>& tree, vector<bool>& visited, int level, Node& n) {
	n.Level = level;
	visited[n.Number] = true;
	for (size_t i = 0; i < n.connected.size(); i++) {
		if (!visited[n.connected[i]]) {
			get_level(tree, visited, level + 1, tree[n.connected[i]]);
		}
	}
}

int main() {
	int N; cin >> N;
	auto tree = vector<Node>(N);
	for (size_t i = 0; i < N; i++) tree[i].Number = i;
	int from, to;
	for (size_t i = 0; i < N - 1; i++) {
		cin >> from >> to;
		tree[from - 1].connected.push_back(to - 1);
		tree[to - 1].connected.push_back(from - 1);
	}
	sort(tree.begin(), tree.end());

	//Fennecからの距離とSunukeからの距離を計算。
	//距離が同じかFennecの方が小さい時はFennecのマスになる。
	//Fの距離
	auto visited = vector<bool>(N, false); get_level(tree, visited, 0, tree[0]);
	auto dist_f = vector<int>(N); for (size_t i = 0; i < N; i++) dist_f[i] = tree[i].Level;
	//Sの距離
	visited = vector<bool>(N, false); get_level(tree, visited, 0, tree[N - 1]);
	auto dist_s = vector<int>(N); for (size_t i = 0; i < N; i++) dist_s[i] = tree[i].Level;
	//	for (size_t i = 0; i < N; i++) cout << dist_f[i] << " "; cout << endl;
	//	for (size_t i = 0; i < N; i++) cout << dist_s[i] << " "; cout << endl;
	int f_count = 0;
	int s_count = 0;
	for (size_t i = 0; i < N; i++) {
		if (dist_f[i] <= dist_s[i])f_count++;
		else s_count++;
	}
	cout << (f_count > s_count ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 12032
#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;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

bool is_ok(string s){
	bool res = true;
	rep(i,s.size())if(!(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'))res = false;
	return res;
}

int main(){
	string s;
	cin >> s;
	for(int i = s.size(); i > 0; --i){
		bool ok = true;
		for(int st = 0; st + i <= s.size(); ++st){
				string t = s.substr(st, i);
				if(is_ok(t)){
					cout << i << endl;
					return 0;
				}
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

struct P
{
    int cnt;
    string s;

    P(int cnt, string s)
    {
        this->cnt = cnt;
        this->s = s;
    }

    bool operator<(const P& p) const
    {
        if (this->cnt < p.cnt) return true;
        else if (this->cnt == p.cnt && this->s > p.s) return true;
        return false;
    }
};

int main()
{
    int n;

    while (cin >> n, n){
        map<string, int> cnt;
        set<string> word[26];
        string line;

        getline(cin, line);
        while (n-- > 0){
            getline(cin, line);
            for (int i = 0; i < line.length(); ){
                int j;
                for (j = i; 'a' <= line[j] && line[j] <= 'z'; j++);

                string s = line.substr(i, j - i);
                int index = s[0] - 'a';

                word[index].insert(s);
                cnt[s]++;

                i = j + 1;
            }
        }

        char k;
        cin >> k;
        vector<P> v;
        for (set<string>::iterator i = word[k - 'a'].begin(); i != word[k - 'a'].end(); i++){
            v.push_back(P(cnt[*i], *i));
        }

        if (v.size() == 0){
            cout << "NA\n";
            continue;
        }

        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        int size = min(v.size(), (size_t)5);
        for (int i = 0; i < size; i++){
            cout << v[i].s << "\n "[i < size - 1];
        }
    }

    return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N, X; cin >> N >> X;
    int L[N];
    rep(i,N) cin >> L[i];
    int D = 0, cnt = 1;
    rep(i,N){
        D = D+L[i];
        if(D <= X){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long H = long.Parse(str[0]);
		int N = int.Parse(str[1]);
		var dic = new Dictionary<int,int>();
		var A = new List<int[]>();
		for(var i=0;i<N;i++){
			string[] str2 = Console.ReadLine().Split();
			int a1 = int.Parse(str2[0]);
			int a2 = int.Parse(str2[1]);
			if(dic.ContainsKey(a2)){
				if(dic[a2]<=a1){
					continue;
				}
			}
			A.Add(new int[2]{a1,a2});
			dic[a2] = a1;
		}
		int[,]D = new int[H+1,N+1];
		int N1 = A.Count;
		for(var i=1;i<=H;i++){
			D[i,0] = 999999999;
			for(var j=1;j<=N1;j++){
				int a = Math.Max(0,i-A[j-1][0]);
				D[i,j] = Math.Min(D[i,j-1],D[a,j]+A[j-1][1]);
			}
		}
		//for(var i=0;i<=H;i++){
        //  	for(var j=0;j<=N;j++){
        //      	Console.Error.Write(D[i,j]+" ");
        //    }
        //  	Console.Error.WriteLine();
        //}
		Console.WriteLine(D[H,N1]);
	}
}

Measured memory_bytes: 52064
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var n = Read();
         
        var c = new List<long>();
        
        for (long i = 1; i <Math.Pow(n,0.5)+1; i++)
        {
            if (n % i == 0)
            {
                long a = n / i;
                c.Add(i + a);
            }     
               
        }
        Console.WriteLine(c.Min()-2);

        Console.Out.Flush();
    }
}

Measured memory_bytes: 13320
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;



char str[1000000];
int main(){
	int A,B;
	cin >> A >> B;
	int ans = A*B;
	printf("%d\n",ans);

}




Measured memory_bytes: 3220