akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int ans = 0;
		Map<Long, Integer> fact = new HashMap<>();
		for(long i = 2; i <= Math.sqrt(N); i++) {
			if(N % i == 0) {
				int n = 0;
				while(N % i == 0) {
					N /= i;
					n++;
				}
				fact.put(i, n);
			}
		}
		if(N > 1)
			fact.put(N, 1);
		for(int i : fact.values()) {
			int x = 1;
			while(i >= x) {
				i -= x;
				x++;
				ans++;
			}
		}
		System.out.println(ans);
	}

}

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

using namespace std;

const int N = 3e5+2;

//compress A[i] first
//so that we can use LIS via Segment tree

long long s;
long long e;
long long val;
long long segtree[N << 2];

void update(int P , int L , int R){
     if(L > e || R < s){
        return;
     } else if(s <= L && R <= e) {
        segtree[P] = val;
        return;
     }
     int mid = (L + R) >> 1;
     update( (P << 1) | 0 , L , mid + 0);
     update( (P << 1) | 1 , mid + 1 , R);
     //segtree[P] = segtree[P << 1] + segtree[P << 1 | 1];
     segtree[P] = max(segtree[P << 1] , segtree[P << 1 | 1]);
}

long long query(int P , int L , int R){
    if(L > e || R < s){
        return 0;
    } else if(s <= L && R <= e){
        return segtree[P];
    } else {
        int mid = (L + R) >> 1;
        long long a = query( (P << 1) | 0 , L , mid + 0);
        long long b = query( (P << 1) | 1 , mid + 1 , R);
        return max(a , b);
    }
}

int n;
int a[N];
int ans[N];
map < int , int > to;
vector < int > adj[N];

void dfs(int u , int p){
    //cout << u << "\n";
    s = a[u] , e = a[u];
    int prv = query(1 , 1 , n);

    s = 1 , e = a[u] - 1;
    ans[u] = query(1 , 1 , n) + 1;
    s = e = a[u];
    val = ans[u];

    update(1 , 1 ,  n);
    ans[u] = max(ans[u] , ans[p]);

    for(auto v : adj[u]){
        if(v == p)
            continue;
        dfs(v , u);
    }

    s = a[u];
    e = a[u];
    val = prv;
    update(1 , 1 , n);
}

int main(){
    scanf("%d" , &n);
    vector < int > all;
    for(int i = 1; i <= n; i++){
        scanf("%d" , &a[i]);
        all.push_back(a[i]);
    }
    int idx = 2;
    sort(all.begin() , all.end());
    for(int i = 0; i < n; i++){
        if(!i){
            to[all[i]] = idx;
            continue;
        }
        if(all[i] == all[i - 1]){
            to[all[i]] = to[all[i - 1]];
        } else {
            to[all[i]] = ++idx;
        }
    }
    for(int i = 1; i <= n; i++){
        a[i] = to[a[i]];
    }

    for(int i = 1; i < n; i++){
        int u , v;
        scanf("%d%d" , &u , &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1 , 0);
    for(int i = 1; i <= n; i++){
        printf("%d\n" , ans[i]);
    }
}


Measured memory_bytes: 42060
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

pre = -1
ans = 0
for a in A:
    ans += B[a - 1]
    if a == pre + 1:
        ans += C[pre - 1]
    pre = a
print(ans)


Measured memory_bytes: 61876
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;
        int a[n + 5];
        map<int, int> mp;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
            mp[a[i]]++;
        }

        int tot[n + 5];
        for(int i = 1; i <= n; i++) {
            int x = mp[i];
            tot[i] = x * (x - 1) / 2;
        }

        int ans = 0;
        for(int i = 1; i <= n; i++)
            ans += tot[i];

        for(int i = 1; i <= n; i++) {
            int x = a[i], cnt = mp[x];
            cout << ans - (cnt - 1) << '\n';
        }
        
    }
    
    return 0;
}



