akhauriyash/Code-Regression huggingface dataset:
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>
using namespace std;

//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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(t,c) for(typeof((c).begin()) t=(c).begin(); t!=(c).end(); ++t)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(t,a,b) for(int t=(a);t<(b);++t)
#define REP(t,n)  FOR(t,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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



const LL mod = 1000000007;

LL gcd(LL a, LL b) { if (a%b == 0) { return b; } else return gcd(b, a%b); }
LL lcm(LL a, LL b) { return a / gcd(a, b)*b; }

#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;

#define POSSIBLE cout<<"POSSIBLE"<<endl; return 0;
#define IMPOSSIBLE cout<<"IMPOSSIBLE"<<endl; return 0;




int main() {

	int n, m, x;
	cin >> n >> m>>x;
	//cin >> s;]
	VI A(n+1);

	REP(i, m) { int a; cin >> a; A[a]++; }
	
	int r = 0, l = 0;
	REP(i, n+1) {
		if (i < x) {
			l += A[i];
		}
		else {
			r += A[i];
		}
	}
	cout << min(l, r) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

int main() {
    int M; cin >> M;
    cout << 24 - M + 24 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin>>N;
    vector<int> s(N);
    vector<int> x(N);
    vector<int> a(N,0),b(N,0);
    REP(i,N) {
        cin>>x[i]>>s[i];
        if(i>0) s[i]+=s[i-1];
        a[i]=s[i]-x[i];
        if(i==0) b[i]=-x[i];
        else b[i]=s[i-1]-x[i];
    }
    int ans=0;
    int mn=INF;
    REP(i,N) {
        chmin(mn,b[i]);
        int tmp=a[i]-mn;
        chmax(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    ll n;
    cin >> n;
    ll ans = 0;
    repn(i, n){
        ans += (n - 1) / i;
    }
    co(ans);

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define _ ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
using namespace std;

int main() { _
    int n; cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i += 2){
        if(arr[i] % 2 == 1){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static System.Math;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int H, W;
        static string[] S;

        public static void Input()
        {
            var cin = new Solve();
            var input = cin.SplitReader();
            H = input[0];
            W = input[1];
            S = new string[H];
            for (var i = 0; i < H; i++)
            {
                S[i] = Console.ReadLine();
            }
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            

            
            for(var i = 0; i < H; i++)
            {
                for(var j = 0; j < W; j++)
                {
                    if (S[i][j] == '.') { continue; }
                    bool ok = false;
                    if (i > 0 && S[i - 1][j]=='#') { ok = true; }
                    if (i < H - 1 && S[i + 1][j] == '#') { ok = true; }
                    if (j > 0 && S[i][j - 1] == '#') { ok = true; }
                    if (j < W - 1 && S[i][j + 1] == '#') { ok = true; }
                    if (!ok)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
            
            
            //Console.Out.Flush();
        }

        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

        
    }
}

    



Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll N;


/*
	i < j とする
	j - i = A[i] + A[j] となるペアを探す
	
	j - A[j] = A[i] + i
	
	j - A[j] でソート
	A[i] + i でソート
	一致する組み合わせを数える
*/

int main(){
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N);
	
	for ( int i = 0; i < N; i++ ){
		cin >> A[i];
		B[i] = i - A[i];
		C[i] = i + A[i];
	}
	
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	
	int b = 0;
	int c = 0;
	ll count = 0;
	while ( b < N && c < N ){
		if ( B[b] < C[c] ){
			b++;
		}
		else if ( B[b] > C[c] ){
			c++;
		}
		else {
			ll blen = 1;
			while ( b+blen < N && B[b] == B[b+blen] )
				blen++;
			
			ll clen = 1;
			while ( c+clen < N && C[c] == C[c+clen] )
				clen++;
			
			count += blen*clen;
			b += blen;
			c += clen;
		}
	}
	
	
	cout << count << endl;
	
	return 0;
}



Measured memory_bytes: 5572
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

lint n;
vector<double> v;

int main() {
    cin >> n;
    v.resize(n);
    for(lint i = 0; i < n; i++)  cin >> v[i];

    while(v.size() != 1) {
        sort(v.begin(), v.end());
        v.push_back( (v[0] + v[1]) / 2 );
        v.erase(v.begin());
        v.erase(v.begin());
    }
    cout << fixed << setprecision(10) << v[0] << endl;
}

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

using namespace std;
#define int long long

int32_t main()
{
    int n; cin >> n;
    if (n % 2 == 1) return cout << 0 << "\n", 0;
    while (n % 5 != 0) n -= 2;
    int ans = 0;
    for (int i = 10; i <= n; i *= 5) ans += n / i;
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1000000000;
int gcd(int p, int q){
  while(q != 0){
  int r = p % q;
  p = q;
  q = r;
  }
  return p;
}

int main() {
  int k;
  cin >> k;
  int ans = 0;
  for(int a = 1; a <= k; ++a){
    for(int b = 1; b <= k; ++b){
      for(int c = 1; c <= k; ++c){
        int ab = gcd(a,b);
        ans += gcd(ab,c);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i <= int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

int mod = 1000000007;

inline int add(int a, int b);
inline int mult(int a, int b);
inline int sub(int a, int b);

int l[200500];
int r[200500];
int a[200500];

long long mx[800500];
long long ad[800500];

void add(int v, int l, int r, int a, int b, long long c) {
    if (r <= a || b <= l)
        return;

    if (a <= l && r <= b) {
        ad[v] += c;
        mx[v] += c;
        return;
    }

    int m = (l + r) >> 1;

    add(v + v + 1, l, m, a, b, c);
    add(v + v + 2, m, r, a, b, c);

    mx[v] = max(mx[v + v + 1], mx[v + v + 2]) + ad[v];
}

long long get(int v, int l, int r, int a, int b) {
    if (r <= a || b <= l)
        return -1e18;

    if (a <= l && r <= b) {
        return mx[v];
    }

    int m = (l + r) >> 1;
    return max(get(v + v + 1, l, m, a, b), get(v + v + 2, m, r, a ,b));
}


int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    int n, m;
    cin >> n >> m;

    forn(i, m) cin >> l[i] >> r[i] >> a[i];

    vector<pair<int, int>> evs;

    forn(i, m) {
        evs.emplace_back(l[i], -i - 1);
        evs.emplace_back(r[i], i + 1);
    }

    forlr(i, 1, n)
     evs.emplace_back(i, 0);

    sort(evs.begin(), evs.end());

    long long ans = 0;

    for (auto p : evs) {
        if (p.second == 0) {
            long long sum = get(0, 0, n + 1, 0, p.first);
            ans = max(ans, sum);
            add(0, 0, n + 1, p.first, p.first + 1, sum);

            //cout << sum << endl;
        } else if (p.second > 0) {
            int id = p.second - 1;
            add(0, 0, n + 1, 0, l[id], -a[id]);
        } else {
            int id = -p.second - 1;
            add(0, 0, n + 1, 0, l[id], a[id]);
        }
    }

    cout << ans;

    return 0;
}

int add(int a, int b) {
    int result = a + b;
    if (result >= mod)
        result -= mod;
    return result;
}

int sub(int a, int b) {
    int result = a - b;
    if (result < 0)
        result += mod;
    return result;
}

int mult(int a, int b) {
    return (a * 1ll * b) % mod;
}

Measured memory_bytes: 21864
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int h,w,i,j;
		boolean state = false;
		h = sc.nextInt();
		w = sc.nextInt();
		while(h != 0 && w != 0){
			for(i = 0; i < h; i++){
				if(i % 2 == 0){
					state = false;
				}else{
					state = true;
				}
				for(j = 0; j < w; j++){
					if(!state){
						System.out.print("#");
						state = true;
					}else{
						System.out.print(".");
						state = false;
					}
				}
				System.out.println("");
			}
			System.out.println("");
			h = sc.nextInt();
			w = sc.nextInt();
		}
	}
}

Measured memory_bytes: 36080
import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        long[] a = new long[n];
        for(int i=0; i<n; i++){
            a[i] = Long.parseLong(sc.next());
        }
        Arrays.sort(a);
        int l = 0;
        int r = n-1;
        long ans = k%2==0 ? 1 : a[r--];
        int b = ans<=0 ? -1 : 1;
        while(k>1){
            long m = a[l]*a[l+1];
            long p = a[r]*a[r-1];
            if(m*b >= p*b){
                ans = ans*(m%MOD)%MOD;
                l+=2;
            }else{
                ans = ans*(p%MOD)%MOD;
                r-=2;
            }
            k-=2;
        }
        System.out.println((ans+MOD)%MOD);
    }
}


Measured memory_bytes: 62172
c(int*l,int*r){return *l-*r;}a[1<<18];i;long s;main(j){for(;~scanf("%d",a+i);)a[i++]-=i;for(qsort(a+1,i-1,4,c);j<i;)s+=abs(a[j++]-a[i/2]);printf("%ld",s);}

Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int A, B;
    cin >> A >> B;
    if (A % 2 == 0 || B % 2 == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    private static final BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) {
        exec(args);
    }

    public static void exec(String[] args) {
        String str = readLineStandardInput();
        int N = Integer.parseInt(str);
        str = readLineStandardInput();
        String[] Astr = str.split(" ");
        int[] Ami = new int[N];
        for(int i = 0; i < Ami.length; i++){
            int tmp = Integer.parseInt(Astr[i]);
            Ami[i] = tmp - (i + 1);
        }
        Arrays.sort(Ami);
        boolean isBi = N / 2 * 2 == N;
        int medianBigIdx = N / 2;
        int medianBig = Ami[medianBigIdx];
        int medianSmallIdx = !isBi ? N / 2 : N / 2 - 1;
        int medianSmall = Ami[medianSmallIdx];
        long sumBig = 0, sumSmall = 0;
        for(int i = 0; i < Ami.length; i++) {
            if(Ami[i] < medianBig) {
                sumBig += medianBig - Ami[i];
            }
            else {
                sumBig += Ami[i] - medianBig;
            }

            if(Ami[i] < medianSmall) {
                sumSmall += medianSmall - Ami[i];
            }
            else {
                sumSmall += Ami[i] - medianSmall;
            }
        }
        long res = sumBig < sumSmall ? sumBig : sumSmall;
        System.out.println(res);
    }

    private static String readLineStandardInput() {
        String str;
        try {
            str = input.readLine();
        } catch(IOException e){
            str = null;
            System.out.println(e);
        }
        return str;
    }
}


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

int main()
{
    string str;
    cin >> str;
    if(str.at(0)==str.at(1)&&str.at(0)==str.at(2)){
        cout << "No" << endl;

    }
    else{
        cout << "Yes" << endl;
    }
    
}

Measured memory_bytes: 256
N=int(input())
A=[int(x) for x in input().rstrip().split()]
B=[int(x) for x in input().rstrip().split()]
C=[int(x) for x in input().rstrip().split()]

bonus=0
for i in range(N-1):
  if A[i]+1==A[i+1]:
    bonus+=C[A[i]-1]
print(sum(B)+bonus)


Measured memory_bytes: 3060
A=[]
x=1.0
y=0.0
for i in range(1,1001):
    A.append([x,y])
    tmp=i**.5
    x,y=x-y/tmp,y+x/tmp

while 1:
    n=input()
    if n==-1:break
    a,b=A[n-1]
    print "%.2f\n%.2f"%(a,b)

Measured memory_bytes: 4448
#include <cstdio>
typedef long long ll;
inline int rd(){
    int x=0,p=1;
    char a=getchar();
    while((a<48||a>57)&&a!='-')a=getchar();
    if(a=='-')p=-p,a=getchar();
    while(a>47&&a<58)x=(x<<1)+(x<<3)+(a&15),a=getchar();
    return x*p;
}
const int N=3002;
struct Edge{
	int to,next;
}edge[N<<1];
int head[N],cnt;
int n,a[N],f[N];
inline void add(int f,int t){
	edge[++cnt].next=head[f];
	edge[cnt].to=t;
	head[f]=cnt;
}
inline void dp(int u,int ft){
	f[u]=0;
	for(int i=head[u];i;i=edge[i].next){
		int v=edge[i].to;
		if(v==ft)continue;
		dp(v,u);
		if(f[v]==0&&a[u]>a[v])f[u]=1;
	}
}
int main(){
	n=rd();
	for(int i=1;i<=n;i++)a[i]=rd();
	for(int i=1;i<n;i++){
		int u=rd(),v=rd();
		add(u,v),add(v,u);
	}
	for(int i=1;i<=n;i++){
		dp(i,0);
		if(f[i])printf("%d ",i);
	}
	puts("");
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

//typedef __int64 lint;

const double EPS = 1e-10;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const int INF = 1001001001;
//const lint INFLL = (__int64)1001001001001001001;

#define clear(a) memset((a), 0, sizeof(a))
#define mclear(a) memset((a), -1, sizeof(a))

#define show(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main()
{
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		int x, y, b, p;
		scanf("%d %d %d %d", &x, &y, &b, &p);
		
		int c1 = x * b + y * p;
		int c2 = x * max(b, 5) + y * max(p, 2);
		
		printf("%d\n", min(c1, c2 * 8 / 10));
	}
	
	return (0);
}

Measured memory_bytes: 1192
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;


int main()
{
	int i;
	long int a,b, def_a, def_b;
	deque<long> soinnsu_a;
	while( cin >> def_a >> def_b ) {
		soinnsu_a.clear();
		if( def_a > def_b ) {
			a = def_a; b = def_b;
		}
		else {
			a = def_b; b = def_a;
		}
		//aを素因数分解行う


		while ( a % 2 == 0 ) {
			soinnsu_a.push_back(2);
			a /= 2;
		}
		for( i = 3;;i+=2 ) {
			while( a % i == 0 ) {
				soinnsu_a.push_back(i);
				a /= i;
			}
			if( a ==1 )
				break;
		}
		
		//bとの最小公倍数を求める
		long LCM = 1;
		long GCD = 1;
       deque< long >::iterator it;
        for ( it = soinnsu_a.begin(); it != soinnsu_a.end();  it++) {
			if( b % *it == 0 ) {
				LCM *= *it;
				b /= *it;
			}
		}
		
		GCD = def_a / LCM * def_b;

		cout << LCM << " " << GCD << endl;
	
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ll long long
#define N 200005
inline ll read()
{
	ll s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch<='9'&&ch>='0'){
		s=(s<<1)+(s<<3)+(ch^48);
		ch=getchar();
	}
	return s*w;
}
ll pre1[N],pre2[N];
int main()
{
	ll n=read(),m=read(),k=read();
	ll ans=0;
	f(i,1,n) pre1[i]=read()+pre1[i-1];
	f(i,1,m) pre2[i]=read()+pre2[i-1];
	for(int i=0;pre1[i]<=k&&i<=n;++i)
	{
		ll sum=i,res=k-pre1[i];
		ll x=upper_bound(pre2+1,pre2+1+m,res)-pre2;
		sum+=x-1;
		ans=max(ans,sum);
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

string s, t;

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

	cin >> s >> t;
	
	int ss = s.size(), st = t.size();
	int dp[ss+1][st+1];

	memset(dp, 0, sizeof dp);
	for(int i = 1; i <= ss; i++){
		for(int j = 1; j <= st; j++){
			if(s[i-1] == t[j-1])
				dp[i][j] = max(dp[i-1][j-1] + 1, dp[i][j]);
			else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	
	int ps = ss, pt = st;
	string ans = "";
	while((ps != 0 || pt != 0) && dp[ps][pt]){
		if(dp[ps][pt] == dp[ps][pt-1])
			pt--;
		else if(dp[ps][pt] == dp[ps-1][pt])
			ps--;
		else{
			ans += s[ps-1];
			ps--;
			pt--;
		}
	}
	
	reverse(ans.begin(), ans.end());
	
	cout << ans << endl;
}


Measured memory_bytes: 35456
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    vector<ll> v(5);
    cin>>str;
    if(str[0]!='A') f=1;
    if(str[1]<='A') f=1; 
    if(str[1]<='Z'&&str[1]>='A') f=1; 
    //cout<<f;
    REP(i,2,str.length()-1){
        if(str[i]=='C') sum++;
        else{
            if(str[i]<='A') f=1; 
        }
    }
    //cout<<f;
    if(str[str.length()-1]<='Z'&&str[str.length()-1]>='A') f=1; 
    //if(str[str.length()-2]<='A') f=1; 
    //if(str[str.length()-1]<='A') f=1; 

    if(sum!=1) f=1;
    if(f==1) cout<<"WA"<<endl;
    else cout<<"AC"<<endl;

    return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    rp(i,ty-sy) cout << "U";
    rp(i,tx-sx) cout << "R";
    rp(i,ty-sy) cout << "D";
    rp(i,tx-sx+1) cout << "L";

    rp(i,ty-sy+1) cout << "U";
    rp(i,tx-sx+1) cout << "R";
    cout << "D";
    cout << "R";
    rp(i,ty-sy+1) cout << "D";
    rp(i,tx-sx+1) cout << "L";
    cout << "U";
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
using System;

public class two
{
    public static void Main()
    {
        int[] heights = new int[10];
        for(int i=0; i<10; i++)
        {
            heights[i] = int.Parse(Console.ReadLine());
        }
        sort(heights);
        Console.WriteLine(heights[0]);
        Console.WriteLine(heights[1]);
        Console.WriteLine(heights[2]);
    }
    private static int[] sort(int[] val)
    {//???????????????
        for (int j = 0; j < val.Length - 1; ++j)
        {
            for (int i = 0; i < val.Length - 1; ++i)
            {
                if (val[i] < val[i + 1])
                {
                    int temp = val[i];
                    val[i] = val[i + 1];
                    val[i + 1] = temp;
                }
            }
        }
        return val;
    }
}

Measured memory_bytes: 9000
#include<cstdio>
#define N (530010)
#define P (998244353)
int n,S,INV,Lim,p[N],q[N];
int ksm(int a,int p){
	int res=1;
	for(;p;p>>=1,a=1ll*a*a%P)if(p&1)res=1ll*res*a%P;
	return res;
}
void FWT(int *a,int tp){
	for(int i=1;i<Lim;i<<=1)
	for(int R=i<<1,j=0;j<Lim;j+=R)
	for(int k=j;k<j+i;k++){
		int x=a[k],y=a[k+i];
		a[k]=(x+y)%P,a[k+i]=(x-y+P)%P;
	}
	if(tp==-1)for(int i=0;i<Lim;i++)a[i]=1ll*a[i]*INV%P;
}
int main(){
	scanf("%d",&n),Lim=1<<n,INV=ksm(Lim,P-2);
	for(int i=0;i<Lim;i++)scanf("%d",&p[i]),S+=p[i]; S=ksm(S,P-2);
	for(int i=0;i<Lim;i++)p[i]=1ll*p[i]*S%P,q[i]=P-1;q[0]=Lim-1,p[0]--,FWT(p,1),FWT(q,1);
	for(int i=1;i<Lim;i++)q[i]=1ll*q[i]*ksm(p[i],P-2)%P; FWT(q,-1);
	for(int i=0;i<Lim;i++)printf("%d\n",(q[i]-q[0]+P)%P);
}

Measured memory_bytes: 5760
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
using namespace std;
ll kt(ll n){
  string key=to_string(n);
  return  key.size();
}
// index が条件を満たすかどうか
bool isOK(ll index, ll key,ll a, ll b) {
    if ( (a*index+b*kt(index))<= key) return true;
    else return false;
}
// 二分探索
ll binary_search(ll key,ll a,ll b) {
    ll left = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll right = 1000000001; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        ll mid = left + (right - left) / 2;
        if (isOK(mid, key,a ,b)) left = mid;
        else right = mid;
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return left;
}

int main(){
  ll n;
  cin >>n;
  vector<ll> vec(n);
  rep(i,n) cin >>vec[i];
  int key=0;
  if(n==1){
    cout<<"Yes"<<endl;
    return 0;
  }
  for(int i=n-2;i>-1;i--){
    if(vec[i]>vec[i+1]+1){
      key=1;
    }else if(vec[i]==vec[i+1]+1){
      vec[i]--;
    }
  }
  if(key==1)cout <<"No"<<endl;
  else cout <<"Yes"<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  int m;
  cin>>m;
  vector<int> b(m);
  for(int i=0;i<m;i++) cin>>b[i];

  vector<int> c;
  set_symmetric_difference(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
  for(int x:c) cout<<x<<endl;
  return 0;
}



Measured memory_bytes: 6544
# from sys import exit
N, M = [int(n) for n in input().split()]
# N = int(input())
a = [(int(n), 1) for n in input().split()]
B = [0 for _ in range(M)]
C = [0 for _ in range(M)]
for i in range(M):
    B[i], C[i] = [int(n) for n in input().split()]
    a.append((C[i], B[i]))

a = sorted(a, key=lambda x: -x[0])
i = 0
ans = 0
# print(a)
while(N != 0):
    num = min(N, a[i][1])
    ans += num*a[i][0]
    # print(num*a[i][0])
    N -= num
    i += 1

print(ans)


Measured memory_bytes: 41340
def resolve():
    '''
    code here
    '''
    N = int(input())
    a_list = [int(input()) for _ in range(N)]

    is_not_found = True
    cnt = 1
    idx = a_list[0] - 1
    while is_not_found:
        if idx == 1:
            is_not_found = False
            print(cnt)
        elif cnt >= N:
            is_not_found = False
            print(-1)
        
        idx = a_list[idx] - 1
        cnt += 1


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 7084
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main() {
    long long a, b; cin>>a>>b;
    long long counter=0;
    int counter1=0;
    int counter2=0;
    long long answer=0;
    if(b<0){
    counter=abs(b-a)+1;
    if(counter%2==0){
    cout<<"Positive"<<endl;}
    else
    cout<<"Negative"<<endl;}
    else if(a>0)
    cout<<"Positive"<<endl;
    else 
    cout<<"Zero"<<endl;}
    


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  bool odd=false;
  int count=0;
  while(true){
    for(int i=0;i<N;i++){
      if(A.at(i)%2==1){
        odd=true;
        break;
      }
    }
    if(!odd){
      for(int i=0;i<N;i++){
        A.at(i)/=2;
      }
      count++;
    }
    else{
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N = int(input())
ts = list(map(int,input().split()))
vs = list(map(int,input().split()))
 
maxv = [0] * (sum(ts) * 2 +1)
dp = [0] * (sum(ts) * 2 + 1)
ima = 1
for i in range(len(ts)):
  k = ts[i]
  if i != 0:
    maxv[ima-1] = min(vs[i],vs[i-1])
  for j in range(k*2):
    maxv[j+ima] = vs[i]
  ima  += k*2
maxv[-1] = 0
for i in range(1,len(dp)):
  dp[i] = min(dp[i-1] + 0.5,maxv[i])
for i in range(len(dp)-1,0,-1):
  dp[i-1] = min(dp[i] + 0.5,maxv[i-1],dp[i-1])
ans = sum(dp)/2
print(ans)

Measured memory_bytes: 3700
import java.util.Scanner;
import java.util.*;
import java.io.*;
public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] nm = reader.readLine().split(" ");
        int n = Integer.valueOf(nm[0]);
        int m = Integer.valueOf(nm[1]);

        Map<Integer, List<Pair>> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            String[] py = reader.readLine().split(" ");
            int pre = Integer.valueOf(py[0]);
            int year = Integer.valueOf(py[1]);
            if (!map.containsKey(pre)) {
                List<Pair> pairs = new ArrayList<>();
                map.put(pre, pairs);
            }
            Pair p = new Pair(i, year);
            map.get(pre).add(p);
        }
        for (Map.Entry<Integer, List<Pair>> entry : map.entrySet()) {
            Collections.sort(entry.getValue(), new PairComparator());
        }
        String[] ans = new String[m];
        for (Map.Entry<Integer, List<Pair>> entry : map.entrySet()) {
            int order = 0;
            for (Pair p : entry.getValue()) {
                order++;
                ans[p.city] = String.format("%06d%06d", entry.getKey(), order);
            }
        }

        PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        for (String s : ans) {
            writer.println(s);
        }
        writer.flush();
    }
}
class Pair {
    int city;
    int year;
    public Pair(int city, int year) {
        this.city = city;
        this.year = year;
    }
    public int compareTo(Pair p) {
        return this.year - p.year;
    }
    public String toString() {
        return String.format("city : %d year: %d %n", this.city, this.year);
    }
}
class PairComparator implements Comparator<Pair> {
    public int compare(Pair p1, Pair p2) {
        return p1.year - p2.year;
    }
}


Measured memory_bytes: 133432
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		// Dequeはインターフェースなので、実装クラスのArrayDequeで実装
		Deque<Integer> stack = new ArrayDeque<>();
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			int curNum = 0;
			String curStr = "";
			if (sc.hasNextInt()) {
				curNum = sc.nextInt();
				stack.push(curNum);
			} else {
				curStr = sc.next();
				int a = stack.pop();
				int b = stack.pop();
				switch (curStr) {
				case "+":
					stack.push(b + a);
					break;
				case "-":
					stack.push(b - a);
					break;
				case "*":
					stack.push(b * a);
					break;
				}
			}

		}
		System.out.println(stack.pop());

	}

}


Measured memory_bytes: 26892
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, k;
    cin >> n >> k;
    vector<i64> h_s(n + 2, 0);
    rep(x, n)
    {
        cin >> h_s[x + 1];
    }

    constexpr i64 ansmax = 3'00'000'000'000;
    // dp[x][l] = [0,l]回変更しxは変更しないときの[0,x]までの最適値
    vector dp(n + 2, vector(k + 1, ansmax));
    fill(dp[0].begin(), dp[0].end(), 0);
    FOR(x, 1, n + 1)
    {
        rep(x2, x)
        {
            FOR(l, x - x2 - 1, k)
            {
                chmin(dp[x][l], dp[x2][l - (x - x2 - 1)] + max((i64)(0), h_s[x] - h_s[x2]));
            }
        }
    }
    cout << dp[n + 1][k] << '\n';

    return 0;
}


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

int main() {
  int a,b;
  cin >> a;
  cin >> b;
  if(a<b){
    cout << "a < b" << endl;
  }
  else if(a>b){
    cout << "a > b" << endl;
  }
  else{
    cout << "a == b" << endl;
  }

}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int data[5];
  for(int i = 0;i < 5;i++)cin >> data[i];
  cout << *min_element(data,data + 3) + *min_element(data + 3,data + 5) - 50 << endl;
  return 0;
}
  

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int x, a, b; cin >> x >> a >> b;

  if (abs(x - a) < abs(x - b)) cout << "A\n";
  else cout << "B\n";
  
  return (0);
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,m,f[100005],ans;
int find(int x)
{
	if(f[x]!=x)
		f[x]=find(f[x]);
	return f[x];
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		if(find(x)!=find(y))
		{
			f[find(x)]=find(y);
		//	ans++;
		}
	}
	for(int i=1;i<=n;i++)
		if(find(i)==i) ans++;
	cout<<ans;
}

Measured memory_bytes: 1152
#include <iostream>

#include <vector>

auto solve(int n, std::vector<long long>& a) {

  constexpr __int128 mx = 1e18;

  for (const auto& x : a) if (x == 0) {
    return 0LL;
  }

  __int128 ans = 1;
  for (const auto& x : a) {
    ans *= __int128(x);
    if (ans > mx) { return -1LL; }
  }

  return (long long)(ans);
}

signed main() {
  int n;
  std::cin >> n;
  std::vector<long long> a;
  a.reserve(n);
  for (int i = 0; i < n; ++i) {
    long long val;
    std::cin >> val;
    a.emplace_back(val);
  }
  auto ans = solve(n, a);
  std::cout << ans << std::endl;
}

Measured memory_bytes: 4028
void main() {
	auto N = ri;
	string res;
	if(N == 0) res = "0";
	while(N != 0) {
		if(abs(N)%2 == 1) {
			N--;
			res ~= '1';
		} else res ~= '0';
		N/=-2;
	}
	auto arr = res.to!(dchar[]);
	arr.reverse();
	arr.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

LL K;

vector<LL> ret;

int main() {
	cin >> K;
	ret.clear();
	FOR (i, 50)
		ret.pb(49);
	LL mod = K % 50LL;
	K /= 50LL;
	FOR (i, ret.sz)
		ret[i] += K;
	FOR (i, mod)
		ret[i]++;
	ffor (i, mod, ret.sz)
		ret[i] -= mod;
	cout << 50 << endl;
	FOR (i, 50)
		cout << ret[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> x;
    long long tmp;
    x.push_back(-1e9-3);
    for(int i = 0;i<n;i++){
        cin >> tmp;
        x.push_back(tmp);
    }
    long l;
    cin >> l;
    x.push_back(1e12);
    int db[20][n+2];
    int db2[20][n+2];
    for(int i = 0;i<n;i++){
        db[0][i+1]=(--upper_bound(x.begin(),x.end(),x[i+1]+l)-x.begin());
        db2[0][i+1]=(lower_bound(x.begin(),x.end(),x[i+1]-l)-x.begin());
        //cout << db[0][i] << endl;
    }
    db[0][n+1]=n+1;
    db[0][n]=n+1;
    db[0][0]=n+1;
    db2[0][1]=0;
    db2[0][0]=0;
    db2[0][n+1]=0;
    for(int i = 0;i<19;i++){
        //cout << "db2[" << i << "][i]:::" << " ";
        //for(int j = 0;j<=n+1;j++) cout << db2[i][j] << " ";
        for(int j = 0;j<=n+1;j++){
            db[i+1][j]=db[i][db[i][j]];
            db2[i+1][j]=db2[i][db2[i][j]];
        }
        //cout << endl;
    }
    int q;
    cin >> q;
    long a,b;
    long ans[q];
    fill_n(ans,q,0);
    for(int i = 0;i<q;i++){
        cin >> a >> b;
        int cnt = 19;
        if(a<b){
            while(a!=b&&cnt>=0){
                if(db[cnt][a]<=b){
                    ans[i]+=pow(2,cnt);
                    a = db[cnt][a];
                }
                cnt--;
            }
            if(a!=b) ans[i]++;        
        }
        else{
            while(a!=b&&cnt>=0){
                if(db2[cnt][a]>=b){
                    ans[i]+=pow(2,cnt);
                    a = db2[cnt][a];
                }
                cnt--;
            }
            if(a!=b) ans[i]++;              
        }
    }
    for(int i = 0;i<q;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 18164
// ARC084
// C - Snuke Festival

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int INF = 1e9 + 1;

int N;
vector<int> a[3];

int main() {
    cin >> N;
    for (int j = 0; j < 3; j++) {
        a[j].resize(N);
        for (int i = 0; i < N; i++) {
            cin >> a[j][i];
        }
        sort(a[j].begin(), a[j].end());
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        int u, l;
        u = lower_bound(a[0].begin(), a[0].end(), a[1][i]) - a[0].begin();
        l = a[2].end() - upper_bound(a[2].begin(), a[2].end(), a[1][i]);
        ans += 1LL * u * l;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1536
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int n, k;
vector<int> v;

int drop_k(vector<int>& v, int k) {
    sort(v.begin(), v.end());
    int ans = 0;
    for (auto vi : v) {
        if (vi < 0 && k > 0) {
            k--;
        } else {
            ans += vi;
        }
    }
    return ans;
}

int calc(int take) {
    int drop = k - take;
    if (take <= drop) return 0;
    vector<int> tmp;
    if (take >= n) {
        tmp = v;
        return drop_k(tmp, drop);
    } else {
        int ans = 0;
        REP(left, take + 1) {
            tmp.clear();
            // D(left);
            REP(j, left) {
                tmp.push_back(v[j]);
                // D(j);
            }
            for (int j = n - 1; j >= n - (take - left); j--) {
                tmp.push_back(v[j]);
                // D(j);
            }
            ans = max(ans, drop_k(tmp, drop));
        }
        return ans;
    }
    return 0;
}

int main()
{
    cin >> n >> k;
    REP(i, n) {
        int vi;
        cin >> vi;
        v.push_back(vi);
    }
    int ans = 0;
    REP(take, k + 1) {
        // DD(take, calc(take));
        ans = max(calc(take), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
int digits_sum(int n)
{
    int sum=0;
    while(n>0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}
int main(void)
{
    int N;
    scanf("%d", &N);
    int sum;
    int min=1000000;
    for(int i=1;i<=N-1;i++){
        sum=digits_sum(i) + digits_sum(N-i);
        if(min > sum) min = sum;
    }
    printf("%d\n", min);
    return 0;
}


Measured memory_bytes: 128
import sys
import itertools

N,M,R=map(int, raw_input().split())

d=[  [ float("inf") for j in range(N+1) ]  for i in range(N+1) ]

r=map(int, sys.stdin.readline().split())

for _ in range(M):
	a,b,c=map(int, sys.stdin.readline().split())
	d[a][b]=c
	d[b][a]=c

for k in range(1,N+1):
	for i in range(1,N+1):
		for j in range(1,N+1):
			d[i][j]=min(d[i][j], d[i][k]+d[k][j])


C=list(itertools.permutations(r))


ans=float("inf")
for x in C:
	tmp_ans=0
	for i in range(R-1):
		fro=x[i]
		to=x[i+1]
		tmp_ans+=d[fro][to]
	ans=min(ans, tmp_ans)

print ans
		

Measured memory_bytes: 39964
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;

int main(){
    ll n,k;
    cin >>n>>k;
    bool loop = true;
    ll diff, ans;
    //ll t1 = n%k;
    //ll t2 = k-t1;
    ll t1 = abs(n-k*(n/k));
    ll t2 = abs(n-k*(n/k+1));
    ans = min(t1,t2);
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using P = pair<double, double>;

const int INF = 1010;

bool with_in_all(const vector<P>& ps, const P& c, double R) {
  for (auto p : ps) {
    double dx = p.fst - c.fst;
    double dy = p.snd - c.snd;
    if (dx * dx + dy * dy > R * R + 1e-9) return false;
  }
  return true;
}

bool check(const vector<P>& ps, const P& p, const P& q, double R) {
  double d = hypot(q.fst - p.fst, q.snd - p.snd);
  if (d > 2 * R) return false;
  double a = atan2(q.snd - p.snd, q.fst - p.fst);
  double th = acos(d / (2 * R));
  P p1(p.fst + R * cos(a + th), p.snd + R * sin(a + th)), p2(p.fst + R * cos(a - th), p.snd + R * sin(a - th));
  return with_in_all(ps, p1, R) || with_in_all(ps, p2, R);
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<P> ps(N);
    for (auto& p : ps) cin >> p.fst >> p.snd;
    double fail = 0, pass = INF;
    for (int t = 0; t < 100; t++) {
      double R = (fail + pass) / 2;
      bool ok = false;
      for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
          ok |= check(ps, ps[i], ps[j], R);
        }
      }
      if (ok) {
        pass = R;
      } else {
        fail = R;
      }
    }
     printf("%.20f\n", pass);
  }
  return 0;
}


Measured memory_bytes: 384