akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	double w,h;
	for(;~scanf("%d,%lf,%lf",&n,&w,&h);){
		if(w/h/h>=25)cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
# A,B,C = [int(n) for n in input().split()]
# N = int(input())
S = str(input())
# T = str(input())
L = len(S)
ans = ""
begin = L
end = 0
for i in range(L):
    if(S[i] == "A" and begin == L):
        begin = i
    elif(S[i] == "Z" and begin != L):
        end = i+1

print(end - begin)


Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int x,n; cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    if(n == 0){
        cout << x << endl;
        return 0;
    }
    vector<bool> ex(105, false);
    rep(i,n){
        ex[p[i]] = true;
    }
    int tmp1 = 0, tmp2 = 0;
    RFOR(i, 0, x+1){
        if(!ex[i]){
            tmp1 = i;
            break;
        }
    }
    FOR(i,x,102){
        if(!ex[i]){
            tmp2 = i;
            break;
        }
    }
    if(abs(x - tmp1) > abs(x - tmp2)) cout << tmp2 << endl;
    else cout << tmp1 << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(10) << num << endl;
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    int x=(c+b-1)/b,y=(a+d-1)/d;
    if(x<=y) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        if(r < 1200)System.out.println("ABC");
        else if(r < 2800) System.out.println("ARC");
        else System.out.println("AGC");
    }
}

Measured memory_bytes: 35640
function timeCalc(){
    x = x - 0;
    var s = x % 60;
    var hm = ( x - s) / 60;
    var m = hm % 60;
    var h = Math.floor(x / 3600);
    console.log(h + ":" + m + ":" + s);
}

var x = require('fs').readFileSync('/dev/stdin', 'utf8');