Measured memory_bytes: 19264
#include <iostream>
#include <vector>
int main()
{
    std::size_t N;
    std::cin >> N;
    std::size_t tmp;
   if( [&]{
        for(size_t i=0; i < N; ++i){
            std::cin >> tmp;
            if (tmp % 2 != 0) return true;
        }
        std::cout << "second" << std::endl;
        return false;
    }())
       std::cout << "first" << std::endl;

}

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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

void init(){
}

int bin(int *p, int n, int x){
    int l = 0, r = n-1;
    while (r >= l){
        int m = (l+r)/2;
        if (p[m] == x) return m;
        if (p[m] > x) r = m-1;
        else l = m+1;
    }
    return -1;
}

void solve(){
    int x, n;
    cin >> x >> n;
    if (n == 0){
        cout << x << '\n';
        return;
    }
    int *p = new int[n];
    forn{
        cin >> p[i];
    }
    sort(p, p+n);
    int ans = 0;
    int i = 0;
    while (true){
        int t1 = bin(p, n, x+i);
        int t2 = bin(p, n, x-i);
        if (t2 < 0){
            ans = x-i;
            break;
        }
        if (t1 < 0){
            ans = x+i;
            break;
        }
        i++;
    }
    cout << ans << '\n';
}


int main(){
    //init();

    ios::sync_with_stdio(0);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

typedef long long int ll;


using namespace std;

string s;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)break;
		vector<vector<int> > v(n,vector<int> (n,0));
		int x=n/2,y=n-x;
		for(int i=1; i<=n*n; i++){
			while(1){
				if(x>=0&&y>=0&&x<n&&y<n&&v[x][y]==0){
					v[x][y]=i;
					x++;
					y++;
					break;
				}
				if(x>=n)x=0;
				if(x<0)x=n-1;
				if(y>=n)y=0;
				if(v[x][y]>0){
					x--;
					y++;
				}
			}
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				printf("%4d",v[j][i]);
			}
			printf("\n");
		}
	}
}

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

int main()
{
    int n, w;
    cin >> n >> w;
    vector<int> weights(n), profits(n);
    for(int i = 0; i < n; i++)
        cin >> weights[i] >> profits[i];
    vector<long> dp (w + 1, INT_MIN);
    for(int i = 0; i <= n; i++)
    {
        vector<long> dp1 (w + 1, INT_MIN);
        for(int j = 0; j <= w; j++)
        {
            if(i == 0 || j == 0)
                dp1[j] = 0;
            else if(j < weights[i - 1])
                dp1[j] = dp[j];
            else
            {
                dp1[j] = max(dp1[j], dp[j]);
                dp1[j] = max(dp1[j], dp[j - weights[i - 1]] + profits[i - 1]);
            }
        }
        dp = dp1;
    }
    cout << dp[w];
    // cout << solve(0, w, weights, profits);
    return 0;
}

Measured memory_bytes: 1804
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      csfs: [(usize, usize, usize); n-1],
    }
    for i in 0..n-1 {
        let mut t = 0;
        for j in i..n-1 {
            let (c, s, f) = csfs[j];
            t = max(t, s);
            if t % f != 0 {
                t = t / f * f + f;
            }
            t += c;
        }
        println!("{}", t);
    }
    println!("{}", 0);
}


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

typedef long long ll;
typedef vector<ll> vl;
const ll        MOD=1000000007;

#define pb push_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n;
bool a[1001];
vl v;
void seive()
{
    ll mx=sqrt(1000),ii,jj;
    for(ii=3;ii<=mx;ii+=2)
        if(!a[ii])
            for(jj=ii*ii;jj<=1000;jj+=2*ii) a[jj]=true;
    v.pb(2);
    for(ll i=3;i<=1000;i+=2) if(!a[i]) v.pb(i);
}

