akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <stdio.h>

int main(void){
	double v = 0;
	double target_v = 0;
	int N;
	
	while(scanf("%lf",&target_v) != EOF){
		v = 0;
		N = 0;
		while(v < target_v){
			N++;
			v = 9.8*sqrt((N*5-5)/4.9);
		}
		printf("%d\n",N);
	}
	
	return 0;
}

Measured memory_bytes: 628
#!/usr/bin/env python3
N, P = map(int, input().split())

dic = {}
n = 2
while n * n <= P:
    while P % n == 0:
        if n not in dic:
            dic[n] = 1
        else:
            dic[n] += 1
        P //= n
    n += 1
if P != 1:
    dic[P] = 1

ans = 1
for k, v in dic.items():
    ans *= pow(k, v // N)

print(ans)


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = N;
    REP(i, N)
    {
        ll t;
        cin >> t;
        if (A <= t && t < B)
            ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#define N 200005
using namespace std;
int n;
long long ans,k,U,a[N],l,r,mid;
long long Judge(long long mid)
{
	int L,R,Mid;
	long long Nans=0,Zans=0;
	for (int i=1;i<=n;i++)
	{
		if (a[i]==0)
		{
			if (mid>0)
				Zans+=n-1;
			continue;
		}
		if (a[i]>0)
		{
			L=1;
			R=n;
			Nans=0;
			while (L<=R)
			{
				Mid=(L+R) >> 1;
				if (a[i]*a[Mid]<mid)
				{
					Nans=Mid;
					L=Mid+1;
				} else
					R=Mid-1;
			}
			//cout << Nans << endl;
			if (Nans>=i)
				Nans--;
			Zans+=Nans;
			//cout << Nans << endl;
		} else
		{
			L=1;
			R=n;
			Nans=n+1;
			while (L<=R)
			{
				Mid=(L+R) >> 1;
				if (a[i]*a[Mid]<mid)
				{
					Nans=Mid;
					R=Mid-1;
					//cout << "Right" << endl;
				} else
					L=Mid+1;
			}
			//cout << Nans << endl;
			if (Nans<=i)
				Nans++;
			Nans=n-Nans+1;
			//cout << Nans << endl;
			Zans+=Nans;
		}
	}
	return Zans/2;
}
int main()
{
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	l=-1000000000000000000;
	r=1000000000000000000;
	/*for (int i=1;i<=n;i++)
		printf("%lld ",a[i]);
	putchar('\n');*/
	//printf("%lld %lld\n",l,r);
	//printf("%lld\n",Judge(-6));
	while (l<=r)
	{
		mid=(l+r) >> 1;
		U=Judge(mid);
		//printf("%lld %lld %lld\n",l,r,U);
		if (U<=k-1)
		{
			ans=mid;
			l=mid+1;
		} else
			r=mid-1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5264
#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;
	cin >>n;
	
	map<VI, int> mp;
	rep(i, n){
		string s;
		cin >> s;
		
		VI wv(30);
		rep(j, sz(s)) wv[s[j]-'a']++;
		mp[wv]++;
	}
	//for(auto x :mp) printf("%d, ",x.second); puts("");
	ll ans=0;
	for(auto z: mp){
		ll cs = z.second;
		
		ans += cs * (cs-1);
	}
	cout << ans/ 2 <<"\n";
	return 0;
}


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

int main(){
	int N,M;
	cin >> N >> M;
	int loop;
	int minN = 2*M+1;
	for(loop=1;loop<M+1-loop;loop++){
		cout << loop << " " << M-loop+1 << endl;
	}
	for(loop=1;loop<M+2-loop;loop++){
		cout << M+loop << " " << minN+1-loop << endl;
	}
	return 0;
}

Measured memory_bytes: 3596
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu(x) push_back(x)
#define eb(x) emplace_back(x)
#define pp pop_back()
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
const int MOD=1e9+7 , INF=INT_MAX;
const long long LINF=LLONG_MAX;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> ivc;
typedef pair<int,int> ipr;
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   // #ifndef ONLINE_JUDGE
  //  	freopen("input.txt", "r", stdin);
   // 	freopen("output.txt","w",stdout);
  //  #endif
    int a,b;
    cin>>a>>b;
    if((a+b)%2!=0)
    	cout<<"IMPOSSIBLE"<<endl;
    else
    	cout<<((a+b))/2<<endl;
 	
 
}

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

int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if (A1 + A2 + A3 < 22) {
    cout << "win" << endl;
  } else {
    cout << "bust" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i= 0; i<(n); i++)
using namespace std;
int main(void){
   int a[5];
   int i = 0;
    for(i; i< 5 ; i++) {
      cin >> a[i];
      if (a[i] == 0) break;
    }
   
   cout << i+1 << endl;
    
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
  if (b == 0) return a;
  return gcd(b, a % b);
}

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

int main()
{
  ll A,B,C,D;
  cin >> A >> B >> C >> D;

  ll cntC = B/C - (A-1)/C;  // Cの倍数
  ll cntD = B/D - (A-1)/D;
  // CでもDでも割り切れる
  ll M = lcm(C,D);  // LCM
  ll cntM = B/M - (A-1)/M;

  // CかDで割り切れるのを除く
  ll ans = (B - A + 1) - (cntC + cntD - cntM);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    ll idx = 0;
    FOR(i, 0, N){
        ll summ = i*(i+1)/2;
        ll sump = (i+1)*(i+2)/2;
        if(summ < N && N <= sump){
            idx = i+1; break;
        }
    }
    ll rem = idx*(idx+1)/2 - N;
    FOR(i, 1, idx+1){
        if(i == rem) continue;
        cout << i << endstr;
    }
    return 0;
}


Measured memory_bytes: 256
#10進数Nを逆2進数リストに変換する関数
def change_2r(N):
    if N==0:
        return [0]
    list=[]
    while N>=2:
        list.append(N%2)
        N=int((N-N%2)/2)
    list.append(1)
    return list
  
#逆2進数リストNのi-1桁目(N[i])へ繰り上がる関数
def moveup(N,i):
    if len(N)<=i:
        N.append(1)
    else:
        if N[i]==0:
            N[i]=1
        elif N[i]==1:
            N[i]=0
            moveup(N,i+1)

N=int(input())
i=0
if N>=0:
    Nlist=change_2r(N)
    while i<len(Nlist):
        if i%2!=0 and Nlist[i]==1:
            moveup(Nlist,i+1)
        i+=1
else:
    N=-N
    Nlist=change_2r(N)
    while i<len(Nlist):
        if i%2==0 and Nlist[i]==1:
            moveup(Nlist,i+1)
        i+=1
        
Nlist.reverse()
print(''.join(map(str,Nlist)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()

int main(){
  ll N,sum=0,ans=0;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A.at(i);
    rep(i,N){
      if(i==0){
        if(A.at(i)>0){
          sum+=A.at(i);
          continue;
        }else{
          sum=1;
          ans+=1-A.at(i);
          continue;
        }
      }
      if(sum>0){
        if(sum+A.at(i)<0){
          sum+=A.at(i);
        }else{
          ans+=sum+A.at(i)+1;
          sum=-1;
        }
      }else{
        if(sum+A.at(i)>0){
          sum+=A.at(i);
        }else{
          ans+=1-(sum+A.at(i));
          sum=1;
        }
      }
    }
    ll ans1=0;
    sum=0;
    rep(i,N){
      if(i==0){
        if(A.at(i)<0){
          sum+=A.at(i);
          continue;
        }else{
          sum=-1;
          ans1+=1+A.at(i);
          continue;
        }
      }
      if(sum>0){
        if(sum+A.at(i)<0){
          sum+=A.at(i);
        }else{
          ans1+=sum+A.at(i)+1;
          sum=-1;
        }
      }else{
        if(sum+A.at(i)>0){
          sum+=A.at(i);
        }else{
          ans1+=1-(sum+A.at(i));
          sum=1;
        }
      }
    }
    cout << min(ans,ans1) << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  int x=0;
  cin >>s>>t;
  for (int i = 0; i <s.size() ; i++) {
    if(s.at(i)!=t.at(i)) x++;
  }
  cout << x << endl;
}

Measured memory_bytes: 3912
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000;
struct edge {ll to, cap, rev; };
vector<edge> G[210];
bool used[210];
ll n, a[110], b[110], c[110], d[110], flow;

ll dfs(ll v, ll f){
    if (v == 2 * n + 1) return f;
    used[v] = true;
    for (ll i = 0; i < G[v].size(); i++){
        edge e = G[v][i];
        if (used[e.to] || e.cap == 0) continue;
        ll g = dfs(e.to, min(f, e.cap));
        if (g > 0){
            G[v][i].cap -= g;
            G[e.to][e.rev].cap += g;
            return g;
        }
    }
    return 0;
}

int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 1; i <= n; i++){
        G[0].push_back(edge{i, 1, 0});
        G[i].push_back(edge{0, 0, i - 1});
        G[n + i].push_back(edge{2 * n + 1, 1, i - 1});
        G[2 * n + 1].push_back(edge{n + i, 0, 0});
    }
    for (ll i = 1; i <= n; i++) cin >> a[i] >> b[i];
    for (ll i = 1; i <= n; i++) cin >> c[i] >> d[i];
    for (ll i = 1; i <= n; i++){
        for (ll j = 1; j <= n; j++){
            if (a[i] < c[j] && b[i] < d[j]){
                G[i].push_back(edge{n + j, 1, (ll)G[n + j].size()});
                G[n + j].push_back(edge{i, 0, (ll)G[i].size() - 1});
            }
        }
    }
    while(true){
        memset(used, 0, sizeof(used));
        ll w = dfs(0, INF);
        if (w == 0) break;
        flow += w;
    }
    cout << flow << endl;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int n,x;
	cin >> n >> x;
	int l[n];
	int count=0;
	int r=0;
	REP(i,n) cin >> l[i];
	REP(i,n){
		r+=l[i];
		if(r<=x) count++;
	}
	cout << count+1 << endl;
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using tl = tuple<ll, ll, ll>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m; cin>>n>>m;
    UnionFind ds(n);
    rep(i, m) {
        ll u, v;
        cin>>u>>v; u--; v--;
        ds.merge(u, v);
    }
    map<ll, ll> cnt;
    rep(i, n) {
        cnt[ds.root(i)]++;
    }
    ll ans = 0;
    for (auto v : cnt) {
        chmax(ans, v.se);
    }
    cout<<ans<<endl;
}

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

int main(){
    ll n,x;
    cin>>n>>x;
    vector<ll>w(n),v(n);
    ll mx=0,mn=INT_MAX;
    rep(i,n){
        cin>>w[i]>>v[i];
        mn=min(mn,w[i]);
    }
    rep(i,n)w[i]-=mn;
    vector<ll>a[4];
    rep(i,4)a[i].push_back(0);
    rep(i,n)a[w[i]].push_back(v[i]);
    rep(i,4)sort(a[i].begin()+1,a[i].end());
    rep(i,4)reverse(a[i].begin()+1,a[i].end());
    rep(i,4){
        rep(j,a[i].size()-1){
            a[i][j+1]+=a[i][j];
        }
    }
    rep(i,a[0].size()){
        rep(j,a[1].size()){
            rep(k,a[2].size()){
                rep(l,a[3].size()){
                    if(i*mn+j*(mn+1)+k*(mn+2)+l*(mn+3)<=x)
                    mx=max(mx,a[0][i]+a[1][j]+a[2][k]+a[3][l]);
                }
            }
        }
    }
    cout<<mx<<endl;
    return 0;
}

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

int main()
{

int coin;
cin>>coin;


int temp = (double)coin/500;


int happy = floor(temp)*500 + floor(temp)*500;

if(coin%500==0){
    cout<<happy<<endl;
}
else{
    int temp2 = (coin - floor(temp)*500) / 5;
    happy = happy + (floor(temp2)*5);
    cout<<happy<<endl;
}

return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int target[3];
int coins[200000][3];

LL result = 0;
set<PII> best_for[3][3];
set<int> by_type[3];

void do_move(int from, int to) {
  int k = best_for[from][to].begin()->nd;
  REP(j,3) if (j != from) best_for[from][j].erase({coins[k][from] - coins[k][j], k});
  REP(j,3) if (j != to) best_for[to][j].insert({coins[k][to] - coins[k][j], k});
  result -= coins[k][from];
  result += coins[k][to];
  by_type[from].erase(k);
  by_type[to].insert(k);
}

int main() {
  REP(i,3) scanf("%d", &target[i]);
  int N = target[0] + target[1] + target[2];
  REP(i,N)REP(j,3) scanf("%d", &coins[i][j]);

  result = 0;
  REP(i,N) {
    int best = 0;
    REP(j,3) if (coins[i][j] > coins[i][best]) best = j;
    by_type[best].insert(i);
    REP(j,3) if (j != best) best_for[best][j].insert({coins[i][best] - coins[i][j], i});
    result += coins[i][best];
  }

  REP(k,3)REP(j,3) while (by_type[j].size() > target[j]) do_move(j, (j+1)%3);

  bool changed = true;
  while (changed) {
    changed = false;
    REP(j,3) if (best_for[j][(j+1)%3].begin()->st + best_for[(j+1)%3][j].begin()->st < 0) {
      do_move(j, (j+1)%3);
      do_move((j+1)%3, j);
      changed = true;
    }
    if (best_for[0][1].begin()->st + best_for[1][2].begin()->st + best_for[2][0].begin()->st < 0) {
      do_move(0, 1);
      do_move(1, 2);
      do_move(2, 0);
      changed = true;
    }
    if (best_for[0][2].begin()->st + best_for[2][1].begin()->st + best_for[1][0].begin()->st < 0) {
      do_move(0, 2);
      do_move(2, 1);
      do_move(1, 0);
      changed = true;
    }
  }
  printf("%lld\n", result);
}


Measured memory_bytes: 15616
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;


int main(void) {
	ll n, a, b, ans;

	scanf("%lld%lld%lld", &n, &a, &b);

	ans = (b - a) * (n - 2) + 1;
	ans = max(0ll, ans);

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
/*
 * ALDS1_10_C.cpp
 *
 *  Created on: May 5, 2018
 *      Author: 13743
 */

#include<cstdio>
#include<cstring>
#include<algorithm>

//int dp[1001][1001];

int lcm(char* X, char* Y, int nx, int ny) {
int dp[1001][1001];
	dp[1][1] = (X[0] == Y[0]);
	for(int i=1; i<=nx; i++) {
		for(int j=1; j<=ny; j++) {
			dp[i][j] = (X[i-1]==Y[j-1]) + dp[i-1][j-1];
			dp[i][j] = std::max(dp[i-1][j], dp[i][j]);
			dp[i][j] = std::max(dp[i][j-1], dp[i][j]);
		}
	}
	return dp[nx][ny];
}

int main() {
	int q;
	scanf("%d", &q);
	char X[1001];
	char Y[1001];
	while(q--) {
		scanf("%s", X);
		scanf("%s", Y);
		int nx = (int)strlen(X);
		int ny = (int)strlen(Y);
		printf("%d\n", lcm(X, Y, nx, ny));
	}
}





Measured memory_bytes: 6656
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var map = new Array(10);
  for(var i = 0; i < 10; i++){
    map[i] = new Array(10).fill(0);
  }
  for(var i = 1; i <= N; i++){
    
    var tmp = i;
    while(tmp >= 10){
      tmp = Math.floor(tmp / 10);
    }
    map[i % 10][tmp]++;
  }
  
  var output = 0;
  for(var i = 1; i <= 9; i++){
    for(var j = 1; j <= 9; j++){
      output += map[i][j] * map[j][i];
    }
  }
  myout(output);
}


Measured memory_bytes: 33040
package main

import (
	"fmt"
	"strconv"
)

func main() {

	var n int
	var a int
	var b int

	fmt.Scan(&n, &a, &b)

	var max int
	var x int

	if a <= b {
		max = a
		x = b
	} else if b <= a {
		max = b
		x = a
	}

	min := ((max + x) - n)

	if min < 0 {
		min = 0
	}

	maxStr := strconv.Itoa(max)
	minStr := strconv.Itoa(min)

	fmt.Println(maxStr + " " + minStr)

}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

    int main() {
    int i, j, k = 1, N, mo = 0, co = 1;
    int flag = 0;
    int A[101];
    double ans = 0;
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
      scanf("%d", A + i);
      ans += (double)1 / A[i];
    }
    ans = 1 / ans;
    printf("%lf", ans);
    return 0;
  }

Measured memory_bytes: 128
import sys
import itertools
input = sys.stdin.readline

n, m = map(int, input().split())
s = []
p = [0] * m
cnt_k = 0
cnt_j = 0
ans = 0

for i in range(m):
    s_k = list(map(int, input().split()))
    s.append(s_k)
    
p = list(map(int, input().split()))

memo = list(itertools.product([0, 1], repeat=n))
for i in range(2 ** n):
    for j in range(m):
        for k in range(1, s[j][0] + 1):
            if memo[i][s[j][k] - 1] == 1:
                cnt_k += 1

        if cnt_k % 2 == p[j]:
            cnt_j += 1
        cnt_k = 0

    if cnt_j == m:
        ans += 1

    cnt_j = 0
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;

bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 

ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = INT_MIN, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 

ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;cin>>n;
    set<string> ans;
    string s;
    f(i,0,n)
    {
        cin>>s;
        ans.insert(s);
    }
    cout<<ans.size()<<endl;
}


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

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

    int tall = 0;
    int max = 0;
    long long stool = 0;
    for(int i = 0; i < n; i++) {
        cin >> tall;
        if (max <= tall) {
            max = tall;
        }
        stool += max - tall;
    }

    cout << stool << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n;
    cin >> n;
    cout << (n * (1 + (n * (1 + n)))) << endl;
}

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