timeCalc(x)


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

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 ll llINF = 1LL << 60;
const int iINF = 1e8;

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

    vector<int> stn(N);
    char c;
    rep(i,N){
        cin >> c;
        if(c=='R') stn[i] = 1;
        else stn[i] = 0;
    }

    int l=-1,r=-1;


    for(int i = 0; i<N ; i++){
        if(stn[i]==0){
            l = i;
            break;
        }
    }

    for(int i = N-1; i>=0 ; i--){
        if(stn[i]==1){
            r = i;
            break;
        }
    }

    if(l*r < 0){
        cout << 0 << endl;
        return 0;
    }


    int ans = 0;


    while(l<r){
        for(int i = l; i<N ; i++){
            if(stn[i]==0){
                l = i+1;
                break;
            }
        }

        for(int i = r; i>=0 ; i--){
            if(stn[i]==1){
                r = i-1;
                break;
            }
        }

        if(l-1>r) break;

        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4044
<?php
$s=trim(fgets(STDIN));
$k=trim(fgets(STDIN));
$n=strlen($s);
if($n==1){
  echo (int)(floor($k/2));
}else{
  $ans=0;
  $c=$s[0];
  $i=1;
  while($i<$n){
    if($c==$s[$i]){
      $c="OK";
      ++$ans;
    }else{
      $c=$s[$i];
    }
    ++$i;
  }
  if($k==1){
    echo $ans;
    exit;
  }
  if($c=="OK"){
    echo (int)($ans*$k);
    exit;
  }
  $ans2=0;
  $i=0;
  while($i<$n){
    if($c==$s[$i]){
      $c="OK";
      ++$ans2;
    }else{
      $c=$s[$i];
    }
    ++$i;
  }
  if($c=="OK"){
    echo (int)(($ans+$ans2)*floor($k/2))+($ans*($k%2));
    exit;
  }
  echo (int)($ans+$ans2*($k-1));
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    string ans = "";
    while(n != 0){
        if (n % 2 != 0){
            n--;
            ans = "1" + ans;
        }else{
            ans = "0" + ans;
        }
        n /= -2;
    }
    if (ans == "") ans = "0";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
n = int(input())
a, b = map(int, input().split(' '))
p = list(map(int, input().split(' ')))
x = y = z = 0
for i in range(n):
    if p[i] <= a:
        x += 1
    elif a + 1 <= p[i] <= b:
        y += 1
    else:
        z += 1
print(min([x, y, z]))


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int x, y;
  cin>>x>>y;
  int ans=0;
  if(x<=3){
    ans+=100000*(4-x);
  }
  if(y<=3){
    ans+=100000*(4-y);
  }
  if(x==1 && y==1){
    ans+=400000;
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a > mod)a %= mod;
}
ll dp[101][2];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
	int d;
	string s;
	cin>>s;
	cin>>d;
	int n = s(s);
	dp[0][0] = 1;
	rep(i,n){
		ll temp[d][2];
		rep(j,d){
			rep(k,2)temp[j][k] = 0;
		}
		rep(j,d){
			rep(k,2){
				rep(di,10){
					if(di > s[i]-'0'){
						if(k){
							add(temp[j][k],dp[(j-di+10*d)%d][k]);
						}
					}
					else if(di == s[i]-'0'){
						add(temp[j][k],dp[(j-di+10*d)%d][k]);
						// add()
					}
					else{
						add(temp[j][1],dp[(j-di+10*d)%d][k]);
					}
				}
			}
		}
		rep(j,d){
			rep(k,2){
				dp[j][k] = temp[j][k];
			}	
		}
	}
	ll ans = 0;
	rep(i,2){
		add(ans,dp[0][i]);
	}
	sub(ans,1ll);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
/*
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
      //////////////////////////////////////////
	 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

 Work hard in silence , let success make a noise!
	- The harder I work THE GREATER MY SUCCCESS -
	'''''''''''''''''''''''''''''''''''''''''
	|	XXX IOI 2018 - Tokyo Japan      |
	'''''''''''''''''''''''''''''''''''''''''
	 It's hard to beat a person who never gives up,
		 and this person can be you!

	  ///////////////////////////////////
       \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
||||||||||||||||||||||||||||||||||||||||||||||||||||||||


*/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define in freopen(".in", "r", stdin)
#define out freopen(".out", "w", stdout)

using namespace std;

const long long INF = (long long)1e17 + 7;
const long long Ln = (long long)1e12 + 7;
const int N = (int)1e6 + 7;
const int sz = (int)1e5 + 7;
const double PI = 3.141592;
const int MX = (int)1e9 + 7;

inline int max(int a, int b)
{
 	if (a > b)return a;

	return b;
}
inline int min(int a, int b)
{
 	if (a < b)return a;

	return b;
}

int a[2001];
main()
{
    int n, x, y;
    int mx = -1;
    cin >> n >> x >> y;

    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    mx = abs(y - a[n - 1]);

    if (n == 1 || mx > abs(a[n - 1] - a[n - 2]))
    {
        cout << max(mx, abs(a[n - 1] - y));
        return 0;
    }
    cout << max(mx, abs(a[n - 1] - a[n - 2]));
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  bool flag;
 
  cin >> s;
 
  sort(s.begin(),s.end());
 
  flag = (s[0]==s[1])&(s[1]!=s[2])&(s[2]==s[3]);
 
  cout << (flag?"Yes":"No") << endl;
 
  return 0;
}


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

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100010;
int a[N];

int main()
{
	int n;
	scanf("%d", &n);
	int mn = 1e9, mx = 0;
	Rep(i, n) {
		scanf("%d", &a[i]);
		mn = min(a[i], mn), mx = max(a[i], mx);
	}

	if (mx - mn >= 2) printf("No\n");
	else if (mn == mx && mx == n - 1) printf("Yes\n");
	else {
		int cnt = 0;
		if (mn == mx) mn = mx - 1;
		Rep(i, n) if (a[i] == mn) cnt ++;
		if (cnt + 1 <= mx && mx <= cnt + (n - cnt) / 2) printf("Yes\n");
		else printf("No\n");
	}
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int sum = 0;
  int hMax = 0;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    
    if (hMax <= h) {
      sum++;
      hMax = h;
    }
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){

    try {
      Scanner scan = new Scanner(System.in);
      String depth = scan.next();
      String width = scan.next();
      int a = Integer.parseInt(depth);
      int b = Integer.parseInt(width);
      int area = a * b;
      int circumference = 2 * (a + b);
      System.out.println(area + " " + circumference);
    } catch (NumberFormatException e) {
      System.out.println("数字が正しくありません");
    }
  }
}



Measured memory_bytes: 26140
import Control.Monad
import Data.Maybe (fromJust)
import Data.List as List