void _case()
{
    cin>>n;
    seive();
    ll ans=1,s=sqrt(n);
    for(ll i=0;i<v.size() and v[i]<=n;i++){
        ll rate=0,x=v[i];
        while(x<=n) {rate+=n/x; x*=v[i];}
        ans*=(rate+1);
        ans%=MOD;
    }
    //for(auto i:v) cout<<i sp;
    cout<<ans<<'\n';
}

main()
{
    fastio();
    _case();

}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef unsigned long lli;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char c;
    cin >> c;
    if(c>='A' && c<='Z') cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
#define rrep(k,i,n) for(long long i=n-1;i>=k;--i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll H,W;
    cin>>H>>W;
    string S;
    bool T[H][W];
    rep(0,i,H){
        cin>>S;
        rep(0,j,W){
            string a=S.substr(j,1);
            if(a==".")T[i][j]=false;
            else T[i][j]=true;
        }
    }
    ll dp[4][H][W];
    rep(0,i,H){
        rep(0,j,W){
            if(T[i][j]==true)dp[0][i][j]=0;
            else if(j==0)dp[0][i][j]=1;
            else dp[0][i][j]=dp[0][i][j-1]+1;
        }
        rrep(0,j,W){
            if(T[i][j]==true)dp[1][i][j]=0;
            else if(j==W-1)dp[1][i][j]=1;
            else dp[1][i][j]=dp[1][i][j+1]+1;
        }
    }
    rep(0,j,W){
        rep(0,i,H){
            if(T[i][j]==true)dp[2][i][j]=0;
            else if(i==0)dp[2][i][j]=1;
            else dp[2][i][j]=dp[2][i-1][j]+1;
        }
        rrep(0,i,H){
            if(T[i][j]==true)dp[3][i][j]=0;
            else if(i==H-1)dp[3][i][j]=1;
            else dp[3][i][j]=dp[3][i+1][j]+1;
        }
    }
    ll ans=0;
    rep(0,i,H){
        rep(0,j,W)ans=max(ans,dp[0][i][j]+dp[1][i][j]+dp[2][i][j]+dp[3][i][j]-3);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 129152
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;
const int MAX_N = 1e5 + 1;
int logA[MAX_N], logB[MAX_N], logBSum[MAX_N];
int N;

int main() {
   cin >> N;
   vector<int> a, b, c;
   int tmp;
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      a.push_back(tmp);
   }
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      b.push_back(tmp);
   }
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      c.push_back(tmp);
   }

   sort(a.begin(), a.end());
   sort(b.begin(), b.end());
   sort(c.begin(), c.end());
   
   ll ans = 0;
   for (int i = 0; i < N; i++) {
      decltype(c)::iterator it = upper_bound(c.begin(), c.end(), b[i]);
      decltype(a)::iterator it2 = lower_bound(a.begin(), a.end(), b[i]);
      ans += (it2 - a.begin()) * (c.end() - it);
   }

   cout << ans << endl;
   return 0;
}


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