Measured memory_bytes: 3648
package main

import (
	"fmt"
	"strconv"
)

func ok(n int) bool {
	var s string
	s = strconv.Itoa(n)
	var flg3, flg5, flg7 bool
	for i := 0; i < len(s); i++ {
		switch s[i] {
		case '3':
			flg3 = true
		case '5':
			flg5 = true
		case '7':
			flg7 = true
		default:
			return false
		}
	}
	if flg3 && flg5 && flg7 {
		return true
	}
	return false
}

func dfs(s string, N int) int {
	var ret int
	n, _ := strconv.Atoi(s)
	if n > N {
		return 0
	}
	if ok(n) {
		ret++
	}
	S := "753"
	for i := 0; i < len(S); i++ {
		ret += dfs(s+string(S[i]), N)
	}
	return ret
}

func main() {
	var N int
	fmt.Scan(&N)
	fmt.Println(dfs(string('0'), N))
}


Measured memory_bytes: 2304
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String r = sc.next();
        String g = sc.next();
        String b = sc.next();
        int num = Integer.valueOf(r+g+b);

        if (num % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
long long max_l(long long a,long long b)
{
    if(a>b)
        return a;
    else
        return b;
}
int main() {

    int n,w;
    cin>>n>>w;
    long long dp[w+1];
    memset(dp,0, sizeof(dp));
    for(int i=0;i<n;i++)
    {
       long long  wei,val;
        cin>>wei>>val;
        for(int k=w;k>=wei;k--)
        {/*
            if(dp[k-wei]+val>dp[k])
                dp[k]=dp[k-wei]+val;
         */
            dp[k]=max_l(dp[k-wei]+val,dp[k]);
        }
        /*
        for(int k=1;k<=w;k++)
        cout<<dp[k]<<' ';
        cout<<endl;*/
    }
    cout<<dp[w]<<endl;
}


Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power_mod(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define outaa(a, m, n) rep(i, m) {rep(j, n) cout << a[i][j] << " "; cout << endl;} cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl

//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always
//product of minimum 9 prime numbers is above 1e9


int main() {
    int n; cin >> n;
    int h[n]; rep(i, n) cin >> h[i];
    
    //sumではなくmin
    
    int dp[n]; fill_n(dp, n, 0);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    dp[2] = min(abs(h[2] - h[0]), dp[1] + abs(h[2] - h[1]));
    rep3(i, 3, n) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    out(dp[n - 1]);
}


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

namespace cs
{
  // 解説みた
    public class Program
    {
        public static void Main(string[] args)
        {
        
        	
        	var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        	var N = a[0];
        	var Q = a[1];
        	var input = Console.ReadLine().ToCharArray();
        	
        	var ACList = new int[N];
        	var cnt = 0;
        	for(int i =1; i < input.Length; i++){
        		if( input[i-1] == 'A'){
        			if(input[i] == 'C'){
        				cnt++;
        			}
        		}
        		ACList[i] = cnt;
        	}
        	
        	for(int i = 0; i < Q; i++){
        		a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        		a[0]--;
        		a[1]--;
        		
        		
        		Console.WriteLine(ACList[a[1]] - ACList[a[0]]);
        	}
        	
        	
        	
        	
        
        
        }
            
    }
}



Measured memory_bytes: 16580
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
	int N,A,B;
	string S;
	int passed = 0;
	int overRank = 0;
	cin>>N>>A>>B;
	cin>>S;
	for(int i = 0;i<S.size();i++)
	{
		if(S.at(i) == 'c')
		{	cout<<"No"<<endl;}
		if(S.at(i) == 'a')
		{
			if(passed<(A+B))
			{
				cout<<"Yes"<<endl;
				passed++;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		if(S.at(i) == 'b')
		{
			if(passed<(A+B))
			{
				if(overRank<B)
				{
					cout<<"Yes"<<endl;
					passed++;
					overRank++;
				}
				else{cout<<"No"<<endl;}
			}
			else{cout<<"No"<<endl;}
		}
		
	}
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        long min = Long.MAX_VALUE;
        int count = 0;
        for (int i = 0; i < n; i++) {
            long a = sc.nextLong();
            sum += Math.abs(a);
            min = Math.min(min, Math.abs(a));
            if (a < 0) {
                count++;
            }
        }
        if (count % 2 == 0) {
            System.out.println(sum);
        } else {
            System.out.println(sum - 2 * min);
        }
    }

    void run2() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] as = new long[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextLong();
        }
        long[][] dp = new long[n][2];
        dp[0][0] = as[0];
        dp[0][1] = -as[0];
        for (int i = 1; i < n; i++) {
            dp[i][0] = Math.max(dp[i - 1][0] + as[i], dp[i - 1][1] - as[i]);
            dp[i][1] = Math.max(dp[i - 1][0] - as[i], dp[i - 1][1] + as[i]);
        }
        System.out.println(dp[n - 1][0]);
    }

    public static void main(String[] args) {
        new Main().run2();
    }
}