solve :: String -> Int
solve [] = 0
solve (x:[]) = 0
solve (x1:x2:xs)
    | x1 /= x2 = 1 + (solve (x2:xs))
    | otherwise = (solve (x2:xs))

main :: IO()
main = do
    c <- getLine
    print $ solve c


Measured memory_bytes: 5244
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
vector<vector<ll>>tree(200000);
map<ll,ll>ans;
void dfs(ll p,ll q){//qが親
 for(ll i:tree[p]){
  if(i!=q){
   ans[i]+=ans[p];
   dfs(i,p);
  }
 }
}
int main(){
 ll n,q;
 cin>>n>>q;
 ll a,b;
 rep(i,0,n-1){
  cin>>a>>b;
  push(tree[b],a);//bの親はa
  push(tree[a],b);
 }

 rep(i,0,q){
  cin>>a>>b;
  ans[a]+=b;
 }
 dfs(1,0);
 rep(i,0,n)cout<<ans[i+1]<<" ";
 pnn;
return 0;}


Measured memory_bytes: 48600
// C - Shopping Street
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int c(int open_pattern, vi &fi){
	int ret = 0;
	rp(j, 0, 10) if(open_pattern>>j & 1 && fi[j]) ret++;
	return ret;
}

int main(){
	int n; cin>>n;
	vvi F(n, vi(10));
	rp(i, 0, n) rp(j, 0, 10) cin>>F[i][j];
	vvi P(n, vi(10+1));
	rp(i, 0, n) rp(j, 0, 10+1) cin>>P[i][j];
	int64_t ans = -10000000*100;
	rp(i, 1, 1<<10){
		int64_t s = 0;
		rp(j, 0, n) s += P[j][c(i, F[j])];
		ans = max(ans, s);
	}
	cout<< ans <<endl;
}


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

int main () 
{
	char str [222];
 	scanf ("%s", str ) ;
 	int n= strlen (str ) ;
 	for (int i=n -2; i; i -=2) 
    {
 		if( strncmp (str , str +i/2 , i/2) ==0) 
        {
 			printf ("%d\n" ,i) ;
 			return 0;
 		}
 	}
 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define all(x) x.begin(),x.end()
#define MOD 1e9+7
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||

signed main(){
	acc_io;
	ll N,W;
	cin>>N>>W;

	vl weight(N+1),value(N+1);
	rep(i,1,N+1) cin>>weight[i]>>value[i];

	vl dp(1000*N+1,1e12);
	dp[0]=0;
	rep(i,1,N+1){
		for(int j=1000*N;j>=value[i];j--){
			dp[j]=min(dp[j],weight[i]+dp[j-value[i]]);
		}
	}
	ll ans=0;
	rep(i,0,1000*N+1){
		if(dp[i]<=W) ans=max(ans,i);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> path(n, vector<int>(n, 0));
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    path[a-1][b-1] = 1;
    path[b-1][a-1] = 1;
  }

  vector<int> route(n-1);
  for(int i = 0; i < n-1; i++) route[i] = i+1;

  int path_cnt = 0;
  
  do {
    bool exist = true;
    if(path[0][route[0]] == 1) {
      for(int i = 0; i < n-2; i++) {
        if(path[route[i]][route[i+1]] == 0) {
          exist = false;
          break;
        }
      }
      if(exist) path_cnt++;
    }
  } while(next_permutation(route.begin(), route.end()));

  cout << path_cnt << endl;

  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int result = 0;

		for (int i = 0; i < N; i++) {
			int val = sc.nextInt();
			if (val != (i + 1)) {
				result++;
			}
		}

		if(result == 0 || result == 2){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 22996
n = int(input())

an = list(map(lambda x :int(x)-1, input().split()))
bn = list(map(int, input().split()))
cn = list(map(int, input().split()))


ans = 0
before = n+1
for i in range(n):
    ans += bn[an[i]]

#    print( (before,an[i]))
    if before + 1 == an[i]:
#        print(cn[an[i]-1])
        ans += cn[ before ]

    before = an[i]
#    print((ans,before))

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;
const double EPS=1E-9;
bool gauss_jordan(const mat& A,const vec& b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];
  
  for(int i=0;i<n;i++)B[i][n]=b[i];
  
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++)if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    swap(B[i],B[pivot]);

    for(int j=0;j<n;j++)
      if(i!=j)
	for(int k=i+1;k<=n;k++)B[j][k]=(B[j][k]+B[j][i]*B[i][k])%2;
  }
  for(int i=0;i<n;i++)if(B[i][i]==0&&B[i][n]==1) return 0;
  return 1;
}