int main(){

    vector<int> N(4);
    cin >> N[0] >> N[1] >> N[2] >> N[3];
    sort(N.begin(), N.end());
    if(N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI a(n), b(n+1);
	rep(i, n){ cin >>a[i]; a[i]--;}
	
	rep(i, n) b[i+1] = (b[i] + a[i] )%k;
	
	ll ans =0;
	unordered_map<int, int> mp; mp.reserve(n);
	rep(i, n+1){
		if(i-k>=0) mp[b[i-k]]--;
		int cr = b[i];
		ans += mp[cr];
		mp[cr]++;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 9728
#include<bits/stdc++.h> 
typedef long long int ll;
using namespace std;
const ll P = 1000000007;


ll solve(){

	string s;
	cin>>s;

	ll sum = 0;
	const ll  mod = 9;
	for(auto &x : s) sum = (sum + (x-'0')) % mod;

	if(!sum) cout<<"Yes\n";
	else cout<<"No\n";

	return 0;
}

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

 	ll t = 1;
    // cin>>t;

    while(t--){
    	solve();
    }   

    return 0;
}	 

Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1};
int dx[] = {1, -1, 0, 0};

int main() {
    int v, d;
    while (cin >> v >> d) {
        vector<int> fib(1001);
        fib[0] = 2; fib[1] = 3;
        rrep(i, 2, 1001) {
            fib[i] = fib[i - 1] + fib[i - 2];
            fib[i] %= 1001;
        }
        sort(fib.begin(), fib.begin() + v);
        int ac = 1;
        //rep(i, v) cout << fib[i] << endl;
        rrep(i, 1, v) {
            if (fib[i] - fib[i - 1] >= d) {
                ac++;
            }
        }
        cout << ac << endl;
    }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
ll x, k, d;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> x >> k >> d;
	if (x < 0) x = -x;
	ll ans = 1000000000000000000;
	if (x/k >= d){
		cout << x - d*k << endl;
		return 0;
	}
	
	if (((x - (x%d))/d % 2) == k%2){
		ans = min(ans, x%d);
	} else {
		ans = min(ans, d - (x%d));
	}
	
	cout << ans << endl;
}

//cout.flush()
//cout << fixed << setprecision(9) << x << endl;

Measured memory_bytes: 3648
import java.util.*;

import static java.lang.System.*;

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

        int[][] distances = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                distances[i][j] = sc.nextInt();
            }
        }

        int[] nums = new int[10];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                int a = sc.nextInt();
                if(a != -1){
                    nums[a]++;
                }
            }
        }

        warshallFloyd(10, distances);

        int ans = 0;
        for(int i = 0; i < 10; i++){
            ans += nums[i] * distances[i][1];
        }

        out.println(ans);
    }

    public static void warshallFloyd(int vertex, int[][] distance) {
        for (int k = 0; k < vertex; k++) {           // 経由する頂点
            for (int i = 0; i < vertex; i++) {        // スタートの頂点
                for (int j = 0; j < vertex; j++) {   // ゴールの頂点
                    if (distance[i][j] > distance[i][k] + distance[k][j]) {
                        distance[i][j] = distance[i][k] + distance[k][j];
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 45472
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string input_1,input_2;
    long long counts=0;

    cin >>  input_1 >> input_2;  

    for(int i=0;i<input_1.length();i++){
        if(input_1[i]!=input_2[i]){
            counts++;
        }
    }
    
    cout << counts << endl;
    return 0;
}

Measured memory_bytes: 3916
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    	Scanner sc = new Scanner(System.in);
	    	int d = sc.nextInt();
	    	if (d == 25) {
	    		System.out.println("Christmas");
	    	} else if (d == 24) {
	    		System.out.println("Christmas Eve");
	    	} else if (d == 23) {
	    		System.out.println("Christmas Eve Eve");
	    	} else if (d == 22) {
	    		System.out.println("Christmas Eve Eve Eve");
	    	}
	}
}


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

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);
		new Solution().solve(in, out);
		out.close();
	}
	
	static class Solution {
		public void solve(InputReader in, PrintWriter out) {
			int a = in.nextInt();
			int b = in.nextInt();
			out.println(a * b);
		}
	}

	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();
				}
			}
			return tokenizer.nextToken();
		}

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


Measured memory_bytes: 25628
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    int t=1;
    // cin>>t;
    while(t--)
    {
        int a;cin>>a;
        cout<<a+(a*a)+(a*a*a);
    }    
} 

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

