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

using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define endl "\n"

#define aim_cpo do{ios::sync_with_stdio(false);\
cin.tie(nullptr);cout.precision(10);cout<<fixed;}while(0)

#define LOCAL_INPUT do{FILE *stream1;\
stream1=freopen("/Users/aim_cpo/CLionProjects/competitive/in.txt","r",stdin);\
if(stream1==nullptr)return 0;}while(0)

#define LOCAL_OUTPUT do{FILE *stream2;\
stream2 = freopen("out.txt", "w", stdout);\
if (stream2 == nullptr) return 0;}while(0)

#ifdef LOCAL_DEFINE
#define show(x) cerr << #x << " = " << x << endl
#else
#define show(x)
#endif

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399

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

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

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
const ll MOD = (ll)1e9 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//LLの数値をつかう時は最後にLをつける癖をつけよう
//
//  ┏┓┏┓　┓　┏┓
//  ┏┛┃┃　┃　┗┫
//  ┗┛┗┛　┻　┗┛
//
//   謹┃賀┃新┃年┃
//   ━┛━┛━┛━┛
//WWWWWWWWWWWWWWWWWWWWWW

int n;
int a[100001];
ll dp[100001];

int main() {
    aim_cpo; // インタラクティブのときは消すように.
#ifdef LOCAL_DEFINE
    LOCAL_INPUT; // インタラクティブのときは消すように.
//    LOCAL_OUTPUT; // ファイルに出力したいときのみ
    show(MOD);
#endif
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        dp[i] = INT_INF;
    }
    for (int i = 0; i < n; i++) {
        if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
        if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
    }
    cout << dp[n - 1] << endl;
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s." << endl;
#endif
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int N;
    std::cin >> N;
    
    int temp;
    std::vector<int> p;
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        p.push_back(temp); 
    }
    std::sort(p.begin(), p.end());
    
    int ans = 0;
    for (auto &&e : p) {
        ans += e;
    }
    
    ans -= p.back() / 2;
    std::cout << ans << std::endl;
}

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

const int p=998244353,inv2=(p+1)/2;
int qpow(int a,int k){
	int ans=1;
	while(k){
		if(k&1) ans=1LL*ans*a%p;
		a=1LL*a*a%p;
		k>>=1;
	}
	return ans;
}

void FWT_xor(int d[],int n0,int flg){
	for(int i=1;i<(1<<n0);i<<=1)
	for(int j=0;j<(1<<n0);j+=(i<<1))
	for(int k=0;k<i;k++){
		int a0=d[j|k],a1=d[i|j|k];
		d[j|k]=(a0+a1)%p,d[i|j|k]=(a0-a1+p)%p;
		if(flg==-1) d[j|k]=1LL*d[j|k]*inv2%p,d[i|j|k]=1LL*d[i|j|k]*inv2%p;
	}
}
int F[1<<18],Q[1<<18],P[1<<18],SP;

int N;

int main(){
	scanf("%d",&N);
	for(int i=0;i<(1<<N);i++) scanf("%d",&P[i]),SP=(SP+P[i])%p;
	SP=qpow(SP,p-2);
	for(int i=0;i<(1<<N);i++) P[i]=1LL*P[i]*SP%p;
	P[0]=(P[0]-1+p)%p;
	Q[0]=(1<<N)-1;
	for(int i=1;i<(1<<N);i++) Q[i]=p-1;
	FWT_xor(P,N,1);FWT_xor(Q,N,1);
	for(int i=1;i<(1<<N);i++) F[i]=1LL*Q[i]*qpow(P[i],p-2)%p;
	FWT_xor(F,N,-1);
	int ans=p-F[0];
	for(int i=0;i<(1<<N);i++) printf("%d\n",(ans+F[i])%p);
}

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

using namespace std;

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

  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < w + 2; ++i) {
    cout << "#";
  }
  cout << "\n";
  for (int i = 0; i < h; ++i) {
    cout << "#" << a[i] << "#\n";
  }
  for (int i = 0; i < w + 2; ++i) {
    cout << "#";
  }
  cout << "\n";
}


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

const long long inf = 1ll << 60;
const long long mod = 1000000007;

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