Measured memory_bytes: 52104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#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()
{
  string s;
  cin >> s;

  string res = "";
  rep(i,s.size()){
    if(s[i]=='0'){
      res += "0";
    }
    else if(s[i]=='1'){
      res += "1";
    }
    else{
      if(res.size()!=0){
	auto it = res.begin()+res.size()-1;
	res.erase(it);
      }
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pl;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}

int main(){

  string w;
  cin >> w;

  set<char> mo;
  rep(i,w.length())
  {
    if(mo.count(w[i])==0){mo.insert(w[i]);}
    else mo.erase(w[i]);
  }

  cout << (mo.empty()==true?"Yes":"No") <<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;




public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int s = cin.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        map.put(s,1);
        for (int i = 2; true; i++) {
            int n = s;
            s = n%2==0? n/2 : 3*n+1;
            if (map.get(s) != null) {
                System.out.println(i);
                break;
            }
            map.put(s,1);
        }
    }


}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	int N,K;
	cin>>N>>K;
	string ans ="NO";
	if(N/2+N%2>=K)ans="YES";
	cout<<ans<<endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int64
solve n m edges = V.create $ do
  -- m 番目の島から順番に島同士が「繋がっていく」と考える

  -- j = assocs ! i : i 番目の島の親が j
  -- assocs <- VM.new n
  -- forM_ [0..n-1] $ \i -> VM.write assocs i i
  assocs <- V.thaw $ V.enumFromN 0 n

  -- numberOfElements ! i : i番目の島と同じ連結成分に属する島の個数
  numberOfElements <- VM.replicate n 1

  rank <- VM.replicate n (0 :: Int)

  let getRoot !i xs = do
        !j <- VM.read assocs i
        if i == j
          then forM_ xs (\l -> VM.write assocs l i) >> return i
          else getRoot j (i:xs)

      -- i 番目の島と j 番目の島を繋いで、新たに繋がった組み合わせの個数を返す
      unify !i !j = do
        !i' <- getRoot i []
        !j' <- getRoot j []
        if i' == j'
          then return 0
          else do
          !ri <- VM.read rank i'
          !rj <- VM.read rank j'
          !k <- case compare ri rj of
                  EQ -> do VM.write rank i' (ri + 1)
                           return i'
                  LT -> return j'
                  GT -> return i'
          VM.write assocs i' k
          VM.write assocs j' k
          !n1 <- VM.read numberOfElements i'
          !n2 <- VM.read numberOfElements j'
          VM.write numberOfElements k (n1 + n2)
          return $! n1 * n2
  result <- VM.new m
  VM.write result (m-1) $ fromIntegral n * (fromIntegral n - 1) `quot` 2
  forM_ [m-1,m-2..1] $ \i -> do
    let (a,b) = edges V.! i
    convenience <- unify a b
    prevInconveniences <- VM.read result i
    VM.write result (i-1) (prevInconveniences - convenience)
  return result

readIntPair :: IO (Int, Int)
readIntPair = do
  [a,b] <- BS.words <$> BS.getLine
  case (BS.readInt a, BS.readInt b) of
    (Just (a', _), Just (b', _)) -> return (a',b')

main = do
  -- (n,m) <- readIntPair
  [n,m] <- map (read . BS.unpack) . BS.words <$> BS.getLine -- 2 <= n <= 10^5, 1 <= m <= 10^5
  edges <- V.replicateM m $ do
    -- (a,b) <- readIntPair
    [a,b] <- map (read . BS.unpack) . BS.words <$> BS.getLine
    return (a-1, b-1)
  -- maxIncovenience < n * (n - 1) / 2 < 10^10 (2^32 < 10^10)
  let result = solve n m edges
  V.forM_ result print


Measured memory_bytes: 6908
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
using namespace std;
const int N=107;
struct V {
	int x,y;
	bool operator < (const V &_) const {
		return atan2(y,x)<atan2(_.y,_.x);
	}
	V operator + (const V &_) const {
		return (V){x+_.x,y+_.y};
	}
	long long len2() {
		return 1LL*x*x+1LL*y*y;
	}
}A[N];
int m,n;
int main() {
	scanf("%d",&m);
	For(i,1,m) {
		++n;
		scanf("%d%d",&A[n].x,&A[n].y);
		if(!A[n].x&&!A[n].y) --n;
	}
	sort(A+1,A+1+n);
	long long ans=0;
	For(i,1,n) {
		V r=(V){0,0};
		For(j,0,n-1) {
			r=r+A[(i+j-1)%n+1];
			ans=max(ans,r.len2());
		}
	}
	printf("%.14f",sqrt(ans));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll N; cin>>N;
    ll MIN=INF;
    ll SUM=0;
    ll fu=0;
    rep(i,N){
        ll A; cin>>A;
        if(A<0) fu++;
        SUM+=abs(A);
        MIN=min(MIN,abs(A));
    }
    if(fu%2) SUM-=(MIN*2);
    cout<<SUM<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




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

    int N;
    ll K;
    cin>>N>>K;
    vector<ll> A(N);
    ll sum=0;
    for(int i=0;i<N;i++) cin>>A[i],sum+=A[i];

    vector<ll> V;
    for(ll i=1;i*i<=sum;i++){
        if(sum%i==0){
            V.push_back(sum/i);
            V.push_back(i);
        }
    }
    sort(V.rbegin(),V.rend());
    ll ret=1;
    for(ll x:V){
        vector<ll> v(N),vv(N);
        int i=0;
        for(ll a:A){
            v[i]=(a%x);
            vv[i]=(x-a%x);
            i++;
        }
        sort(v.begin(),v.end());
        sort(vv.begin(),vv.end());
        for(int i=1;i<N;i++) v[i]+=v[i-1];
        for(int i=1;i<N;i++) vv[i]+=vv[i-1];
        ll ans=INF;
        for(int i=1;i<N;i++){
            chmin(ans,max(v[i-1],vv[N-i-1]));
        }
        if(ans<=K) chmax(ret,x);
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define el '\n'

using namespace std;
ll n,k,r;
ll pc[4005];

ll ppow(ll a,ll b){
    if (b==0) return 1;
    ll tm=ppow(a,b/2);
    if (b&1) return (tm*tm%MOD)*a%MOD;
    return tm*tm%MOD;
}

ll comb(ll n,ll k)
{
    return pc[n]*ppow(pc[k]*pc[n-k]%MOD,MOD-2)%MOD;
}
ll sol(ll a)
{
    ll mxmid=k-1;
    ll mid=a-1;
    if (r<mid)
        return 0;
    ll res=comb(mxmid,mid);
    ll sisa=r-mid;
    res=res*comb(sisa+a,a)%MOD;
    return res;
}

int main () 
{ 
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    pc[0]=1;
    for (ll i=1;i<4005;i++)
        pc[i]=pc[i-1]*i%MOD;
    cin >> n >> k;
    r=n-k;  
    for (ll i=1;i<=k;i++)
        cout << sol(i) << el;
    
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int tot[20];
int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	tot[1] = 1;
	tot[3] = 1;
	tot[5] = 1;
	tot[7] = 1;
	tot[8] = 1;
	tot[10] = 1;
	tot[12] = 1;
	tot[4] = 2;
	tot[6] = 2;
	tot[9] = 2;
	tot[11] = 2;
	tot[2] = 3;
	if(tot[a] == tot[b]) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 2302000
#define offset 8010
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef pair<map<ll,ll> ,ll> mi;
typedef pair<ii,ii> iiii;
typedef vector<ll> vi;
const ll MOD=1e9+7;
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    string txt;
    cin>>txt;
    int tot=0,c=0;
    if (txt[0]==txt[txt.size()-1])
    {
        forr(i,0,txt.size())
        {
            if (txt[i]==txt[0])
            {
                tot+=max(c-1,0);
                c=0;
            }
            else
                c++;
        }
    }
    else
    {
        forr(i,0,txt.size())
        {
            if (txt[i]==txt[0])
            {
                tot+=max(c-1,0);
                c=0;
            }
            else
                c++;
        }   
        tot+=c-1;
    }
    if (tot%2==0)
        cout<<"Second\n";
    else
        cout<<"First\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

//解説AC

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	int distx = gx - sx;
	int disty = gy - sy;
	{
		REP(i, distx)cout << 'R';
		REP(i, disty)cout << 'U';
	}
	{
		REP(i, distx)cout << 'L';
		REP(i, disty)cout << 'D';
	}
	{
		cout << 'L';
		REP(i, disty + 1)cout << 'U';
		REP(i, distx + 1)cout << 'R';
		cout << 'D';
	}
	{
		cout << 'R';
		REP(i, disty + 1)cout << 'D';
		REP(i, distx + 1)cout << 'L';
		cout << 'U';
	}
	cout << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
MODULO = 10**9+7

n, m = list(map(int, input().split()))

def ModulousProdct(x, y):
    return x*y % MODULO

def ModulousFactorial(n):
    v = 1
    for i in range(1, n+1):
        v = ModulousProdct(v, i)
    return v


if n == m:
    print(ModulousProdct(ModulousProdct(ModulousFactorial(n), ModulousFactorial(m)), 2))
elif n+1==m or n==m+1:
    print(ModulousProdct(ModulousFactorial(n), ModulousFactorial(m)))
else:
    print(0)




Measured memory_bytes: 3064
x,y,z,k=map(int,input().split())
list_a=list(map(int,input().split()))
list_b=list(map(int,input().split()))
list_c=list(map(int,input().split()))
list_a.sort(reverse=True)
list_b.sort(reverse=True)
list_c.sort(reverse=True)
dict_p={}
dict_p[(0,0,0)]=list_a[0]+list_b[0]+list_c[0]
pop_list=[]
for i in range(0,k):
    Max=max(dict_p.values())
    print(Max)
    for j in dict_p:
        if dict_p[j]==Max:
            now=j
            dict_p.pop(now)
            pop_list.append(now)
            break
    if now[0]+1<x:
        if not (now[0]+1,now[1],now[2]) in pop_list:
            dict_p[(now[0]+1,now[1],now[2])]=list_a[now[0]+1]+list_b[now[1]]+list_c[now[2]]
    if now[1]+1<y:
        if not (now[0],now[1]+1,now[2]) in pop_list:
            dict_p[(now[0],now[1]+1,now[2])]=list_a[now[0]]+list_b[now[1]+1]+list_c[now[2]]
    if now[2]+1<z:
        if not (now[0],now[1],now[2]+1) in pop_list:
            dict_p[(now[0],now[1],now[2]+1)]=list_a[now[0]]+list_b[now[1]]+list_c[now[2]+1]
    


Measured memory_bytes: 4576
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    if((a==b)&&(a==c)&&(b==c)){
      System.out.println("No");
    }else if((a!=b)&&(a!=c)&&(b!=c)){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
  }

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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

  vvi dp(61, vi(3));
  dp[60][0] = 1;

  for(int i = 59; i >= 0; i--){
    if(n & 1LL<<i){
      dp[i][0] = dp[i+1][0];
      dp[i][1] = dp[i+1][0]+dp[i+1][1];
      dp[i][2] = 2*dp[i+1][1] + 3*dp[i+1][2];
    }else{
      dp[i][0] = dp[i+1][0]+dp[i+1][1];
      dp[i][1] = dp[i+1][1];
      dp[i][2] = dp[i+1][1] + 3*dp[i+1][2];
    }

    dp[i][0] %= mod;
    dp[i][1] %= mod;
    dp[i][2] %= mod;
  }

  cout << (dp[0][0]+dp[0][1]+dp[0][2])%mod << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int x = scan.nextInt();
			int y = scan.nextInt();
			int s = scan.nextInt();
			if (x + y + s == 0)
				break;
			int max = 0;
			for (int i = 1; i < s; i++) {
				for (int j = 1; j < s; j++) {
					int xi = (i * (100 + x) / 100);
					int xj = (j * (100 + x) / 100);
					if (xi + xj == s) {
						int yi = (i * (100 + y) / 100);
						int yj = (j * (100 + y) / 100);
						max = Math.max(max, yi + yj);
					}
				}
			}
			System.out.println(max);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 29188