class Graph {
    int V;
    vector<list<int>> edges;
    public:
    Graph(int nodes){
        V = nodes;
        edges.resize(nodes + 1);
    }
    void addEdge(int from, int to){
        edges[from].push_back(to);
    }
    int min_dist(int &fin, int i, map<int ,bool> &special, vector<bool> &check){
        check[i] = true; 
        multiset<int> ms;     
        int k;
        for(auto it = edges[i].begin(); it != edges[i].end(); it++){
            if(check[*it] == true)
                continue;
            k = min_dist(fin, *it, special, check);
            if(k != 0)
                ms.insert(k);
        }
        for(auto it = ms.begin(); it != ms.end(); it++){
            fin += (*it);
            //cout << *it << " ";
        }
        //cout << endl;
        if(ms.size() % 2 == 0){
            if(special[i])    
                return 1;
            return 0;
        }
        else{
            if(special[i])
                return 0;
            auto it = ms.begin();
            fin -= (*it);
            return (*it) + 1;
        }
    }
};


int main(){
    int t = 1;
    //cin >> t;
    while(t--){
        string a, b;
        cin >> a >> b;
        int min_del = INT_MAX;
        for(int i = 0; i <= a.size() - b.size(); i++){
            int del = 0;
            for(int j = 0; j < b.size(); j++){
                if(a[i + j] != b[j]){
                    del++;
                }
            }
            //cout << i << " " << " " << del << endl;
            if(min_del > del){
                min_del = del;
            }
        }
        
        cout << min_del << endl;
    }
    return 0;
}







Measured memory_bytes: 3640
import sys
from functools import reduce

input = sys.stdin.readline

N = int(input())
A = input().rstrip().split()

def main():
    result = 1
    if '0' in A:
        return 0

    for a in A:
        a = int(a)
        result *= a

        if result > pow(10, 18):
            return -1

    return result

ans = main()
print(ans)

Measured memory_bytes: 82172
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define f first
#define s second
#define mod 1000000007
#define inf 1<<30


ll N,M,R;

vector<vector<ll>> g(210,vector<ll>(210,inf));

int main() {
    cin >> N >> M >> R;
    vector<ll>r(R);
    rep(i,R) {
        ll s; cin >> s;
        r[i] = s-1;
    }
    rep(i,M){
        ll A,B,C;
        cin >> A >> B >> C;
        g[A-1][B-1] = C;
        g[B-1][A-1] = C;
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                if (g[i][j] > g[i][k] + g[k][j]){
                    g[i][j] = g[i][k] + g[k][j];
                }
            }
        }
    }
    ll ans = inf;
    sort(all(r));
    do{
        ll temp = 0;
        rep(i,R-1){
            temp += g[r[i]][r[i+1]];
        }
        if (temp < ans){
            ans = temp;
        }
    }while(next_permutation(all(r)));
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) {
        cin >> s[i];
    }
    set<string> s_set(s.begin(), s.end());

    cout << s_set.size() << endl;

    return 0;
}

Measured memory_bytes: 25168
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	vi p(300001, 1);
	p[0] = false;
	p[1] = false;
	p[2] = false;
	p[3] = false;
	p[4] = false;
	p[5] = false;
	FOR(i, 6, p.size()) {
		if (p[i] && (i % 7 == 6 || i % 7 == 1)) {
			for (int j = 1; i*(j * 7 - 1) < 300001; ++j) {
				if (i*(j * 7 - 1) < p.size())p[i*(j * 7 - 1)] = false;
				if (i*(j * 7 + 1) < p.size())p[i*(j * 7 + 1)] = false;
			}
		}
		else {
			p[i] = false;
		}
	}

	while (1) {
		int n;
		cin >> n;
		if (n == 1)break;
		cout << n << ":";
		FOR(i, 1, 300001) {
			if (n%i == 0 && p[i])cout << " " << i;
		}
		cout << endl;

	}
	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  unordered_map<int, int64_t> counts;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    counts[A[i]]++;
  }

  int64_t total = 0;
  for (const auto& p : counts) {
    int64_t count = p.second;
    total += (count) * (count - 1) / 2;
  }

  for (int i = 0; i < N; i++) {
    int64_t count = counts[A[i]];
    int64_t used = (count) * (count - 1) / 2;
    int64_t actual = (count - 1) * (count - 2) / 2;
    int64_t answer = total - used + actual;
    cout << answer << endl;
  }

  return 0;
}


