akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n;cin>>n;
    int t=n;
    int sum=0;
    while (t) {
        sum+=t%10;
        t/=10;
    }
    if (n%sum==0)
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		while(sc.hasNext()){
			BigDecimal a=sc.nextBigDecimal();
			BigDecimal b=sc.nextBigDecimal();
			BigDecimal r=a.divide(b,MathContext.DECIMAL128);
			int n=sc.nextInt();
			int sum=0;
			for(int i=0;i<n;i++){
				r=r.multiply(BigDecimal.TEN);
				sum+=r.remainder(BigDecimal.TEN).intValue();
			}
			ln(sum);
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 13000
d, n = map(int, input().split())

# print(100 ** 0)
# print(100 ** 1)
# print(100 ** 2)

start = 100 ** d
# step = 100 ** d
# end 

# print(start * n)

value = start
count = 1
while True:
    # print(f'{count} : {value}')
    if n == count:
        break
    
    value += start
    if d == 0:
        if value % 100 != 0:
            count += 1
    elif d == 1:
        if value % 10000 != 0:
            count += 1
    elif d == 2:
        if value % 1000000 != 0:
            count += 1
    else:
        count += 1
    
print(value)

Measured memory_bytes: 9096
#include <cstdio>
#include <map>
using namespace std;
int n,q,a,b,c;
long long s;
map<int,int>m;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		++m[a];
		s+=a;
	}
	scanf("%d",&q);
	for(int i=1;i<=q;++i){
		scanf("%d%d",&b,&c);
		m[c]+=m[b];
		s+=(c-b)*m[b];
		m[b]=0;
		printf("%lld\n",s);
	}
	return 0;
}


Measured memory_bytes: 7680
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  int64 m;
  scanf("%d%lld", &n, &m);
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  bool tight = true;
  int64 ret = 0;
  for (int k = 59; k >= 0; --k) {
    int up = (m & (1LL << k)) ? 1 : 0;
    if (!tight) up = 1;
    int best = -1, best_i = -1;
    for (int i = 0; i <= up; ++i) {
      int cnt = 0;
      for (int j = 0; j < n; ++j) {
        if ((1LL << k) & a[j]) ++cnt;
      }
      if (i) cnt = n - cnt;
      if (best < cnt) {
        best = cnt;
        best_i = i;
      }
    }
    ret += ((int64)best) << k;
    if (tight && best_i != up) tight = false;
    // trace(k, best, best_i, tight);
  }
  printf("%lld\n", ret);
  return 0;
}


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

int main() {
    int n, m, s, c;
    int ans = 0;
    vector<int> a(5, -1);

    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> s >> c;

        if (s == 1 && c == 0 && n != 1) ans = -1;
        
        if (a[s] == -1 || a[s] == c) a[s] = c;
        else ans = -1;
    }

    if (ans == -1) cout << ans << endl;
    else {
        if (a[1] == -1 && n != 1) a[1] = 1;
        for(int i = 1; i <= n; i++) {
            if (a[i] == -1) a[i] = 0;
            cout << a[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); i++)
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ll cnt=0;
  for(ll i=0;i<n;i++){
    ll x = (ll)(lower_bound(a.begin(),a.end(),b[i])-a.begin());
    ll y = (ll)(c.end()-upper_bound(c.begin(),c.end(),b[i]));
    cnt+=x*y;
  }
  cout<<cnt<<endl;


}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const ull mx=1e18;
void solve()
{	
		int n;cin>>n;
		vector< unsigned long long > a(n);
		int f=0;
		for(ull &x:a){
			cin>>x;
			if(!x)
			f=1;
		}
		if(f){
			cout<<0<<'\n';
			return;
		}
		ull ans=1;
		for(ll x:a){
			
			if(ans<=(mx/x))
			ans*=x;
			else{
				cout<<-1<<'\n';
				return;
			}
			
		}
		cout<<ans<<'\n';
}
int main()
{	Fast;
	//int t;cin>>t;
	//while(t--)
	solve();
}

Measured memory_bytes: 3976
import java.util.Scanner;

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

        int K = sc.nextInt();
        int X = sc.nextInt();

        if (K * 500 >= X){
            System.out.println("Yes");     
        }else{
            System.out.println("No");  
         } 
    
}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}

