akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INF (ll)1000000007
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    int N;
    cin >> N;
    int A[N];
    int mx = 0;
    REP(i,N){ cin >> A[i]; A[i]--; chmax(mx, A[i]+1);}
    VI n(mx, 0);
    REP(i,N) n[A[i]]++;

    int rmv = 0;
    REP(i,mx){
        if(n[i] > 0) rmv += n[i]-1;
    }
    if(rmv%2 == 1) rmv++;

    cout << N-rmv << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        double L = sc.nextDouble();
        double ans = Math.pow(L/3.0,3);
        System.out.println(String.format("%.12f",ans));

    }
}


Measured memory_bytes: 24264
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstdio>
#include <deque>
#include <cmath>
#include <stack>
#include <ctime>
#include <queue>
#include <set>
#include <map>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
#define X first
#define Y second
#define MP make_pair
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
 
const int ppr[] = {257, 263};
const ll INF = 2e18;
const int inf = 2e9;
const int mod[] = {int(1e9 + 7), int(1e9 + 9)};
const int N = 1e6 + 123;
const ld pi = 3.141592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
 
int n, a;

main() {             	
//  freopen(".in", "r", stdin);                          
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));
	
	speed;

	cin >> n;

	a = (n + 1) / 2;

	cout << fixed << setprecision(6) << double(a + 0.0) / double(n + 0.0);
	     
    return 0;                                        
}  

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

using  Graph=vector<vector<int>> ;


int main()
{
 int N,Q; cin >> N >> Q;
 Graph G(N);
 for(int i=0;i<N-1;i++){
     int a,b; cin >> a >> b;
     a-=1;
     b-=1;
     G[a].push_back(b);
     G[b].push_back(a);
 }
 vector<long> counter;
 vector<bool> seen;
 vector<int> par;
 vector<int> order;

 seen.assign(N,false);
 seen[0]=true;
 par.assign(N,-1);
 order.assign(N,0);
 counter.assign(N,0);

 stack<int> s;
 s.push(0);
 seen[0]=true;
 int cur=0;
 while(s.size()!=0){
     int u=s.top();
     s.pop();
     order[cur]=u;
     cur++;
     for(auto v:G[u]){
         if(seen[v])continue;
         seen[v]=true;
         s.push(v);
         par[v]=u;
     }
 }

 for(int i=0;i<Q;i++){
     int u,x; cin >> u >> x;
     counter[u-1]+=x;
 }
 for(int i=0;i<order.size();i++){
     if (order[i]==0){
         continue;
     }
     else{
         int u=order[i];
         counter[u]+=counter[par[u]];
     }
 }
 for(int i=0;i<N;i++){
     cout << counter[i] << ' ';
 }
 return 0;
}

Measured memory_bytes: 17908
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 998244353;
const ll INF = LLONG_MAX;
const ll LOG = 29;
 
long long binpow(long long a, long long b) {
    // a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a) ;
 
        
        b >>= 1;
    }
    //res;
    return res;
} 

ll div(ll n){
    set<ll> se;
    for(int i =1;i<=sqrt(n);i++){
        if(n%i==0){
            se.insert(i);
            se.insert(n/i);
        }
    }
    return se.size()*1ll;
}

void solve(){
    ll n;
    cin>>n;
    ll a[n+1];
    ll e=0,o = 0;
    for(int i =1;i<=n;i++){
        cin>>a[i];
        if(a[i]&1)o+=a[i];
        else e+=a[i];
    }    
    if(o&1){
        cout<<"NO\n";
    }
    else{
        cout<<"YES\n";
    }
}
 
 
int main(){
    ios_base::sync_with_stdio(0);
     cin.tie(NULL);
     
    ll t=1;
    while(t--){
        solve();
    }
     
 
 
    return 0;     
    
        
}


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

int use[100],m,n,c;
struct poi { int n,f[100];};
struct bri { int a,b,c; };
bri b[5000],g;
poi p[100];
void check(int v) {
	int i; c++;
	for (i=0;i<p[v].n;i++) if (p[v].f[i]>-1) if (use[p[v].f[i]]==0) {use[p[v].f[i]]=1; check(p[v].f[i]);}
	}