int dz[4] = {1,-1,-1,1};
int dw[4] = {1,1,-1,-1};
int main() {
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int q;cin >> q;
    int ans = 0;
    rep(i,q){
	int b;cin >> b;
	if(b==*lower_bound(a.begin(),a.end(),b))ans++;
    } 
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
int a[5];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	if(a[1]==a[2]&&a[2]!=a[3])
	{
		cout<<"Yes\n";
		return 0;
	}
	if(a[1]!=a[2]&&a[2]==a[3])
	{
		cout<<"Yes\n";
		return 0;
	}
	cout<<"No\n";
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

/*UnionFind--------------------------*/
class UnionFind {
using i32 = int_fast32_t;
private:
    std::vector<i32> parent;
    std::vector<i32> siz;

public:
    UnionFind(i32 sz): parent(sz), siz(sz, 1) {
        for(i32 i = 0; i < sz; ++i) parent[i] = i;
    }
    void init(i32 sz) {
        for(i32 i = 0; i < sz; ++i) parent[i] = i;
    }
    /*Member Func------*/
    /*return root id*/
    i32 root(i32 x) {
        while(parent[x] != x) {
            x = parent[x] = parent[parent[x]];
        }
        return x;
    }
    /*merge two groups*/
    bool merge(i32 x, i32 y) {
        x = root(x);
        y = root(y);
        if(x == y) return false;
        //Merge Tech
        if (siz[x] < siz[y]) std::swap(x,y);
        siz[x] += siz[y];
        parent[y] = x;
        return true;
    }
    /*同じ集合にあるか*/
    bool issame(i32 x, i32 y) {
        return (root(x) == root(y));
    }
    /*xの属する集合の大きさ*/
    i32 size(i32 x) {
        return siz[root(x)];
    }
};

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n,m;
    cin >> n >> m;
    vi a(m),b(m);
    rep(i,m) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }

    UnionFind UF(n), UF_init(n);
    int cnt = 0;
    rep(i,m) {
        UF = UF_init;
        rep(j, m) if (j != i) {
                UF.merge(a[j], b[j]);
            }
        if (UF.size(0) != n) ++cnt;
    }
    cout << cnt << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var nmk = Input.ar;
        for (var i = 0; i <= nmk[0]; i++)
            for (var j = 0; j <= nmk[1]; j++)
                if ((nmk[0] - i) * j + i * (nmk[1] - j) == nmk[2])
                {
                    WriteLine("Yes"); return;
                }
        WriteLine("No");
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

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

signed main()
{
   int n; cin >> n;
   V<int> b(n);
   for (int i = 0; i < n; i++) {
      cin >> b[i];
   }

   stack<int> ans;
   for (int k = n; k >= 1; k--) {
      bool updated = false;
      for (int i = k-1; i >= 0; i--) {
         if (b[i] == i+1) {
            ans.push(i+1);
            b.erase(b.begin()+i);
            updated = true;
            break;
         }
      }
      if (!updated) {
         cout << "-1" << endl;
         return 0;
      }
   }
   while (!ans.empty()) {
      cout << ans.top() << endl;
      ans.pop();
   }


   return 0;
}


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

bool prime(int n) {
  bool f = true;
  if(n < 2) {
    f = false;
  } else if(n == 2) {
    f = true;
  } else if(n % 2 == 0) {
    f = false;
  }
  for(int i = 3; i <= sqrt(n); i += 2) {
    if(n % i == 0) {
      f = false;
    }
  }

  return f;
}

int main() {
  int n;
  int ans = 0;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(prime(a[i])) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3128
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 2005;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=2.718281828459045235360287471352662;
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back

int main()
{
    ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int a,b,x;
    cin>>a>>b>>x;
    if(x>=a&&x<=a+b)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ca = 0
cb = 0
for i in range(n):
    if a[i] > b[i]:
        ca += a[i] - b[i]
    elif a[i] < b[i]:
        cb += (b[i] - a[i]) // 2

if ca <= cb:
    ans = "Yes"
else:
    ans = "No"
print(ans)

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

int main()
{
  vector<int> a(3);

  cin >> a[0] >> a[1] >> a[2];

  sort(a.begin(), a.end());

  cout << a[0] + a[1] + a[2]*10 << endl;

  return 0;

}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

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

const ll MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 順列数計算
long long Per(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * finv[n - k] % MOD;
}

// 二項係数計算
long long Com(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll i, j, k;
    ll N, M;
    cin >> N >> M;
    COMinit();

    ll a = Per(M, N);
    ll b = 0;
    for(i = 0; i < N + 1; i++) {
        ll sub = Com(N, i) * Per(M - i, N - i) % MOD;
        if(i % 2 == 0) {
            b = (b + sub) % MOD;
        } else {
            b = (b + MOD - sub) % MOD;
        }
    }
    ll ans = a * b % MOD;
    cout << ans << endl;

    return 0;
}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll l,r,d; cin>>l>>r>>d;
    ll cnt=0;
    for(int i=l; i<=r; i++) cnt+=i%d==0;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define longinf 9223372036854775807LL
#define intinf 2147483647
#define inf 1000000007
#define lol long long
#define in(n,s) insert(n,s)//ノート参照
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int gcd(int x,int y){//最大公約数
  if(y>x) swap(x,y);
  int r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }
  return y;
}
int Lcm(int x,int y){//最小公倍数
  int t=x*y;
  return t/gcd(x,y);
}
lol a,b,c,d,e,g,h,ans=0;
lol dp[111111];
lol i[111111];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>a>>b;
  for(int n=0;n<a;n++) cin >>i[n],dp[n]=intinf;
  dp[0]=0;
  for(int n=0;n<a-1;n++){
      for(int m=1;m<=b;m++){
	  if(n+m>=a) break;
	  dp[n+m]=min(dp[n+m],dp[n]+abs(i[n],i[n+m]));
      }
  }
  cout <<dp[a-1]<<'\n';
  return (0);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a=0,b=0,c=0,d=0,i;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="AC")
        {
            a++;
        }
        else if(s=="WA")
        {
            b++;
        }
        else if(s=="TLE")
        {
            c++;
        }
        else if(s=="RE")
        {
            d++;
        }

    }
    cout<<"AC"<<" "<<"x "<<a<<endl;
        cout<<"WA"<<" "<<"x "<<b<<endl;
        cout<<"TLE"<<" "<<"x "<<c<<endl;
        cout<<"RE"<<" "<<"x "<<d<<endl;

}



