akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
vector<int> positionZip(vector<int>zipped){
	vector<int> zip;
	vector<int> ziping;
	for (int i = 0; i < zipped.size(); i++){
		ziping.push_back(zipped[i]);
	}
	sort(ziping.begin(), ziping.end());
	ziping.erase(unique(ziping.begin(), ziping.end()), ziping.end());
	for (int i = 0; i < zipped.size(); i++){
		zip.push_back(lower_bound(ziping.begin(), ziping.end(), zipped[i]) - ziping.begin());
	}
return zip;
}
int main(){
	int n,m;
	
	cin >>n>>m;
	vector<vector<int>> town(n + 5);

	vector<pair<int,int>>data(m+1);
	vector<vector<int>> belong(n+5);
	vector<int>hash(m+1,0);
	rep(i,m){
		cin>>data[i].F>>data[i].S;
		town[data[i].F].push_back(data[i].S);
		belong[data[i].F].push_back(i);

	}

	vector<int>tmp;
	reps(i,n){
	//	clog<<i<<" "<<endl;
		tmp=positionZip(town[i]);
		for(int j=0;j<tmp.size();j++){
		//	clog<<(tmp[j])<< " ";
		//	clog<<belong[i][j];
			hash[belong[i][j]]=tmp[j];
		}
		//clog<<endl;

		tmp.clear();
	}
	rep(i,m){
		printf("%06d%06d\n",data[i].F,hash[i]+1);
	}
	//cout<<ans<<endl;
}

Measured memory_bytes: 13568
# -*- coding: utf-8 -*-
import itertools

import numpy as np


# 読み込み
n, m = map(int, input().split())
swicthes = np.zeros((m, n), dtype=int)

for i in range(m):
    _, *s = map(lambda x: int(x) - 1, input().split())
    swicthes[i, np.array(s, dtype=int)] = 1

l = list(map(int, input().split()))
p = np.array(l, dtype=int)

# bit全探索
count = 0
for on in itertools.product([0, 1], repeat=n):
    _on = np.array(on, dtype=int)
    status = np.sum(swicthes * _on, axis=1) % 2
    if np.sum(p == status) == m:
        # 全ての電球が点灯している
        count += 1

print(count)


Measured memory_bytes: 27256
//
// Created by Nivras on 2017/5/9.
//

#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn = 3030;
int num[maxn];

void bubbleSort(int n, int& times) {
    times = 0;
     bool needToSort = true;
    while (needToSort) {
        needToSort = false;
        for (int j = n - 1; j > 0; j--) {
            if (num[j] < num[j-1]) {
                swap(num[j], num[j-1]);
                needToSort = true;
                times++;
            }
        }
    }
}

void show(int n) {
    printf("%d", num[0]);
    for (int i = 1; i < n; i++) {
        printf(" %d", num[i]);
    }
    puts("");
}

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

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

    int times = 0;
    bubbleSort(n, times);

    show(n);
    printf("%d\n", times);


}

Measured memory_bytes: 2748
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=2e5+4;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int n;
int a[N];
int sum;
int main() {
//	freopen("in.txt","r",stdin);
	n=read();
	for (register int i=1;i<=n;++i) {
		a[i]=read();
		sum^=a[i];
	}
	for (register int i=1;i<=n;++i) {
		printf("%d ",sum^a[i]);
	}
	return 0;
}

Measured memory_bytes: 4504
#include <iostream>
#include <string>
#include <locale>
#include <math.h>

using namespace std;

int main()
{
    int A, B;
    cin>>A>>B;
    if(A<=12&&A>=6)
    {
        cout<<B/2;
    }
    else if(A<=5&&A>=0)
    {
        cout<<"0";
    }
    else
    {
        cout<<B;
    }



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

/*-- template --*/

int main() {
    string S;
    cin >> S;
    int N = S.size();
    rep(i, N - 2) {
        if(S[i] == S[i + 1] || S[i] == S[i + 2]) {
            cout << i + 1 << ' ' << i + 3 << endl;
            return 0;
        }
    }
    if(S[N - 2] == S[N - 1] && N != 2) {
        cout << N - 2 << ' ' << N << endl;
        return 0;
    }else if(S[N - 2] == S[N - 1] && N == 2){
        cout << 1 << ' ' << 2 << endl;
        return 0;
    }
    cout << -1 << ' ' << -1 << endl;

}


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

int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> f(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  ll left = -1, right = 1e12;
  while (left + 1 < right)
  {
    // std::cout << "left=" << left << " right=" << right << endl;
    ll c = (left + right) / 2;
    bool ok = [&]() {
      ll total = 0;
      rep(i, n)
          total += max(0ll, a[i] - c / f[i]);
      return total <= k;
    }();
    if (ok)
    {
      right = c;
    }
    else
    {
      left = c;
    }
  }
  std::cout << right << endl;
}


Measured memory_bytes: 1792
NUM = 10**5 + 1
MOD = 10**9 + 7
dp = [-1] * NUM
dp[0] = 1
for i in range(1, NUM):
    dp[i] = (dp[i-1] * i) % MOD

def inv(p):
    res = 1
    k = MOD - 2
    while k > 0:
        if k & 1:
            res = (res * p) % MOD
        p = (p * p) % MOD
        k //= 2
    return res

def comb(n, k):
    p = dp[n]
    q = (dp[n-k] * dp[k]) % MOD
    return (p * inv(q)) % MOD

def solve(n, k, a):
    a = sorted(a)
    minX = sum(comb(n-l, k-1) * a[l-1] for l in range(1,n+1) if l+k-1 <= n)
    maxX = sum(comb(r-1, k-1) * a[r-1] for r in range(1,n+1) if r >= k)
    return (maxX - minX) % MOD

n, k = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, k, a))

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