int h,w,d,mp[25][25];

int main(){
  while(1){
    cin>>w>>h>>d;
    if(!w&&!h&&!d)break;
    mat A(h*w,vec(h*w));
    vec B(h*w);
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin>>mp[i][j];
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	int idx=w*i+j;
	B[idx] = mp[i][j];
	for(int y=0;y<h;y++)
	  for(int x=0;x<w;x++){
	    int t = abs(i-y)+abs(j-x);
	    if(t==d||t==0)A[idx][w*y+x]=1;				
	  }
      }
    cout<<gauss_jordan(A,B)<<endl;
  }
  return 0;
}

Measured memory_bytes: 5920
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N, H;
    long a[100000];
    long b[100000];
    long sum = 0;
    cin >> N >> H;
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
    }
    sort(a, a+N, greater<long>());
    sort(b, b+N, greater<long>());
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(b[i] <= a[0]) break;
        sum += b[i];
        cnt++;
        if(sum >= H){
            cout << i+1 << endl;
            return 0;
        }
    }
    //cout << (H-sum) << ' ' << a[0] << endl;
    if((H-sum)%a[0] == 0){
        cout << cnt+(H-sum)/a[0] << endl;
    }else{
        cout << cnt+(H-sum)/a[0]+1 << endl;
    }
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.length() == 3) {
			if(S.equals("RRR")) {
				System.out.println("3");
			}else if(S.equals("RRS") || S.equals("SRR")) {
				System.out.println("2");
			}else if(S.equals("RSR") || S.equals("SRS") || S.equals("SSR") || S.equals("RSS")) {
				System.out.println("1");
			}else {
				System.out.println("0");
			}
		}
	}
}

