akhauriyash/Code-Regression huggingface dataset:
'use strict'

const main = (input) => {
    input = input.split(' ').map(i => parseInt(i))
    const A = input[0]
    const B = input[1]
    const X = input[2]
    if(A <= X && X <= A + B){
        console.log('YES')
    }else{
        console.log('NO')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

const int MX = 500005;

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

struct WATER
{
	int v;
	double t;
	
	WATER operator += (const WATER &o)
	{
		t = (t*v + o.t*o.v) / (v+o.v);
		v = v + o.v;
	}
};

int n, l;
WATER wat[MX], que[MX];

int main()
{
	read(n), read(l);
	for(int i=1; i<=n; i++) read(wat[i].t), read(wat[i].v);
	int sum = 0, h = 0, t = 1;
	double Q = 0;
	for(int i=1; i<=n; i++)
	{
		while(t<=h && sum+wat[i].v>l)
		{
			int del = min(que[t].v, sum+wat[i].v-l);
			que[t].v -= del;
			Q -= que[t].t*del;
			sum -= del;
			if(!que[t].v) t++;
		}
		que[++h] = wat[i];
		sum += wat[i].v;
		Q += wat[i].v*wat[i].t;
		while(t<h && que[h-1].t>=que[h].t) que[h-1] += que[h], h--;
		printf("%.8lf\n", Q/l);
	}
	return 0;
}

Measured memory_bytes: 25088
/*
	In the name of Allah.
*/

#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define gap ' '
#define INF 99999999
#define L(i) ((i) & -(i))
 
const int MAXN = 1e5 + 10;
int n, P[MAXN], cnt[MAXN];


int main(){
	cin >> n;
	ll sum = 0;
	for(int i = 0; i < n; ++i){
		cin >> P[i];
		sum+=P[i];
		cnt[P[i]]++;
	}
	int q; cin >> q;
	while(q--){
		int x, y; cin >> x >> y;
		int k = cnt[x];
		sum = sum + ((y*k) - (x*k));
		cnt[x] = 0, cnt[y]+=k;
		cout << sum << endl;
	}

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n;
vl a;
/******* define variable end *******/
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
int solve() {
	cin >> n;
	a.resize(n);
	ll same = true;
	REP(i, n){
		cin >> a[i];
		if(i > 0){
			if(a[i] == a[i-1]){
				same = true;
			}else{
				same = false;
			}
		}
	}
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	if(same){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	sort(ALL(a));
	if(a[0] == a[1]){
		ans--;
	}
	REP(i, n){
		vl enums = enum_divisors(a[i]);
		bool flag = true;
		if(i != 0){
			for(auto j : enums){
				auto ite = lower_bound(a.begin(), a.begin()+i-1, j);
				if(ite != a.end()){
					if(*ite == j){
						flag = false;
					}
				}
				auto ite2 = lower_bound(a.begin()+i+1, a.end(), j);
				if(ite2 != a.end()){
					if(*ite2 == j){
						flag = false;
					}
				}
			}
		}
		if(flag){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int x, t;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> t;
  cout << max(x-t, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

char s[1009][1009];
char t[1009][1009];
int r[1009];

int main(){
	DRI(n);
	REP(i,n){
		RS(s[i]);
	}
	int ans=1<<30;
		MS0(r);
		REP(i,n){
			REP(j,n){
				r[i]+=s[i][j]=='#';
			}
		}
		int fc=0;//full columns
		REP(i,n){
			int f=1;
			REP(j,n){
				f&=(s[j][i]=='#');
			}
			fc+=f;
		}
		REP(i,n){
			REP(j,n){
				if(s[i][j]=='#'){
					ans=min(ans,(n-r[j])+n-fc);
					REP(k,n){
						ans=min(ans,(n-r[k])+n-fc+1);
					}
				}
			}
		}
	if(ans!=1<<30)printf("%d",ans);
	else printf("-1");
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;

     signed main(){
       string s;
       cin>>s;
       for(int i=1;i<s.size();i++)if(s[i]==s[i-1]){
          cout<<i<<' '<<i+1<<endl;
          return 0;
       }
       for(int i=2;i<s.size();i++)if(s[i]==s[i-2]){
          cout<<i-1<<' '<<i+1<<endl;
          return 0;
       }
       cout<<-1<<' '<<-1<<endl;


      }

        


Measured memory_bytes: 512
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
//#include<ext/rope>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
const double PI=acos(-1.0);
const double eps=1e-6;
ll a[100005],x[100005];
inline ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
template<typename T> void debug(T x)
{
    cout<<"value="<<x<<endl;
    return;
}
signed main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    ll n;
    while(cin>>n){
        for(ll i=1;i<=n;i++) a[i]=read();
        ll tmp=0;
        for(ll i=1;i<=n;i++){
            if(i%2==1) tmp+=a[i];
            else tmp-=a[i];
        }
        x[1]=tmp/2;
        for(ll i=2;i<=n;i++) x[i]=a[i-1]-x[i-1];
        for(ll i=1;i<=n;i++) printf("%d ",2*x[i]);
        cout<<endl;
    }
	return 0;
}


Measured memory_bytes: 5232
#include <iostream>
#include <vector>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
int main() {
  int in(N); int in(K);

  vector<int> h(N), dp(N+1, 1e9);
  rep(i, N) {
    cin >> h[i];
  }
  dp[0] = 0;
  rep(i, N) rep(j, K) {
    if (i+j+1 <= N-1)
      dp[i+j+1] = min(dp[i+j+1], dp[i] + abs(h[i] - h[i+j+1]));
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;
const int INF = 1e18;

void solve()
{

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

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

    int n;
    cin >> n;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    map<int, int> mp;
    rep(i, n) mp[A[i]]++;

    int tmp1 = 0;
    for (auto a : mp)
    {
        if (a.second >= 2)
        {
            tmp1 = max(tmp1, a.first);
        }
    }
    mp[tmp1] -= 2;

    int tmp2 = 0;
    for (auto a : mp)
    {
        if (a.second >= 2)
        {
            tmp2 = max(tmp2, a.first);
        }
    }
    mp[tmp2] -= 2;

    cout << tmp1 * tmp2 << endl;

}

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


Measured memory_bytes: 7296
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int a,b,x,n;
    scanf("%d%d",&x,&n);
    x%=500;
    if(x<=n) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 128
///
// File:  2590.cpp
// Author: ymiyamoto
//
// Created on Thu Dec 28 11:40:56 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t N, M, Q;
    cin >> N >> M >> Q;
    if (N == 0 && M == 0 && Q == 0) break;

    vector<bool> sw(N, false);
    vector<vector<bool>> switches(M, vector<bool>(N, true));
    for (uint32_t i = 0; i < Q; i++) {
      string ops, state;
      cin >> ops >> state;

      for (auto &op : ops) {
        if (op == '1') {
          sw[(&op - &ops[0])] = !sw[(&op - &ops[0])];
        }
      }

      for (uint32_t j = 0; j < state.size(); j++) {
        for (uint32_t k = 0; k < ops.size(); k++) {
          if (state[j] == '1') {
            if (!sw[k]) {
              switches[j][k] = false;
            }
          } else {
            if (sw[k]) {
              switches[j][k] = false;
            }
          }
        }
      }
    }

    string nums = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string numbers;
    for (uint32_t i = 0; i < M; i++) {
      bool not_determine = false;
      int32_t num = -1;
      for (uint32_t j = 0; j < N; j++) {
        if (switches[i][j]) {
          if (num != -1) {
            not_determine = true;
          }
          num = j;
        }
      }
      if (not_determine) {
        numbers += '?';
      } else {
        numbers += nums[num];
      }
    }
    cout << numbers << endl;
  }

  return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<array>
#include<vector>
#include<string>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<deque>
#include<algorithm>
#include<cmath>

using namespace std;
#define ll long long
#define ff first
#define ss second
#define e endl

void solve() {
	ll n; cin >> n;
	vector<ll> a, res;
	ll t = -1;
	for (ll i = 0; i < n; i++) {
		ll x; cin >> x; a.push_back(x);
		if (t == -1) t = x;
		else t ^= x;
	}
	
	for (ll i = 0; i < n; i++) {
		res.push_back(t ^ a[i] ^ 0);
		cout << res[i] << e;
	}
}

int main()
{
	//ll t; cin >> t; while (t--)
	solve();
	
}

Measured memory_bytes: 7932
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
const int N=2e5+5;
int n;

template <class T> inline void apx(T &x,const T y){
	if(x<y) x=y;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

namespace G{
	int st_f,st_s,dep[N],xdis;
	int fa[N],sz[N],son[N],top[N];
	std::vector <int> vf[N],vs[N];

	inline int get_lca(int x,int y){
		while(top[x]!=top[y]){
			dep[top[x]]>dep[top[y]]?x=fa[top[x]]:y=fa[top[y]];
		}
		return dep[x]<dep[y]?x:y;
	}

	inline int get_dis(const int x,const int y){
		return dep[x]+dep[y]-(dep[get_lca(x,y)]<<1);
	}

	void dfs_sz(const int x){
		sz[x]=1;
		for(std::vector <int> ::iterator it=vs[x].begin(); it!=vs[x].end(); ++it){
			if(!sz[*it]){
				dep[*it]=dep[x]+1;
				fa[*it]=x;
				dfs_sz(*it);
				if(sz[*it]>sz[son[x]]) son[x]=*it;
				sz[x]+=sz[*it];
			}
		}
	}

	void dfs_top(const int x){
		top[x]=son[fa[x]]==x?top[fa[x]]:x;
		for(std::vector <int> ::iterator it=vs[x].begin(); it!=vs[x].end(); ++it){
			if(!top[*it]) dfs_top(*it);
		}
	}

	bool dfs_free(const int x,const int fa,const int dis){
		std::vector <int> ::iterator it;
		if(dis<dep[x]){
			for(it=vf[x].begin(); it!=vf[x].end(); ++it){
				if(get_dis(x,*it)>2) return 1;
			}
		}
		for(it=vf[x].begin(); it!=vf[x].end(); ++it){
			if(*it!=fa&&dis+1<dep[*it]){
				if(dfs_free(*it,x,dis+1)) return 1;
			}
		}
		return 0;
	}

	void dfs_xdis(const int x,const int fa,const int dis){
		apx(xdis,dep[x]);
		for(std::vector <int> ::iterator it=vf[x].begin(); it!=vf[x].end(); ++it){
			if(*it==fa) continue;
			if(dis+1==dep[*it]) apx(xdis,dis+1);
			if(dis+1<dep[*it]){
				dfs_xdis(*it,x,dis+1);
			}
		}
	}
}

int main(){
	n=nxi();
	G::st_f=nxi(),G::st_s=nxi();
	for(int i=1; i<n; ++i){
		const int x=nxi(),y=nxi();
		G::vf[x].push_back(y);
		G::vf[y].push_back(x);
	}
	for(int i=1; i<n; ++i){
		const int x=nxi(),y=nxi();
		G::vs[x].push_back(y);
		G::vs[y].push_back(x);
	}
	G::dfs_sz(G::st_s);
	G::dfs_top(G::st_s);
	if(G::dfs_free(G::st_f,0,0)){
		puts("-1");
		return 0;
	}
	G::dfs_xdis(G::st_f,0,0);
	printf("%d\n",G::xdis<<1);
	return 0;
}

Measured memory_bytes: 35840
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
	ll N,P;
    cin >> N;
    ll i;
    ll mn=N+1;
    ll ans=0;
    for(i=0;i<N;i++){
        cin >> P;
        if(mn>P){mn=P;ans++;}
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

using int64 = long long;
using uint64 = unsigned long long;

#define repeat(i, x) for (int64 i = 0; (i) < (x); (i)++)
#define rev_repeat(i, x) for (int64 i = (x) - 1; (i) >= 0; (i)--)
#define countup(i, n) for (int64 i = 0; (i) <= (n); (i)++)
#define countdown(i, n) for (int64 i = (n); (i) >= 0; (i)--)
#define range(i, a, b) for (int64 i = (a); (i) < (b); (i)++)
#define traverse(it, ctn) for (auto it = begin(ctn); (it) != end(ctn); (it)++)
#define rev_traverse(it, ctn) for (auto it = rbegin(ctn); (it) != rend(ctn); (it)++)

template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec)
{
    os << "[";
    repeat (i, vec.size())
    {
        os << (i == 0 ? "" : ", ") << vec[i];
    }
    os << "]";
    return os;
}

template<typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T>& s)
{
    os << "{";
    traverse (it, s)
    {
        if (it != s.begin()) os << ", ";
        os << *it;
    }
    os << "}";
    return os;
}

template<typename K, typename V>
ostream& operator<<(ostream& os, map<K, V>& m) 
{
    os << "{";
    traverse (it, m)
    {
        if (it != m.begin()) os << ", ";
        os << it->first << ": " << it->second;
    }
    os << "}";
    return os;
}

//
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//

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

    int N, K;
    cin >> N >> K;

    vector<int64> x(N);
    repeat (i, N)
    {
        cin >> x[i];
    }

    int64 ans = (1LL << 60);

    for (int l = 0; l + K <= N; l++)
    {
        int r = l + K - 1;
        int64 xl = x[l],
              xr = x[r];
        if (xr <= 0)
        {
            ans = min(ans, abs(xl));
        }
        else if (xl >= 0)
        {
            ans = min(ans, abs(xr));
        }
        else
        {
            ans = min(ans, abs(xr - xl) + min(abs(xl), abs(xr)));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import math
a, b, k =map(int, input().split())
divesor_list = []
c = min(a, b)
if c == 1:
    divesor_list = [1]
else:
    for i in range(c, 0, -1):
            if (a % i == 0) & (b % i == 0):
                divesor_list.append(i)
print(divesor_list[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  b = 0;
  string s;
  in(s);
  rep(i, 3){
    if(s[i] == 'o')
      b++;
  }
  a = 700 + 100 * b;
  out(a);
  memi;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

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

		double avg =0;
		for ( int i =0; i < iN; i ++){
			ai[i] =  sc.nextInt();
			avg += ai[i];
		}

		int cost = 0;
//		System.out.println(avg);
		double avgd = avg /iN;
//		System.out.println(avgd);
//		int avgd = Math.round(avg /iN);
		BigDecimal bd = new BigDecimal(avgd);
		BigDecimal bd1 = bd.setScale(0, BigDecimal.ROUND_HALF_UP);

//		System.out.println(bd1.intValue());
		for ( int i =0; i < iN; i ++){
//			System.out.println((ai[i] - bd1.intValue()));
			cost += Math.pow((ai[i] - bd1.intValue()),2);
		}

		System.out.println(cost);

		sc.close();
	}

}


Measured memory_bytes: 10064
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;
const int OPEN = 100000;
const int CLOSE = 100001;

string Replace(string S, string X, string Y) {
	string::size_type  Pos(S.find(X));
	while(Pos != string::npos) {
		S.replace(Pos, X.length(), Y);
		Pos = S.find(X, Pos + Y.length());
	}
	return S;
}

string s;
map<string, int> ms;

bool comp(const string& s1, const string& s2) {
	return s1.size() > s2.size();
}

vector<int> conv(string s) {
	vector<string> x;
	for(auto& p : ms) {
		x.push_back(p.first);
	}
	sort(x.begin(), x.end(), comp);

	for(auto& m : x) {
		s = Replace(s, m, '@' + to_string(ms[m]) + '@');
	}
	for(char c : s) {
		if(isalpha(c)) return vector<int>();
	}

	vector<int> ret;
	int i = 0;
	while(i < s.size()) {
		if(s[i] == '(') {
			ret.push_back(OPEN);
			i++;
		}
		else if(s[i] == ')') {
			ret.push_back(CLOSE);
			i++;
		}
		else if(s[i] == '@') {
			i++;
			string num;
			while(s[i] != '@') num += s[i++];
			i++;
			ret.push_back(atoi(num.c_str()));
		}
		else {
			assert(isdigit(s[i]));
			string num;
			while(i < s.size() && isdigit(s[i])) num += s[i++];
			ret.push_back(-atoi(num.c_str()));
		}
	}
	return ret;
}

int cur, n;
vector<int> c;

int calc() {
	int ret = 0;
	while(cur < n) {
		if(c[cur] == OPEN) {
			cur++;
			int x = calc();
			assert(c[cur] < 0);
			x *= -c[cur];
			ret += x;
			cur++;
		}
		else if(c[cur] == CLOSE) {
			cur++;
			return ret;
		}
		else {
			if(c[cur] < 0) {
				ret += c[cur - 1] * (-c[cur] - 1);
			}
			else {
				ret += c[cur];
			}
			cur++;
		}
	}
	return ret;
}

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

	while(cin >> s, s != "END_OF_FIRST_PART") {
		int w;
		cin >> w;
		ms[s] = w;
	}

	while(cin >> s, s != "0") {
		c = conv(s);
		n = c.size();
		if(n == 0) {
			cout << "UNKNOWN" << endl;
			continue;
		}

		cur = 0;
		cout << calc() << endl;
	}
}

Measured memory_bytes: 3212
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int n, r;
	cin >> n >> r;
	if (n < 10) cout << r + 100 * (10 - n);
	else cout << r;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    cnt = 0
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print('Yes')
            break
    else:
        print('No')



if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion



int main(void) {
	lint n; cin >> n;
	ld cnt = 0;
	for (int i = 0; i < n; i++) {
		ld x; cin >> x;
		x = 1 / x;
		cnt += x;
	}
	printf("%.100Lf\n", 1 / cnt);

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a;
  cin >> a;
  int tmp = a;
  int count=1;
  int ans=0;
  for(int i=1; i<N; i++){
    cin >> a;
    if(tmp==a) count++;
    else{
      ans += count/2;
      count=1;
      tmp = a;
    }
  }
  ans+=count/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int n; cin >> n;
    vi v(n+1);

    rep (i, 1, n) {
    	cin >> v[i];
    }

    vector<int> ar(n+1);
    rep (i, 1, n) {
    	int start = i - v[i] + 1;
    	if (start < 1) continue;

    	ar[start]++;
    }
    ll res = 0;
    rep (i, 1, n) {
    	int start = v[i] + i + 1;
    	if (start > n) continue;
    	res += (ll)ar[start];
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

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

int imos[30][101010];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,C;
    cin >> N >> C;
    rep(i,N){
      int a,b,c;
      cin >> a >> b >> c;
      a--; c--;
      imos[c][a]++;
      imos[c][b]--;
    }
    rep(c,C) REP(i,1,101010) imos[c][i] += imos[c][i-1];
    rep(c,C) REP(i,1,101010) if (imos[c][i]) imos[c][i] = 1;

    int ans = 0;
    rep(i,101010){
      int cnt = 0;
      rep(c,C) cnt += imos[c][i];
      chmax(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
book = Hash.new(0)
a.each do |x|
  book[x] += 1
end

res = 0
book.each do |k, v|
  if k < v
    res += v - k
  elsif k > v
    res += v
  end
end
puts res

Measured memory_bytes: 15492
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var A = NextInt();
		var B = NextInt();
		var C = NextInt();

		for (var i = 0; i < B; i++) {
			if (A * i % B == C) {
				WriteLine("YES");
				return;
			}
		}
		WriteLine("NO");
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}


Measured memory_bytes: 13268
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,T,A,H;
  cin >> N >> T >> A;
  vector<int> temperature(N);
  int ans;
  double temp,dist=10000;
  for(int i=0;i<N;++i){
    cin >> H;
    if(fabs(T-H*0.006 - A)<dist){
      ans=i;
      dist=fabs(T-H*0.006 - A);
    }
  }

  cout << ans+1 << endl;

  return 0;
}


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

int main()
{
    string a,b;
    cin>>a>>b;
    if( a.length()> b.length())
        cout<<"GREATER";
    if( a.length()<b.length())
        cout<<"LESS";
    if( a.length()== b.length())
    {
        if( a> b)
        {
            cout<<"GREATER";
        }
        if( a<b)
        {
            cout<<"LESS";
        }
        if( a== b)
            cout<<"EQUAL";
    }
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int n,a[26];
std::string s;
int main() {
	std::cin>>n>>s;
	for(int i=0;i<n;i++){
		a[s[i]-'a']++;
	}
	lint ans=1;
	for(int i=0;i<26;i++){
		ans*=a[i]+1;
		ans%=1000000007;
	}
	std::cout<<ans-1<<std::endl;
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a1,a2,a3,b1,b2,b3;
	int x[4][4];
	
	for(int i=1; i<=3; i++){
		for(int j=1; j<=3; j++){
			cin>>x[i][j];
		}
	}	
	a1=0;
	b1=x[1][1]-a1;
	b2=x[1][2]-a1;
	b3=x[1][3]-a1;	
	a2=x[2][1]-b1;
	a3=x[3][1]-b1;	
	if(a2+b2==x[2][2] && a2+b3==x[2][3] && \
	   a3+b2==x[3][2] && a3+b3==x[3][3]){
		 cout<<"Yes"<<endl;
		 return 0;
	}	
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i;
    scanf("%d",&i);
    if(400<=i&&i<600){
        printf("8");
    }
    if(600<=i&&i<800){
        printf("7");
    }
    if(800<=i&&i<1000){
        printf("6");
    }
    if(1000<=i&&i<1200){
        printf("5");
    }
    if(1200<=i&&i<1400){
        printf("4");
    }
    if(1400<=i&&i<1600){
        printf("3");
    }
    if(1600<=i&&i<1800){
        printf("2");
    }
    if(1800<=i&&i<2000){
        printf("1");
    }
}

Measured memory_bytes: 1660
from itertools import permutations
n = int(input())
C = [[0, 0] for i in range(n)]    #Coordinate

for i in range(n):
    xi, yi = map(int, input().split())
    C[i][0], C[i][1] = xi, yi

def dis(x1:int, y1:int, x2:int, y2:int):
    return ((x1-x2)**2+(y1-y2)**2)**(1/2)

ans = 0
R = list(permutations(C))
for V in R:
    tmp = 0
    for i in range(len(V)-1):
        tmp += dis(V[i][0], V[i][1], V[i+1][0], V[i+1][1])
    ans += tmp/len(R)

print(ans)

Measured memory_bytes: 8180
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    string S, T;
    cin >> S >> T;

    for(int i=0; i<S.size(); i++){
        if(S.at(i) != T.at(i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3132
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex> //正規表現
using namespace std;
#define _GLIBCXX_DEBUG /GCC環境下で[]による配列要素参照のエラーを出す
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
  int n;
  cin>>n;
  vector<int>vec(n);
  rep(i,n){
    vec.at(i)=i;
  }
  vector<vector<int>>pos(n,vector<int>(2));
  int x,y;
  rep(i,n){
    cin>>x>>y;
    pos[i][0]=x;
    pos[i][1]=y;
  }
  int b=1;
  double d=0;
  rep(i,n){
    b*=(i+1);
  }
  do{
    rep(i,n-1){
      d+=sqrt(pow((pos[vec.at(i)][0]-pos[vec.at(i+1)][0]),2)+pow((pos[vec.at(i)][1]-pos[vec.at(i+1)][1]),2));
    }
  }while (next_permutation(vec.begin(), vec.end()));
  cout<<fixed<<setprecision(10);
  cout<<d/b<<endl;
}

  

Measured memory_bytes: 3808
#include <iostream>
using namespace std;

int main(){
 unsigned long long int n,b,a,time;
 cin >> n >> b >> a;
  if(a==0&&b==0){
   cout << 0 << endl;
    return 0;
  }
 time = n/(a+b);
  a=n%(a+b);
  if(a>b)a=b;
  cout << b*time+a << endl;
}

Measured memory_bytes: 256
n = int(input())
lst = [int(i) for i in input().split()]

for i in range(n):
    num = 0
    x = lst[i]
    while x%2==0:
        x /= 2
        num += 1
    
    if i==0:
        ans = num
    elif num < ans:
        ans = num
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;


int main(){
    ll n;cin>>n;
vector<char>ani(1000);
    while(1){
    int k=n%26;
    if(k==0)k=26;
    char ans='a'+(k-1);
    ani.pb(ans);
    
    //cout<<ans;
    n-=k;
    if(n==0)break;
    n/=26;
   // cout<<n<<endl;
    
   
    }
    reverse(all(ani));
    int i=0;
    while(ani.at(i)!=NULL){
        cout<<ani.at(i);
        i++;
    }
   cout<<endl;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int r = in.nextInt();
		System.out.println(r * r);
	}
}

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

int gcd(int a, int b) {
	if (a * b == 0) return a + b;
	if (a < b) gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

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

	vector<int> L(N + 1);
	vector<int> R(N + 1);

	L[0] = 0;
	R[N] = 0;
	for (int i = 0; i < N; i++) {
		L[i + 1] = gcd(L[i], A[i]);
		R[N - 1 - i] = gcd(R[N - i], A[N - 1 - i]);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, gcd(L[i], R[i + 1]));
	}

	cout << ans << endl;
}

Measured memory_bytes: 1408
N,M = map(int,input().split())
mod = 10**9+7

def plmi(k):
    if k%2 == 0:
        return 1
    else:
        return -1

# 1!,2!,3!,...,n! (mod m)
def mod_factorials(n, m):
    mod_factorials = [1] * (n + 1)
    for i in range(1, n+1):
        mod_factorials[i] = mod_factorials[i-1]*i
        mod_factorials[i] %= m
    return mod_factorials

# 1!,2!,3!,...,n! の逆元 (mod m)
def mod_inv_factorials(n, m):
    mod_invs = [1] * (n + 1)
    invs = [1] * (n + 1)
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m

    for i in range(1, n+1):
        mod_invs[i] = invs[i]*mod_invs[i-1]
        mod_invs[i] %= m
    return mod_invs

mod_facts = mod_factorials(M,mod)
mod_inv_facts = mod_inv_factorials(M,mod)

ans = 0

for i in range(0,N+1):
    tmp = 1
    tmp *= plmi(i)*mod_facts[N]*mod_facts[M-i]*mod_inv_facts[i]*mod_inv_facts[N-i]*mod_inv_facts[M-N]
    ans += tmp
    ans %= mod

ans *= mod_facts[M]*mod_inv_facts[M-N]
ans %= mod

print(ans)









Measured memory_bytes: 96156
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,x;
    cin>>n;
    bool flag;
    for(int i=0;i<n;i++){
        cin>>x;
        if(x%2==0){
            if(x%3==0 || x%5==0){
                flag=true;
            }
            else{
                flag=false;
                break;
            }
        }
    }
    if(flag){
        cout<< "APPROVED"<<endl;
    }else{cout<< "DENIED"<<endl;}

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;

int main(){
  int n;
  cin >> n;
 
  string a = "No";
  int answer;
  for(int i=1; i<10; i++){
    for(int j=1; j<10; j++){
      if(n==i*j){
        a = "Yes";
        break;
      }
    }
  }
  
  cout << a << endl;
  return 0;
}

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

int main() {
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double a = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
 
  printf("%.8lf\n", a);
}


Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

int main(int argc, char **argv) {
    i64 n;
    cin >> n;

    cout << (n==0?1:0) << endl;

    return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<vector>
#include<utility>
using namespace std;

int g[801][801],visit[801][801];
vector<pair<int,int> > e[801];

int dfs(int a,int b){
  visit[a][b]=1;
  for(int i=0;i<e[b].size();i++)
    if(e[b].size()>1&&e[e[b][i].second].size()>1&&visit[a][e[b][i].second]==0){
      g[a][e[b][i].second]=g[a][b]+e[b][i].first;
      dfs(a,e[b][i].second);
    }
}

int main(){
  int n,p[800],d[800],ans=0,maxa=0;
  scanf("%d",&n);
  while(n){
    for(int i=0;i<n-1;i++)
      scanf("%d",&p[i]);
    for(int i=0;i<n-1;i++){
      scanf("%d",&d[i]);
      e[i+2].push_back(make_pair(d[i],p[i]));
      e[p[i]].push_back(make_pair(d[i],i+2));
    }
    for(int i=0;i<n-1;i++){
      if(e[i+2].size()==1||e[p[i]].size()==1)
        ans+=d[i];
      else
        ans+=d[i]*3;
    }
    for(int i=1;i<=n;i++)
      dfs(i,i);
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
        if(maxa<g[i][j])
          maxa=g[i][j];
    printf("%d\n",ans-maxa);
    ans=maxa=0;
    for(int i=0;i<=n;i++)
      for(int j=0;j<=n;j++)
        g[i][j]=visit[i][j]=0;
    for(int i=1;i<=n;i++)
      e[i].clear();
    scanf("%d",&n);
  }
}


Measured memory_bytes: 7784
#include <stdio.h>

#define N 128

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int a[ N ];
  int n;
  int i;

  scanf ( "%d", &n );
  for ( i = 0; i < n; ++i )
  {
    scanf ( "%d", &a[ i ] );
  }

  while ( n-- )
  {
    printf ( "%d", a[ n ] );
    putchar ( n ? ' ' : '\n' );
  }

  return ( 0 );
}

Measured memory_bytes: 0
(N, M), Ss, Ts = readlines.map{|l| l.split.map(&:to_i)}
MOD = 10**9 + 7

dp = Array.new(N + 1){Array.new(M + 1, 0)}
(N + 1).times{|i| dp[i][0] = 1}
(M + 1).times{|j| dp[0][j] = 1}
(1 .. N).each do |i|
  (1 .. M).each do |j|
    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - (Ss[i - 1] == Ts[j - 1] ? 0 : dp[i - 1][j - 1])) % MOD
  end
end
puts dp[-1][-1]

Measured memory_bytes: 33556
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> v;
    bool hazime;
    int iro = -1;
    for (int i=1; i<=n; ++i) {
      bool a;
      cin >> a;
      if (i%2) {
        if (iro != a)
          v.push_back(1);
        else {
          v[v.size()-1]++;
        }
        if (i==1) hazime = a;
      } else if (iro == a)
        v[v.size()-1]++;
      else if (v.size()==1) {
        hazime ^= 1;
        v[0]++;
      } else {
        v[v.size()-2] += v[v.size()-1] + 1;
        v.pop_back();
      }
      // FOR(it,v) {
      //   cout << *it << " ";
      // }cout <<endl;
      iro = a;
    }
    int res = 0;
//    cout << "hazime = " << hazime << endl;
    REP(i,v.size()) {
      if (!hazime && !(i%2)) {
        res += v[i];
      }
      else if (hazime && i%2)
        res += v[i];
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<limits.h>

#define MAX_DATA 500000

int S[MAX_DATA];
int counter = 0;

int merge(int left , int mid , int right){
  int i , j , k ;

  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1 + 1];
  int R[n2 + 1];
  for(i = 0 ; i < n1 ; i++){
    L[i] = S[left + i];
  }
  for(i = 0 ; i < n2 ; i++){
    R[i] = S[mid + i];
  }
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;
  i = 0;
  j = 0;
  for(k = left ; k < right ; k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i = i + 1;
      counter++;
    }
    else{
      S[k] = R[j];
      j = j + 1;
      counter++;
    }
  }
}

int mergeSort(int left ,int right){
  if(left+1 < right){
    int mid = (left+right)/2;
    mergeSort(left,mid);
    mergeSort(mid , right);
    merge(left, mid , right);
  }

}


int main(){

  int i;
  int n;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&S[i]);
  }
  mergeSort(0 , n);

  for(i = 0 ; i < n ; i ++){
    if(i > 0)printf(" ");
    printf("%d",S[i]);
  }
  printf("\n");
  printf("%d\n",counter);

}



Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
int wei(long long x,long long y)
{
	int w1=0,w2=0;
	while (x>0)
	{
		w1++;
		x/=10;
	}
	while (y>0)
	{
		w2++;
		y/=10;
	}
	return max(w1,w2);
}
int main()
{
	scanf("%lld",&n);
	for (int i=sqrt(n);i>=1;i--)
	if (n%i==0)
	{
	    ans=n/i;
	    break;
	}
	printf("%d",wei(ans,n/ans));
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        aa: [String; n]
    };
    // 1 -> 0
    // 2 -> 1 0
    // 3 -> 2 0 1
    // 4 -> 3 1 0 2
    // 5 -> 4 2 0 1 3
    // 6 -> 5 3 1 0 2 4
    let evens = (0..(n + 1) / 2)
        .map(|i: usize| aa[2 * i].as_str())
        .collect::<Vec<&str>>();
    let odds = (0..n / 2)
        .map(|i: usize| aa[2 * i + 1].as_str())
        .collect::<Vec<&str>>();
    let (mae, ato) = if n % 2 == 0 {
        (odds, evens)
    } else {
        (evens, odds)
    };
    println!(
        "{}",
        mae.into_iter()
            .rev()
            .chain(ato.into_iter())
            .collect::<Vec<_>>()
            .join(" ")
    );
}


Measured memory_bytes: 20340
/**
 * C - Grid Repainting 2
 * https://atcoder.jp/contests/abc096/tasks/abc096_c
 **/
#include<iostream>
#include<vector>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> s(H+2, vector<int>(W+2, 0));
    for(int i=1; i<H+1; i++) {
        for(int j=1; j<W+1; j++) {
            char tmp;
            cin >> tmp;
            if(tmp == '#') {
                s[i][j] = 1;
            } else {
                s[i][j] = 0;
            }
        }
    }
    bool flag=true;
    for(int i=1; i<H+1; i++) {
        for(int j=1; j<W+1; j++) {
            if(s[i][j]==1) {
                if(s[i-1][j]+s[i][j-1]+s[i][j+1]+s[i+1][j]==0) {
                    flag = false;
                }
            }
        }
    }

    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256