Measured memory_bytes: 9928
import java.util.Scanner;

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

		if (N != 100) {
			int baseCount = 1;
			for (int i = 1; i <= D ; i++) {
				baseCount = baseCount * 100;
			}
			System.out.println(baseCount*N);
		} else {
			int result = 0;
			if (D == 0) {
				result = 101;
			} else if(D == 1) {
				result = 10100;
			} else {
				result = 1010000;
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 23764
/*
    Author: Shivam Shukla
    Title : DP_M_Modified.cpp
    Date : 02/09/2020   >> 14:49:30
*/

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
#define INF(x) numeric_limits<x>::max()
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
    fastio();
    auto tstart= clock();
 
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      freopen("error.txt","w",stderr);
    #endif   

    int n, k; cin >> n >> k;
    vl a(n); repa(i, n) cin >> a[i];

    vc(vl) dp(n + 1, vl(k + 1, 0)), pre(n + 1, vl(k + 1, 0));

    dp[0][0] = 1;
    pre[0][0] = dp[0][0];
    rep(j, 1, k + 1)
        pre[0][j] = pre[0][j - 1] + dp[0][j], dp[0][j] = pre[0][j];
  
    rep(i, 1, n + 1) {
        repa(j, k + 1) {
            dp[i][j] = (dp[i][j] + MOD + pre[i - 1][j] - ((j > a[i - 1]) ? pre[i - 1][j - a[i - 1] - 1] : 0) % MOD) % MOD;
            pre[i][j] = (((j) ? pre[i][j - 1] : 0) + dp[i][j]) % MOD;
        }        
    }   

    cout << dp[n][k] << endl;

    cerr << setprecision(2) << fixed<<"Time elapsed: " << (double)(clock() - tstart)/CLOCKS_PER_SEC << endl; 
    return 0; 
}

Measured memory_bytes: 161968
cnt = 9


def solve():
    k = int(input())

    numl = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    keta = 1
    dr = [-1, 0, 1]

    def dfs(n, nowk, s):
        if nowk == keta:
            global cnt
            cnt = cnt + 1
            # print(s, cnt, k)
            if cnt == k:
                print(s)
                return True
            else:
                return False


        for d in dr:
            cand = n + d
            if cand == -1 or cand == 10:
                continue
            if dfs(cand, nowk+1, s + str(cand)):
                return True
        return False

    flag = False

    while 1:
        if k < 10:
            print(k)
            break
        keta = keta + 1
        for n in numl:
            # print('1st: ', n)
            if dfs(n, 1, str(n)):
                flag = True
                # print(cnt, 'aaa')
                break
        if flag:
            break




if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    a = int(input())

    #output
    print(a + a**2 + a**3)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = k; i < n; i++) {
        int l = a[i - k];
        int r = a[i];
        if (r > l) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4048
loop do
    t = gets.to_i
    break if t == 0
    cycle = gets.split.map(&:to_i)

    schedule = Hash.new(Float::INFINITY)
    n = gets.to_i
    n.times do
        d, t = gets.split.map(&:to_i)
        schedule[d] = t if t < schedule[d]
    end

    table = [nil] * cycle.size
    table[-1] = 0
    (1..schedule.keys.max).each do |d|
        m = table.compact.min + 1
        table.unshift(table.pop)
        (1..cycle.size-1).each do |i|
            table[i] = nil if cycle[i] > schedule[d]
        end
        table[0] = m if !table[0] || m < table[0]
    end

    p table.compact.min
end

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve()
{
  ll n, m, a, b;
  cin >> n >> m;
  vector<P> input(m);
  vector< vector<int> > edge(n, vector<int>());
  for(int i = 0; i < m; ++i)
  {
    cin >> a >> b;
    a--; b--;
    input[i] = P(a, b);
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
  }

  int ans = 0;
  for(int removed = 0; removed < m; ++removed)
  {
    vector<bool> visited(n, false);
    queue<int> que;
    que.push(0);
    while(!que.empty())
    {
      int now = que.front();
      que.pop();
      visited[now] = true;
      for(const auto& to : edge[now])
      {
        if (input[removed].first == now && input[removed].second == to ) continue;
        if (input[removed].first == to  && input[removed].second == now) continue;
        if (!visited[to]) que.push(to);
      }
    }
    bool ok = true;
    for(int i = 0; i < n; ++i) ok &= visited[i];
    ans += !ok;
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  ll X;
  scanf("%lld", &X);

  ll ans = 0;
  ll cur = 100;
  while (cur < X) {
    cur += (cur / 100);
    ans++;
  }
  printf("%lld\n", ans);
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}



Measured memory_bytes: 3780
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
#define F first
#define S second
#define pb push_back
#define p push
using namespace std;
using ll = long long;
const ll maxn=5e5+5,inf = 1e18+18;
ll n,m,t;
string s;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0 ) ,cout.tie(0);
	cin>>n;
	if(n>29)cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var encode = new Dictionary<string, string>()
			{
				{ " ",     "101" }, { "'",  "000000" }, { ",",   "000011" }, { "-", "10010001" },
				{ ".",  "010001" }, { "?",  "000001" }, { "A",   "100101" }, { "B", "10011010" },
				{ "C",    "0101" }, { "D",    "0001" }, { "E",      "110" }, { "F",    "01001" },
				{ "G","10011011" },{ "H",   "010000" }, { "I",     "0111" }, { "J", "10011000" },
				{ "K",    "0110" }, { "L",   "00100" }, { "M", "10011001" }, { "N", "10011110" },
				{ "O",   "00101" }, { "P",     "111" }, { "Q", "10011111" }, { "R",     "1000" },
				{ "S",   "00110" }, { "T",   "00111" }, { "U", "10011100" }, { "V", "10011101" },
				{ "W",  "000010" }, { "X","10010010" }, { "Y", "10010011" }, { "Z", "10010000" }
			};
			var decode = new Dictionary<string, string>()
			{
				{ "00000", "A" }, { "00001", "B" }, { "00010", "C" }, { "00011", "D" },
				{ "00100", "E" }, { "00101", "F" }, { "00110", "G" }, { "00111", "H" },
				{ "01000", "I" }, { "01001", "J" }, { "01010", "K" }, { "01011", "L" },
				{ "01100", "M" }, { "01101", "N" }, { "01110", "O" }, { "01111", "P" },
				{ "10000", "Q" }, { "10001", "R" }, { "10010", "S" }, { "10011", "T" },
				{ "10100", "U" }, { "10101", "V" }, { "10110", "W" }, { "10111", "X" },
				{ "11000", "Y" }, { "11001", "Z" }, { "11010", " " }, { "11011", "." },
				{ "11100", "," }, { "11101", "-" }, { "11110", "'" }, { "11111", "?" },
			};

			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				var encoded = string.Join("", s.Select(c => encode[c.ToString()]).ToArray());
				if (encoded.Length % 5 != 0)
					encoded += new string(Enumerable.Repeat('0', (5 - (encoded.Length % 5))).ToArray());
				var splited = new List<string>();
				int index = 0;
				while (index + 5 <= encoded.Length)
				{
					splited.Add(encoded.Substring(index, 5));
					index += 5;
				}
				var decoded = string.Join("", splited.Select(c => decode[c]).ToArray());
				Console.WriteLine(decoded);
			}
		}
	}
}