Measured memory_bytes: 35748
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         char[] arr = infile.readLine().toCharArray();
         int res = 1;
         char ch = arr[0];
         for(int i=1; i < N; i++)
         {
            if(arr[i] != ch)
            {
               ch = arr[i];
               res++;
            }
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 24404
#include<stdio.h>
int main()
{
    int N,K,sum=0,x,h;
    scanf("%d %d",&N,&K);
    for (x=0;x<N;x++)
    {
    	scanf("%d",&h);
    	if (h>=K)
    	{
    		sum++;
		}
	}
	printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
def main():
    a = [chr(ord('a') + i) for i in range(26)]
    a.insert(0,"a")
    list = []
    num = int(input()) 

    while(num > 0):
        if(num % 26 == 0):
            list.append(26)
            num = num // 26 -1
            continue
        else:
            list.append(num % 26)
        num = num // 26

    list.reverse()

    ans = []
    for i in range(0,len(list)):
        ans.append(a[list[i]])
    print(''.join(ans))
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define X first
#define Y second
const int MN=150000+5;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<pll> v;
template<typename T>inline T IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n;
int t[MN][2];ll w[MN][2],mn[MN],mid;
vector<pll>f[MN];
inline bool cmpx(pll a,pll b){return a.X<b.X;}
inline bool cmpy(pll a,pll b){return a.Y<b.Y;}
void merge(v &ls,v &rs,v& u){
	int sl=ls.size(),sr=rs.size();if(sl>sr)swap(ls,rs),swap(sl,sr);
	sort(ls.begin(),ls.end(),cmpy),sort(rs.begin(),rs.end(),cmpx),mn[0]=rs[0].Y;
	for(int i=1;i<sr;++i)mn[i]=min(mn[i-1],rs[i].Y);
	for(int i=0,j=sr-1;i<sl;++i){
		while(j>=0&&ls[i].Y+rs[j].X>mid)j--;
		if(j>=0)u.push_back(pll(ls[i].X,mn[j]));
	}
	sort(ls.begin(),ls.end(),cmpx),sort(rs.begin(),rs.end(),cmpy),mn[0]=rs[0].X;
	for(int i=1;i<sr;++i)mn[i]=min(mn[i-1],rs[i].X);
	for(int i=0,j=sr-1;i<sl;++i){
		while(j>=0&&ls[i].X+rs[j].Y>mid)j--;
		if(j>=0)u.push_back(pll(mn[j],ls[i].Y));
	}
}
void dfs(int u){
	if(!f[u].empty())f[u].clear();
	if(t[u][0]+t[u][1]==0)return f[u].push_back(pll(0,0)),void();
	for(int i=0,v;i<2;++i)if(v=t[u][i]){
		dfs(v);
		for(int j=0;j<f[v].size();++j)f[v][j].X+=w[u][i],f[v][j].Y+=w[u][i];
	}
	merge(f[t[u][0]],f[t[u][1]],f[u]);f[t[u][0]].clear(),f[t[u][1]].clear();
}
void input(){
	IN(n);
	for(int i=2,x;i<=n;++i){
		IN(x);
		if(t[x][0])t[x][1]=i,IN(w[x][1]);
		else t[x][0]=i,IN(w[x][0]);
	}
	ll l=0,r=1e10;
	while(l<r){
		mid=l+r>>1;dfs(1);
		if(f[1].empty())l=mid+1;
		else r=mid;
	}
	printf("%lld\n",l);
}
int main(){
	input();
	return 0;
}

Measured memory_bytes: 30452
A, B = map(int, input().split())

# ans = 0
# for i in range(A, B + 1):
#     ans ^= i

# print(ans)

if A == B:
    print(A)
    exit()

if A % 2 == 0 and B % 2 == 1:
    if (A & 2) == (B & 2):
        print(1)
    else:
        print(0)

    exit()

if A % 2 == 0 and B % 2 == 0:
    temp = 0
    if (A & 2) != (B & 2):
        temp = 1

    print(B + temp)
    exit()

if A % 2 == 1 and B % 2 == 1:
    temp = 0
    if (A & 2) != (B & 2):
        temp = 1

    print(A - temp)
    exit()

temp = 0
if (A & 2) == (B & 2):
    temp = 1

xo = A ^ B
print(xo - temp)


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

int main() {
  int X;
  cin >>X;
  
  int syou = X/100;
  int amari = X%100;
  
  int ans=0;
  
  if(amari<=syou*5)ans =1;
  
  cout << ans << endl;
}

Measured memory_bytes: 3564
/*
 * ABC093_B.cpp
 *
 *  Created on: May 21, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



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

	int A, B, K;
	cin >> A >> B >> K;

	if(2*K >= B-A+1) {
		FOR(i, A, B) cout << i << "\n";
		cout << endl;
		return 0;
	}

	REP(i, K) {
		cout << A+i << "\n";
	}
	REP(i, K) {
		cout << B-K+1+i << "\n";
	}
	cout << endl;
}






Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int main(){
  string str;
  int len;


  while( cin >> str ){
  
    reverse(str.begin(),str.end());
    //len = str.length();
    /*
  for(int i=len;i>=0;i--){
    cout << str[i];
    
  }
    */
    cout << str<<endl;

  

  }
}

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