int main(){
    int N;
    int A[100010];
    int B[100000];
    cin >> N;
    for(int a=0; a<N+1; a++){
        cin >> A[a];
    }
    for(int b=0; b<N; b++){
        cin >> B[b];
    }

    long long answer = 0;


    for(int i=0; i<N; i++){
        if(A[i] >= B[i]){              //全力
            //A[i] -= B[i];
            answer += B[i];
        }
        else{                          //余力あり
            if(A[i+1] >= B[i]-A[i]){   //i+1のモンスターあまる
                answer += A[i];  
                A[i+1] -= B[i] - A[i];
                answer += B[i] - A[i];
            }
            else{                      //あまらない
                answer += A[i] + A[i+1];
                A[i+1] = 0;
            }
            //A[i] = 0;
        }
    }

    cout << answer;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  int n, m, cnt = 0, i, sum = 0;
  double x;
  cin>>n>>m;
  int a[n];
  for(i = 0; i<n ; i++)
  {
      cin>>a[i];
      sum+=a[i];
  }
  x = (1.0/(4.0*m))*sum;
  //cout<<x<<endl;
  for(i = 0; i<n; i++)
  {   //cout<<a[i]<<endl;
      if(a[i]>= x)
      {
          cnt++;
          //cout<<cnt<<endl;
      }
      if(cnt == m)
      {
          cout<<"Yes"<<endl;
          return 0;
      }
  }
 
  cout<<"No"<<endl;
 
 
 
 
return 0;
}

Measured memory_bytes: 3608
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2021&lang=jp
// ICPC: 模擬国内2008D
// Princess in Danger