Measured memory_bytes: 3632
def count(s, t):
    hai=[]
    for i in range(len(s)):
        if not(s[i] in hai):
            hai.append(s[i])
    hai2=[]
    for i in range(len(t)):
        if not(t[i] in hai2):
            hai2.append(t[i])
    kotae=0
    for h in hai:
        if h in hai2:
            kotae+=1
    return kotae

n=int(input())
s=input()
kotae=0

for i in range(n):
    mae=s[:i]
    ato=s[i:]
    kazu=count(mae, ato)
    if kazu>=kotae:
        kotae=kazu

print(kotae)

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

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

  int total = 0;
  int left = n;

  if(n % 4 == 0){
    cout << "Yes" << endl;
    return 0;
  }

  while(total < n){
    if((n - total) % 7 == 0){
      cout << "Yes" << endl;
      return 0;
    }
    total += 4;
  }

  cout << "No" << endl;

  return 0;

}

Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val Array(n, k, q) = readLine.split(" ").map(_.toInt)
  val array = Array.fill(n)(0)
  for (_ <- 0 until q) {
    val i = readInt
    array(i - 1) = array(i - 1) + 1
  }

  array.foreach { i =>
    println(if (k > q - i) "Yes" else "No")
  }
}


Measured memory_bytes: 39224
'''
Introduction to Heuristics Contest
A - AtCoder Contest Scheduling
'''

def main():
    # 本番テストケースは365
    D = int(input())

    # コンテストタイプごとの満足度の下がりやすさ
    C = list(map(int, input().split()))

    # 満足度row日目にコンテストcolタイプを開催したときの満足度の増加
    S = []
    for _ in range(D):
        sday = list(map(int, input().split()))
        S.append(sday)

    ''' とりあえず順番にやってくだけ
    for i in range(D):
        tmp = i % 26 + 1
        print(tmp)
    '''

    ''' 満足度Siの最高を選ぶ、満足度低下するCは未考慮
    for i in range(D):
        high = S[i].index(max(S[i])) + 1
        print(high)
    '''

#main()

def intro_heuristics_b():
    # 本番テストケースは365
    D = int(input())

    # コンテストタイプごとの満足度の下がりやすさ
    C = list(map(int, input().split()))

    # 満足度row日目にコンテストcolタイプを開催したときの満足度の増加
    S = []
    for _ in range(D):
        sday = list(map(int, input().split()))
        S.append(sday)

    # 回答(出力)
    T = [int(input()) for _ in range(D)]

    # さいごに開催したコンテストの日付
    last = [-1] * 26

    # 満足度と不満度を計算して出力
    val = 0
    for d in range(D):
        idx = T[d] - 1
        satis = S[d][idx]
        last[idx] = d
        complain = 0
        for j in range(26):
            complain += C[j] * (d - last[j])
        val += satis - complain
        print(val)

intro_heuristics_b()

#def intro_heuristics_c():


