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

void fst()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int nxt()
{
    int x;
    cin >> x;
    return x;
}
int nex_l()
{
    long long x;
    cin >> x;
    return x;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define binary(n) cout << bitset<31>(n) << "\n";
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cin >> a[i];
#define print_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cout << a[i] << " ";
#define deb(n) cerr << #n << "=" << n << "\n";

int main()
{
    ll n;
    cin>>n;
    vl a(n);
    ll xr=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        xr^=a[i];
    }
    for(int i=0;i<n;i++){
        cout<<(xr^a[i])<<" ";
    }
    
}


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
using namespace std;


int main() {
	int N;
	int Y = 0;
	cin >> N;
	pair<int, int> ab[101];
	pair<int, int> cd[101];



	for (int i = 0; i < N; i++) {
		cin >> ab[i].first >> ab[i].second;
	}
	for (int i = 0; i < N; i++) {
		cin >> cd[i].first >> cd[i].second;
	}

	sort(ab, ab + N);
	sort(cd, cd + N);

	for (int i = 0; i<N; i++) {
		int R = -1;
		int W = -1;
		
		for (int k = N - 1; k >= 0; k--) {
			
			if (cd[i].first > ab[k].first&&cd[i].second > ab[k].second) {
				
				if (R<ab[k].second) {
					R = ab[k].second;
					W = k;
					
				}
			}
		}
		if (W >= 0) {
			ab[W].second = 100000;
			Y++;
		
		}
	
	}



	cout << Y << endl;

	return 0;
}



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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int main(){
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	cout<<max(a,b)+max(max(a,b)-1,min(a,b));	
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by zzt on 17-1-22.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        ArrayList<Integer>[] graph = new ArrayList[N];
        for (int i = 0; i < N; i++) {
            graph[i] = new ArrayList<>();
        }
        for (int i = 1; i < N; i++) {
            int a = scanner.nextInt() - 1;
            graph[a].add(i);
        }
        System.out.println(dfs(0, graph) - 1);
    }
    private static int dfs(int v, ArrayList<Integer>[] graph) {
        if (graph[v].isEmpty()) {
            return 1;
        }
        int[] tmp = new int[graph[v].size()];
        for (int i = 0; i < tmp.length; i++) {
            int u = graph[v].get(i);
            tmp[i] = dfs(u, graph);
        }

        Arrays.sort(tmp);
        int max = 0;
        for (int t :
                tmp) {
            if (t <= max)
                max++;
            else max = t;
        }
        max++;
        return max;
    }
}

Measured memory_bytes: 71792
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  int Ans = max(A+B,max(A-B,A*B));
  printf("%d\n",Ans );
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

  string s,t;
  int k;
  cin >> s >> k;

  t = s+s+s+s;

  int l = s.size();


  FOR(i,1,l*4){
    if(t[i] == t[i-1]){
      t[i] = '.';
    }
  }

  ll c[5] = {};
  FOR(i,l*0,l*1) c[0] += t[i]=='.';
  FOR(i,l*1,l*2) c[1] += t[i]=='.';
  FOR(i,l*2,l*3) c[2] += t[i]=='.';
  FOR(i,l*3,l*4) c[3] += t[i]=='.';

  ll ans = c[0];
  k--;

  if(k%2){
    k/=2;
    ans += c[1]*(k+1) + c[2]*k;
  }else{
    k/=2;
    ans += c[1] * k + c[2]*k;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
  long long int n,a,b,set=0,ans=0;
  scanf("%lld%lld%lld",&n,&a,&b);
  if(n>=a+b){
    set=n/(a+b);
  }
  n=n-(a+b)*set;
  
  if(a>=n){
    ans=n+a*set;
    printf("%lld",ans);
    return 0;
  }
  else{
    ans=a+a*set;
    printf("%lld",ans);
    return 0;
  }
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
#define LL long long
const int MAX = 1e6 + 10;
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int l, r, d;
    cin >> l >> r >> d;
    cout << r / d - (l - 1) / d << endl;
    return 0;
}


Measured memory_bytes: 3088
////////////////////////////////////////////    _LeMur_
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 1000 * 1000 + 5;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 + 3;