/*
Point.
ダイクストラ法を適用する。
1. 最小経路を探索
2. 最終的な時間は、移動時間 + max(0, 移動時間-M) で求められる。
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using ppint = pair<int, pint>;

#define INF 1e5

struct edge{
  int to, cost;
};

int N, M, L, K, A, H;
int dijkstra(vector<vector<edge>> G, vector<vector<int>>& d, vector<int> heal){
  priority_queue<ppint, vector<ppint>, greater<ppint>> que;
  d[A][M] = 0;
  que.push({0, {A, M}});
  while(!que.empty()){
    ppint p = que.top(); que.pop();
    int now = p.second.first;
    if(d[now][p.second.second] < p.first) continue;
    if(now == H) return p.first;
    if(heal[now]){
      for(int i = 0; i < G[now].size(); i++){
        edge e = G[now][i];
        for(int j = p.second.second; j <= M; j++){
          if(j - e.cost >= 0 && p.first + e.cost + (j - p.second.second) < d[e.to][j - e.cost]){
            d[e.to][j - e.cost] = p.first + e.cost + (j - p.second.second);
            que.push({d[e.to][j - e.cost], {e.to, j - e.cost}});
          }
        }
      }
    }
    else{
      for(int i = 0; i < G[now].size(); i++){
        edge e = G[now][i];
        if(p.second.second - e.cost >= 0 && p.first + e.cost < d[e.to][p.second.second - e.cost]){
          d[e.to][p.second.second - e.cost] = p.first + e.cost;
          que.push({d[e.to][p.second.second - e.cost], {e.to, p.second.second - e.cost}});
        }
      }
    }
  }
  return -1;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  while(cin >> N >> M >> L >> K >> A >> H && N){
    vector<vector<edge>>  G(N);
    vector<vector<int>> d(N, vector<int>(M+1, INF));
    vector<int> heal(N, 0);
    for(int i = 0; i < L; i++){
      int t;
      cin >> t;
      heal[t] = 1;
    }
    for(int i = 0; i < K; i++){
      int x, y, t; cin >> x >> y >> t;
      G[x].push_back({y, t});
      G[y].push_back({x, t});
    }
    int ans = dijkstra(G, d, heal);
    if(ans == -1) cout << "Help!" << endl;
    else cout << ans << endl;
  }
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



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

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

  vector<string> blue(N);

  for(int i=0; i<N; i++) {
    cin >> blue.at(i);
  }

  int M;
  cin >> M;

  vector<string> red(M);

  for(int i=0; i<M; i++) {
    cin >> red.at(i);
  }

 int max = -100;

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

    for(int j=0; j<N; j++) {
      if(blue.at(i) == blue.at(j)) {
        count++;
      }
    }
    for(int j=0; j<M; j++) {
      if(blue.at(i) == red.at(j)) {
        count--;
      }
    }
    if(max < count) {
      max = count;
    }
  }

  if(max < 0) max = 0;
  
  cout << max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<ll,ll>,null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
 
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007
#define PRECISE cout.precision(18);
 #define F first
 #define S second



const ll mod = 1000000007; 
  const ll MAX=1000000+1;
ll prime[MAX]; 
unordered_map<ll, ll> max_map; 
  
// Function to return a^n 
ll power(ll a, ll n) 
{ 
    if (n == 0) 
        return 1; 
    ll p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 
  
// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (ll i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (ll j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  
// Function to return the LCM modulo M 
ll lcmModuloM(ve <ll> ar, ll n) 
{ 
  
    for (ll i = 0; i < n; i++) { 
        ll num = ar[i]; 
        unordered_map<ll, ll> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            ll factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    ll ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
}


ll bexp(ll a,ll b,ll m){
ll ans=1;
ll d1=a;
while(b>0){
	if(b%2==0){
		d1=(d1*d1)%m;
		b/=2;
	}
	else{
		ans=(ans*d1)%m;
		b-=1;
	}
}
 
return ans;
 
}
 ///////////////////////////////////




int main(){
 

    FAST
	//PRECISE

ll n;
cin>>n;
ve <ll> v(n,0);
FOR(i,0,n)
cin>>v[i];

sieve();

ll l=lcmModuloM(v,n);




ll ans=0;
FOR(i,0,n){
	ans+=(l*bexp(v[i],M-2,M))%M;
	ans=ans%M;
}
cout<<ans;

return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	int ans=0;
	if(x*2==w&&y*2==h)ans=1;
	fcout(10)<<w*h/2.0<<" "<<ans<<endl;;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC082C - Good Sequence
  // Nを超える数は全て取り除くので、配列に入れずにansに加算する
  int N; cin >> N;
  vector<int> cnt(N+1, 0); // 各数値の個数を管理
  int a, ans = 0;
  REP(i, N){
    cin >> a;
    if(a > N){
      ans++;
    }else{
      cnt[a]++;
    }
  }
  REP(i, N+1){
    if(cnt[i] > 0 && cnt[i] > i) ans += cnt[i] - i;
    if(cnt[i] > 0 && cnt[i] < i) ans += cnt[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	long long n,k;
	scanf("%lld%lld",&n,&k);
	long long h[n+1],z=0;
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&h[i]);
		z+=h[i];
	}
	sort(h+1,h+n+1);
	long long d=n-k;
	if(d<0)	d=0;
	for(long long i=n;i>d;i--)
	{
		z-=h[i];
	}
	printf("\n%lld",z);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

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

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


int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	int t;
	vector<int> b(n);
	for (int i = 0; i < n; i+=t+1)
	{
		t = 0;
		for (int j = i; j < n-1; j++)
		{
			if (a.at(j) >= a.at(j + 1))
				t++;
			else
				break;
		}
		b.at(i) = t;

	}
	int M = *max_element(b.begin(), b.end());
	cout << M << endl;

}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String text = sc.nextLine();
        
        for(int i = 0; i < text.length(); i++){
            char c = text.charAt(i);
            
            if(Character.isUpperCase(c)){
                c = Character.toLowerCase(c);
                System.out.print(c);
            }else{
                c = Character.toUpperCase(c);
                System.out.print(c);
            }
        }
        System.out.println("");
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  ll width = 0ll;
  for (int i=0; i<N-1; i++) {
    if (A.at(i)==A.at(i+1)) {
      width = A.at(i);
      A.erase(A.begin(), A.begin()+i+2);
      break;
    }
  }
  ll height = 0ll;
  for (int i=0; i+1<A.size(); i++) {
    if (A.at(i)==A.at(i+1)) {
      height = A.at(i);
      break;
    }
  }
  cout << width*height << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<int>a(n);
  rep(i, n)cin>>a[i];

  queue<int> q;
  rep(i, k)q.push(a[i]);

  for(int i=k; i<n; i++){

    if(q.front()<a[i])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    q.pop();
    q.push(a[i]);
  }

  return 0;
}



Measured memory_bytes: 4752
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cassert>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
int N;
/*
int Sx[] = {0,0,1,-1};
int Sy[] = {1,2,1,1};

int Mx[] = {1,2,2,2,1,1,0,0};
int My[] = {0,0,1,2,1,2,1,2};

int Lx[] = {0,0,0,0,1,1,1,2,-1,-1,-1,-2};
int Ly[] = {1,2,3,4,1,2,3,2,1,2,3,2};
*/
struct P
{
  int x,y,type;
  P(int x = -1,int y = -1,int type = -1):x(x),y(y),type(type){}
};
int SMLx[3][12] = {{0,0,1,-1},{1,2,2,2,1,1,0,0},{0,0,0,0,1,1,1,2,-1,-1,-1,-2}};
int SMLy[3][12] = {{1,2,1,1},{0,0,1,2,1,2,1,2},{1,2,3,4,1,2,3,2,1,2,3,2}};
int SML[] = {4,8,12};
bool F;
int Cx[] = {0,1,0};
int Cy[] = {1,1,2};