int main(void){
    char X, Y;
    cin >> X >> Y;
    if(X<Y)
        cout << "<" << endl;
    else if(X>Y)
        cout << ">" << endl;
    else
        cout << "=" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int N, M, K, S, A[10][10];
 
  cin >> N >> M >> K >> S;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
 
  int v[11] = {}, r[11] = {};
 
  auto getCol = [&](int x)
  {
    for(int i = 0; i < N; i++) v[i + 1] = A[i][x] + v[i];
    r[N] = v[N];
    for(int i = N - 1; i >= 0; i--) r[i] = max(r[i + 1], v[i + 1]);
    int ret = 0;
    for(int i = 0; i < N; i++) ret = max(ret, r[i] - v[i]);
    return (ret);
  };
 
 
  auto getRow = [&](int y)
  {
    for(int i = 0; i < M; i++) v[i + 1] = A[y][i] + v[i];
    r[M] = v[M];
    for(int i = M - 1; i >= 0; i--) r[i] = max(r[i + 1], v[i + 1]);
    int ret = 0;
    for(int i = 0; i < M; i++) ret = max(ret, r[i] - v[i]);
    return (ret);
  };
 
 
  int a = 0, b = 0;
  vector< int > latte, malta;
  for(int i = 0; i < M; i++) {
    if(getCol(i) > S) ++a, latte.emplace_back(i);
  }
  for(int i = 0; i < N; i++) {
    if(getRow(i) > S) ++b, malta.emplace_back(i);
  }
 
  if(a > K || b > K) {
    cout << "No" << endl;
    return (0);
  }
 
  vector< pair< int, int > > vs;
  for(int i = 0; i < M; i++) {
    if(getCol(i) > S) for(int j = 0; j < N; j++) vs.emplace_back(j, i);
  }
  for(int i = 0; i < N; i++) {
    if(getRow(i) > S) for(int j = 0; j < M; j++) vs.emplace_back(i, j);
  }
  sort(begin(vs), end(vs));
  vs.erase(unique(begin(vs), end(vs)), end(vs));
 
  int dep = 0;
  function< bool(int, int) > dfs = [&](int idx, int sz)
  {
    ++dep;
    if(dep >= 1145141) {
      cout << "No" << endl;
      exit(0);
    }
    if(idx == vs.size()) {
      for(int i : latte) if(getCol(i) > S) return (false);
      for(int i : malta) if(getRow(i) > S) return (false);
      return (true);
    }
    for(int i : malta) {
      if(vs[idx].first <= i) break;
      if(getRow(i) > S) return (false);
    }
    if(sz + 1 <= K) {
      if(A[vs[idx].first][vs[idx].second] > 0) {
        A[vs[idx].first][vs[idx].second] *= -1;
        if(dfs(idx + 1, sz + 1)) return (true);
        A[vs[idx].first][vs[idx].second] *= -1;
      }
    }
    return (dfs(idx + 1, sz));
  };
 
 
  if(dfs(0, 0)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3160
n=int(input())
t=[]
tt=[]
for _ in range(n):
  T=int(input())
  t.append(T)
for i in range(n):
  if t[i] not in tt:
    tt.append(t[i])
import fractions
ans=tt[0]
for i in range(1,len(tt)):
  ans=ans*tt[i]//fractions.gcd(ans,tt[i])
print(ans)

Measured memory_bytes: 5432
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(){
    int a ,b;
    scanf("%d%d",&a,&b);
    if ((a+b) %2 !=0){
        printf("%d\n",(a+b+1)/2);
    }
    else{
        printf("%d\n",(a+b)/2);
    }

    return 0;
}


Measured memory_bytes: 128
N = gets.to_i
hist = Hash.new {|h, k| h[k] = 0 }
A = gets.split.map {|l|
  a = l.to_i
  hist[a-1] += 1
  hist[a] += 1
  hist[a+1] += 1
  a
}
x, max = hist.to_a.sort {|a, b| a[1]<=>b[1] }.last
puts max


Measured memory_bytes: 20504
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>

using std::endl;

#define ll long long int
#define FOR(a, s, n) for(int a = s; a < n; ++a)
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define MOD 1000000007
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std
#define asn ans

struct edge
{
	ll min;
	ll max;
};

ll N, buf, ans;
ll Data[300];

int main()
{
	IN >> N;

	LEP(a, N)
	{
		IN >> buf;

		while (1)
		{
			if (buf % 2 == 1) break;
			buf /= 2;
			Data[a]++;
		}

	}

	ans = INF;

	LEP(a, N)
	{
		ans = std::min(ans, Data[a]);
	}

	OUT << ans << endl;

	return 0;
}

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

#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
typedef unsigned long long ull;

const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
const int bb=13331;
ll a,b,c,d,n,m;

int main()
{
    //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>a>>b;
    c=0;
    while(1+(a-1)*c<b)c++;
    cout<<c<<endl;
    
}

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

int main () {

  int D, N;
  cin >> D >> N;
  
  if ((D == 0) && (N ==100)) cout << 101 << endl;
  else if (D == 0) cout << N << endl;
  else if ((D == 1) && (N == 100)) cout << 10100 << endl;
  else if (D == 1) cout << N*100 << endl;
  else if ((D == 2) && (N == 100)) cout << 1010000 << endl;
  else cout << N* 10000 << endl;
}

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

int main(){
  int w,h;
  while(cin>>w>>h,w+h){
    vector<vector<int> > wall_side(h,vector<int>(w-1));
    vector<vector<int> > wall_ud(h-1,vector<int>(w));
    vector<vector<int> > map(h,vector<int>(w,0));
    for(int i=0;i<2*h-1;i++){
      if(i%2==0){
	for(int j=0;j<w-1;j++)
	  cin>>wall_side[i/2][j];
      }else{
	for(int j=0;j<w;j++)
	  cin>>wall_ud[i/2][j];
      }
    }
    queue<int> q;
    int x=0;
    int y=0;
    q.push(y*w+x);
    map[y][x]=1;

    while(!q.empty()){
      x=q.front()%w;
      y=q.front()/w;
      q.pop();
      //up
      if(y-1>=0 && !wall_ud[y-1][x] && map[y-1][x]==0){
	q.push((y-1)*w+x);
	map[y-1][x]=map[y][x]+1;
      }
      //down
      if(y+1<h && !wall_ud[y][x] && map[y+1][x]==0){
	q.push((y+1)*w+x);
	map[y+1][x]=map[y][x]+1;
      }
      //left
      if(x-1>=0 && !wall_side[y][x-1] && map[y][x-1]==0){
	q.push(y*w+x-1);
	map[y][x-1]=map[y][x]+1;
      }
      //right
      if(x+1<w && !wall_side[y][x] && map[y][x+1]==0){
	q.push(y*w+x+1);
	map[y][x+1]=map[y][x]+1;
      }
    }
    /*
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)
	printf("%02d ",map[i][j]);
      cout<<endl;
      }*/
    cout<<map[h-1][w-1]<<endl;

  }
  return 0;
}

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

int N, M;
const int MAX_M = 1.0e5 + 100;
pair<int, int> ba[MAX_M];

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

    sort(ba, ba+M);

    int ans = 1;
    int bridge = ba[0].first - 1;
    for (int i = 1; i < M; i++) {
        if (bridge < ba[i].second) {
            ans++;
            bridge = ba[i].first - 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        int s;
        s=min(a+b,min(b+c,a+c));
        cout<<s<<endl;
    }
    return 0;
}


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

int main() { 
    int h, w, k, ans = 1000000;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    
    for(int bit = 0; bit < (1 << (h - 1)); ++bit) {
        int n = 0;
        vector<int> group(h, 0);
        for (int i = 0; i < h - 1; ++i) {
            if (bit & (1<<i)) {
                group[i+1] = group[i] + 1;
                n++;
            } else {
                group[i+1] = group[i];
            }
        }
        int cut = n, l = 0;
        vector<int> one(n+1, 0);
        for(int i = 0; i < w; ++i) {
            for(int j = 0; j < h; ++j) {
                one[group[j]] += s[j][i] - '0';
                if(one[group[j]] > k) {
                    one = vector<int>(n+1, 0);
                    cut++;
                    i--;
                    if(cut >= 1010) i = w, j = h;
                    break;
                }
            }
        }
        ans = min(ans, cut);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<long long> x, y;
  REP(_, n) {
    int xi, yi; cin >> xi >> yi;
    if (xi != 0 || yi != 0) {
      x.emplace_back(xi);
      y.emplace_back(yi);
    }
  }
  n = x.size();
  vector<int> idx(n);
  iota(ALL(idx), 0);
  sort(ALL(idx), [&](int a, int b) { return atan2(y[a], x[a]) < atan2(y[b], x[b]); });
  REP(i, n) {
    x.emplace_back(x[i]);
    y.emplace_back(y[i]);
  }
  long long ans = 0;
  REP(i, 2 * n) FOR(j, i, min(i + n, 2 * n)) {
    long long X = 0, Y = 0;
    FOR(k, i, j + 1) {
      X += x[idx[k % n]];
      Y += y[idx[k % n]];
    }
    ans = max(ans, X * X + Y * Y);
  }
  printf("%.11f\n", sqrt(ans));
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

swap(int *a, int *b) {
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

int main() {
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b) {
		swap(&a, &b);
	}
	if (b > c) {
		swap(&b, &c);
	}
	if (a > b) {
		swap(&a, &b);
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],s[n];
	for(int i=0;i<n;i++){
	cin>>a[i];
	s[i]=a[i];
	}
	sort(s,s+n);
	for(int i=0;i<n;i++){
		if(a[i]<s[n/2])cout<<s[n/2]<<endl;
		else cout<<s[n/2-1]<<endl;
	}
}

Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

LL inputValue(){
  LL a;
  cin >> a;
  return a;
};

string inputString(){
  string a;
  cin >> a;
  return a;
};

vector<LL> inputVector(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> inputVectorString(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> inputVector2D(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 0
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, vector<LL>& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, vector<string>& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, vector<vector<LL>>& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, char* s) {
  cout << line << ":" << name << ":char* " << s << endl;;
}
#else
#define debug(n)
#endif

const LL cut = 1000000007;

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code
  LL n = inputValue();
  LL k = inputValue();
  auto a = inputVector(n);
  // inside n;
  debug(n);
  debug(k);
  debug(a);
  LL out = 0;
  REP(i, n-1) {
    REPD(j,i, n) {
      if (a[i] > a[j]) {
        out++;
      }
    }
  }
  debug(out);
  out%=cut;
  out*=k;
  out%=cut;
  LL out2=0;
  REP(i, n) {
    REP(j, n) {
      if (a[i] > a[j]) {
        out2++;
        debug(a[i]);
        debug(a[j]);
        debug("---");
      }
    }
  }
  debug(out2);
  LL out3 = 0;
  /*
  REP(i,k) {
    out3+=i;
    out3%=cut;
  } */
  out3 =(k-1)*k/2;
  debug(out3);
  out += ((out2%cut)*(out3%cut)%cut);
  cout << (out%cut) << endl;
  return 0;
}


Measured memory_bytes: 384
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    N, M = map(int, sys.stdin.readline().split())
    L = sorted([ int(sys.stdin.readline()) for _ in range(N)])
    #print(L)

    ans = 10 ** 10
    for i in range(N - M + 1):
        #print(L[i + (M - 1)])
        ans = min(L[i + (M - 1)] - L[i], ans)
    print(ans)

Measured memory_bytes: 10476
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    map<char, int> mp;
    for(auto &x : s){
        mp[x]++;
    }
    bool ok = true;
    for(auto &i : mp){
        ok &= (mp[i.F] % 2 == 0);
    }
    if(ok){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N=int(input())
X=list(map(int,input().split()))
A=sorted(X)
mid1=A[N//2-1]
mid2=A[N//2]
for i in range(N):
    if X[i]<=mid1:
        print(mid2)
    else:
        print(mid1)
        


Measured memory_bytes: 85972
#include <stdio.h>
#include <string.h>
int main(void)
{
    char S[11];
    scanf("%s", S);
    if (strcmp(S, "hi") == 0) {
        printf("Yes");
    }
    else if (strcmp(S, "hihi") == 0) {
        printf("Yes");
    }
    else if (strcmp(S, "hihihi") == 0) {
        printf("Yes");
    }
    else if (strcmp(S, "hihihihi") == 0) {
        printf("Yes");
    }
    else if (strcmp(S, "hihihihihi") == 0) {
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=10010;
int n,arr[20],sum;
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++) cin>>arr[i];
  sort(arr+1,arr+1+n);
  for(int i=1;i<n;i++) sum+=arr[i];
  if(sum>arr[n]) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
int n, m, q;
int d[N], f[N], r[N], u[N];
vector<int> e;

int main(){
	mset(r, -1);
	cin>>n>>m>>q;
	rep(i, q) cin>>d[i];
	rep(i, q) d[i]--;
	reverse(d, d+q);
	rep(i, q){
		int x = d[i];
		if(r[x]==-1){
			r[x] = e.size();
			e.push_back(x);
			f[0]++;
		} else {
			int y = r[x];
			int lb = 0, ub = n-1; // (lb, ub]
			while(ub-lb>1){
				int md = (lb+ub+1)/2;
				(f[md]>y?lb:ub)=md;
			}
			if(f[ub]==y) f[ub]++;
		}
	}
	//rep(i, n) cerr<<f[i]<<" "; cerr<<endl;
	//rep(i, e.size()) cerr<<e[i]<<" "; cerr<<endl;
	rep(i, f[n-1]) u[e[i]] = 1;
	for(int i = 0, j = f[n-1]; i < m && j < f[0]; i++){
		if(u[i]==0){
			if(e[j]!=i){
				cout<<"No"<<endl;
				return 0;
			} else j++;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 1912