int q;
int f[N];

int binpow(int a,int b){
    if(b == 0)return 1;
    if(b % 2)return a * 1ll * binpow(a , b - 1) % mod;
    int t = binpow(a , b / 2);
    return t * 1ll * t % mod;
}

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
	f[0] = 1;
	for(int i=1;i<=mod;i++){
        f[i] = f[i - 1] * 1ll * i % mod;
	}
    cin >> q;
    while(q--){
        int x , d , n;
        scanf("%d%d%d",&x,&d,&n);
        if(d == 0){
            printf("%d\n",binpow(x , n));
            continue;
        }
        int pat = binpow(d , n - 1) * 1ll * x % mod;
        int st = x * 1ll * binpow(d , mod - 2) % mod;
        if(n > 1){
            if(n >= mod){
                printf("0\n");
                continue;
            }
            int l = (st + 1) % mod;
            int r = (st + n - 1) % mod;
            if(l == 0 || r < l){
                printf("0\n");
                continue;
            }
            int S = f[r];
            if(l) S = S * 1ll * binpow(f[l - 1] , mod - 2) % mod;
            pat = pat * 1ll * S % mod;
        }
        printf("%d\n",pat);
    }
	return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int ans=0;
  int cur=1;
  rep(i,n){
    if(a[i]!=cur)ans++;
    else{
      cur++;
    }
  }
  if(ans==n)ans=-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX (ll)(8e1 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main () {
	int x, n;
	cin >> x >> n;
	set<int> se;
	for (int i = 0; i < n; i++) {
		int v;
		cin >> v;
		se.insert (v);
	}
	int ma = MOD, in;
	for (int i = x - n; i <= x + n; i++) {
		if (se.count (i) == 0) {
			if (abs (i - x) < ma) {
				ma = min (ma, abs (i - x));
				in = i;
			}
		}
	}
	cout << in << "\n";
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;
ll a, b, n;
ll cal(ll x) {
    return a * x / b - a * (x/b);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //ll a, b, n;
    cin >> a >> b >> n;
    ll tar1 = n;
    ll tar2 = n / b * b + b - 1;
    while(tar2 > n) {
        tar2 -= b;
    }
    cout << max(cal(tar1),cal(tar2)) << '\n';
}

Measured memory_bytes: 3600
F = range(2, 55556)
primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239]
N = int(raw_input())
i = 1
oks = []
while len(oks) < N:
  p = i*10+1
  j = 0
  isPrime = True
  while primes[j]*primes[j] <= p:
    if p % primes[j]==0:
      isPrime = False
      break
    j += 1
  if isPrime:
    oks.append(p)
  i += 1
ans = str(oks[0])
for a in  oks[1:]:
  ans += ' {}'.format(a)
print ans


Measured memory_bytes: 4356
import sys
input = lambda : sys.stdin.readline().rstrip()

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f = sorted(f, reverse=True)
cost = []
for i in range(n):
    cost.append(a[i]*f[i])
left = -1
right = max(cost)
def solve(x):
    cnt = 0
    for i in range(n):
        d = cost[i] - x
        if d <= 0:
            continue
        cnt += d//f[i] + int(d % f[i] != 0)
    if cnt <= k:
        return True
    else:
        return False
while right - left > 1:
    mid = (right + left) // 2
    if solve(mid):
        right = mid
    else:
        left = mid
print(right)

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

int main() {
  int X;
  int Y;
  cin >> X >> Y;
  int t;
  int k;
  for (int i = 0; i <= X; i++) {
    t = i;
    k = X - i;
    if (Y == t * 2 + k * 4) {
      cout << "Yes" << endl;
      break;
    }
    if (i == X) {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        for(int i =n;;i++){
            boolean flag = true;
            for(int j=2;j*j<=i;j++){
                if(i%j==0){
                    flag = false;
                    break;
                }
            }
            if(flag) {
                System.out.println(i);
                break;
            }
        }
    }
}




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: 25384
n,l = map(int,input().split())
sum = 0
flag = True
for i in range(l,l+n):
    sum += i
    if i == 0:
        flag = False
if flag:
    if sum > 0:
        print(sum-l)
    else:
        print(sum-l-n+1)
else:
    print(sum)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define nax 100000
int main(){
	int F[nax];
	int v[nax];
	int n; 
	scanf("%i",&n);
	for(int i = 0  ; i <n ; i++){
		scanf("%i",&v[i]);
	}
	F[0] = 0;
	F[1] = abs(v[1] - v[0]);
	for(int i=2;i<n;i++){
		F[i] = min(F[i-1] + abs(v[i] - v[i-1]), F[i-2] + abs(v[i] - v[i-2]));
	}

	printf("%i",F[n-1]);

}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll mod = 1e9+7;

int main(void){
  int m1,d1,m2,d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  cout << (m1 < m2 ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    long double a,b,x,temp;
    cin>>a>>b>>x;
    temp=a*a*b;
    if(x<=temp/2){
        double flag=(2.0)*x/sqrt(a*a*b*b*b*b+(4.0)*x*x);
        double val=asin(flag)*180/3.14159265;
        cout<<fixed<<setprecision(10)<<90-val<<endl;
    }
    else{
        double flag=a/((2.0)*(b-x/(a*a)));
        double val=atan(flag)*180/3.14159265;
        cout<<fixed<<setprecision(10)<<90-val<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
mod = 10**9 + 7
ans = (2 ** (n // 2)) % mod
b = []
for i in range(n):
  b += [abs(n+1-2*(i+1))]
b.sort()

if a == b :
  print(ans)
else:
  print(0)



Measured memory_bytes: 13880
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	int n, d;
	cin >> n >> d;

	int t = 2*d+1;
	int sum = n/t;
	if(n % t) ++sum;
	cout << sum;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize(7)
using namespace std;
int n,m,v,p,cnt,a[100010];
signed main() 
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>v>>p; 
	for (int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	if (v<=p)
	{
		for (int i=1;i<=n;i++) if (a[i]+m>=a[n-p+1]) cnt++;
		cout<<cnt<<endl;
	} 
	else
	{
		for (int i=1;i<=n;i++) 
		{
			int j=n-i+1; 
			if (j<=p) 
			{
				cout<<n-i+1<<endl;
				break;
			}
			if (i+p-1>=v&&a[i]+m>=a[n-p+1]) 
			{
				cout<<n-i+1<<endl;
				break;
			}
			int tmp=v*m-(i+p-1)*m,temp=0;
			for (int k=i+1;a[k]<a[i]+m,k<=n-p+1;k++) temp+=a[i]+m-a[k];
			if (temp>=tmp && a[i]+m>=a[n-p+1])
			{
				cout<<n-i+1<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4412
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<climits>
#include<map>
using namespace std;

long long int max(long long int a,long long int b)
{
    if(a>=b)
    {
        return a;
    }
    else
    {
        return b;
    }
}

int main()
{
    long long int n;
    cin>>n;
    long long int arr[3][n+1];
    arr[0][0] = 0;
    arr[1][0] = 0;
    arr[2][0] = 0;
    for(long long int i=1;i<(n+1);i++)
    {
        long long int a,b,c;
        cin>>a>>b>>c;
        arr[0][i] = (max(arr[1][i-1],arr[2][i-1]) + a);
        arr[1][i] = (max(arr[0][i-1],arr[2][i-1]) + b);
        arr[2][i] = (max(arr[0][i-1],arr[1][i-1]) + c);
    }
    vector<long long int> v;
    v.push_back(arr[0][n]);
    v.push_back(arr[1][n]);
    v.push_back(arr[2][n]);
    sort(v.begin(),v.end());
    cout<<v[2]<<endl;
}




Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

int n;
char s[128], t[128];

int main()
{
	int ans;
	int i, j;

	scanf("%d", &n);
	scanf("%s %s", s, t);

	ans = n;

	for (i = 0; i < n; i++) {
		j = 0;

		while (i + j < n && s[i + j] == t[j]) {
			j++;
		}

		if (i + j == n) {
			break;
		}

		ans++;
	}

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

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();


int main(){
  int  n,m; cin>>n>>m;
  map<int,string> mp;
  
  REP(i,m){
    int p; string s;
    cin>>p>>s;
    
    if(s=="AC") mp[p]+='1';
    else mp[p]+='0';
    //cout<<p<<" "<<mp[p]<<endl;
  }
  int res=0,pen=0;

  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    string s=itr->second;
    //cout<<s.length()<<endl;
    int sum=0;
    REP(i,s.length()){     
      if(s[i]=='1'){
        pen+=sum;
        res++;
        break;
      }else sum++; 
      
    }
    }

  cout<<res<<' '<<pen<<endl;
  
  }



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

using namespace std;

int len,ans;
char s[110];

int main()
{
	scanf("%s",s+1);
	for(int i=1;i<=100;i++) {
		if(s[i]>='a'&&s[i]<='z') {
			len++;
		}
	}
	if(len&1) { //len%2
		for(int i=1;i<=(len-1)>>1;i++) {
			if(s[i]!=s[len-i+1]) {
				ans++;
				//printf("%d %d\n",i,len-i+1);
			}
		}
	}
	else {
		for(int i=1;i<=len>>1;i++) {
			if(s[i]!=s[len-i+1]) {
				ans++;
				//printf("%d %d\n",i,len-i+1);
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;


int main(){
	set<char> b;
	b.insert('a');
	b.insert('i');
	b.insert('u');
	b.insert('e');
	b.insert('o');
	while(1){
		int  n = in.nextInt();
		if(n == 0) break;
		vector<string> s(n);
		rep(i, n) s[i] = in.next();
		vector<string> v(n);
		rep(i, n){
			v[i] += s[i][0];
			for(int j = 1; j < s[i].size(); j++){
				if(b.count(s[i][j-1])) v[i] += s[i][j];
			}
		}
		int l = 0, r = 51;
		for(int i = 0; i < 10; i++){
			int m = (l + r) / 2;
			set<string> st;
			for(int j = 0; j < n; j++){
				if(v[j].size() < m) st.insert(v[j]);
				else st.insert(v[j].substr(0, m));
			}
			if(st.size() == n) r = m;
			else l = m;
			//cout<<" "<<st.size() <<" "<< l << " " << r<<endl;
		}
		cout<<(r == 51 ? -1 : r)<<endl;
	}
}

Measured memory_bytes: 3180
#include<stdio.h>
#define N 100000

int A[N];
int partition(int p,int r){
int x,i,j,change;
x=A[r-1];
i=p-1;//pは0を渡す、i=0での入れ替え用
for(j=p;j<r-1;j++){
  if(A[j]<=x){
    i++;
    change=A[i];
    A[i]=A[j];
    A[j]=change;
  }
}
change=A[i+1];//基準はi+1の位置に動く
A[i+1]=A[r-1];
A[r-1]=change;
return i+1;
}

int main(){
int i,p,n;
scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%d",&A[i]);
}
p=partition(0,n);
for(i=0;i<n;i++){
  if(i==p){
    printf("[%d] ",A[i]);
  }
  else if(i==(n-1)) printf("%d",A[i]);
  else printf("%d ",A[i]);
}
printf("\n");




  return 0;
}



Measured memory_bytes: 2156
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	ll n, a, b, prv, ans = 0, x;
	cin >> n >> a >> b >> prv;
	lp(i,2,n)
	{
		cin >> x;
		ans += min((x - prv) * a, b);
		prv = x;
	}
	f(ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int nx = sx, ny = sy;
  while(ny < ty){
    cout << "U";
    ny++;
  }
  while(nx < tx){
    cout << "R";
    nx++;
  }
  while(ny > sy){
    cout << "D";
    ny--;
  }
  while(nx > sx){
    cout << "L";
    nx--;
  }
  cout << "L";
  nx--;
  while(ny < ty+1){
    cout << "U";
    ny++;
  }
  while(nx < tx){
    cout << "R";
    nx++;
  }
  cout << "D";
  ny--;
  cout << "R";
  nx++;
  while(ny > sy-1){
    cout << "D";
    ny--;
  }
  while(nx > sx){
    cout << "L";
    nx--;
  }
  cout << "U" << endl;
  return 0;
}



Measured memory_bytes: 256
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s,t;
    cin >> s >> t;
    map<string, int> cnt;
    int a, b;
    cin >> a >> b;
    cnt[s] = a;
    cnt[t] = b;
    
    string u;
    cin >> u;
    cnt[u]--;
    cout << cnt[s] << ' ' << cnt[t] << "\n";
    
    return 0;
}


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

vector<int> dx = {1, 0, -1, 0, 1, 1, -1, -1}, dy = {0, 1, 0, -1, 1, -1, 1, -1};

void bfs(int i, int j, int h, int w, vector<vector<int>> &c) {
  queue<pair<int, int>> q;
  q.push(make_pair(i, j));
  c.at(i).at(j) = 0;
  
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    for (int i = 0; i < 8; i++) {
      if (p.first + dx[i] >= 0 && p.first + dx[i] < h
       && p.second + dy[i] >= 0 && p.second + dy[i] < w) {
        if (c.at(p.first + dx[i]).at(p.second + dy[i]) == 1) {
          c.at(p.first + dx[i]).at(p.second + dy[i]) = 0;
          q.push(make_pair(p.first + dx[i], p.second + dy[i]));
        }
      }
    }
  }
  
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int w, h;
    cin >> w >> h;
    if (w + h == 0) break;
    
    vector<vector<int>> c(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> c.at(i).at(j);
      }
    }
    
    int ans = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (c.at(i).at(j) == 1) {
          bfs(i, j, h, w, c);
          ans++;
        }
      }
    }
    
    cout << ans << '\n';
  }
}


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

int main(){
  int n;
  int x;
  stack<int> a;

  cin>>n;

  for(int i=0; i<n; i++){
    cin>>x;
    a.push(x);
  }

  for(int i=0; i<n; i++){
    if(i==n-1){
      cout<<a.top()<<endl;
    }else{
      cout<<a.top()<<" ";
      a.pop();
    }
  }

  return 0;

}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  int* dp = new int[n];
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  dp[2]=min(dp[1]+abs(arr[2]-arr[1]),dp[0]+abs(arr[2]-arr[0]));
  for(int i=3;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

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

int m, n, res;
int blue[510], red, match[510];
bool used[510];
vector<int> g[510];

int gcd(int x, int y)
{
	int t;
	if(x < y) swap(x, y);
	while(y)
		t = x % y, x = y, y = t;
	return x;
}

bool dfs(int v)
{
	for(int i = 0; i < g[v].size(); ++i)
	{
		int t = g[v][i];
		if(used[t]) continue;
		used[t] = true;
		if(match[t] == -1 || dfs(match[t]))
		{
			match[t] = v;
			return true;
		}
	}
	return false;
}

int main()
{
	while(cin >> m >> n && m)
	{
		for(int i = 0; i < m; ++i)
			cin >> blue[i], g[i].clear();
		for(int i = 0; i < n; ++i)
		{
			cin >> red;
			for(int j = 0; j < m; ++j)
				if(gcd(blue[j], red) > 1)
					g[j].push_back(i);
		}
		res = 0;
		fill_n(match, n, -1);
		for(int i = 0; i < m; ++i)
		{
			fill_n(used, n, false);
			if(dfs(i)) ++res;
		}
		cout << res << endl;
	}
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
int n;
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    cout << 800 * n - (n/15)*200 << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define INF 10000000000
#define M 1000000007
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

#define B 310

int main() {
	long N, L, Q;
	long x[100001];
	long i, j, k;
	long a, b, tmp;
	long move1day[100001];
	long moveBday[100001] = {0};
	long right;
	long ans[100001] = {0};
	
	scanf("%ld", &N);
	for(i=1;i<=N;i++) scanf("%ld", &x[i]);
	scanf("%ld", &L);
	
	right = 2;
	for(i=1;i<=N;i++) {
		for(j=right;j<=N;j++) {
			if(x[j] - x[i] > L) {
				j--;
				break;
			}
		}
		move1day[i] = j;
		right = j;
	}
	
	for(i=1;i<=N;i++) {
		k = i;
		for(j=0;j<B;j++) {
			if(k >= N) break;
			k = move1day[k];
		}
		if(j == B) moveBday[i] = k;
	}
	
	scanf("%ld", &Q);
	for(i=1;i<=Q;i++) {
		scanf("%ld %ld", &a, &b);
		
		if(a > b) { tmp = a; a = b; b = tmp; }
		
		j = a;
		while(moveBday[j] > 0 && moveBday[j] < b) {
			j = moveBday[j];
			ans[i] += B;
		}
		
		while(j < b) {
			j = move1day[j];
			ans[i]++;
		}
	}
	
	for(i=1;i<=Q;i++) printf("%ld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3968
#ifdef __GNUG__
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <functional>
#endif

//#pragma optimize GCC("O3")
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	int r = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'R')
		{
			r++;
			ans = max(ans, r);
		}
		else
			r = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define EQ(x, y) (abs(x - y) < 1e-9)
typedef long long ll;

int v[50];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	sort(v, v + n);
	
	double ans = v[0];
	for (int i = 0; i < n - 1; ++i){
		ans = (ans + v[i + 1]) / 2;
	}
	cout << ans << '\n';

#ifdef local
	cout << setprecision(3) << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n)
    cin >> a[i];

  vector<ll> s(n+1);
  map<ll, ll> c;
  rep(i,n)
    s[i+1] = s[i] + a[i];
  rep(i,n+1)
    c[s[i]]++;
  
  ll ans = 0;
  for(auto itr : c){
    ll num = itr.second;
    ans += num * (num-1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vecl A(N); REP(i,N) cin >> A[i];
    ll ans = 0;
    sort(A.begin(),A.end(),greater<ll>());
    ans += A[0];
    int cnt = 0;
    if(N == 2) {
        cout << ans << endl;
        return 0;
    }
    REP(i,N) {
        if(i == 0) continue;
        else {
            ans += A[i];
            cnt++;
            if(cnt == N-2) break;
            ans += A[i];
            cnt++;
            if(cnt == N-2) break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
        Map<String, Integer> map = new TreeMap<String, Integer>();
        for (int i = 0 ; i < n ; i++) {
            if (map.containsKey(s[i])) {
                map.put(s[i], map.get(s[i]) + 1);
            } else {
                map.put(s[i], 1);
            }
        }

        int min = 0;
        for (Entry<String, Integer> entry : map.entrySet() ) {
            min = Math.max(min, entry.getValue());
        }

        List<String> list = new ArrayList<String>();
        for (Entry<String, Integer> entry : map.entrySet() ) {
            if (entry.getValue() == min) {
                list.add(entry.getKey());
            }
        }

        Collections.sort(list);
        for (int i = 0 ; i < list.size() ; i++) {
            System.out.println(list.get(i));
        }


    }

}

Measured memory_bytes: 78292
#include<bits/stdc++.h>
using namespace std;
int ans,n,a[10000];
int main(){
cin>>n;
for(int k=1;k<=n;k++)
    cin>>a[k];
for(int k=1;k<=n;k++){
   for(int i=k+1;i<=n;i++)
       ans+=(a[k]*a[i]);

}
cout<<ans;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 100000000000000000
#define UB upper_bound
#define LB lower_bound
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
/////number of edges in a graph equal (v[i].size() ka summation of all the vertices)//
int main()
{
    fast;
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif	
    ll int n,k;
    cin>>n>>k;
    ll int z,i,ans;
    z=n/k;
    n=n-z*k;
    ans=n;
    for(i=1;i<=1000000;i++)
    {
    	n=abs(n-k);
    	ans=min(ans,n);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
edge_out = [[] for i in range(N)] #edge_out[i]はiから出ている道
edge_in = [[] for i in range(N + 1)] # edge_in[i]はiに行く道
for i in range(M):
    s, t = map(int, input().split())
    edge_out[s].append(t)
    edge_in[t].append(s)

edge_sum = [len(edge_out[i]) for i in range(N)] # edge_sum[i] = iから出ている道の本数

dp = [0.0]*(N + 1) # dp[i]はiからNへの距離の期待値
dp[N - 1] = 1.0
# 道を塞がない場合
for i in range(N - 2, 0, - 1):
    dp[i] = 1 + sum(dp[j] for j in edge_out[i])/edge_sum[i]
    
p_to_i = [0]*(N + 1) # p_to_i[i]は1から各iへ到達する確率
p_to_i[1] = 1
for i in range(2, N + 1):
    p_to_i[i] = sum(p_to_i[j]/edge_sum[j] for j in edge_in[i])


t = 0

for i in range(1, N - 1):
    if edge_sum[i] == 1:
        continue
        # iから出ている道の先にある部屋のうち、その部屋からNまでの距離の期待値が最も大きいものへ通ずる道を塞ぐ
    t = max(t, p_to_i[i]*(dp[i] - 1- ((dp[i] - 1)*edge_sum[i] - max(dp[j] for j in edge_out[i]))/(edge_sum[i] - 1)))
    
print(dp[1] - t)

Measured memory_bytes: 12960
import java.util.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
//    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt(),k=sc.nextInt();
        boolean dp[]=new boolean[k+1];
        int a[]=new int[n];
        for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
			dp[a[i]]=true;
		}
        
        sort(a);
                
        for (int i = a[0]+1; i <= k; i++) {
			for (int j = 0; j < a.length; j++) {
				if(i-a[j]<0)break;
				dp[i]|=!dp[i-a[j]];
			}
		}

        out.println(dp[k]?"First":"Second");
        out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    ll n,m,k,a,b,x,y,q;
    ll sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>k;

    ll bi = 1;
    ll base = 1;
    for(;base<k;base<<=1);

    for(int i=1;i<=n;i++){
        bi = 1;
        for(;bi*i<k;bi<<=1);
        bi = base/bi;
        sum+=(ll)bi;
    }

    long double res = (long double)sum;
    res/=(long double)(base*n);

    cout<<fixed;
    cout.precision(15);
    cout<<res<<"\n";


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
typedef long long ll;
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll ans[1000];
    for(int i=0;i<n;i++)
    {
    	cin>>ans[i];
	}
    ll sum=0;
    for(int i=0;i<n;i++)
    sum+=ans[i];
    double t=1.0*sum/n;
    //cout<<t<<endl;
    //ll p=ll(t);
    ll p=t*10;
    p%=10;
    ll q;
    if(p<=4)
    q=sum/n;
    else
    q=sum/n+1;
   // cout<<q<<endl;
    sum=0;
    for(int i=0;i<n;i++)
    {
    	sum+=(ans[i]-q)*(ans[i]-q);
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {
  val input = readLine().split(" ").map(_.toInt)
  val k = input(0)
  val x = input(1)

  val bottom = x - (k - 1)
  val top = x + (k - 1)

  val ls = (bottom to top).toList

  var ans = ""
  for (e <- ls) yield ans += e + " "

  println(ans.trim)
}

Measured memory_bytes: 25540
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
            int[] c = new int[3];
            for(int i = 0;i < 3;i++){
            	c[i] = scan.nextInt();
            }
            if(c[0] == 0 && c[1] == 0 && c[2] == 0){
            	break;
            }
            Arrays.sort(c);
            double a = (double)c[1] * 0.5;
            double b = (double)c[0] * 0.5;
            int n = scan.nextInt();
            for(int i = 0;i < n;i++){
            	double r = (double)scan.nextInt();
            	if(r <= a){
            		System.out.println("NA");
            		continue;
            	}
            	if(b < Math.sqrt(r*r - a*a)){
            		System.out.println("OK");
            	}else{
            		System.out.println("NA");
            	}
            }
        }
    }
}

Measured memory_bytes: 17204
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val t = (1..3).map { (1..3).map { sc.nextInt() }.toMutableList() }
    val n = sc.nextInt()
    val s = (1..n).map { sc.nextInt() }
    for (i in 0..2) {
        for (j in 0..2) {
            if (s.contains(t[i][j])) {
                t[i][j] = 0
            }
        }
    }
    if (t[0][0] == 0 && t[0][1] == 0 && t[0][2] == 0 ||
        t[1][0] == 0 && t[1][1] == 0 && t[1][2] == 0 ||
        t[2][0] == 0 && t[2][1] == 0 && t[2][2] == 0 ||
        t[0][0] == 0 && t[1][0] == 0 && t[2][0] == 0 ||
        t[0][1] == 0 && t[1][1] == 0 && t[2][1] == 0 ||
        t[0][2] == 0 && t[1][2] == 0 && t[2][2] == 0 ||
        t[0][0] == 0 && t[1][1] == 0 && t[2][2] == 0 ||
        t[2][0] == 0 && t[1][1] == 0 && t[0][2] == 0) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 31648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 1000005
const ll MOD = 1000000007;

ll fact[MAX],invfact[MAX];

inline ll addmod(ll a, ll b){
	return (a+b)%MOD;
}

inline ll mulmod(ll a, ll b){
	return (a*b)%MOD;
}

ll modexp(ll a, ll n){
	if(n == 0)
		return 1;
	ll p = modexp(a,n/2);
	p = mulmod(p,p);
	if(n&1)
		p = mulmod(p,a);
	return p;
}

ll nCr(ll n, ll r){
	if(r < 0 || r > n)
		return 0;
	return mulmod(fact[n],mulmod(invfact[r],invfact[n-r]));
}	

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

	fact[0] = 1;
	for(int i=1;i<MAX;i++)
		fact[i] = mulmod(fact[i-1],i);
	invfact[MAX-1] = modexp(fact[MAX-1],MOD-2);
	for(int i=MAX-2;i>=0;i--)
		invfact[i] = mulmod(invfact[i+1],i+1);
	
	ll n,m;
	cin>>n>>m;

	ll ans = 0;
	int flag = 0;
	for(ll r=0;r<=n;r++){
		ll term = mulmod(mulmod(nCr(n,r),nCr(m-r,n-r)),fact[n-r]);
		if(flag)
			term = MOD-term;
		ans = addmod(ans,term);
		flag ^= 1;
	}

	ans = mulmod(ans,mulmod(nCr(m,n),fact[n]));

	cout<<ans<<endl;
}

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

int GCD(int x, int y) {
  int A, B;
  A = max(x, y);
  B = min(x, y);
  while (A % B != 0) {
    int r;
    r = A % B;
    A = B;
    B = r;
  }
  return B;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int ans = A.at(0);
  for (int i = 1; i < N ; i++) {
    ans = GCD(ans, A.at(i));
  }
  cout << ans << endl;
}


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

int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X);
  vector<long long> B(Y);
  vector<long long> C(Z);
  for (int i = 0; i < X; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < Y; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < Z; i++) {
    cin >> C[i];
  }

  vector<long long> AB(X * Y);
  int index = 0;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      AB[index] = A[i] + B[j];
      index += 1;
    }
  }

  sort(AB.begin(), AB.end());
  reverse(AB.begin(), AB.end());

  vector<long long> V(min(K, X * Y));
  for (int i = 0; i < min(K, X * Y); i++) {
    V[i] = AB[i];
  }

  index = 0;

  vector<long long> abc(V.size() * Z);
  for (int i = 0; i < Z; i++) {
    for (int j = 0; j < V.size(); j++) {
      abc[index] = C[i] + V[j];
      index += 1;
    }
  }

  sort(abc.begin(), abc.end());
  reverse(abc.begin(), abc.end());

  vector<long long> ans(K);
  for (int i = 0; i < K; i++) {
    ans[i] = abc[i];
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
};


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
const long double PI =(acos(-1));
#define INF 1000000

int main(){
    int n;
    cin >> n; 
    int mini=INF;
    int maxi=-1000000;
    long long int sum=0;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin >> a.at(i);
        sum+=a.at(i);
        mini=min(mini,a.at(i));
        maxi=max(maxi,a.at(i));
    }
    cout << mini << " " << maxi << " " << sum << endl;
    

    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
int main() {
    int X; cin >> X;
    int ans = 0;
    int tmp = X / 500;
    ans += tmp * 1000;
    X -= tmp * 500;
    tmp = X / 5;
    ans += tmp * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    string s;
    cin >> s;

    map<char, int> mp;
    for(auto x: s)mp[x]++;

    for(auto x: mp){
        if(x.second != 2){
            cout << "No";
            return;
        }
    }
    if(mp.size() != 2){
            cout << "No";
            return;
    }
    cout << "Yes";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 256