void print(const VVI& G)
{
  cout << "print---" << endl;
  for(int i=0;i<10;i++)
    {
      for(int j=0;j<10;j++)
	{
	  cout << G[i][j] << " ";
	}
      cout << endl;
    }
  cout << endl;
}

bool check(VVI& G,int x,int y,int type)
{
  //cout << "check " << x << " " << y << endl;
  //print(G);
  G[y][x]--;
  for(int i=0;i<SML[type];i++)
    {
      int nx = x + SMLx[type][i];
      int ny = y + SMLy[type][i];
      if(!(0 <= nx && nx < 10 && 0 <= ny && ny < 10) || G[ny][nx] <= 0)
	{
	  G[y][x]++;
	  for(int j=i-1;j>=0;j--)
	    {
	      nx = x + SMLx[type][j];
	      ny = y + SMLy[type][j];
	      G[ny][nx]++;
	    }
	  return false;
	}
      G[ny][nx]--;
    }
  //cout << "after chec" << endl;
  //print(G);
  //cout << endl;
  return true;
}

void draw(VVI& G,int x,int y,int type)
{
  G[y][x]++;
  for(int i=0;i<SML[type];i++)
    {
      int nx = x + SMLx[type][i];
      int ny = y + SMLy[type][i];
      if(!(0 <= nx && nx < 10 && 0 <= ny && ny < 10))
	assert(false);	 	
      G[ny][nx]++;
    }
}


void dfs(VVI& G,int x,int y,int cnt,vector<P> perm)
{
  if(cnt > N)
    return;
  //cout << x << " "  << y << endl;
  
  //print(G);
  if(F)
    return;
    //return false;
    
  perm.push_back(P(-1,-1,-1));
  for(int i=y;i<10;i++)
    for(int j= (i == y?x:0);j<10;j++)
      if(G[i][j] >= 1)
	{
	  bool found = false;
	  for(int k=0;k<3;k++)
	    {
	      if(!check(G,j,i,k))
		continue;
	      perm[perm.size()-1] = P(j+Cx[k],i+Cy[k],k+1);
	      //found |= dfs(G,j,i,cnt+1,perm);
	      //cout << x << " " << y<< " goto " << j << " " << i << endl << endl; 
	      //print(G);
	      //cout << "goto ----" << endl << endl;
	      dfs(G,j,i,cnt+1,perm);
	      draw(G,j,i,k);
	    }
	  
	  //cout << x << " " << y << " -> "  << found << endl;
	  //return found;
	  return;
	}


  if(cnt == N  && !F)
    {
      for(int i=0;i<N;i++)
	{
	  cout << perm[i].x << " " << perm[i].y << " " << perm[i].type << endl; 
	}      
      assert(!F);
      F = true;
      //return true;
    }
  //else
  //assert(false);//決められた回数より少ない回数でおわっちゃった なんてある？
}

int main()
{
  F = false;
  cin >> N;
  assert(N <= 12);
  VVI G(10,VI(10));

  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      cin >> G[i][j];
  dfs(G,0,0,0,vector<P>());
  assert(F);
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	int first, second;
	first = max(a[0], a[1]);
	second = min(a[0], a[1]);
	for (int i = 2; i < n; i++) {
		if (a[i] > first) {
			second = first;
			first = a[i];
		} else if (a[i] > second)
			second = a[i];
	}
	for (int i = 0; i < n; i++) {
		cout << (a[i] == first ? second : first) << endl;
	}

}


Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

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

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll N,M;
vector<ll>A(106);