class ModCom {
    public:
        ModCom(int _n, long long _mod){
            assert(_n>=2);
            n = _n+1;
            mod = _mod;
            fac.assign(n,0);
            finv.assign(n,0);
            inv.assign(n,0);
            init();
        }

        long long com(int _n, int k){
            if(_n < k){return 0;}
            if(_n < 0 || k < 0){return 0;}
            return fac.at(_n) * (finv.at(k) * finv.at(_n - k) % mod) % mod;
        }

    private:
        int n;
        long long mod;
        vector<long long> fac;
        vector<long long> finv;
        vector<long long> inv;

        void init(void){
            fac.at(0) = fac.at(1) = 1;
            finv.at(0) = finv.at(1) = 1;
            inv.at(1) = 1;
            for(int i = 2;i < n; i++){
                fac.at(i) = fac.at(i - 1) * i % mod;
                inv.at(i) = mod - inv.at(mod % i) * (mod / i) % mod;
                finv.at(i) = finv.at(i - 1) * inv.at(i) % mod;
            }
            return;
        }
};

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    vector<ll> a(n,0), csum(n+100,0);
    ModCom com(500000, MOD);
    rep(i,n) {
        cin>>a[i];
    }
    if (k==1) {
        cout << 0 << endl;
        return 0;
    }
    sort(begin(a), end(a));
    ll tmp = a[0];
    rep(i,n) {
        a[i] -= tmp;
    }
    ll res = 0;
    ll pls = 0, mns = 0;

    rep(i,n) {
        if (i+k-1<n) {
            DEBUG{
                cout << n-i-1 << " ";
            }
            mns += a[i] * com.com(n-i-1, k-1);
            mns %= MOD;
        }
        if (i-k+1>=0) {
            DEBUG{
                cout <<"ue" << i<< " ";
            }
            pls += a[i] * com.com(i,k-1);
            pls %= MOD;
        }
    }
    res = (pls - mns + MOD) % MOD;
    cout << res << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

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

    int cnt_invalid = 0;
    for(int i = 0; i < N; i++){
        if(p[i] != i){
            cnt_invalid++;
        }
    }

    if(cnt_invalid == 2 || cnt_invalid == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(false);
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时，答案应至多初始化为INT_MIN；求最小值时，答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
*/
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
int n, ans;
int main() {
	n = read();
	vector<int>a(n + 1, 1);
	for (int i = 2; i <= n; ++i)
		for (int j = i; j <= n; j += i) a[j] ++;
	for (int i = 1; i < n; ++i) {
		int t = n - i;
		ans +=  a[t];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7088
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b;
	if (a > b) {
		cout << a - b << "\n";
	}
	else {
		cout << '0' << "\n";
	}
	
	std::cin >> e;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

int m,n,obj[128];

int dp[1<<11][1<<11];
int dfs(int asked,int S){ // asked : すでに質問した特徴, S : 知りたい物体の特徴 ( 判明した bit は 0 or 1, 不明な bit は 0 )
	int cnt=0; // 今わかっている情報と矛盾しない候補の個数
	rep(i,n) if((obj[i]&asked)==(S&asked)) cnt++;
	if(cnt==0) return -INF;
	if(cnt==1) return 0;

	if(dp[asked][S]!=-1) return dp[asked][S];

	int res=INF;
	rep(i,m) if((asked>>i&1)==0) {
		res=min(res,max(dfs(asked|1<<i,S),dfs(asked|1<<i,S|1<<i))+1);
	}
	return dp[asked][S]=res;
}

int main(){
	for(;scanf("%d%d",&m,&n),m;){
		rep(i,n){
			char s[128]; scanf("%s",s);
			obj[i]=0;
			rep(j,m) if(s[j]=='1') obj[i]|=1<<j;
		}
		memset(dp,-1,sizeof dp);
		printf("%d\n",dfs(0,0));
	}
	return 0;
}

Measured memory_bytes: 17424
#include <bits/stdc++.h>
using namespace std;
class UnionFind{
public:
  vector<int> parent;
  UnionFind(int n){
    parent = vector<int>(n,-1);//0からだからきをつけようね
  }
  int root(int x){
    if(parent[x]<0) return x;
    return parent[x]=root(parent[x]);
  }
  //頂点の数
  int size(int x){
    return -parent[root(x)];
  }
  bool connect(int a,int b){
    //root(a)にroot(b)をつける
    a = root(a);b = root(b);
    if(a == b)return false;
    if(size(a) < size(b)) swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
};

int main(){
int n,m;
cin >> n >> m;
vector<int> a(m),b(m);
for (int i=0;i<m;i++){
  cin >> a[i] >> b[i];
  a[i]--;b[i]--;//島は1~N　配列は0~N-1
}
vector<long long>ans(m);
UnionFind Uni(n);
ans[m-1]=(long long)n*(n-1)/2;
for(int i=m-1;i>=1;i--){
  if(Uni.root(a[i])!=Uni.root(b[i])){
    ans[i-1] = ans[i] - (long long)Uni.size(a[i])*Uni.size(b[i]);
    Uni.connect(a[i],b[i]);
  }
  else ans[i-1] = ans[i];
}
for(int i=0;i<m;i++){
  cout << ans[i] << endl;
}
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n, a;
    cin >> n >> a;
    cout << n*n -a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char a;
	scanf("%c",&a);
	if(a>='a'&&a<='z')
	{
		printf("a");	
	}
	else if(a>='A'&&a<='Z')
	{
		printf("A\n");	
	}
	return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    bool ok = false;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '7')  ok = true;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s=="a" || s=="e" || s=="i" || s=="o" || s=="u"){
    cout<<"vowel"<<'\n';
  }
  else{
    cout<<"consonant"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
#define Graph vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
#define inf 1000000321
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};



int main(){
    ll L,R;
    cin >> L >> R;
    ll a,b;
    a = b = 2020;
    if(R-L > 3030){
        cout << 0 << endl;
        return 0;
    }
    else{
        for(ll i = L;i < R;i++){
            for(ll j=i+1;j<=R;j++){
                a = min(a,(i*j)%2019);
            }
        }
        cout << a << endl;
    }

}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;

int par1[100011];
int rank1[100011];
//n要素で初期化
void init(int n){
   for(int i=0;i<n;i++){
       par1[i]=i;
       rank1[i]=0;
   }
}
//木の根を求める
int find(int x){
    if(par1[x] ==x){
         return x;
    }else{
         return par1[x]=find(par1[x]);
    }
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rank1[x]<rank1[y]){
         par1[x]=y;
    }else{
         par1[y]=x;
         rank1[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
     return find(x)==find(y);
}

int A[100005];
int B[100005];
string S;
int M;
int L[100001];
int R[100001];
LL C[100001];
int main(){
    cin>>S;
    A[0]=0;
    REP(i,S.size()){
        A[i+1]=(S[i]-'a');
    }
    A[S.size()+1]=0;
    REP(i,S.size()+1){
        B[i]=A[i+1]-A[i];
    }
    init(S.size()+2);
    {
       int l=0;
       int r=S.size();
       while(l<r){
           unite(l,r);
           l++;
           r--;
       }
    }
    cin>>M;
    REP(i,M){
        cin>>L[i]>>R[i];
        L[i]--;
        unite(L[i],R[i]);
    }
    REP(i,S.size()+1){
        C[i]=26*(LL)(1000000000);
        //C[i]=26;
    }
    REP(i,S.size()+1){
        int p=find(i);
     //   cout<<p<<" ";
        C[p]+=B[i];
    }
   // cout<<endl;
    bool check=true;
    REP(i,S.size()+1){
        if(C[i]%26!=0)check=false;
    }
   /* REP(i,S.size()+2){
        cout<<A[i]<<" ";
    }
    cout<<endl;
    REP(i,S.size()+1){
        cout<<B[i]<<" ";
    }
    cout<<endl;
    REP(i,S.size()+1){
        cout<<C[i]<<" ";
    }
    cout<<endl;
    */
    if(check){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return(0);
}

Measured memory_bytes: 3584
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    
    string s;

    cin >> s;

    for(int i=0;i<s.length();i=i+2){
        cout << s[i];
    }
    cout << endl;
    return 0;
       
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int A, B, C, X; cin >> A >> B >> C >> X;
    int ans = 0;
    rep(i, A+1)rep(j, B+1)rep(k, C+1)if (500 * i + 100 * j + 50 * k == X)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3608
N = int(input()) # 数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

x_0 = 0

for i in range(N):
    if (i % 2) == 0:
        x_0 += List[i]
    else:
        x_0 -= List[i]

result_x = []
result_x.append(x_0)

for j in range(N-1):
    result_x.append(int((List[j] - (result_x[j])/2) *2))

print(*result_x)

Measured memory_bytes: 14092
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = -100; i <= 100; i++) {
			int cost = 0;
			for (int j = 0; j < n; j++) {
				cost += (arr[j] - i) * (arr[j] - i);
			}
			min = Math.min(min, cost);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 21844
L, R = map(int, input().split())

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 総当たり
    ans = 2019
    for X in range(L, R):
        for Y in range(X + 1, R + 1):
            ans = min((ans, (X * Y) % 2019))

    return ans


print(get_ans())

Measured memory_bytes: 3060
import copy
input()
a=[int(i) for i in input().split()]
sa=copy.copy(a)
for i in range(len(a)):
    sa[i]=sa[i]-(i+1)
sa.sort()
msa=sa[int(len(sa)/2)]
sb=0
for i in range(len(a)):
    sb=sb+abs(a[i]-(msa+i+1))
print(sb)

Measured memory_bytes: 27220
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int n, a, b;

int solve(vector<int>& p) {
  sort(p.begin(), p.end());
  int s[4] = {0, a + 1, b + 1, 100};
  vector<int> groups_cnt = {0, 0, 0};
  for (int i = 0; i < p.size(); ++i) {
    int target = p[i];
    for (int k = 0; k < 3; ++k) {
      if (target >= s[k] && target < s[k + 1])
        groups_cnt[k]++;
    }
  }
  return *min_element(groups_cnt.begin(), groups_cnt.end());
}

int main() {
  cin >> n >> a >> b;
  vector<int> p(n);
  REP(i, n) cin >> p[i];
  cout << solve(p) << endl;
}


Measured memory_bytes: 256
#include <iostream>

static const int N = 1000;

void trace(int A[N], int n) {
    int i;
    for ( i = 0; i < n; i++ ){
        if ( i > 0 ) std::cout << " ";
        std::cout << A[i];
    }
    std::cout << std::endl;
}

int main(void) {
    int n;
    int A[N];
    std::cin >> n;
    for (int i=0; i<n; ++i) {
        std::cin >> A[i];
    }
    trace(A, n);

    for (int i=1; i<n; ++i) {
        int key = A[i];
        int j = i-1;
        while(j >= 0 && A[j] > key) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        trace(A, n);
    }
}



Measured memory_bytes: 3044
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.function.IntToDoubleFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        scanner.nextLine();
        List<Double> values = new ArrayList<Double>();
        String[] valueString = scanner.nextLine().split(" ");
        Stream<String> stream = Arrays.stream(valueString);
        values = stream.map(v -> Double.parseDouble(v)).collect(Collectors.toList());
        Collections.sort(values);
        Double ans = values.stream().reduce((val, elm) -> (val + elm)/2).orElse(0.0);
        System.out.println(ans);        
    }
}

Measured memory_bytes: 27092
a = gets.to_i
 
numbers = [a]
value = false
b = a
sum = 1

until value
  if b % 2 == 0
    sum += 1
    b = b / 2
    numbers.each do |number|
      if number == b
        value = true
        puts sum
      end
    end
    numbers.push(b)
  else
    sum += 1
    b = b * 3 + 1
    numbers.each do |number|
      if number == b
        value = true
        puts sum
      end
    end 
    numbers.push(b)
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define p pair<int, int>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<p> v(n);
    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        v[i] = make_pair(x + l, x - l);
    }
    sort(v.begin(), v.end());
    int prev = v[0].first;
    int ans = 1;
    for (int i = 1; i < n; i++) {
        if (v[i].second >= prev) {
            ans++;
            prev = v[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<string> S(N);
    REP(i,0,N) cin >> S[i];

    set<string> words_set;
    multiset<string> words_multiset;
    map<string,ll> words_cnt;

    REP(i,0,N){
        words_set.insert(S[i]);
        words_multiset.insert(S[i]);
    }

    ll cnt, prev_cnt, max_cnt = 0;
    FORR(word,words_set){
        cnt = words_multiset.count(word);
        max_cnt = MAX(cnt,max_cnt);
        words_cnt.insert(make_pair(word,cnt));
    }

    vector<string> maxwords;
    FORR(w,words_cnt) {
        if (w.second == max_cnt) {
            maxwords.pb(w.first);
        }
    }

    sort(ALL(maxwords));
    FORR(w,maxwords) {
        _PR(w);
    }

    return 0;
}

/*



*/

Measured memory_bytes: 48116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
int main(){
    string s;
    cin >> s;
    int length = s.size();
    ll ans = 0;
    ll temp;
    for (int bit = 0; bit < (1<<(length-1)); ++bit){
        temp = s[0] - '0';
        for (int i=0; i<length-1; i++){
            if (bit & (1<<i)) ans += temp, temp = s[i+1] - '0';
            else temp = 10 * temp + s[i+1] - '0';
        }
        ans += temp;
        //cout << bit << " " << ans << endl;
    }
    cout << ans << endl;
}



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

public class Main {
public static char getChar(int i)
{
	if(i==-1)
		return '-';
	else return '+';
}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int []a=new int [4];
		String  s=sc.next();
		for(int i=0;i<4;i++)
			a[i]=s.charAt(i)-'0';
		
		
		int x=0;int y=0;int z=0;
		int []arr={-1,1};
		for( int i:arr)
		{	
			
			for(int j:arr)
				for( int k:arr)
				{
					
					int ans=a[0]+a[1]*i+a[2]*j+a[3]*k;
					if(ans==7)
					{
						x=i;y=j;z=k;
						break;
					}
					
				}
		}	
		System.out.print(a[0]);
		char c1=getChar(x);
		char c2=getChar(y);
		char c3=getChar(z);
		System.out.print(c1+""+a[1]+""+c2+""+a[2]+c3+""+a[3]+"=7\n");
	}
	
	

	
	
	
	
	
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}


	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B,C,D;
  string a,b,c;
  cin >>a>>b;
  if(a[0]+0>b[0]+0)Out(">");
  else if(a==b)Out("=");
  else Out("<");
}

Measured memory_bytes: 256
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

def knapsack(wt,sm,W,n,V):
    K = [float('inf')]*(sm+1)
    K[0] = 0
    for i in range(n):
        for j in range(sm-V[i],-1,-1):
                K[j+V[i]] = min(K[j+V[i]],K[j]+W[i])
    #print(K)
    return max([i for i in range(sm+1) if K[i] <= wt])

n,wt = ip()
V,W = [0]*n,[0]*n
for i in range(n):
    w,v = ip()
    V[i] = v
    W[i] = w
ans = knapsack(wt,sum(V),W,n,V)
print(ans)
    


Measured memory_bytes: 79808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		double min = Double.MAX_VALUE;
		double max = Double.MIN_VALUE;
		while(sc.hasNextDouble()){
			double h = sc.nextDouble();
			if(min>h)min=h;
			if(max<h)max=h;
		}
		System.out.println(max-min);
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b; cin >> a >> b;
  cout << (b >= a? a : a-1) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	ll tans = 0;
	if(n%2){
		rep(ri,2){
			ll ans = 0;
			for(int  i = 0; i <= n/2-2;i++){
				ans += 2 * a[i];
			}
			ans += a[n/2-1];
			ans += a[n/2];
			for(int i = n/2+1; i < n; i++){
				ans -= 2 * a[i];
			}
			reverse(a.begin(), a.end());
			chmax(tans, ans*(ll)pow(-1,ri));
		}
	}else{
		rep(ri, 2){
			ll ans = 0;
			for(int i = 0; i <= n/2-2; i++){
				ans += 2 * a[i];
			}
			ans += a[n/2-1];
			ans -= a[n/2];
			for(int i = n/2+1; i < n; i++){
				ans -= 2 * a[i];
			}
			reverse(a.begin(), a.end());
			chmax(tans, ans * (ll)pow(-1, ri));
		}
		
	}
	cout << tans << endl;
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

struct edge {
	int from, to, cost;
};

edge g[3000];
int d[1050];
int V, E, S;

signed main() {
	cin >> V >> E >> S;
	rep(i, E) {
		cin >> g[i].from >> g[i].to >> g[i].cost;
	}
	fill(d, d + V, inf);
	d[S] = 0;
	for (int i = 0; i < V; i++) {
		bool update = false;
		rep(j, E) {
			edge e = g[j];
			if (d[e.from] != inf && d[e.from] + e.cost < d[e.to]) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update) {
			break;
		}
		if (i == V - 1) {
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}
	rep(i, V) {
		if (d[i] == inf) {
			cout << "INF" << endl;
		}
		else {
			cout << d[i] << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3124
// 5/19
// ANT2-4-3. Union Find Tree, 食物連鎖
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LLP = pair<ll, ll>;
using Graph = vector<vector<int>>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> p(N);
    rep(i, N) {
        cin >> p[i];
        p[i]--;
    }

    vector<int> x(M), y(M);
    rep(i, M) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }

    UnionFind uf(N);

    rep(i, M) {
        uf.unite(x[i], y[i]);
    }
    
    // p[i]のルートと、iのルートが同じものの個数を探す
    int ans = 0;
    rep(i, N) {
        if (uf.same(i, p[i])) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
//C
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
#define MAXN 100000
int n,k,a[MAXN+5];
int minn=INT_MAX,p;
int F,B;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1)p=i;
    }
    if(k==n){printf("1");return 0;}
    for(int i=max(1,p-k+1);i<=p;i++)
    {
        F=ceil((double)(i-1)/(k-1)),B=ceil((double)(n-i-k+1)/(k-1));
        //printf("%d\n",B);
        minn=min(F+B+1,minn);
    }
    printf("%d",minn);
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<pair<int,int> > A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}
	sort(A.rbegin(), A.rend());
	for (int i = 0; i < N; i++) {
		if (A[0].second == i) {
			cout << A[1].first << endl;
		}
		else {
			cout << A[0].first << endl;
		}
	}
}

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

using namespace std;

int main() {
   int a,b,c,d,e;
   cin>>a>>b>>c>>d>>e;
   if(a==0)
   {
       cout<<1<<endl;
   }
   else if(b==0)
   {
       cout<<2<<endl;
   }
   else if(c==0)
   {
       cout<<3<<endl;
   }
   else if(d==0)
   {
       cout<<4<<endl;
   }
  else if(e==0)
   {
       cout<<5<<endl;
   }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<string> A(H);
    rep(i, H) cin >> A[i];
    int cnt = 0;
    int H2 = 1 << H, W2 = 1 << W;
    rep(i, H2) rep(j, W2) {
        int cntblack = 0;
        rep(h, H) rep(w, W) {
            if(A[h][w] == '#' && (((1 << h) & i) == 0) && (((1 << w) & j) == 0)) cntblack++;
        }
        if(cntblack == K) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N, res = 0, mx = 0, cnt;
cin >> N;
vector<int> a(N), d(100001,0);
for (int i = 0; i < N; ++i) cin >> a[i];
for (int i = 0; i < N; ++i) d[a[i]]++;
sort(a.begin(), a.end());
for (int i = max(1, a[0]); i <= a[N - 1] + 1; ++i) {
        cnt = d[i - 1] + d[i] + d[i + 1]; 
        mx = max(mx, cnt);
}    
cout << mx << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
long long int a[2][200000];
int main(){
	long long int n, k, zero = 0, a2, flag;
	cin >> n >> k;
	for(long long int i = 0;i < n;i++){
		cin >> a[0][i];
	}
	for(long long int i = 0;i < k;i++){
		for(long long int j = 0;j < n;j++){
			a[1][j] = 0;
		}
		for(long long int m = 0;m < n;m++){
			a[1][max(m - a[0][m], zero)]++;
			if((n - 1) >= (m + a[0][m] + 1)){
				a[1][m + a[0][m] + 1]--;
			}
		}
		a[0][0] = a[1][0];
		flag = 1;
		if(a[0][0] != n){
			flag = 0;
		}
		for(long long int j = 1;j < n;j++){
			a[0][j] = a[0][j - 1] + a[1][j];
			if(a[0][j] != n){
				flag = 0;
			}
		}
		if(flag == 1){
			for(int j = 0;j < n - 1;j++){
				cout << n << " ";
			}
			cout << n << endl;
			return  0;
		}
	}
	for(int j = 0;j < n - 1;j++){
		cout << a[0][j] << " ";
	}
	cout << a[0][n - 1] << endl;
}

Measured memory_bytes: 6720
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

inline int isPrime(ll n){
  for(ll i = 2; i*i <= n; i++) if(n % i == 0) return 0;
  return 1;
}

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  vi num;
  for(int i = 2; i <= 55555; i++){
    if(isPrime(i)) num.push_back(i);
  }
  int n; cin >> n;
  int cnt = 0;
  for(auto x : num){
    if(x % 5 == 1){
      cout << x << " ";
      cnt++;
    }
    if(cnt == n) break;
  }
  // cout << "\n";
  return 0;
}


Measured memory_bytes: 3624
n = int(input())
L = list(map(int,input().split()))
sunuke = 0
arai = 0
min1 = 10**10
sum1 = sum(L)
for i in range(n-1):
    sunuke += L[i]
    arai = (sum1 - sunuke)
    min1 = min(min1,abs(sunuke-arai))
    #print(sunuke,arai,min1)
print(min1)


Measured memory_bytes: 24800
#include "bits/stdc++.h"
using namespace std;

string s;
int ind=0;
//'['を検知したら開始
int saiki(int a,int b,int c,int d)
{
	int ret=0;
	if(s[0]!='[')
	{
		switch(s[0])
		{
			case 'a':
			return a;
			case 'b':
			return b;
			case 'c':
			return c;
			case 'd':
			return d;
		}
	}
	ind++;
	//cerr<<ind<<" "<<s[ind]<<endl;
	int op;//+...0 ^...1 *...2
	//operatorの検出
	if(s[ind]=='+')
		op=0;
	else if(s[ind]=='^')
		op=1;
	else
		op=2;
	ind++;
	//数字の検出
	int num[2];
	for(int i=0;i<2;i++)
	{
		if(s[ind]=='[')
			num[i]=saiki(a,b,c,d);
		else{
			switch(s[ind])
			{
				case 'a':
				num[i]=a;
				break;
				case 'b':
				num[i]=b;
				break;
				case 'c':
				num[i]=c;
				break;
				case 'd':
				num[i]=d;
			}
			ind++;
		}
	}
	if(op==0)
		ret=(num[0]|num[1]);
	else if(op==1)
		ret=(num[0]^num[1]);
	else
		ret=(num[0]&num[1]);
	ind++;
	return ret;
}

int main()
{
	while(1)
	{
		cin>>s;
		if(s[0]=='.')
			break;
		string p;
		cin>>p;
		ind=0;
		int hash=saiki(p[0]-'0',p[1]-'0',p[2]-'0',p[3]-'0');
		int ans=0;
		cout<<hash<<" ";
		for(int a=0;a<10;a++)
		{
			for(int b=0;b<10;b++)
			{
				for(int c=0;c<10;c++)
				{
					for(int d=0;d<10;d++)
					{
						ind=0;
						int tmp=saiki(a,b,c,d);
						if(tmp==hash)
							ans++;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
	int A, B, K;
	cin >> A >> B >> K;

	std::set<int> int_array;
	for (int i = A; i < A + K; i++) {
		if (i <= B) {
			int_array.insert(i);
		}
	}
	for (int j = B; j > B - K; j--) {
		if (j >= A) {
			int_array.insert(j);
		}
	}

	for (auto l: int_array) {
		cout << l << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>

using namespace std;
const int64_t INF=1e10;

int main(){
	int64_t n,k;
	cin>>n>>k;
	int64_t min_n = n;
	int64_t temp = abs(n-k);
	if(temp%k<min_n){
		min_n = temp%k;
	}
	if(k-(temp%k)<min_n){
		min_n = k-(temp%k);
	}
	cout<<min_n<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC084B
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var s = Console.ReadLine();

            string sa = s.Substring(0, AB[0]);
            string sb = s.Substring(AB[0] + 1);
            bool ans = true;
            if (s.Count() != AB.Sum() + 1)
            {
                ans = false;
            }
            if (s[AB[0]] != '-')
            {
                ans = false;
            }
            foreach (char c in sa)
            {
                if (!char.IsNumber(c)) ans = false;
            }
            foreach (char c in sb)
            {
                if (!char.IsNumber(c)) ans = false;
            }

            if (ans == true) Console.WriteLine("Yes");
            else Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13396
//created by pyoxiao on 2020/05/02
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
int k, a, b;
void solve() {
    scanf("%d %d %d", &k, &a, &b);
    for(int i = a; i <= b; i ++) {
        if(i % k == 0) {
            puts("OK");
            return;
        }
    }
    puts("NG");
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 998244353;

struct mint {
    lint v;
    lint _mod;
    mint() : v(0) {}
    mint(signed v, lint _mod = mod) : v(v), _mod(_mod) {}
    mint(lint t, lint _mod = mod) : _mod(_mod) {
        v = t % _mod;
        if (v < 0)
            v += _mod;
    }

    mint pow(lint k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }
    mint inv() { return pow(_mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += _mod - a.v;
        if (v >= _mod)
            v -= _mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = v * a.v % _mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(_mod - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
ostream &operator<<(ostream &os, mint m) { return os << m.v; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, s;
    cin >> n >> s;
    vector<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<vector<mint>> dp(n + 1, vector<mint>(s + 1, 0));
    for (int i = 0; i <= n; ++i) {
        dp[i][0] = 1;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= s; ++j) {
            dp[i + 1][j] += dp[i][j];
            if (j + a[i] <= s)
                dp[i + 1][j + a[i]] += dp[i][j];
        }
    }
    mint ret = 0;
    for (int i = 1; i <= n; ++i) {
        ret += dp[i][s];
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 141184
n = int(input())
a = list(map(int,input().split()))
dp = [0,abs(a[1]-a[0])]
for i in range(2,n):
    dp.append(min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2])))
print(dp[-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
typedef		vector<int>				 vi;
typedef 	vector<vi>				vii;
typedef		pair<int,int>			pii;
typedef		unsigned long long		ull;
typedef		long long				ll ;
#define MOD (int)(1e9+7)
#define INF (int)(1<<29) 
#define fori(i,a,b)		for(int i=a ; i <= b ; i++) 			
#define ford(i,a,b)  	for(int i=a ; i >= b ; i-- ) 
#define rep(i,n)   		for(int i=0; i < n ; i++ ) 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;

int findnum ( int j ) 
{
	int ret = 0 ;
	while ( j != 0 ) 
	{
		if (( j & 1) == 0 ) 
		{
			++ret ; 
		}
		else 
			break ; 
		j >>= 1 ; 
	}
	return ret ; 
}

void calc ( int n ) 
{
	int ans = 1 , powe = 0 ;
	int curr = 0 ;
	for(int i = 1 ; i <= n ; ++i ) 
	{
		curr = findnum(i) ;
		//cout << i << " " << curr << endl  ;
		if ( curr > powe ) 
		{
			ans = i ; 
			powe = curr ;
		}

	}
	cout << ans << endl ; 
}

int main()
{
	ios_base::sync_with_stdio(0);	
	int n ;
	cin >> n ;
	calc ( n ) ;
	return 0 ;
}



Measured memory_bytes: 256
/*************************************************************************
    > File Name: C.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com 
    > Created Time: 2018-05-26 20:02:39
 ************************************************************************/

#include<bits/stdc++.h>
#define MAXN 300005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,sum1[MAXN],sum2[MAXN];
string str;
int main()
{
    scanf("%d",&n);
    cin>>str;
    for(int i=0;i<n;i++)
        sum1[i+1]=str[i]=='W'?sum1[i]+1:sum1[i];
    for(int i=n;i>=1;i--)
        sum2[i]=str[i-1]=='E'?sum2[i+1]+1:sum2[i+1];
    int ans=INF;
    for(int i=1;i<=n;i++)
        ans=min(ans,sum1[i-1]+sum2[i+1]);
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 2948
N,*A=map(int, open(0).read().split())
A.sort()
m,M=A[0],A[-1]
B=A[1:-1]
ans=[]
for b in B:
    if b>=0:
        ans.append((m,b))
        m-=b
    else:
        ans.append((M,b))
        M-=b
ans.append((M,m))
print(M-m)
for x,y in ans:
    print(x,y)

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    ll cnt = 0,ans = 0,tmp = h[0];
    REP(i,1,n){
        if(tmp>=h[i]){
            cnt++;
            ans = max(ans,cnt);
        }
        else cnt = 0;
        tmp = h[i];
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
    ll n; cin>>n;
    vector<ll> a(n),num(n+1);
    rep(i, n) {
        cin>>a[i];
        num[a[i]]++;
    }
    ll sum = 0;
    rep1(i,n){
        if(num[i]>1)  sum += num[i]*(num[i]-1)/2;
    }
    rep(i,n){
        ll now = sum;
        if(num[a[i]]>1) now -= num[a[i]]-1;
        cout<<now<<endl;
    }
}

Measured memory_bytes: 5760
X, K, D = map(int,input().split())

ans = 0
ref = abs(X) // D

if ref >= K:
    ans = abs(X) - K * D
else:
    ans = abs(X) - ref * D
    K = K - ref
    if K % 2 == 1:
        ans = abs(ans - D)
    else:
        pass

print(ans)

Measured memory_bytes: 9180