akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 3; i++) {
		if ((a * b * i) % 2 == 1) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	dump("No");
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main(void){
int a,b=0;
cin>>a;
vector<int>d(a);
for(int i=0;i<a;i++){
    cin>>d[i];
}
for(int i=0;i<a;i++){
    for(int j=i+1;j<a;j++){
        b+=d[i]*d[j];
    }
}
cout<<b<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define vec vector<int>
using namespace std;
int main()
{
    int X, A, B;
    cin >> X >> A >> B;
    if (X < (B - A))
    {
        cout << "dangerous" << endl;
    }
    else if (A >= B)
    {
        cout << "delicious" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
}

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

using ll = long long int;
int A[100000];
ll M[100000];
int nonzero[100000];
int main() {
	int N, S, W, Q;
	map<int, int> cnt;
	while (cin >> N >> S >> W >> Q, N) {
		int g = S;
		for (int i = 0; i < N; i++) {
			A[i] = (g / 7) % 10;
			if (g % 2 == 0) g = g / 2;
			else g = (g / 2) ^ W;
		}
		ll k = 1;
		ll ans = 0;
		for (int i = 1; i < N; i++) {
			nonzero[i] = nonzero[i - 1];
			if (A[i - 1] != 0) nonzero[i]++;
		}
	
		if (Q == 2) {
			for (int i = 0; i < N; i++) {
				if (A[i] % 2 == 0) ans += nonzero[i] + (A[i] != 0);
			}
			cout << ans << endl;
			continue;
		}
		else if (Q == 5) {
			for (int i = 0; i < N; i++) {
				if (A[i] % 5 == 0) ans += nonzero[i] + (A[i] != 0);
			}
			cout << ans << endl;
			continue;
		}
		cnt.clear();
		for (int i = N - 1; i >= 0; i--) {
			M[i] = (A[i] * k) % Q;
			if (i + 1 < N) (M[i] += M[i + 1]) %= Q;
			(k *= 10) %= Q;
			if (A[i] != 0) {
				if (M[i] == 0) ans++;
				ans += cnt[M[i]];
			}
			cnt[M[i]]++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 8832
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

now = 1
path = [1]

for i in range(N + 2):
    now = A[now]
    path.append(now)

if i >= K:
    print(path[K])
    quit()

now = path.pop()
lo_start = i - 1
while path[lo_start] != now:
    lo_start -= 1

loop = path[lo_start:]

ans = loop[(K - path.index(now)) % len(loop)]

print(ans)

Measured memory_bytes: 32332
import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

N, K = map(int,input().split())
H = list(map(int,input().split())) ## 横一列

ans = 0
for i in range(N):
  if H[i] >= K:
    ans += 1
    
print(ans)

Measured memory_bytes: 22340
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  string s;
  cin>>s;
  int n=s.size();

  if(n==2){
    if(s[0]!=s[1]) cout<<"-1 -1"<<endl;
    else cout<<1<<" "<<2<<endl;
    return 0;
  }
  if(s[0]==s[1]){
    cout<<"0 1"<<endl;
    return 0;
  }
  for(int i=2; i<n; ++i){
    if(s[i]==s[i-1]){
      cout<<i<<" "<<i+1<<endl;
      return 0;
    }
    if(s[i]==s[i-2]){
      cout<<i-1<<" "<<i+1<<endl;
      return 0;
    }
  }
  cout<<"-1 -1"<<endl;
  return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	int N=in(),K=in();
	auto P=vecin(N);
	sort(ALL(P));
	
	out(accumulate(P.begin(),P.begin()+K,0));
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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


int d = 0;

int u[510][510];

void rec(set<int> s, int d) {
    if (s.size() == 1) return;
    int x = 0;
    set<int> a[2];
    for (auto i : s) {
        a[x % 2].insert(i);
        x++;
        x %= 2;
    }
    for (auto i : a[0]) {
        for (auto j : a[1]) {
            u[i][j] = u[j][i] = d;
        }
    }

    rec(a[0], d + 1);
    rec(a[1], d + 1);

}

void solve(long long N) {
    set<int> A;
    for (int i = 0; i < N; i++) A.insert(i);
    rec(A, 1);
    for (int i = 0; i + 1 < N; i++) {
        for (int j = i + 1; j < N; j++) {
            cout << u[i][j] << " ";
        }
        cout << endl;

    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    VEC(int) Heights(N);
    READVEC(Heights);
    VEC(bool) Good(N, true);

    FOR(i, 0, M) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        if (Heights[u] >= Heights[v])
            Good[v] = false;
        if (Heights[v] >= Heights[u])
            Good[u] = false;
    }

    int ret = 0;
    FOR(i, 0, N)
        ret += Good[i];
    cout << ret << endl;

    return 0;
};


Measured memory_bytes: 3728
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
//const int MOD = 1000000007;
const int MOD = 998244353;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___combination___////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

///////////////////////////////////////////////////////////

int n,p[210000],t[210000], c[210000];
int dfs(int x){
  if(t[x+1] < t[x] || x == n)return c[x] = 1;
  else return c[x] = dfs(x+1) + 1;
}
signed main(){
  cin>>n;
  rep(i,n){
    cin>>p[i];
    t[p[i]] = i;
  }
  repd(i,1,n+1)c[i] = -1;
  repd(i,1,n+1)if(c[i] == -1)dfs(i);
  int ans = INF;
  rep(i,n+1){
    chmin(ans, n-c[i+1]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 8192
// AOJ 0303
#include<cstdio>
#include<algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

const int MAX_N = 1000, INF = 1001;

int N;
int c[MAX_N], w[MAX_N];
int wS[MAX_N];
bool P[MAX_N][MAX_N];
int dp[MAX_N];

int main()
{
	scanf( "%d", &N );
	rep( i, N )
		scanf( "%d%d", c+i, w+i );

	wS[0] = w[0];
	rep( i, N-1 )
		wS[i+1] = wS[i] + w[i+1];

	rep( i, N )
		P[i][i] = true;

	rep( w, N )
	{
		rep( i, N-w )
		{
			int j = i+w;
			
			if( !P[i][j] )
				continue;

			if( j+1 < N && wS[j]-(i-1>=0?wS[i-1]:0) <= c[j+1] )
				P[i][j+1] = true;
			if( i-1 >= 0 && wS[j]-(i-1>=0?wS[i-1]:0) <= c[i-1] )
				P[i-1][j] = true;
		}
	}

	std::fill( dp, dp+N, INF );

	dp[0] = 1;
	rep( i, N ) rep( j, N ) if( P[i][j] )
		dp[j] = std::min( dp[j], (i-1>=0?dp[i-1]:0)+1 ); 

	printf( "%d\n", dp[N-1] );

	return 0;
}

Measured memory_bytes: 2000
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        for(int c10k=0; c10k<=Y/10000; c10k++){
            int c5kmax = (Y-10000*c10k)/5000;
            for(int c5k=0; c5k<=c5kmax; c5k++){
                if(Y-10000*c10k-5000*c5k==(N-c10k-c5k)*1000){
                    String ans = Integer.toString(c10k)+" "+Integer.toString(c5k)+" "+Integer.toString(N-c5k-c10k);
                    System.out.println(ans);
                    System.exit(0);
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 21972
package main
import(
  "fmt"
  "bufio"
  "os"
  "strconv"
)
var sc=bufio.NewScanner(os.Stdin)
func nextInt() int{
  sc.Scan()
  i, e :=strconv.Atoi(sc.Text())
  if e!=nil{
    panic(e)
  }
  return i
}
func main(){
  var i int
  ans:=0
  sc.Split(bufio.ScanWords)
  n:=nextInt()
  a:=make([]int, n)
  for i=0;i<n;i++{
    a[i]=nextInt()
    ans+=a[i]-1
  }
  fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int a, b;
  cin >> a >> b;
  int ans = 6-a-b;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 1e5;
const int INF = 1e9 + 7;
int a[maxn + 5];
int n;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	int Min = INF;
	int pos = 0;
	for(int i = 1; i <= n; i++) {
		if(abs(a[i] - (a[n] + 1) / 2) < Min) {
			Min = abs(a[i] - (a[n] + 1) / 2);
			pos = i;
		}
	}
	printf("%d %d\n", a[n], a[pos]);
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		int a = ia[0];
		int b = ia[1];
		int c = ia[2];
		int d = ia[3];
		int s = max(a, c);
		int e = min(b, d);
		int ans = max(0, e - s);
		pln(ans);
	}

	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}
ll h(const string&s){
    ll ret=0;
    REPA(i,s){
        ret=ret*26+s[i]-'a';
    }
    return ret;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    map<ll,int> m;
    string s;
    REP(i,n){
        cin>>s;
        sort(all(s));
        m[h(s)]++;
    }
    ll ans=0;
    for(const auto& x:m){
        ans+=1ll*x.S*(x.S-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
const ll inf = 1e9+10;
 
 
vector<int> v[maxN];
int st[maxN],tot,tag[maxN],vis[maxN];
int val,flag;
int nxt[maxN];
void dfs(int x)
{
	st[++tot] = x;
	vis[x] = tag[x] = 1;
	for(auto y:v[x])
	{
		if(!vis[y])
		{
			dfs(y);
		}
		else if(tag[y])
		{
			val = y;
			flag = 1;
		}
		if(flag)
		{
			return;
		}
	}
	st[tot--] = 0;
	vis[x] = 0;
} 
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
	{
		if(!tag[i])
		{
			dfs(i);
			if(flag)
				break;
		}
	}
	if(flag == 0)
	{
		puts("-1");
		return 0;
	}
	int pos;
	for(int i=1;i<=tot;i++)
	{
		if(st[i] == val)
		{
			pos = i;
			break;
		}
	}
	nxt[st[tot]] = val;
	for(int i=pos;i<tot;i++)
	{
		nxt[st[i]] = st[i+1];
	}
	for(int i=1;i<=n;i++)
	{
		if(!nxt[i])continue;
		for(auto y:v[i])
		{
			if(!nxt[y])
				continue;
			int p = i,q = nxt[i];
			while(q != y)
			{
				int r = nxt[q];
				nxt[p] = r;
				nxt[q] = 0;
				q = r;
			}
		}
	}
	int x = 0;
	for(int i=1;i<=n;i++)
	{
		if(nxt[i])
		{
			x = i;
			break;
		}
	}
	vector<int> a;
	a.push_back(x);
	while(1)
	{
		int y = nxt[x];
		if(y == a[0])
			break;
		a.push_back(y);
		x = y;
	}
	int len = a.size();
	printf("%d\n",len);
	for(int i=0;i<len;i++)
	{
		printf("%d\n",a[i]);
	}
	return 0;
}

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

int n, a[100000];
vector<int> d;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  d.push_back(1);
  int size = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) d[size]++;
    else d.push_back(1), size++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = i; j <= size && j < i + 3; j++) sum += d[j];
    ans = max(ans, sum);
  }
  printf("%d\n", ans);
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int x;
    cin >> x;
    int a = 9;
    if (x >= 400) a--;
    if (x >= 600) a--;
    if (x >= 800) a--;
    if (x >= 1000) a--;
    if (x >= 1200) a--;
    if (x >= 1400) a--;
    if (x >= 1600) a--;
    if (x >= 1800) a--;
    cout << a << endl;
}

Measured memory_bytes: 3692
//趣题
//评价
//劣质代码
//#pragma GCC optimize(3)
//#pragma G++ optimize(3)
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	ios::sync_with_stdio(0);
	string str;
    cin>>str;
    cout<<str[0]<<str.size()-2<<str[str.size()-1];
	return 0;
}
//终于写完了！！！
//祝：WA声一片
//评测结果...


Measured memory_bytes: 256
x, k, d = map(int, input().split())
x = abs(x)
wantk = x // d
if wantk > k:
    print(abs(x - k * d))
    exit()
x -= wantk * d
k -= wantk
if k % 2 == 0:
    print(abs(x))
else:
    print(abs(x - d))

Measured memory_bytes: 9120
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e5) + 17;

int n, k;

bool read() {
    if (!(cin >> n))
        return false;

    return true;
}

void solve() {
    for (int i = 0; i * 4 <= n; ++i)
        if ((n - i * 4) % 7 == 0) {
            cout << "Yes\n";
            return ;
        }

    cout << "No\n";
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cmath>
#define ll long long
#define pb push_back
#define vi vector<int>
#define si set<int>
#define msi multiset<int>
#define vll vector<ll>
#define ff first
#define ss second
#define pii pair<int,int>
#define mp make_pair
#define all(a) a.begin(),a.end()
#define f(i,x,n) for(int i=x;i<n;i++)
#define fd(i,n,x) for (int i=n;i>=x;i--)
#define itr :: iterator it
#define endl '\n'
#define INF 1e9
#define mod 1e9+7

using namespace std;
ll knapsack(ll i,ll n,ll w,ll wt[],ll v[],vector<vector<ll> >&dp)
{
    if(i>=n||w<=0)
        return 0;
    if(dp[i][w]!=-1)
        return dp[i][w];
        if(wt[i]<=w)
        {
            ll left=v[i]+knapsack(i+1,n,w-wt[i],wt,v,dp);
            ll right=knapsack(i+1,n,w,wt,v,dp);
            return dp[i][w]=max(left,right);
        }
     return dp[i][w]=knapsack(i+1,n,w,wt,v,dp);
}
int main()
{
    ll n,w;
    cin>>n>>w;
    ll wt[105];
    ll v[105];
    vector<vector<ll> >dp(n,vector<ll>(w+1,-1));
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>v[i];
    }
    cout<<knapsack(0,n,w,wt,v,dp);
}


Measured memory_bytes: 82388
#include <bits/stdc++.h>
using namespace std;
int a[100100];
int n;

int main() {
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> a[i];
  }
  int x = a[1];
  int cnt = 1;
  for(int i=0; i<n; i++){
    if(x==2) {
      cout << cnt << endl;
      return 0;
    }
    x = a[x];
    cnt++;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int k,x;
  cin>>k>>x;
  for(int i=x-k+1;i<=x+k-1;i++){
    if(i!=x+k-1){cout<<i<<' ';}
    else cout<<i;}
  cout<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int pos = (H / h) * (W / w);
    int posi = 1000, mini = - (h * w - 1) * posi - 1;
    if((H * W - pos) * posi <= - pos * mini){
        cout << "No" << '\n';
        return 0;
    }
    // int remH = (H + h - 1)/ h * h - H;
    cout << "Yes" << '\n';
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cout << (i % h == 0 && j % w == 0 ? mini : posi) << ' ';
            // cout << (i % h == 0 && j % w == 0 ? mini : i == H ? remH : 1) << ' ';
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
int main(){
  long long n,i,j,a,b,c,s=0,M=1e9+7,d[300010]={};
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld",&d[i]);
  for(i=0;i<60;i++){
    c=(1LL<<i);
    a=b=0;
    for(j=0;j<n;j++){
      if(d[j]&c)a++;
      else      b++;
    }
    //printf("%lld\n",a*b);
    a%=M;
    b%=M;
    c%=M;
    s=(s+(a*b)%M*c%M)%M;
  }
  printf("%lld\n",s%M);
  return 0;
}


Measured memory_bytes: 2560
o = list(input())
e = list(input())
ans = ""

while True:
	if len(o) == 0 and len(e) == 0:
		break
		
	if len(o) != 0:
		ans = ans + o[0]
		o.remove(o[0])
	if len(e) != 0:
		ans = ans + e[0]
		e.remove(e[0])
print(ans)

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool ok = true;
    rep(i,n){
        if (i%2 == 0 && s[i] == 'L') ok=false ;
        if (i%2 == 1 && s[i] == 'R') ok = false ;
    }
    if (ok) puts("Yes"); else puts("No");
    return 0;
}

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

const int MAX_N = 8;
int H, W, C;
int G[MAX_N][MAX_N];

bool vis[MAX_N][MAX_N];

int dfs(int x, int y, int c) {
  const static int dx[] = {1,0,-1,0};
  const static int dy[] = {0,1,0,-1};
  int res = 1;
  vis[y][x] = true;
  for(int i = 0; i < 4; ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || nx >= W) continue;
    if(ny < 0 || ny >= H) continue;
    if(G[ny][nx] != c) continue;
    if(vis[ny][nx]) continue;
    res += dfs(nx, ny, c);
  }
  return res;
}

int solve() {
  int g[MAX_N][MAX_N];
  int res = 1;
  for(int a = 1; a <= 6; ++a) {
    for(int b = 1; b <= 6; ++b) {
      for(int c = 1; c <= 6; ++c) {
	for(int d = 1; d <= 6; ++d) {
	  int col[] = {a, b, c, d, C};
	  copy(G[0], G[MAX_N], g[0]);
	  for(int k = 0; k < 5; ++k) {
	    fill(vis[0], vis[MAX_N], false);
	    dfs(0, 0, G[0][0]);
	    for(int i = 0; i < H; ++i) {
	      for(int j = 0; j < W; ++j) {
		if(vis[i][j]) G[i][j] = col[k];
	      }
	    }
	  }
	  fill(vis[0], vis[MAX_N], false);
	  res = max(res, dfs(0, 0, G[0][0]));
	  copy(g[0], g[MAX_N], G[0]);
	}
      }
    }
  }
  return res;
}

int main() {
  while((cin >> H >> W >> C) && (H || W || C)) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	cin >> G[i][j];
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 868
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

ll N, A, B;

signed main(){
    cin >> N >> A >> B;
    if(N < A+B-1 || A*B < N){
        cout << -1 << endl;
        return 0;
    }

    vector<ll> v;
    int k = N-A;
    for(ll i=0; i<A; i++){
        for(ll j=0; k>0&&j<B-1; j++){
            v.pb((i+1)*B-1-j);
            k--;
        }
        v.pb(i*B);
    }

    vector<ll> z = v;
    sort(all(z));
    rep(i, v.size()){
        cout << lower_bound(all(z), v[i]) - z.begin() + 1 << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  
  int d1 = n/1000;
  int d2 = n/100 % 10;
  int d3 = n/10 % 10;
  int d4 = n % 10;
  
  if ((d1 == d2 && d2 == d3) || (d2 == d3 && d3 == d4)) {
    cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n = gets.chomp.to_i
s = []
n.times do
  s.push gets.chomp
end
h = Hash.new(0)
s.each do |name|
  if %w[M A R C H].include?(name[0])
    h[name[0]] += 1
  end
end
if h.empty? || h.size < 3
  puts 0
else
  puts h.to_a.map{ |e| e.last }.combination(3).to_a.map { |e| e.reduce(1) { |mul, c| mul * c }}.reduce(:+)
end


Measured memory_bytes: 10236
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

long long inp_c, i1, out_n;

string inp_a[200005];

long long readNumber() {
	long long temp_func;
	scanf("%lld", &temp_func);
	return temp_func;
};
long long printNumber(long long temp_func) {
	printf("%lld", temp_func);
	return 0;
};

int main() {
	
	inp_c = readNumber();
	
	for (i1 = 1; i1 <= inp_c; i1++) {
		
		cin >> inp_a[i1];
		
	};
	
	sort(inp_a + 1, inp_a + 1 + inp_c);
	
	for (i1 = 1; i1 <= inp_c; i1++) {
		
		out_n += inp_a[i1] != inp_a[i1 - 1];
		
	};
	
	printNumber(out_n);
	
}

Measured memory_bytes: 10084
#include<stdio.h>
int main(void)
{
	int a,b,c,i,cnt;
	scanf("%d %d %d",&a,&b,&c);
	cnt=0;
	for(i=a;i<=b;i++) {
		if(c%i==0) {
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 596
/* author   : mpily :-()
    title : Competing.cpp
    time :Sat Oct 19 15:35:41 2019
     
    */
    #include<bits/stdc++.h>
    using namespace std;
   // int dp[1003];
    int dp[2003][1003];
    int main(){
    	int N;
    	cin>>N;
    	vector<int>arr(N);
    	for(int i = 0; i < N; i++){
    		cin>>arr[i];
    	}
    	sort(arr.begin(),arr.end());
    	long long fans = 0;
	for(int i = 0; i < 1003;i++)dp[0][i] = 0;
	for(int i = 1; i <= N; i++){			
		for(int j = 0; j < 1003; j++){
			dp[i][j] = dp[i-1][j];
			if(arr[i-1] < j)dp[i][j]+=1;
		}
	}

	/*for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			int ulim = min(1002,arr[i]+arr[j]);
			fans+=max(0,dp[N][ulim] - dp[j][ulim]);
			if(arr[j] < ulim)fans-=1;
		}
	}
	cout<<fans<<"\n";*/
	long long anans = 0;
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			for(int k = j+1; k < N; k++){
				if(arr[k] < (arr[i]+arr[j]))anans+=1;	
			}
		}
	}
	cout<<anans<<"\n";
    	return 0;
    }


Measured memory_bytes: 8064
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
drinks = []
for _ in range(N):
    a,b = map(int,input().split())
    drinks.append((a,b))

drinks.sort(key=lambda x:x[0])

sum = 0
price = 0
for d in drinks:
    if sum + d[1] < M:
        sum += d[1]
        price += d[0]*d[1]
    else:
        price += d[0]*(M-sum)
        break

print(price)



Measured memory_bytes: 82644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
signed main(){
    int a,b;
    set<int> se;
    se.insert(1);
    se.insert(2);
    se.insert(3);

    cin>>a>>b;
    se.erase(a);
    se.erase(b);

    auto i = se.begin();
    cout<<*i<<endl;
}

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

int main()
{	
	int N, satisfaction = 0;
	cin >> N;

	int *A = new int[N];
	int *B = new int[N];
	int *C = new int[N - 1];
	for (int i = 0; i < N; cin >> A[i], i++);
	for (int i = 0; i < N; cin >> B[i], i++);
	for (int i = 0; i < N - 1; cin >> C[i], i++);

	for (int i = 0; i < N; i++)
	{
		satisfaction += B[A[i] - 1];

		if ((i != N - 1) && (A[i + 1] == A[i] + 1))
			satisfaction += C[A[i] - 1];
	}
	cout << satisfaction << endl;

	delete[] A, B, C;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 998244353;

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

  LL n;
  cin >> n;
  vector<LL> v(n);
  REP(i,n){
    cin >> v[i];
  }

  LL min = 1e18;

  REP(i,n){
    LL sum = 0;
    REP(j, n)
    {
      if(i==j){
        sum += v[j]/2;
      }
      else
      {
        sum += v[j];
      }
    }
    if(sum<min){
      min = sum;
    }
  }

  cout << min << endl;
}


Measured memory_bytes: 256
require "date"

S = gets.chomp

sDate = Date.strptime(S, '%Y/%m/%d')

hDate = Date.strptime('2019/04/30', '%Y/%m/%d')

sub = sDate - hDate

if sub > 0
  puts 'TBD'
else
  puts 'Heisei'
end

Measured memory_bytes: 2040
n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in A}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        tmp = 2
        while a * tmp <= maxA:
            D[a * tmp] = 1
            tmp += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)


Measured memory_bytes: 104020
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1].to!long;
    auto A = readln.split.map!(to!long).array;
    auto B = new long[][](N, 2);

    auto S = A.sum;
    long[] P;
    for (long i = 1; i * i <= S; ++i) {
        if (i * i == S) {
            P ~= i;
        } else if (S % i == 0) {
            P ~= i;
            P ~= S / i;
        }
    }
    P.sort();

    foreach_reverse (p; P) {
        foreach (i, a; A){
            B[i][0] = a % p;
            B[i][1] = (p - a % p) % p;
        }
        B.sort!"a[0]-a[1] < b[0]-b[1]";
        long tmp = 0;
        long sm = 0;
        for (int i = 0, j = N - 1; i < j; ) {
            long x = min(B[i][0], B[j][1]);
            tmp += x;
            B[i][0] -= x;
            B[j][1] -= x;
            if (B[i][0] == 0) i++;
            if (B[j][1] == 0) j--;
            sm += x;
        }
        if (sm <= K && B.map!(b => b[0] % p == 0 || b[1] % p == 0).all) {
            writeln(p);
            return;
        }
    }
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

//最大公約数
ll GCD(ll a, ll b)
{
    if (a == b || b == 0) {
        return a;
    } else if (a < b) {
        return GCD(b, a);
    } else {
        return GCD(b, a % b);
    }
}

//最小公倍数
ll LCM(ll a, ll b)
{
    return a * b / GCD(a, b);
}

vector<ll> primenum;
void get_prime_nembers(ll n)
{
    ll m = n;
    FOR(i,2,m+1) {
        bool flag = true;
        REPALL(j,primenum) {
            if (i % primenum[j] == 0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            primenum.push_back(i);
            while (m % i == 0) {
                m /= i;
            }
        }
        if (i > sqrt(n)+1) {
            primenum.push_back(m);
            break;
        }
    }
}

vector<pair<int, int>> prime_factorization(ll n)
{
    if (primenum.empty())
        get_prime_nembers(n);

    vector<pair<int, int>> rtn;
    REPALL(i,primenum) {
        int num = 0;
        ll tmpn = n;
        while(tmpn % primenum[i] == 0) {
            num++;
            tmpn /= primenum[i];
        }
        if (num > 0)
            rtn.push_back(make_pair(primenum[i],num));
    }
    return rtn;
}

vector<vector<ll>> comb(111111, vector<ll>(100, -1));
ll Combination(ll a, ll b)
{
    if (comb[a][b] != -1) {
        return comb[a][b];
    }

    if (b > a / 2) {
        return Combination(a, a - b);
    }

    if (a == b || b == 0) {
        return 1;
    }

    if (comb[a-1][b-1] == -1) {
        comb[a-1][b-1] = Combination(a-1, b-1);
    }

    if (comb[a-1][b] == -1) {
        comb[a-1][b] = Combination(a-1, b);
    }

    comb[a][b] = (comb[a-1][b-1] + comb[a-1][b]) % MOD;

    return comb[a][b];
}


int main()
{
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    a--;
    ll ans = b - a;
    ans -= b / c - a / c;
    ans -= b / d - a / d;
    ans += b / LCM(c,d) - a / LCM(c,d);
    cout<<ans<<endl;

    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;


int n,m;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m;
    int ans=n*(n-1)/2 + m*(m-1)/2;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  int N;
  cin >> N;
  int pi4 = 0, pi2 = 0, pi3 = 0;
  REP(i, N) {
    int a;
    cin >> a;
    if (a % 4 == 0)
      pi4++;
    else if (a % 2 == 0)
      pi2++;
    else
      pi3++;
  }
  if (pi3 <= pi4||((pi3+pi4==N)&&(pi3-1<=pi4))) {
    puts("Yes");
  } else {
    puts("No");
  }
}

Measured memory_bytes: 256
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
constexpr ll mod = 1000000007;

int main() {
    ll n, w, v[100], u[100], p[101][11001];
    cin >> n >> w;
    for (int i = 0; i < n; i++) {
        cin >> v[i] >> u[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= w; j++) {
            p[i + 1][j + u[i]] = max(p[i + 1][j + u[i]], p[i][j] + v[i]);
            p[i + 1][j] = max(p[i + 1][j], p[i][j]);
        }
    }
    cout << p[n][w] << endl;
}


Measured memory_bytes: 11704
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
   
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  for(var i = 0, len = input.length - 1; i < len; i++){
    var inp = input[i] - 0;
    if(!inp){
      return;
    }
    
    console.log(primeNumbers[inp]);
  }
  
    
}
  
function calcPrimeNumbers(){
  var max = 104729;
  var primeNumbers = new Int8Array(max + 1);
  
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
      
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
  
  var primeNums = new Int32Array(max + 1);
  var sum = 0;
  var c = 0;
  for(var i = 1; i <= max; i++){
    if(!primeNumbers[i]){
      sum = primeNums[++c] += sum + i;
    }
  }
    
  return primeNums;
}

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; int N; ll K; cin >> N >> K;
  vi A(N); FORE(i,A) cin >> i, --i;
  vi pos(N, -1); pos[0] = 0;
  int p = 0;
  int t = 0;
  while(1){
    p = A[p];
    t ++;
    K --;
    if(pos[p] >= 0 || K == 0){
      K %= t - pos[p];
      REP(i,K) p = A[p];
      cout << p+1 << endl;
      return 0;
    }
    pos[p] = t;
  }
}


Measured memory_bytes: 4784
N = int(input())

def F(A):
     return len(str(A))

upper_bound = int(N ** (0.5))
ans = float("inf")
for i in range(1, upper_bound + 1):
     if N % i == 0:
          j = N // i
          ans = min(ans, F(j))
print(ans)

Measured memory_bytes: 38896