void batten(ll i,ll k){
	if(i==N)return;
	if((A[i]%k)>(A[i+1]%k)){
		swap(A[i],A[i+1]);
		batten(i+1,k);
		return;
	}else{
		batten(i+1,k);
		return;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N,M,K;
	cin>>N>>M>>K;
	for(int n=0;n<=N;n++){
		for(int m=0;m<=M;m++){
			ll num=n*M+m*N-2*n*m;
			if(num==K){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}



Measured memory_bytes: 768
let () = Printf.printf "%d\n" @@ 
  let array = Array.make 5 0 in
  for i=0 to 4 do
    if i < 4 then Scanf.scanf " %d" @@ fun x -> array.(i) <- x
    else Scanf.scanf " %d\n" @@ fun x -> array.(i) <- x
  done;
  List.find (fun i -> array.(i-1) = 0) @@
  List.init 5 (fun i -> i+1)

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n,m;cin >> n >> m;
  vector<vector<char>> a(n,vector<char>(n));
  vector<vector<char>> b(m,vector<char>(m));
  for(auto&i:a){
    for(auto&j:i) cin >> j;
  }
  for(auto&i:b){
    for(auto&j:i) cin >> j;
  }
  bool flag = false;
  rep(i,n){
    rep(j,n){
      flag = false;
      if(a[i][j]==b[0][0]&&j+m<=n&&i+m<=n){
        rep(s,m){
          rep(t,m){
            if(a[i+s][j+t]==b[s][t]) flag = true;
            else flag = false;
            if(!flag) break;
          }
          if(!flag) break;
        }
        if(flag){
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }

  cout << "No" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1e9+7;
const ll N = 1e6;

ll mod_pow(ll x,ll n,ll mod){
  if(n==0)return 1;
  ll res=mod_pow( x*x%mod , n/2 , mod );
  if( n & 1 )res = res*x%mod;
  return res;
}

ll fact[N];
ll infact[N];

void make_factorial(void){
  fact[0] = 1;
  for( ll i = 1 ; i < N ; i++ ){
    fact[i] = fact[i-1] * i;
    fact[i] %= MOD;
  }
  for( ll i = 0 ; i < N ; i++ ){
    infact[i] = mod_pow( fact[i] , MOD-2 , MOD );
  }
}

ll comb(ll a,ll b){
  if(a == 0 && b == 0)return 1;
  if(a < b || a < 0)return 0;
  ll tmp = infact[a-b]* infact[b] % MOD;
  return tmp * fact[a] % MOD; 
}

ll perm(ll a,ll b){
  if(a == 0 && b == 0)return 1;
  if(a < b || a < 0)return 0;
  return fact[a] * infact[a-b] % MOD;
}

int main(){
  ll n,k;
  cin >> n >> k;
  if(n > k){
    cout << 0 << endl;
    return 0;
  }
  make_factorial();
  cout << comb(k,k-n) * fact[n] % MOD << endl; 
  return 0;
}



Measured memory_bytes: 18764
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 1000003

long long n, sum;
long long dp[mx];

int main(){
	cin >> n;
	for(int i = n; i > 0; i--){
		long long &ret = dp[i];
		// debug(i);
		ret = 0;
		if(i == n){
			ret = n;
			sum = (sum + n) % MOD;
			// debug(ret);
			continue;
		}
		if(i == n - 1){
			ret = n * n % MOD;
			sum = (sum + ret) % MOD;
			// debug(ret);
			continue;
		}
		// naruh angka < n - i terus 1
		ret = sum;
		ret = (ret - dp[i + 2]) % MOD;
		ret = (ret + MOD) % MOD;
		// debug(ret);
		//naruh angka >= n - i terus bebas
		ret = (ret + (i + 1) * n) % MOD;
		// debug(ret);
		//naruh 1 < angka < n - i  terus selain 1
		ret = (ret + (n - i - 2) * (n - 1)) % MOD;
		sum = (sum + ret) % MOD;
		// debug(ret);
	}
	cout << dp[1] << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int main(void){
    string s;
    cin>>s;
    int n = s.size();
    if (n == 26) {
        if(s == "zyxwvutsrqponmlkjihgfedcba"){
            cout<<-1<<endl;
            return 0;
        }
        
        for(int i = 24; i>=0; i--){
            string next = s;
            next_permutation(next.begin()+i, next.end());
            if(s[i] == next[i]){
                cout<<string(next.begin(), next.begin()+i+2)<<endl;
                return 0;
            }
        }
        cout<<char(s[0] + 1)<<endl;

    } else {
        rep(i,26){
            bool used = false;
            for(char c : s){
                if(c == 'a'+i){
                    used = true;
                }
            }
            if(!used){
                s.push_back(char('a'+i));
                cout<<s<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

#define MAXI 1000000

struct NODE{
	int h, w;
	NODE(){h = w = 0;}
	NODE(int h, int w): h(h), w(w){}
	
	bool operator<(const NODE r){
		if(h * h + w * w != r.h * r.h + r.w * r.w) return h * h + w * w < r.h * r.h + r.w * r.w;
		return h < r.h;
	}
	
};

int main() {

	vector<NODE> vec;
	REP(i, 1, 151){
		REP(j, i+1, 151){
			vec.push_back(NODE(i, j));
		}
	}
	
	SORT(vec);
	
	
	int h, w;
	while(cin >> h >> w, h, w){
		int num = 0;
		while(vec[num].h != h || vec[num].w != w) num++;
		cout << vec[num+1].h << " " << vec[num+1].w << endl;
	}
	
	

	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

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

    cout << (1900*M + 100*(N-M))*pow(2, M) << endl;

    return 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())
a = list(map(int, input().split()))

if 0 in a:
  K = K - 1
  if K == 0:
    print('0')
    exit()

aLow = list(filter(lambda x: x < 0, a))
aLow = list(map(lambda x: abs(x), aLow))
aLow.sort()

aHigh = list(filter(lambda x: x > 0, a))

least = 99999999999999999

#print(aLow)
#print(aHigh)

for i in range(0,K+1):
  j = K - i
  if i > len(aLow) or j > len(aHigh):
    continue

  if i == 0:
    dist = aHigh[j-1]
  elif j == 0:
    dist = aLow[i-1]
  else:
    dist = min(2*aLow[i-1]+aHigh[j-1], aLow[i-1]+2*aHigh[j-1])

  if least > dist:
    least = dist

print(least)


Measured memory_bytes: 14480
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////


typedef pair <int, int> P;
 
const ll MOD=1000000007;
 
ll power(ll x, ll k, ll p){
    if (k==0) return 1;
    else if (k==1) return x%p;
    else if (k%2==0) return (power(x,k/2,p) * power(x,k/2,p))%p;
    else return (power(x,k/2,p) * power(x,k/2+1,p))%p;
}
 
ll dp[2][1010];
 
void solve() {
    ll N, M;
    cin >> N >>M;
    
    if (M==1){
        cout << 1<< endl;
    }
    else {
        int a=0;
        ll b=2;
        while (b<=1000){
            if (M%b==0){
                dp[0][a]=b;
                while (M%b==0){
                    M/=b;
                    dp[1][a]++;
                }
                a++;
            }
            b++;
        }
		if(M != 1) {
			dp[0][a] = M;
			dp[1][a] = 1;
			a++;
		}
        ll ans=1;
        if (a==0){
            cout << N << endl;
        }
        else {
            rep(i, 0, a){
                ll p=1;
                ll q=1;
                for (ll j=N ;j< dp[1][i]+N; j++){
                    p*=j;
                    p%=MOD;
                }
                for(ll j=1; j<dp[1][i]+1; j++){
                    q*=j;
                    q%=MOD;
                }
                ans*=(p*power(q, MOD-2, MOD)) % MOD;
                ans%=MOD;
            }
            cout << ans << endl;
        }
    }
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define MOD 1000000007
#define N 1000006
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define INF 1000000000000000000
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define randright srand(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;
// int my_rand(){ int a=rand(); int b=rand(); return a*(RAND_MAX+1)+b; }

#define int long long int

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}

int power(int a, int b, int m=MOD){
    int ans = 1;
    while (b > 0) 
    {
        if (b & 1) 
            ans = (ans*a)%m; 
        
        b = b>>1;
        a = (a*a)%m;
    }
    return ans;
}

int inv(int a, int m=MOD){
    return power(a,m-2,m);
}

void solve(){
    int n,k,ans=0;
    cin>>n>>k;
    //cout<<n<<" "<<k<<endl;
    vector<int> vals(k+1,0);
    for(int i=k; i>=1; i--){
        //cout<<i<<endl;
        int nums = 1;
        int sub = 0;
        for(int j=2; i*j<=k; j++){
            nums++;
            sub = (sub + vals[i*j])%MOD;
        }

        vals[i] = (power(nums, n) - sub + MOD)%MOD;
        //cout<<i<<" "<<nums<<" "<<vals[i]<<endl;
        ans = (ans + (i*vals[i]))%MOD;
    }
    cout<<ans<<"\n";
}

signed main(){
    fastio
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3988
# -*- coding:utf-8 -*-

import sys

def insertionSort(A,N):
    for i in range(N):
        v = A[i]
        j = i-1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
    return A

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

for i in range(1,n+1):
    A = insertionSort(A,i)
    for l in range(len(A)):
        if l == len(A)-1:
            print(A[l])
            break
        print(A[l], end=' ')
        

Measured memory_bytes: 8064
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if ( (a*b)%2 == 0 ) {
      System.out.println ("Even");
    } else {
      System.out.println ("Odd");
    }
  }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

#define MAX 2000000
#define INF (1<<30)

int h;
int a[MAX+1];

void maxHeapify(int i){
  int l = 2*i;
  int r = 2*i+1;
  int max = a[i];
  int index = i;
  if(l <= h && a[l] > max){max = a[l]; index = l;}
  if(r <= h && a[r] > max){max = a[r]; index = r;}
  if(index == l){
    swap(a[i], a[l]);
    maxHeapify(l);
  }
  else if(index == r){
    swap(a[i], a[r]);
    maxHeapify(r);
  }
}
// void maxHeapify(int i){
//   int l, r, largest;
//   l = 2*i;
//   r = 2*i+1;
//
//   if(l<=h && a[l]>a[i]) largest = l;
//   else largest = i;
//   if(r<=h && a[r]>a[largest]) largest = r;
//
//   if(largest != i){
//     swap(a[i], a[largest]);
//     maxHeapify(largest);
//   }
// }

int extract(){
  int maxv;
  if(h < 1) return -INF;
  maxv = a[1];
  a[1] = a[h--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  if(key < a[i]) return;
  a[i] = key;
  while(i > 1 && a[i/2] < a[i]){
    swap(a[i], a[i/2]);
    i = i/2;
  }
}

void insert(int key){
  h++;
  a[h] = -INF;
  increaseKey(h, key);
}

int main(){
  h = 0;
  
  while(1){
    string com; cin >> com;
    if(com == "insert"){
      int x; cin >> x;
      insert(x);
    }
    else if(com == "extract"){
      cout << extract() << endl;
    }
    else if(com == "end"){
      break;
    }
  }

  return 0;
}





Measured memory_bytes: 7016
#include<iostream>
#include<cstdio>
#define gmi(a,b) a=a<(b)?a:(b)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=1010;
int n,m,f[N][N];
char s[N][N];
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d",&n,&m);
	FOR(i,1,n) scanf("%s",s[i]+1);
	f[1][1]=s[1][1]=='#';
	FOR(i,1,n)FOR(j,1,m)if(i>1 || j>1){
		f[i][j]=n+m;
		if(i>1) gmi(f[i][j],f[i-1][j]+(s[i][j]=='#' && s[i-1][j]=='.'));
		if(j>1) gmi(f[i][j],f[i][j-1]+(s[i][j]=='#' && s[i][j-1]=='.'));
	}
	cout<<f[n][m]<<'\n';
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

ll d = 1e9+7;

ll madd(ll a, ll b){
    return (a + b) % d;
}

ll mpow(ll a, ll b){
    return (a*b) % d;
}

ll gyaku(ll n){
    ll e = d - 2;
    ll ret = 1;
    ll bai = n;
    while(e > 0){
        if(e%2 == 1){
            ret = mpow(ret, bai);
        }
        bai = mpow(bai, bai);
        e/=2;
    }
    return ret;
}

vector <int> primes;

vector <int> is_primes(1e6+10, 0);

map<int,int> soinsus(int n){
    map<int, int> ret;
    if (is_primes[n] > 0){
        n /= is_primes[n];
        ret[n]++;
    }
    for(auto p: primes){
        while (n%p == 0){
                ret[p]++;
                n /= p;

        }
    }
    if (n > 1){
        ret[n]++;
    }
    return ret;
}


int main(void){
    is_primes[0] = is_primes[1] = -1;
    for(int i=2; i<1e3+5; i++){
        if (!is_primes[i]){
            continue;
        }
        ll idx = i*2;
        while(idx < 1e3+5){
            is_primes[idx] = i;
            idx += i;
        }
    }
    REP(i, 1e3+5){
        if (is_primes[i] == 0){
            primes.push_back(i);
        }
    }
    ll n; cin >> n;
    vector <ll> as;
    REP(i, n){
        ll a; cin >> a; as.push_back(a);
    }
    map<int, int> koubai;
    REP(i, n){
        map<int, int> soinsu = soinsus(as[i]);
        for(auto p: soinsu){
            koubai[p.first] = max(p.second, koubai[p.first]);
        }
    }
    dump(as.size())
    ll kbi = 1;
    for(auto p: koubai){
        REP(_, p.second){
            kbi = mpow(kbi, p.first);
        }
    }
    dump(primes.size())
    ll ans = 0;
    REP(i, n){
        ans = madd(ans, mpow(kbi, gyaku(as[i])));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

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

    int n,k;
    cin>>n>>k;
    ll h[n];
    for(int i = 0; i<n; i++){
        cin>>h[i];
    }
    sort(h,h+n);
    ll ans =0;
    for(int i = 0; i<n-k; i++){
        ans+=h[i];
    }
    cout<<ans<<"\n";   
}

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << "a ";
    if(a<b) cout << "< ";
    if(a==b) cout << "== ";
    if(a>b) cout << "> ";
    cout << "b" << endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include<algorithm>
#include<cstdio>
#include<stack>
#include<vector>
using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int>> S2;

  char ch;
  int i = 1, j, sum = 0, a;
  while (scanf("%c", &ch) != EOF) {
    if (ch == '\\') S1.push(i);
    else if (ch == '/' && 0 < S1.size()) {
      j = S1.top(); S1.pop();
      sum += i - j;
      a = i - j;
      while (0 < S2.size() && j < S2.top().first) {
        a += S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(j, a));
    }
    i++;
  }

  printf("%d\n", sum);
  printf("%d", S2.size());

  vector<int> ans;
  while (0 < S2.size()) {
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(), ans.end());

  for (int idx = 0; idx < ans.size(); idx++)
    printf(" %d", ans[idx]);

  printf("\n");

  return 0;
}



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

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

  int main(){
       int k;
        cin >> k;
        int ans=0;
        rep(i,k)rep(j,k)rep(l,k){
            ans+=gcd(gcd(i,j),l);
        }
        cout << ans << endl;
        return 0;
    
  }

Measured memory_bytes: 3632
"use strict"
const Main = (input)=>{
	let xs = input.trim().split("\n");
    let N = xs[0].split(" ").map(Number);
    let A = xs[1].split(" ").map(Number);
    let B = xs[2].split(" ").map(Number);
    let C = xs[3].split(" ").map(Number);
    let ans = 0;  
      for(let i = 0; i < N; i++){
        ans += B[A[i]-1];
          if(i >= 1){
          let a = A[i];
          let b = A[i-1];
            if(a-b == 1){
            ans += C[A[i]-2];
            }
          }
        }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    int i,tmp,res;
    int n;
    cin >> n;
    tmp = (n+1)/2;
    cout << (double)tmp/(double)n << endl;
}

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

long long lucas(int n,vector<long long> &memo){
    if(n==0){
        return 2;
    }
    if(n==1){
        return 1;
    }
    if(memo.at(n) != -1){
        return memo.at(n);
    }
    return memo.at(n) = lucas(n-2,memo)+lucas(n-1,memo);
}

int main(){
    int n;
    long long ans;
    cin >> n;
    vector<long long> memo(n+1,-1);
    ans = lucas(n,memo);
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7

ans = 1
counter = [0] * 10**5
for i, a in enumerate(A):
    if a == 0:
        ans *= (3 - counter[a]) % mod
        counter[a] += 1
    else:
        ans *= (counter[a-1] -counter[a]) % mod
        counter[a] += 1

print(ans % mod)


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> V(M);
  for (int i = 0; i < M; i++)
    cin >> V.at(i);
  
  for (int j = 0; j < M; j++)
    N -= V.at(j);
  
  if (N < 0)
    cout << -1 << endl;
  else
    cout << N << endl;
  
     
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	// prepare data from args

	// first args
	int N{ 0 };
	int X{ 0 };

	cin >> N >> X;
	cin.ignore();

	// second args
	string s = "";
	getline(cin, s);
	
	string::size_type currentPos = 0;
	string::size_type pos = s.find(' ');
	vector<int> LenghtList;
	while (pos != string::npos)
	{
		string tmpL = s.substr(currentPos, pos);

		LenghtList.push_back(stoi(tmpL));
		currentPos = pos;
		pos = s.find(' ', pos + 1); // next delimitor
	}
	// last one
	string tmpL = s.substr(currentPos, pos);
	LenghtList.push_back(stoi(s));


	// calculation, num of bound starting from 1
	int bound = 1;
	int tmpX = X;
	for(int l : LenghtList)
	{
		tmpX = tmpX - l;
		if (tmpX < 0)
		{
			break;
		}
		
		bound++;
	}

	cout << bound;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int sumw[200001], sumt[200001];
int c[15], b[15];

int main() {

  int M, N; cin >> M >> N;
  rep(i, M) {
    scanf("%d%d", &sumw[i+1], &sumt[i+1]);
    sumw[i+1] += sumw[i];
    sumt[i+1] += sumt[i];
  }
  rep(i, N) {
    cin >> c[i] >> b[i];
  }

  int dp[1<<N]; zero(dp);

  rep(S, 1<<N) {
    rep(i, N) {
      if(S >> i & 1) { continue; }
      int k = upper_bound(sumw + dp[S], sumw + M + 1, c[i] + sumw[dp[S]]) - sumw - 1;
      int l = upper_bound(sumt + dp[S], sumt + M + 1, b[i] + sumt[dp[S]]) - sumt - 1;
      dp[S|(1<<i)] = max(dp[S|(1<<i)], min(k, l));
    }
  }

  cout << dp[(1<<N)-1] << endl;

  return 0;
}

Measured memory_bytes: 4788