Measured memory_bytes: 6052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, n; cin >> h >> w >> n;
  int mx = max(h, w);
  cout << (n+mx-1)/mx << endk;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  bool f = true;
  h[0] = max(h[0] - 1, 0);
  rep1(i,n-1) {
    if(h[i-1] <= h[i] - 1) h[i]--;
    else if(h[i-1] > h[i]) {
      f = false;
      break;
    }
  }
  if(f) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 768
MOD = 10 ** 9 + 7
ONE = '1'.freeze

def nCk(n, k)
  res = 1
  i = k
  j = 1
  while i > 0
    res = res * (n - i + 1)
    res %= MOD
    j *= i
    j %= MOD
    i -= 1
  end
  res *= inv(j)
  res %= MOD
  res
end

def repeated_nCk(n, k)
  # 仕切りのイメージで
  nCk(n + k - 1, n - 1) % MOD
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == ONE
    beki = (beki * beki) % MOD
  end
  res
end

n, pp = gets.split.map(&:to_i)
cookies = gets.split.map(&:to_i)
odd_count = cookies.count { |n| n.odd? }
even_count = n - odd_count
zeros = 1
ones = 0

(1..odd_count).each do |i|
  if i.odd?
    ones += nCk(odd_count, i)
  else
    zeros += nCk(odd_count, i)
  end