Measured memory_bytes: 9264
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    // cout << s << endl;
    string ans = "";
    for(int i=0; i<n; i++){
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
	if (a < b) return euclidean_gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

ll lcm(ll a, ll b) {
	ll c = euclidean_gcd(a, b);
	return a / c * b;
}


int main() {

	ll x;

	cin >> x;

	ll ans = lcm(360, x);
	ans /= x;

	cout << ans << endl;
	

	return 0;
}

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

int main() {
  int K, N, a, b, max;
  cin >> K >> N;
  vector<int> vec(N), decoy(N);
  cin >> a;
  vec.at(0) = a;
  decoy.at(0) = a;
  max = a;
  for(int i = 1; i < N; i++) {
    cin >> decoy.at(i);
    vec.at(i) = decoy.at(i) - decoy.at(i-1);
    if (i==N-1) {
      vec.at(0) += (K-decoy.at(N-1));
      if (vec.at(0) > max) {
        max = vec.at(0);
      }
    }
    if(vec.at(i) > max) {
      max = vec.at(i);
    }
    // cout << vec.at(i) << ' ' << max << endl; //
  }
  cout << K - max;
  
}



Measured memory_bytes: 1792
import sys
from collections import defaultdict, deque

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    graph = [[] for _ in range(N)]
    indegrees = defaultdict(int)
    for _ in range(N - 1 + M):
        a, b = map(lambda x: int(x) - 1, rl().split())
        graph[a].append(b)
        indegrees[b] += 1
    
    que = deque([])
    for i in range(N):
        if indegrees[i] == 0:
            que.append(i)
    
    ans = [0] * N
    while que:
        idx = que.pop()
        for child in graph[idx]:
            indegrees[child] -= 1
            if indegrees[child] == 0:
                que.append(child)
                ans[child] = idx + 1
    print(*ans, sep='\n')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 72352
import sys
from collections import Counter
import heapq

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    h, w = inl()
    counter = Counter()
    for i in range(h):
        for c in ins():
            counter[c] += 1

    p4 = (h // 2) * (w // 2)
    p1 = 1 if h % 2 == 1 and w % 2 == 1 else 0
    p2 = (h * w - p4 * 4 - p1) // 2

    xs = [-x for x in counter.values()]
    hp = []
    for x in xs:
        heapq.heappush(hp, x)

    while hp:
        x = heapq.heappop(hp)
        k = -x
        if p4 > 0:
            if k < 4:
                return False
            m = k // 4
            p = min(m, p4)
            p4 -= p
            k -= p * 4
            if k > 0:
                heapq.heappush(hp, -k)
        elif p2 > 0:
            if k < 2:
                return False
            m = k // 2
            p = min(m, p2)
            p2 -= p
            k -= p * 2
            if k > 0:
                heapq.heappush(hp, -k)
        elif p1 > 0:
            if k == 1:
                return True
            return False
    return True


print("Yes" if solve() else "No")


Measured memory_bytes: 9504
n,k=map(int,input().split())

ac=[0 for i in range(n+1)]
ans=0
cle=0

for i in range(k):
    inp=input().split()
    p=int(inp[0])
    s=inp[1]
    if ac[p]>=0:
        if s=="AC":
            ans+=ac[p]
            ac[p]=-1
            cle+=1
        else:
            ac[p]+=1

print(cle,ans)

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	int n;
	cin >> n;
	int k = 1;
	while (true)
	{
		int now = k*(k-1) / 2;
		if (now == n) break;
		if (now > n) {
			cout << "No" << endl;
			return 0;
		}
		k++;
	}
	cout << "Yes" << endl;
	cout << k << endl;
	vector<vector<int>> ans(k);
	int x = 1;
	rep(i,k) {
		for (int j = i+1; j < k; j++)
		{
			ans[i].push_back(x);
			ans[j].push_back(x);
			x++;
		}
	}

	rep(i,k) {
		cout << k-1 << ' ';
		rep(j,k-1) {
			cout << ans[i][j] << ' ';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 4308
#include <iostream>
#include <cstdio>
using namespace std;
int abs(int a)
{
    if(a<0)
        return -a;
    return a;
}
int a[100010],n,aska[100010];
char ask[200000],spe[2]={'W','S'},ans[200000];
int main()
{
    cin>>n;
    for(int i=0; i<=n+1; i++)
    {
        scanf("%c",&ask[i]);
        if(ask[i]=='o')
            aska[i]=1;
        else
            aska[i]=0;
    }
    for(int i=1; i>=0; i--)
    {
        a[1]=i;
        ans[1]=spe[i];
        for(int j=1; j>=0; j--)
        {
            a[2]=j;
            ans[2]=spe[j];
            for(int k=3; k<=n; k++)
            {
                if(a[k-1]==1)
                {
                    if(ask[k-1]=='o')
                    {
                        a[k]=a[k-2];
                        ans[k]=spe[a[k-2]];
                        continue;
                    }
                    else
                    {
                        a[k]=1-a[k-2];
                        ans[k]=spe[a[k]];
                        continue;
                    }
                }
                if(a[k-1]==0)
                {
                    if(ask[k-1]=='x')
                    {
                        a[k]=a[k-2];
                        ans[k]=spe[a[k-2]];
                        continue;
                    }
                    else
                    {
                        a[k]=1-a[k-2];
                        ans[k]=spe[a[k]];
                        continue;
                    }
                }
            }
            bool sc=(a[1]==a[n-1]);
            bool sp=(a[2]==a[n]);
            if(abs(sc-abs(aska[n]-a[n])) && abs(abs(aska[1]-a[1])-sp))
            {
                for(int p=1; p<=n; p++)
                    printf("%c",ans[p]);
                cout<<endl;
                return 0;
            }
        }
    }
    cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int menseki = 0;
		int nagasa = 0;
		int a = 0,c=0,d = 0,e=0,s=0;
		String t = "";
		
		while(true){
			try {
				t = br.readLine();
				if (t == null) {
					break;
				}
			} catch (IOException e1) {
				// TODO 自動生成された catch ブロック
				e1.printStackTrace();
			}
			d = 0;
			for(int i=0;i<t.length();i++){
				if(s == 0){
					a = d+a;
					d = 0;
				}
				s = 0;
				if(t.charAt(i) == '0'){
					d = d*10 + 0;
					s = 1;
				}
				else if(t.charAt(i) == '1'){
					d = d*10 + 1;
					s = 1;
					
				}
				else if(t.charAt(i) == '2'){
					d = d*10 + 2;
					s = 1;
					
				}
				else if(t.charAt(i) == '3'){
					d = d*10 + 3;
					s = 1;
					
				}
				else if(t.charAt(i) == '4'){
					d = d*10 + 4;
					s = 1;
					
				}
				else if(t.charAt(i) == '5'){
					d = d*10 + 5;
					s = 1;
					
				}
				else if(t.charAt(i) == '6'){
					d = d*10 + 6;
					s = 1;
					
				}
				else if(t.charAt(i) == '7'){
					d = d*10 + 7;
					s = 1;
					
				}
				else if(t.charAt(i) == '8'){
					d = d*10 + 8;
					s = 1;
					
				}
				else if(t.charAt(i) == '9'){
					d = d*10 + 9;
					s = 1;
				}
				
				
			}
			a = d + a;

		}
		System.out.println(a);

		
	}

}

Measured memory_bytes: 16864
#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;


namespace my
{
	//-----------------------------------------------------------------------------
	inline char cn()
	{
		static char buf[1000010],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
	}
	#define cn getchar
	template<class TY>void read(TY &x)
	{
		x=0;int f1=1;char ch=cn();
		while(ch<'0'||ch>'9'){if(ch=='-')f1=-1;ch=cn();}
		while(ch>='0'&&ch<='9')x=x*10+(ch-'0'),ch=cn(); x*=f1;
	}
	char OP[1000030],Zhan[30];int op=0,Top;
	void fcheck(int type=0){if(type||op>=1000000)fwrite(OP,1,op,stdout),op=0;}
	template<class TY>inline void write(TY x)
	{
		if(x==0){OP[op++]='0';fcheck();return;}
		Top=0;while(x)Zhan[++Top]=x%10+'0',x/=10;
		while(Top)OP[op++]=Zhan[Top--];fcheck();
	}
	#define K_G OP[op++]=' '
	//----------------------------快读快输 ----------------------------------------
	
	//--------------------------------------------------------------------------------------------
	#define ll long long
	#define uint unsigned int
	#define ull unsigned long long
	#define INV(x) ksm(x,mod-2)
	const int maxn=100010,inf=1000000007;
	int mod=998244353;
	void add(int &x,int y){x=(x+y>=mod?x+y-mod:x+y);}
	int ksm(int x,int y){int re=1;for(;(y&1?re=1ll*re*x%mod:0),y;y>>=1,x=1ll*x*x%mod);return re;}
	int fac[maxn],inv_fac[maxn],inv[maxn];
	void work_math()//阶乘
	{
		inv[1]=1;for(int i=2;i<=maxn-10;i++)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fac[0]=inv_fac[0]=1;for(int i=1;i<=maxn-10;i++)fac[i]=1ll*fac[i-1]*i%mod;
		inv_fac[maxn-10]=INV(fac[maxn-10]);
		for(int i=maxn-11;i>=1;i--)inv_fac[i]=1ll*inv_fac[i+1]*(i+1)%mod;
	}
	struct disc{int x,y;};
	bool compp(disc x,disc y){return x.x<y.x;}
	void discretization(int *darr,int dn)//离散化 
	{
		static disc b[maxn];
		for(int i=1;i<=dn;i++)
		b[i].x=darr[i],b[i].y=i;
		sort(b+1,b+dn+1,compp);
		static int tot=0;b[0].x=-9666;
		for(int i=1;i<=dn;i++)
		if(b[i].x!=b[i-1].x)darr[b[i].y]=++tot;
		else darr[b[i].y]=tot;
	}
	template<class TY>TY gcd(TY x,TY y){return !y?x:gcd(y,x%y);}
	//----------------------------------------------板子---------------------------------------------
	
	//----------------------------------------------------------------------------------------------- 
	int T,n;char s[maxn];ll a[maxn],d[64];
	bool add(ll x)
	{
		for(int i=60;i>=0;i--)
		if(x&(1ll<<i))
		{
			if(d[i])x^=d[i];
			else {d[i]=x;return true;}
		}
		return false;
	}
	
	void main()
	{
		scanf("%d",&T);while(T--)
		{
			scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%lld",&a[i]);scanf("%s",s+1);
			bool ans=true;
			for(int i=1;i<=n;i++)if(s[i]=='1')
			{
				memset(d,0,sizeof(d));
				for(int j=i+1;j<=n;j++)if(s[j]=='0')add(a[j]);
				if(add(a[i]))ans=false;
			}
			if(ans)printf("0\n");else printf("1\n");
		}
//		fcheck(1);return;
	}
}


int main(){my::main();return 0;}

Measured memory_bytes: 1652
#include<stdio.h>
int main(){
	int S,h,m;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	S=S-3600*h-60*m;
	printf("%d:%d:%d\n",h,m,S);
	return 0;
}

Measured memory_bytes: 2752
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

const int N = 260;
const int K = 555;
int ok[K][K];
vector<int> G[K];

int id[55][55];
char field[55][55];
int visit[55][55];

char ch[K];
int dp[K][K][2][2];
vector<int> ord;

inline int check(int c1, int c2){
	return ch[c1] - 'a' == ch[c2] - 'A';
}

int rec(int l, int r, int a, int b){
	if (r - l <= 1) return !a && !b && check(ord[l], ord[r]);
	int &res = dp[l][r][a][b];
	if (res + 1) return res;
	res = 0;

	if (!a && !b && check(ord[l], ord[r])){
		res = 1 + rec(l, r, 1, 1);
	}

	for (int k = l + 1; k < r; ++k){
		if (ok[ord[l]][ord[k]] && ok[ord[k]][ord[r]]){
			res = max(res, rec(l, k, a, 1) + rec(k, r, 0, b));
			res = max(res, rec(l, k, a, 0) + rec(k, r, 1, b));
		}
	}
	return res;
}

int h, w;
void dfs(int r, int c, int v){
	visit[r][c] = 1;
	rep(i, 2){
		int nr = r + i, nc = c + !i;
		if (nr < 0 || nc < 0 || nr >= h || nc >= w) continue;
		if (field[nr][nc] == '#') continue;
		if (visit[nr][nc]) continue;
		if (id[nr][nc] >= 0){
			G[v].push_back(id[nr][nc]);
			ok[v][id[nr][nc]] = 1;
		}
		dfs(nr, nc, v);
	}
}

void tdfs(int v, vector<int> &visit, vector<int> &res){
	visit[v] = 1;
	for (auto to : G[v]){
		if (visit[to]) continue;
		tdfs(to, visit, res);
	}
	res.push_back(v);
}

vector<int> tsort(int n){
	vector<int> vis(n), res;
	rep(i, n) if(!vis[i]) tdfs(i, vis, res);
	reverse(ALL(res));
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	while (cin >> h >> w, h){
		rep(i, h) cin >> field[i];
		rep(i, w) field[h][i] = "#."[i == w - 1];
		++h;

		MEMSET(id, -1);
		MEMSET(ch, 0);
		int num = 0;
		rep(i, h) rep(j, w){
			if (isupper(field[i][j]) || islower(field[i][j])){
				ch[num] = field[i][j];
				id[i][j] = num++;
			}
		}
		int SRC = num++;
		int SNK = num++;
		id[h - 1][w - 1] = SNK;

		MEMSET(visit, 0);
		MEMSET(ok, 0);
		rep(i, num) G[i].clear();
		dfs(0, -1, SRC);
		rep(i, h) rep(j, w) if (!visit[i][j]) field[i][j] = '#';
		rep(i, h) rep(j, w){
			if (id[i][j] >= 0){
				MEMSET(visit, 0);
				dfs(i, j, id[i][j]);
			}
		}

		if (!ok[SRC][SNK]){
			cout << -1 << endl;
			continue;
		}

		ord = tsort(num);
		MEMSET(dp, -1);

		int r = -1;
		rep(i, num) if (ord[i] == SNK) r = i;

		cout << rec(0, r, 0, 0) << endl;
	}
}

Measured memory_bytes: 7712
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

bool judge(string s, string t,int i,bool flag)
{
	int f = i+1;
	if(f>=t.length())
		f=0;
	int r = i-1;
	if(r<0) r = t.length()-1;
	if(s[i]=='o')
	{
		if(t[i]=='S' && t[f]!=t[r])
			flag = 0;
		else if(t[i]=='W' && t[f]==t[r])
			flag = 0;
	}
	else
	{
		if(t[i]=='S' && t[f]==t[r])
			flag = 0;
		else if(t[i]=='W' && t[f]!=t[r])
			flag = 0;
	}
	if(i==0)
		return flag;
	else
		return judge(s,t,0,flag);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	string t[4];
	t[0] += "SS";
	t[1] += "SW";
	t[2] += "WS";
	t[3] += "WW";
	for(int i = 1,j2=2; j2<s.length(); i++,j2++)
	{
		for(int j = 0; j<4; j++)
		{
			if(s[i]=='o')
			{
				if(t[j][i]=='S')
					t[j] += t[j][i-1];
				else
					t[j] += 'S'+'W'-t[j][i-1];
			}
			else 
			{
				if(t[j][i]=='W')
					t[j] += t[j][i-1];
				else
					t[j] += 'S'+'W'-t[j][i-1];
			}
		}
	}
	for(int i = 0; i<4; i++)
	{
	   // cout<<t[i]<<endl;
		if(judge(s,t[i],n-1,1))
		{
			cout<<t[i]<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

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


Measured memory_bytes: 2056
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final PrintStream so = System.out;
    static final Scanner sc = new Scanner(System.in);
    static final int INF = Integer.MAX_VALUE;

    static int[] mh = {0, 1, 0, -1};
    static int[] mw = {1, 0, -1, 0};
    
    public static void main(String[] args) {
        int N = ni();
        
        int count = 0;
        for (int i = 6; i <= 55555; i+=5) {
            if (isPrime(i)) {
                so.print(i + " ");
                count++;
            }
            if (count == N)
                break;
        }
    } 
    
    static boolean isPrime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    static int ni() {
        return sc.nextInt();
    }
    
    static long nl() {
        return sc.nextLong();
    }

    static char[] nsToChars() {
        return sc.next().toCharArray();
    }
}


Measured memory_bytes: 21716
function main()
	N=parse(Int,readline())
	T=map(x->parse(Int,x),split(readline()))
	A=map(x->parse(Int,x),split(readline()))
	h=zeros(Int,N)
	pre=0
	for i=1:N
		if pre<T[i]
			pre=T[i]
			h[i]=T[i]
			if A[i]<h[i]
				println(0)
				exit()
			end
		end
	end
	pre=0
	for i=N:-1:1
		if pre<A[i]
			if h[i]!=0&&h[i]!=A[i]
				println(0)
				exit()
			end
			pre=A[i]
			h[i]=A[i]
			if T[i]<h[i]
				println(0)
				exit()
			end
		end
	end
	mod=10^9+7
	ans=1
	for i=1:N
		if h[i]==0
			ans=ans*min(T[i],A[i])%mod
		end
	end
	println(ans)
end
main()


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

#define BR "\n"
#define SP " "

int main() {
  ll N, A;
  cin >> N;

  vector<ll> V;
  cin >> A;
  V.push_back(A);

  for (int i = 1; i < N; i++) {
    cin >> A;
    auto l = lower_bound(V.begin(), V.end(), A);

    if (l != V.begin()) {
      V.erase(l - 1);
    }
    
    auto u = upper_bound(V.begin(), V.end(), A);
    V.insert(u, A);
  }
  cout << V.size() << BR;

  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 3000000000 //1e9
#define SIZE 100005

using namespace std;
typedef long long ll;

int main(){
	long long n, input, ans=0, b, kari=0;
	vector<long long int> a;
	
	cin >> n;
	REP(i,n){
		cin >> input;
		input -= i+1;
		a.push_back(input);
	}
	
	sort(a.begin(), a.end() );
	
	if (n%2==0){
		kari = 0;
		b = a[(n-1)/2];
		REP(i,n) kari += abs(b-a[i]);
	}
	
	b = a[n/2];
	REP(i,n) ans += abs(b-a[i]);
	
	if (n%2==0) ans = min(ans, kari);
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

int main(){
	
	int n;
	
	cin >> n;
	
	double a[n];
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	double ans = 0;
	
	for (int i = 0; i < n; i++){
		
		ans += 1/a[i];
		
	}
	
	cout << 1/ans;
	
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }
    ll sum = 0;
    for(ll a : A){
        sum += a;
    }

    bitset<2000*2000+1> dp;
    dp[0] = 1;
    for(ll a : A){
        dp |= (dp<<a); // ここのコストも2000
    }
    dp[0] = 0;

    vector<ll> V;
    FOR(i, 0, 2000*2000+1){
        if(dp[i]==1) V.push_back(i);
    }

    // ll target = sum/2; // これはだめ
    ll target = (sum+1)/2;

    auto it = lower_bound(ALL(V), target);
    p(*it);
    
    return 0;
}

Measured memory_bytes: 19688
#include <stdio.h>
#include <iostream>
#include <vector>

int main(void){
	int N;
	scanf("%d",&N);

	std::vector<int>* anlist=new std::vector<int>();
		anlist->push_back(0);

	for(int i=0;i<N;i++){

		int tmp;
		scanf("%d",&tmp);
		anlist->push_back(tmp);
	}
	int i=1;
	int nakayoshi=0;
	while(i<N){
		hoge:
		int an=(*anlist)[i];
		if(an!=0 && i==(*anlist)[an]) {
			(*anlist)[an]=0;
			(*anlist)[i]=0;
			nakayoshi++;
		}else (*anlist)[i]=0;
		i++;

		
	}
	std::cout << nakayoshi << "\n";

	return 0;
}

Measured memory_bytes: 892
#include  <stdio.h>
int main (){
	char huruf = 'a';
	int i;
	scanf("%c", &huruf);
    if(huruf >= 'a' && huruf <= 'z') {
    	printf("a\n", huruf);
    }
		else if (huruf >='A' && huruf <= 'Z'){
    	printf("A\n", huruf);
    }

	return 0;
	
}




Measured memory_bytes: 1628
#include<stdio.h>
#include<string.h>
 
int LCSLength(char *X, char *Y){
  int i,j,m,n,c[1001][1001];
  m = strlen(X);
  n = strlen(Y);
   
  for(i=0; i<m; i++){
    c[i][0] = 0;
  }
  for(j=0; j<n; j++){
    c[0][j] = 0;
  }
 
  for(i=1;i<m+1;i++){
    for(j=1;j<n+1;j++){
      if (X[i-1]==Y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if (c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  return c[i-1][j-1];
}
 
int main(){
  int i, q;
  char X[1001], Y[1001];
   
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%s", X);
    scanf("%s", Y);
    printf("%d\n", LCSLength(X, Y));
 
  }
  return 0;
}

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    for ( int i = 0; i < N; i++ ) cin >> B[i];
    for ( int i = 0; i < N; i++ ) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    vector<ll> NB(N), NC(N);
    ll ans = 0;

    int a = 0,b,c;
    for ( b = 0; b < N; b++ ) {
        while ( a < N && A[a] < B[b] ) a++;
        NB[b] = a;
    }
    b = 0;
    ll nb = 0;
    for ( c = 0; c < N; c++ ) {
        while ( b < N && B[b] < C[c] ) {
            nb += NB[b];
            b++;
        }
        NC[c] = nb;
        ans += nb;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4096
/**
 *   Praveen Fulera    
**/

// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define endl '\n'
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>

const int mod = 1e9 + 7;
//const int mod = 998244353;

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif

  int t = 1; //cin >> t;
  while(t--){      
    int n, val = 0, k; cin >> n >> k;
    int data[n+5];

    for(int i = 1; i <= n; i++){
        cin >> data[i];
    }
    for(int i = 50; i >= 0; i--){
        int cnt = 0;
        for(int j = 1; j <= n; j++){
             if(data[j]&(1ll<<i)){
                 cnt++;
             }
        }
        if(2*cnt < n){
            int temp = val^(1ll<<i);
            if(temp <= k){
                val = temp;
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += (val^data[i]);
    }
    cout << ans << '\n';
  }   
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

#define MOD 1000000007

ll dp[100010];
bool deteT[100010];
bool deteA[100010];

int main(){
    
    ll N; cin>>N;
    vector<ll> T(N),A(N);
    REP(i,N)cin>>T[i];
    REP(i,N)cin>>A[i];
    
    REP(i,100010)deteT[i]=false;
    REP(i,100010)deteA[i]=false;
    
    REP(i,N)dp[i]=T[i];
    ll mh=-1;
    REP(i,N){
        if(T[i]>mh){
            deteT[i]=true;
            mh=T[i];
        }
    }
    
    mh=-1;
    RREP(i,N){
        if(A[i]>mh){
            deteA[i]=true;
            mh=A[i];
        }
        dp[i]=min(dp[i],A[i]);
    }
    
    REP(i,N){
        if(deteA[i]){
            if(A[i]!=dp[i]){
                cout<<0<<endl;
                return 0;
            }
        }
        if(deteT[i]){
            if(T[i]!=dp[i]){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    
    ll ans=1;
    REP(i,N){
        if(!deteT[i]&&!deteA[i]){
            ans*=dp[i];
            ans%=MOD;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 2816
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;
  std::vector<i64> A;
  tools::read(A, N);

  i64 ideal = 0;
  for (i64 i = 39; i >= 0; --i) {
    i64 sum = 0;
    for (const i64& A_i : A) {
      sum += (A_i >> i) & 1;
    }
    ideal |= static_cast<i64>(sum * 2 >= N ? 0 : 1) << i;
  }

  bool limited = true;
  i64 X = 0;
  for (i64 i = 39; i >= 0; --i) {
    const i64 K_i = K & (static_cast<i64>(1) << i);
    const i64 ideal_i = ideal & (static_cast<i64>(1) << i);
    X |= limited ? std::min(K_i, ideal_i) : ideal_i;
    limited = limited && K_i <= ideal_i;
  }

  i64 answer = 0;
  for (const i64& A_i : A) {
    answer += X ^ A_i;
  }
  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<map>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int z = 1000000007;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}


Measured memory_bytes: 3592