int main() {
	int i,j,s,x,y;
    while(cin >> n >> m) {
		if (n==0) break;
		for (i=0;i<100;i++) p[i].n=0;
		for (s=0,i=0;i<m;i++) { cin >> b[i].a >> b[i].b >> b[i].c;
		 p[b[i].a].f[p[b[i].a].n]=b[i].b;  p[b[i].a].n++;
		 p[b[i].b].f[p[b[i].b].n]=b[i].a;  p[b[i].b].n++;  
		 s+=b[i].c;}
		for (i=m-1;i>0;i--) for (j=0;j<i;j++) if (b[j].c<b[j+1].c) { g=b[j]; b[j]=b[j+1]; b[j+1]=g;}
		for (i=0;i<m;i++) {
			for (j=0;j<p[b[i].a].n;j++) if (p[b[i].a].f[j]==b[i].b) { x=j; p[b[i].a].f[j]=-1; }
			for (j=0;j<p[b[i].b].n;j++) if (p[b[i].b].f[j]==b[i].a) { y=j; p[b[i].b].f[j]=-1; }
			for (j=0;j<n;j++) use[j]=0; 
			use[0]=1; c=0; check(0); 
			if (c==n) s-=b[i].c; else { p[b[i].a].f[x]=b[i].b; p[b[i].b].f[y]=b[i].a;}
		}  
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
//CGL_2_B
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    double xp0, xp1, yp0, yp1, xp2, yp2, xp3, yp3;
    int q;
    int i;
    double s1x0, s1y0, s2x0, s2y0, s3x0, s3y0, s10, s20;
    double s1x1, s1y1, s2x1, s2y1, s3x1, s3y1, s11, s21;

    q = sc.nextInt();
    for(i = 0;i < q;i++){
      xp0 = sc.nextDouble();
      yp0 = sc.nextDouble();
      xp1 = sc.nextDouble();
      yp1 = sc.nextDouble();
      xp2 = sc.nextDouble();
      yp2 = sc.nextDouble();
      xp3 = sc.nextDouble();
      yp3 = sc.nextDouble();

      s1x0 = xp1 - xp0;
      s1y0 = yp1 - yp0;
      s2x0 = xp2 - xp0;
      s2y0 = yp2 - yp0;
      s3x0 = xp3 - xp0;
      s3y0 = yp3 - yp0;

      s10 = s1x0 * s2y0 - s1y0 * s2x0;
      s20 = s1x0 * s3y0 - s1y0 * s3x0;

      s1x1 = xp3 - xp2;
      s1y1 = yp3 - yp2;
      s2x1 = xp0 - xp2;
      s2y1 = yp0 - yp2;
      s3x1 = xp1 - xp2;
      s3y1 = yp1 - yp2;

      s11 = s1x1 * s2y1 - s1y1 * s2x1;
      s21 = s1x1 * s3y1 - s1y1 * s3x1;

      if(s10 * s20 > 0 || s11 * s21 > 0){
        System.out.println("0");  //no
      }else if(s10 == 0 && s20 == 0 &&
               (s1x0 * s2x0 < 0 || s1y0 * s2y0 < 0) &&
               (s1x0 * s3x0 < 0 || s1y0 * s3y0 < 0)
              ){
        System.out.println("0");  //no
      }else if(s10 == 0 && s20 == 0 &&
        ((s1x0 * s1x0) + (s1y0 * s1y0) < (s2x0 * s2x0) + (s2y0 * s2y0)) &&
        ((s1x0 * s1x0) + (s1y0 * s1y0) < (s3x0 * s3x0) + (s3y0 * s3y0))
              ){
        System.out.println("0");  //no
      }else{
        System.out.println("1");  //yes
      }
    }

/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 48508
<?php

list($n, $k) = explode(" ", trim(fgets(STDIN)));

$arr_cnt = [];
for ($i=$k; $i>=1; $i--) {
  $x = intdiv($k, $i);
  $y = repeatSqrt($x, $n, 1000000007);
  for($j=2*$i; $j<=$k; $j+=$i){
    //echo $j.PHP_EOL;
    $y-=$arr_cnt[$j];
  }
  //echo $i." ".$x." ".$y.PHP_EOL;
  $arr_cnt[$i]=$y;
}

//var_dump($arr_cnt);

$ans=0;
for($i=1;$i<=$k;$i++){
  $ans+=$arr_cnt[$i]*$i;
  $ans%=1000000007;
}
echo $ans;

function repeatSqrt($b, $p, $m){
  if($p==1)
  {
    return $b;
  }
  else if($p%2 == 0)
  {
    $t = repeatSqrt($b, floor($p/2), $m);
    return ($t * $t) % $m;
  }
  else
  {
    return ($b * repeatSqrt($b, $p-1, $m)) % $m;
  }
}

Measured memory_bytes: 23100
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
n = int(input())
if n == 3:
    print('61')
    quit()

divide = 1000000007

agct = ['A', 'G', 'C', 'T']

out = set()
for c in agct:
    out.add('AGC' + c)
    out.add(c+'AGC')
    out.add( 'A' + c + 'GC')
    out.add('AG' + c + 'C')
    out.add('GAC' + c)
    out.add(c+'GAC')
    out.add('ACG' + c)
    out.add(c+'ACG')

##後ろ4文字を与えて，それがokかどうか
def isok(str):
    if str[-4:] in out:
        return False
    return True


#N文字で最後の4文字がstrの時の種類数
@lru_cache(maxsize=1000000)
def saiki(n,str):
    if n == 4:
        if isok(str):
            return 1
        return 0
    ret = 0
    if isok(str)==False:
        return 0
    for c in agct:
        next = c+str
        next = next[0:4]
        ret += saiki(n-1,next)
    return ret%divide

strlist = list(itertools.product(agct, repeat=4))
#print('len is ',len(strlist))
rr = 0
for strs in strlist:
    rr += saiki(n,''.join(strs))
print(rr%divide)




Measured memory_bytes: 13692
#include<stdio.h>
int main(){
  int pos[6],i,max;
  for(i=0;i<5;i++)
    scanf("%d",&pos[i]);
  scanf("%d",&max);
  if(pos[4]-pos[0]>max)
    printf(":(\n");
  else
    printf("Yay!\n");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n;cin >> n;
	
	
	ll ans = 0;
	for(ll i = 1;i < 1000000;i++)
	{
		if(i*i <= n)
			ans = i*i;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











const ll table_size = 300005;
ll fact[table_size], finv[table_size], inv[table_size];

void make_table(ll mod) {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < table_size; i++){
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll comb(ll n, ll r, ll mod){
    if(n < r || n < 0 || r < 0) return 0;
    return fact[n] * (finv[r] * finv[n - r] % mod) % mod;
}

int main(){
    make_table(MOD);
    
    ll n, k;
    cin >> n >> k;
    if(k == 1){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll s1 = 0, s2 = 0;
    REP(i, n - 1){
        s1 += a[n - 1 - i] * comb(n - 1 - i, k - 1, MOD) % MOD;
        s1 %= MOD;
    }
    REP(i, n){
        s1 -= a[i] * comb(n - 1 - i, k - 1, MOD) % MOD;
        s1 += MOD;
        s1 %= MOD;
    }
    cout << (s1 - s2 + MOD) % MOD << endl;
}

Measured memory_bytes: 8064
import java.util.Scanner;

import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String string = sc.nextLine();
		
		String[] array = string.split("");
		int[] array2 = new int[4];
		for(int i=0; i<array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
		}
		int[] array3 = new int[2];
		int a = (array2[0]*10) + array2[1];
		int b = (array2[2]*10) + array2[3];
		
		if(a > 12 && b > 12 || a==0 && b==0) {
			System.out.println("NA");
		}else if(a < 13 && b < 13 && a!=0 && b!=0) {
			System.out.println("AMBIGUOUS");
		}else if(a > 12 && b<13 && b>0 || a==0 && b<13) {
			System.out.println("YYMM");
		}else if(b > 12 && a<13 && a>0 || b==0 && a<13){
			System.out.println("MMYY");
		}else {
			System.out.println("NA");
		}
	}

}


Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc139/tasks/abc139_c
# 整数の入力
n, k = map(int, input().split())
s = str(input())
c = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        c += 1

c = c + 2*k
print(c) if c < n-1 else print(n-1)


Measured memory_bytes: 3316
#include<stdio.h>
struct abc{

};
int main(void)
{
    int n,m;
    int i,j;
    int temp,max,maxi;
    while(1){
        max = 0;
        scanf("%d %d",&n,&m);
        if(n == 0 && m == 0) break;
        int a[m];
        for(i = 0; i < m; i++) a[i] = 0;
        for(i = 0; i < n; i++){
            for(j = 0; j < m; j++){
                temp = a[j];
                scanf("%d",&a[j]);
                a[j] += temp;
                temp = 0;
            }
        }
        for(i = 0; i < m; i++){
            for(j = 0; j < m; j++){
                if(max < a[j]){
                    max = a[j];
                    maxi = j + 1;
                }
            }
            a[maxi - 1] = 0;
            printf("%d",maxi);
            max = 0;
            if(i == m - 1){
                printf("\n");
                continue;
            }
            printf(" ");
        }
    }

    return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;

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

    int N;
    string s, t;
    cin >> N >> s >> t;
    
    int ans = N;

    REP (i, N) {
        int num = N - i;
        bool check = true;
        REP (j, num) {
            if (s[i+j] != t[j]) check = false;
        }

        if (check) {
            cout << ans << "\n";
            return 0;
        } else {
            ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int N;
	int A[201];
	int res = 0;
	int flag = 1;

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

	do{
		for (int i = 0; i < N; i++){
			if(A[i] % 2 == 0){
				A[i] = A[i]/2;
			}
			else{
				cout << res << endl;
				return 0;
			}
		}	
		res++;
	}while(flag == 1);

	cout << res << endl;
	return 0;
}


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

int main() {
  char s;
cin>>s;
if(s=='a'){
cout<<"vowel"<<endl;
}else if(s=='e'){
cout<<"vowel"<<endl;
}else if(s=='i'){
cout<<"vowel"<<endl;
}else if(s=='o'){
cout<<"vowel"<<endl;
}else if(s=='u'){
cout<<"vowel"<<endl;
}else{
cout<<"consonant"<<endl;
}
}


Measured memory_bytes: 256
n=int(input())
s=list(input())
a=0
b=0
c=0
for i in range(n):
    d=s[i]
    if d=='(':
        a+=1
    else:
        b+=1
        if b-c>a:
            c+=1
print('('*c+''.join(s)+')'*(a-b+c))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, m, n) for(ll i = (ll)m; i < (ll)n; i++)
#define PER(i, m, n) for(ll i = (ll)m; i > (ll)n; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> v(n);
    REP(i, 0, n){
        cin >> v[i];
        v[i] -= x;
    }
    ll ans = abs(v[0]);
    if(n >= 2) REP(i, 1, n) ans = gcd(ans, abs(v[i]));
    cout << ans << endl;
}


Measured memory_bytes: 3992
#152_E
from fractions import gcd
from functools import reduce

def lcm(x, y):
    return x * y // gcd(x, y)

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
x = reduce(lcm, a)

print(sum(x // ai for ai in a) % mod)

Measured memory_bytes: 6140
#include<stdio.h>
#include<string.h>
int n,m,q[100];
char s[100][100],p[100],d[100];
int f(char *str){
	int i;
	for(i=0;i<n&&strcmp(str,s[i]);i++);
	return i;
}
int main()
{
	int i,k,a,b,j;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%s %d",s[i],&q[i]);
		}
		scanf("%d",&m);
		for(i=0;i<m;i++){
			b=0;
			scanf("%s %d",p,&k);
			for(j=0;j<k;j++){
				scanf("%s",d);
				b+=q[f(d)];
			}
			q[f(p)]=q[f(p)]>b?b:q[f(p)];
		}
		scanf("%s",p);
		printf("%d\n",q[f(p)]);
	}
	return 0;
}

Measured memory_bytes: 1048
#include <iostream>	
#include <stdio.h>	
#include <bits/stdc++.h>	
#include <queue>	
using namespace std;	
#define N 100
	
int h,w; 
int d[N][N];	
int color[N][N]; //color=0の時行ける　color=1の時行けない
int col[N][N];
	
typedef struct{	
    int s;	
    int t;	
}num; //queueに二次元配列は使えない	
	
void bfs(int x, int y){	
    for (int i=1; i<=h; i++){
        for (int j=1; j<=w; j++){
            color[i][j]=col[i][j];
        }
    }
    queue<num> q; //標準ライブラリのqueue 入るものは最後尾　出すものは先頭	
    num p;	
    p.s=x;	
    p.t=y;	
    q.push(p); 	
    color[x][y]=1;
    d[x][y]=0; 	
    num u;	
    while (!q.empty()){ //qが空になるまで続ける	
        u=q.front(); //uはqの先頭	
        q.pop(); //qの先頭を取り出す	
        if (u.s-1>0 && color[u.s-1][u.t]==0){	
            num p2;	
            p2.s=u.s-1;	
            p2.t=u.t;	
            d[u.s-1][u.t]=d[u.s][u.t]+1;	
            color[u.s-1][u.t]=1;	
            q.push(p2);	
        }	
        if (u.s+1<=h && color[u.s+1][u.t]==0){	
            num p2;	
            p2.s=u.s+1;	
            p2.t=u.t;	
            d[u.s+1][u.t]=d[u.s][u.t]+1;	
            color[u.s+1][u.t]=1;	
            q.push(p2);	
        }	
        if (u.t-1>0 && color[u.s][u.t-1]==0){	
            num p2;	
            p2.s=u.s;	
            p2.t=u.t-1;	
            d[u.s][u.t-1]=d[u.s][u.t]+1;	
            color[u.s][u.t-1]=1;	
            q.push(p2);	
        }	
        if (u.t+1<=w && color[u.s][u.t+1]==0){	
            num p2;	
            p2.s=u.s;	
            p2.t=u.t+1;	
            d[u.s][u.t+1]=d[u.s][u.t]+1;	
            color[u.s][u.t+1]=1;	
            q.push(p2);	
        }	
    }	
}	
	
int main(){	
    for (int i=0; i<N; i++){	
        for (int j=0; j<N; j++){	
            col[i][j]=1;	
        }	
    }	
    cin>>h>>w;	
    int sx,sy,gx,gy;	
    for (int i=1; i<=h; i++){	
        for (int j=1; j<=w; j++){	
            char a;	
            cin>>a;	
            
            if (a=='.'){	
                col[i][j]=0;	
            }	
            
        }	
    }
    
    int maxnum=0;
    for (sx=1; sx<=h; sx++){
        for (sy=1; sy<=w; sy++){
            if (col[sx][sy]==0) bfs(sx,sy);
            for (gx=1; gx<=h; gx++){
                for (gy=1; gy<=w; gy++){
                    
                    if (maxnum<d[gx][gy]) maxnum=d[gx][gy]; 
                }
            }
        }
    }
    cout<<maxnum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h){
    cin >> s[i];
  }
  vector<vector<int> > up(h, vector<int>(w));
  vector<vector<int> > lr(h, vector<int>(w));
  rep(j, w){
    int num=0;
    rep(i, h){
      if(s[i][j]=='#'){
        num=0;
      } else {
        num++;
        up[i][j]=num;
      }
    }
    for(int i=h-1; i>=0; i--){
      if(s[i][j]=='.' && i!=h-1 && s[i+1][j]!='#'){
        up[i][j]=up[i+1][j];
      }
    }
  }
  rep(i, h){
    int num2=0;
    rep(j, w){
      if(s[i][j]=='#'){
        num2=0;
      } else {
        num2++;
        lr[i][j]=num2;
      }
    }
    for(int j=w-1; j>=0; j--){
      if(s[i][j]=='.' && j!=w-1 && s[i][j+1]!='#'){
        lr[i][j]=lr[i][j+1];
      }
    }
  }
  int ans=0;
  rep(i, h){
    rep(j, w){
      ans=max(ans, up[i][j]+lr[i][j]-1);
    }
  }
  cout <<ans << endl;
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<double> p(n+1);
	for (int q = 1; q <= n; q++)
	{
		cin >> p[q];
	}
	vector<vector<double>> dp(n+1, vector<double>(n+1));
	dp[0][0] = 1;
	for (int q = 1; q <= n; q++)
	{
		dp[q][0] = dp[q-1][0] * (1-p[q]);
		for (int w = 1; w <= n; w++)
		{
			dp[q][w] = dp[q-1][w] * (1-p[q]) + dp[q-1][w-1] * p[q];
		}
	}
	double prob = 0;
	for (int q = n/2+1; q <= n; q++)
	{
		prob += dp[n][q];
	}
	printf("%.10f\n", prob);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int ans = 0;
  rep(i, N-1) {
    if (S[i] != S[i+1]) ans++;
  }
  
  cout << ++ans << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const long long INF = 1LL << 60;
const long long 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;
}

int main(){
    ll N,M,a,b;
    cin>>N>>M;
    a=-1;
    b=0;
    vl dp(N+1,0);
    rep(i,N+1){
        if(a==-1&&b<M){
            cin>>a;
            b++;
        }
        if(i==a){
            dp.at(i)=0;
            a=-1;
            continue;
        }
        else if(i==0||i==1){
            dp.at(i)=1;
            continue;
        }
        dp.at(i)=(dp.at(i-1)+dp.at(i-2))%MOD;
    }
    cout<<dp.at(N)%MOD<<endl;
}


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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 998244353ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう
int main(){
    ll n,m;
    std::cin >> n>>m;
    std::vector<int> w(n),v(n);
    rep(i,n)std::cin >> w[i]>>v[i];
    ll dd=w[0];
    irep(i,n){
        w[i]-=dd;
        w[i]+=300;
    }
    erep(i,w){
     //   std::cout << i <<' ';
    }
    std::cout << std::endl;
    vvector(dp,ll,n+1,40000,0);
    rep(i,n){
        rep(j,30500){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }
            else{
                dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
            }
        }
    }
    ll ans=0;
    rep(i,n+1){
        rep(j,30500){
            if(j/300*dd+j%300<=m&&(j==0||dp[i][j]!=dp[i][j-1])){
                if(chmax(ans,dp[i][j])){
         //           pppri(i,j,dp[i][j]);
                }
            }
        }
    }
    std::cout << ans<< std::endl;
}

Measured memory_bytes: 32512
def partition(a, p, r):
    x = a[r]
    i = p - 1
    for j in range(p, r):
        if a[j] <= x:
            i += 1
            tmp = a[i]
            a[i] = a[j]
            a[j] = tmp
    tmp = a[r]
    a[r] = a[i+1]
    a[i+1] = tmp
    return i + 1


n = int(input())
a = [int(i) for i in input().split()]

q = partition(a, 0, n-1)

a = [str(i) for i in a]
a[q] = '[%s]' % a[q]
print(' '.join(a))


Measured memory_bytes: 16364
// ARC096C.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 3030;

int n, mod, binomial[MAX_N][MAX_N], stiring[MAX_N][MAX_N];

int fpow(int bas, int tim, int cmod)
{
    int ret = 1;
    while (tim)
    {
        if (tim & 1)
            ret = 1LL * ret * bas % cmod;
        bas = 1LL * bas * bas % cmod;
        tim >>= 1;
    }
    return ret;
}

int main()
{
    scanf("%d%d", &n, &mod);
    binomial[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        binomial[i][0] = binomial[i][i] = 1;
        for (int j = 1; j < i; j++)
            binomial[i][j] = (0LL + binomial[i - 1][j - 1] + binomial[i - 1][j]) % mod;
    }
    stiring[0][0] = 1;
    for (int i = 1; i <= n + 1; i++)
        for (int j = 1; j <= i; j++)
            stiring[i][j] = (0LL + 1LL * j * stiring[i - 1][j] % mod + stiring[i - 1][j - 1]) % mod;
    int ans = 0;
    for (int i = 0, opt = 1; i <= n; i++, opt = mod - opt)
    {
        int pans = 0;
        for (int j = 0; j <= i; j++)
            pans = (0LL + pans + 1LL * fpow(fpow(2, n - i, mod), j, mod) * stiring[i + 1][j + 1] % mod) % mod;
        pans = 1LL * pans * fpow(2, fpow(2, n - i, mod - 1), mod) % mod * binomial[n][i] % mod;
        ans = (0LL + ans + 1LL * opt * pans % mod) % mod;
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

int main()
{
	int k,n;
	cin>>k>>n;
	int l = n-(k-1);
	int r = n+(k-1);
	
	for(int i=l; i<=r; i++)
	{
		cout<<i<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j, key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for(i=2; i<=n; i++){
    key=A[i];
    j=i-1;

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

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

const int N = 1e5 + 7;

int dp[N];

vector <int> adj[N];

void dfs(int u) {
        if(dp[u]) return;
        for(int v: adj[u]) {
                dfs(v);
                dp[u] = max(dp[u], dp[v] + 1);
        }
}

int main() {
        int n, m; cin >> n >> m;
        for(int i = 1; i <= m; i++) {
                int u, v; cin >> u >> v;
                adj[u].push_back(v);
        }

        for(int i = 1; i <= n; i++) {
                dfs(i);
                dp[0] = max(dp[0], dp[i]);
        }
        cout << dp[0] << endl;
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

signed main(){
	
	int k,t;cin>>k>>t;
	
	int dai = 0;
	rep(i,t)
	{
		int a;cin >>a;
		dai = max(dai,a);
	}
	
	int ans = max(0LL,2*dai-k-1);
	cout << ans << endl;
}

//cout << ans << endl;

Measured memory_bytes: 256
l = input()
n = len(l)
law = 10 ** 9 + 7
dp = [[0, 0] for _ in range(n)]

dp[0] = [2, 1]
for i in range(n - 1):
    if l[i+1] == '0':
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = dp[i][1] * 3
    else:
        dp[i+1][0] = dp[i][0] * 2
        dp[i+1][1] = dp[i][1] * 3 + dp[i][0]
    dp[i+1][0] %= law
    dp[i+1][1] %= law
print(sum(dp[n-1]) % law)

Measured memory_bytes: 19700
n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)

if a.count(m) > 1:
    for i in range(n):
        print(m)
else:
    b = sorted(set(a))
    m2 = b[-2]
    for i in range(n):
        if a[i] != m:
            print(m)
        else:
            print(m2)


Measured memory_bytes: 69080
import math

n = int(input())
nmax = int(math.sqrt(n))
primes = [i for i in range(n+1)]
primes[0] = 0
primes[1] = 0
i = 2
while i <= n:
    if primes[i] == 0:
        i += 1
        continue
    for j in range(i*2,n+1,i):
        primes[j] = 0
    i += 1
    
primes = [i for i in range(n+1) if primes[i] != 0 ]
#print(primes)

primediv = [0]*len(primes)

for k in range(2,n+1):
    for j, p in enumerate(primes):
        cnt = 0
        while k % p == 0:
            cnt += 1
            k = k // p
        primediv[j] += cnt

ans = 1
for k in primediv:
    if k == 0:
        continue
    ans = (ans*(k+1))%(10**9+7)
print(ans)
        

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

using namespace std;
using ll = long long;

int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  ll x = abs(X);
  ll a = x / D;
  if (K <= a) {
    cout << abs(x - K * D) << endl;
  } else {
    x = x - a * D;
    if ((K - a) % 2 == 0) {
      cout << min(x, abs(x - 2 * D)) << endl;
    } else {
      cout << min({abs(x - D), abs(x - 3 * D), abs(x + D)}) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
using namespace std;
int n,A,B;
int a[40],b[40],c[40];
int dp[50][500][500];
int main(){
    cin>>n>>A>>B;
    for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
    for(int i=0;i<=n;i++)for(int j=0;j<500;j++)for(int k=0;k<500;k++)dp[i][j][k]=100000;
    dp[0][0][0]=0;
    for(int i=0;i<n;i++){
        for(int ca=0;ca<=400;ca++){
            for(int cb=0;cb<=400;cb++){
                dp[i+1][ca][cb]=min(dp[i][ca][cb],dp[i+1][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
            }
        }
    }
    int ans=4000000;
    for(int i=1;i*max(A,B)<500;i++){
        ans=min(ans,dp[n][i*A][i*B]);
    }
    if(ans==100000) cout<<-1;
    else cout<<ans;
    return 0;
}


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

typedef long long int ll;

int main()
{
	ll i,j,k,l,m,n,u,v;
	char a;
	cin >> a;

	if(a-'a' >= 0)
		cout << "a\n";
	else
		cout << "A\n";


}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
import math

def main():
    big = 10 ** 9 + 7

    N = int(input())
    A = list(map(int, input().split()))
    num = A[0]
    for i in range(1, N):
        num = num * A[i] // math.gcd(num, A[i])

    res = 0
    for a in A:
        res += num // a

    print(res % big)

if __name__ == '__main__':
    main()



Measured memory_bytes: 75156
from collections import Counter

def solve(a):
    counter = Counter(a)
    l = list(counter.values())
    if counter[0] > 0:
        if len(l) == 1:
            return True
        if len(l) != 2:
            return False
        return min(l) == counter[0] and counter[0] * 2 == max(l)
    ks = list(counter.keys())
    if len(l) != 3:
        return False
    return l[0] == l[1] and l[2] == l[0] and ks[0] ^ ks[1] == ks[2]



if __name__ == '__main__':
    n = int(input())
    a = [int(s) for s in input().split()]
    print('Yes' if solve(a) else 'No')


Measured memory_bytes: 14468
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>
#include <functional>

using namespace std;

int main() {
  while( true ) {
	int n, m;
	cin >> n >> m;
	if ( n == 0 && m == 0 ) break;

	vector<int> xs( n + 1 );
	for ( int i = 1; i <= n; i++ ) {
	  cin >> xs[ i ];
	}
	sort( xs.begin() + 1, xs.end(), greater<int>() );
	
	int sum = 0;
	for ( int i = 1; i <= n; i++ ) {
	  sum += ( i % m == 0 ? 0 : xs[ i ] );
	}
	cout << sum << endl;
  }  
}

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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define mod 1000000007

using namespace std;

int main()
{
	//#ifdef ONLINE_JUDGE
//	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	std::ios_base::sync_with_stdio(false);

	string s;
	string fr="",ba="";
	cin>>s;
	ll q;
	ll p=0;
	cin>>q;
	while(q--)
	{
		ll t;
	
		cin>>t;
		if(t==1)
		{
			if(p==1)
			p=0;
			else
			p=1;
		}
		else
		{
			ll f;
			string c;
			cin>>f>>c;
			if(f==1&&p==0)
			{
				fr=c+fr;
			}
			else if(f==1&&p==1)
			{
				ba=ba+c;
			}
			else if(f==2&&p==0)
			{
				ba=ba+c;
			}
			else if(f==2&&p==1)
			{
				fr=c+fr;
			}
		}
	}
	s=fr+s;
	s=s+ba;
	if(p==0)
	cout<<s;
	else if(p==1)
	{
		reverse(s.begin(),s.end());
		cout<<s;
	}
	
	return 0;
}

Measured memory_bytes: 1304
#include<stdio.h>
#define NUMBER 3
int main(void)
{
    int i,j,x[NUMBER],tmp;
    for(i=0;i<NUMBER;i++){
        scanf("%d",&x[i]);
    }
   for(i=0;i<NUMBER;i++){
       for(j=i+1;j<NUMBER;j++){
           if(x[i]>x[j]){
               tmp=x[j];
               x[j]=x[i];
               x[i]=tmp;
           }
       }
   } 
 printf("%d %d %d\n",x[0],x[1],x[2]); 
   return 0;
}


Measured memory_bytes: 2760
from operator import mul
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    X = list(map(int, input().split()))

    ans = INF
    x_min = min(X)
    x_max = max(X)
    for p in range(x_min, x_max + 1):
        tmp = 0
        for x in X:
            tmp += (x - p) ** 2
        ans = min(ans, tmp)
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 66156
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String e ="keyence";
		if((a.substring(a.length()-7,a.length())).equals(e)){
			System.out.println("YES");
			return;
		}else if((a.substring(0,7)).equals(e)){
			System.out.println("YES");
			return;
		}
		for(int i = 1; i <= 7; i++){
				if((a.substring(0,i)).equals(e.substring(0,i))){
						if((a.substring(a.length()-7+i,a.length())).equals(e.substring(i,e.length()))){
							System.out.println("YES");
							return;
						}
				}
		}
		System.out.println("NO");
	}
}

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

struct UnionFind {
    // 根を保存する（根のみ負値で木の大きさが保存される）
    vector<int> Parent;
 
    // 要素数Nで初期化
    UnionFind(int N) { Parent = vector<int>(N, -1); }

    // 根を求める
    int root(int A) {
        if (Parent[A] < 0) return A;
        else return Parent[A] = root(Parent[A]);
    }

    // 属する木の大きさ
    int size(int A) { return -Parent[root(A)]; }
 
    // 統合
    void unite(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) return;
 
        if (size(A) < size(B)) swap(A, B);
 
        Parent[A] += Parent[B];
        Parent[B] = A;
    }
 
    // 同じ木に属するか
    bool same(int A, int B) { return root(A) == root(B); }
};

int main() {
    int n,m;
    cin >> n >> m;
    int p[100100];
    for (int i=0;i<n;i++) {
        cin >> p[i];
    }

    UnionFind tree_i(100100);
    int x,y;
    for (int i=0;i<m;i++) {
        cin >> x >> y;
        tree_i.unite(x,y);
    }

    int cnt=0;
    for (int i=0;i<n;i++) {
        if(tree_i.same(p[i],i+1)) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#pragma region Include/Defines
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <limits.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <cassert>
#include <map>
#include <set>
#include <iostream>
#include <queue>
#include <time.h>

using namespace std;
typedef long long lli;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<pii> vpii;
typedef vector <pll> vpll;
typedef long double ld;
#define all(a) std::begin(a), std::end(a)

const int INF = 0x3f3f3f3f;
const lli LINF = 0x3f3f3f3f3f3f3f3f;

template<typename T, typename T2> inline void _max(T &a, T2 b) { a = max((T)a, (T)b); }
template<typename T, typename T2> inline void _min(T &a, T2 b) { a = min((T)a, (T)b); }

#ifdef _DEBUG
#define epr(...) fprintf(stderr,__VA_ARGS__)
#else
#define epr(...) 
#endif
#pragma endregion

const int MAX = 1e5 + 10;
int n, a[MAX];

void clear() {
}

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

void solve() {
	int nOdd = 0;
	int n4 = 0;
	for (int i = 0; i < n; i++) nOdd += a[i] % 2, n4 += a[i] % 4 == 0;
	int n2 = n - n4 - nOdd;
	printf(n4 >= nOdd || (nOdd == n4 + 1 && n == n4 + nOdd) ? "Yes\n" : "No\n");
}

int main() {
#ifdef _LOCAL_VAN
	freopen("in.txt", "r", stdin);
#endif
	while (scanf("%d", &n) == 1) {
		clear();
		read();
		solve();
#ifndef _LOCAL_VAN
		return 0;
#endif
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
  
int main(int argc, char *argv[])
{
  int n, i, j, k;
  int *A;
  int cnt, m, G[12], v;
  
  scanf("%d", &n);
  
  A = (int *)malloc(sizeof(int) * n);
  
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
  
  cnt = 0;
  m = 1;
  G[0] = 1;
  while (3 * G[m-1] + 1 < n) {
    G[m] = 3 * G[m-1] + 1;
    m++;
  }
  
  for (i = 0; i < m / 2; i++) {
    v = G[i];
    G[i] = G[m-1-i];
    G[m-1-i] = v;
  }
  
  printf("%d\n", m);
  for (i = 0; i < m; i++) {
    if (i != m - 1) printf("%d ", G[i]);
    else printf("%d\n", G[i]);
  }
  
  for (i = 0; i < m; i++) {
    for (j = G[i]; j < n; j++) {
      v = A[j];
      k = j - G[i];
      while (k >= 0 && A[k] > v) {
    A[k+G[i]] = A[k];
    k -= G[i];
    cnt++;
      }
      A[k+G[i]] = v;
    }
  }
  
  printf("%d\n", cnt);
  for (i = 0; i < n; i++) printf("%d\n", A[i]);
  
  return 0;
}

Measured memory_bytes: 4504
import sys
def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write
    MOD = 998244353

    N = int(readline())
    P = [list(map(int, readline().split())) for i in range(N)]

    P.sort()

    Y = [y for x, y in P]

    def compress(X):
        *XS, = set(X)
        XS.sort()
        return list(map({e: i for i, e in enumerate(XS)}.__getitem__, X))
    Y = compress(Y)

    data = [0]*(N+1)
    def add(k, x):
        while k <= N:
            data[k] += x
            k += k & -k
    def get(k):
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    pow2 = [1]*(N+1)
    r = 1
    for i in range(1, N+1):
        pow2[i] = r = r * 2 % MOD

    def gen(add, get, pow2):
        for i, y in enumerate(Y):
            v = get(y+1); add(y+1, 1)
            p1 = pow2[v]; p0 = pow2[y - v]
            q1 = pow2[i - v]; q0 = pow2[(N - y - 1) - (i - v)]
            yield (p0 + p1 + q0 + q1 - (p0 + q1) * (p1 + q0)) % MOD
    write("%d\n" % ((sum(gen(add, get, pow2)) + N*pow2[N] - N) % MOD))
solve()

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define pow(x) (x)*(x)
#define mid(min, max) ((min + max) / 2)

int main() {
	in(n);
	string s, t;
	cin >> s >> t;

	string ans;

	rep(i, n) {
		ans.push_back(s[i]);
		ans.push_back(t[i]);
	}

	out(ans);

	return 0;
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;


int main() {
    ll n; cin >> n;
    ll a[n]; rep(i,0,n) cin >> a[i];
    sort(a,a+n);
    ll ans =1;
    bool f = false;
    rep(i,0,n){
        if(a[i] > 0 && ans > (ll)1e18/a[i]) f = true;
        ans *= a[i];
    }
    if(f ) cout << -1 << "\n";
    else cout << ans << "\n";
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int sa = int.Parse(s);
            switch (sa)
            {
                case 25:
                    Console.WriteLine("Christmas");
                    break;
                case 24:
                    Console.WriteLine("Christmas Eve");
                    break;
                case 23:
                    Console.WriteLine("Christmas Eve Eve");
                    break;
                case 22:
                    Console.WriteLine("Christmas Eve Eve Eve");
                    break;
            }
            
        
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092