end

if pp == 0
  puts zeros * 2 ** even_count
else
  puts ones * 2 ** even_count
end


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int N;
int A[111111];

int l[111111];
int r[111111];

signed main() {
  cin >> N;
  rep (i, N) {
    cin >> A[i];
  }

  rep (i, N) {
    l[i+1] = __gcd(l[i], A[i]);
  }
  for (int i = N; i >= 1; i--) {
    r[i] = __gcd(r[i+1], A[i-1]);
  }
  // print1(l, l+N+2);
  // print1(r, r+N+2);

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int t = __gcd(l[i-1], r[i+1]);
    chmax(ans, t);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    while True:
        n, m = map(int, input().split())
        if [n, m] == [0, 0]:
            break
        else:
            A = [int(input()) for i in range(n)]
            B = [0] + A
            # 累積和を格納したリスト．A[l:r]の総和はB[r] - B[l]
            B = list(accumulate(B))

            val = max([B[i + m] - B[i] for i in range(n - m + 1)])
            print(val)

resolve()


Measured memory_bytes: 15484
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

bool is_ok(const int& start_pos, const int& S_size,  const string& S, const string& T) {
  string S_tmp {};
  srep(i, start_pos, S_size) {
    S_tmp += S[i];
  }
  rep(i, start_pos) {
    S_tmp += S[i];
  }
  return S_tmp == T;
}
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  string S, T;
  cin >> S >> T;

  int S_size = S.size();
  bool is_find = false;
  rep(i, S_size) {
    if (is_ok(i, S_size, S, T)) {
      is_find = true;
      break;
    }
  }
  if (is_find == true) cout << "Yes\n";
  else cout << "No\n";
}


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

int n;
const int N = 25;
int a[N], b[N], c[N];

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

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)
for _ in range(M):
    x, y, c = map(int, input().split())
    pay = a[x - 1] + b[y - 1] - c
    ans = min(ans, pay)

print(ans)


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

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}

int main()
{
	int n;
	double x,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%lf",&x);
		sum+=1.0/x;
	}	
	printf("%lf",1.0/sum);
	return 0;	
} 

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))

xs = sorted(x)
med = dict()
for i, k in enumerate(xs):
  if i < n//2:
    med[k] = xs[n//2]
  else:
    med[k] = xs[n//2 - 1]

for k in x:
  print(med[k])

Measured memory_bytes: 34820
N, M = map(int, input().split())
List = list(map(int, input().split()))
total = 0
for n in range(N):
    total += List[n]
limit = total/(4*M)
count = 0
for n in range(N):
    if List[n] >= limit:
        count += 1
if count >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int l, r; cin >> l >> r;
    int val = r - l;
    if(val > 3000) cout << 0 << endl;
    else{
        int ans = INF;
        for(int i = l; i <= r; i++){
            for(int j = i + 1; j <= r; j++){
                ans = min(ans, (i * j) % 2019);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256