akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}

int main(){
       ll x,n;
       cin>>x>>n;
       vi a(n);
       map<int,ll> m;
       rep(i,0,n,1)cin>>a[i],m[a[i]]++;
       sort(a.begin(),a.end());
       if(m.find(x)==m.end()){
        cout<<x<<endl;
       }
       else{
           ll d=0;
           ll max1=x;
           for(int i=1;i<=101;i++){
                if(m.find(i)==m.end()){
                    ll s=abs(x-i);
                    if(max1>s){
                        max1=s;
                        d=i;
                    }

                }
           }
           cout<<d<<endl;
       }

}


// 1 2 3 1 5 3 1 0 1 0 2
// 1 2 3 4 5 6 7 8 9 10 11






Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s,t;
  	cin>>s>>t;
  	ll i,as=0,ac=1,bs=0,bc=1,n=s.size();
  	vector<int> a(27),b(27);
  
  	for(i=0;i<n;i++){
		a[s[i]-'0'-49]++;
		b[t[i]-'0'-49]++;
    }
  	
  	for(i=0;i<26;i++){
      	  as+=a[i];
      	  bs+=b[i];
		if(a[i]!=0){
          ac*=a[i];
        }
      	if(b[i]!=0){
          bc*=b[i];
        }
    }
  
  
  	if(as==bs &&ac==bc){
		cout<<"Yes"<<endl;
    }else{
		cout<<"No"<<endl;
    }

}

Measured memory_bytes: 904
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int solve(int n, int a, int b, int c, int x) {
    vector<int> y(n);
    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }
    int ret = -1;
    for (int i = 0, j = 0; i < n && j < 10001; j++) {
        if (x == y[i]) i++;
        x = (a*x+b)%c;
        if (i == n) ret = j; 
    }
    return ret;
}

int solve(int N) {
    int ret = 0;
    vector<string> vs(N);
    for (int i = 0; i < N; i++) {
        cin >> vs[i];
    }
    bool down = true;
    int left = 0;
    int right = 0;
    vector<string> steps = {"lu", "ld", "ru", "rd"};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++) {
            if (steps[j] == vs[i]) {
                if (j == 0) {
                    left = 1;
                } else if (j == 1) {
                    left = 0;
                } else if (j == 2) {
                    right = 1;
                } else {
                    right = 0;
                }
            }
        }
        if (down) {
            if (right + left == 2) {
                down = false;
                ret++;
            }
        } else {
            if (right + left == 0) {
                down = true;
                ret++;
            }
        }
    }
    return ret;
}

int main(){
    int N;
    vector<int> ans;
    while (1) {
        cin >> N;
        if (!N) break;
        ans.push_back(solve(N));
    }
    for (auto &i: ans) {
        cout << i << endl;
    }

    return 0;
}





Measured memory_bytes: 3188
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

#コンビネーション
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = 2 * 10 ** 5 + 100  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


h, w, a, b = MAP()
ans = 0
for i in range(1, h - a + 1):
    debug(i, b + i - 2, i - 1, w - b + h - i - 1, h - i)
    debug(cmb(b + i - 2, i - 1), cmb(w - b + h - i - 1, h - i))
    ans += cmb(b + i - 2, i - 1) * cmb(w - b + h - i - 1, h - i) % mod
    ans %= mod
print(ans)



Measured memory_bytes: 102636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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 LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    int x;
    
    cin >> x ;
    
    cout << 48-x << endl;
    
    
    

    
/////////////////////////////////////////////////////
return 0;}

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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        s[i]+=n;
        if(s[i]>90){
            s[i]-=26;
        }
    }
    for(int i=0;i<s.size();i++){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  uint64_t N, K;
  cin >> N >> K;
  vector<int> A(N + 1);
  map<int, int> X, Y;
  for (int i = 1; i <= N; i++) {
    cin >> A.at(i);
  }
  X[0] = 1;
  for (int i = 0; i < N + 1; i++) {
    X[i + 1] = A.at(X.at(i));
  }
  int a;
  for (int i = 0; i < N + 1; i++) {
    Y[X[i]]++;
    if(Y[X.at(i)] == 2) {
      a = X.at(i);
      break;
    }
  }
  int first, second;
  for (int i = 0; i < N + 1; i++) {
    if(X.at(i) == a) {
      first = i;
      break;
    }
  }
  for (int i = first + 1; i < N + 1; i++) {
    if(X.at(i) == a) {
      second = i;
      break;
    }
  }
  int ans;
  if (K <= N + 1) {
    ans = X.at(K);
  }
  else {
    int res = (K - first) % (second - first);
    ans = X.at(first + res);
  }
  cout << ans << endl;
}

Measured memory_bytes: 22628
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll N;

ll th = 26000000000000001;

vector<ll> p, v;

void init(){
    ll tmp = 1;
    ll sum = 0;
    while(tmp <= th){
        p.push_back(tmp);
        v.push_back(sum);
        tmp *= 26;
        sum += tmp;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    init();
    
    ll M = N;
    int len;
    for(int i = 0; i < v.size(); i++){
        ll m = v[i];
        if(m >= N){
            len = i;
            M -= v[i-1];
            break;
        }
    }
    M--;
    for(int i = len-1; i >= 0; i--){
        ll m = p[i+1];
        ll tmp = (M%m)/p[i];
        cout << (char)('a'+tmp);
    }
    cout << endl;
}

Measured memory_bytes: 3652
#include <iostream> // cout, endl, cin
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <cstdio> // printf
#include <map> // map


using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);

  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=0;i<n;i++){
    cin>>q[i];
  }
  vector<int> a(n);
  for(int i=0;i<n;i++){
    a[i]=i+1;
  }
  map<vector<int>, int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
  return 0;
}
    
    
    
  
  
  
  
  
  
  
  
  
  
  


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
using ll = long long;

const int INF = 1001001001;

int main()
{
	int n, a;
	cin>>n;
	rep(i, n){
	    cin>>a;
	    if(a%2==0){
	        if(a%3==0||a%5==0){
	            continue;
	        }else{
	            cout<<"DENIED"<<endl;
	            return 0;
	        }
	    }
	}
	
	cout<<"APPROVED"<<endl;
	
}

Measured memory_bytes: 256
#include <stdio.h>

#define min(x, y) x<y ? x : y

int main(void){

    long n, a, b, res;
    scanf("%ld %ld %ld", &n, &a, &b);

    res = ((n/(a+b))*a);
    res += min(a, (n%(a+b)));
    printf("%ld\n", res);

    return 0;
}

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

int main(){
long long int n;
  cin >> n;
  string s = to_string(n);
  long long int tmp=0;
  //cout << s << endl;
  rep(i,s.size())tmp += (int)(s.at(i)-48);
  if(n%tmp==0) cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N; cin >> N;
    vector<int> A(N) , B(N), C(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    ll ans = 0;

    for(int i = 0; i < N; i++){
        ll a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        ll c = C.end() - upper_bound(C.begin(), C.end(), B[i]) ;
        ans += a * c;
    }
    cout <<ans <<endl;
}

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

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

int ans, N, A;

int main() {
    cin >> N;
    cin >> ans;
    for (int i=1; i<N; ++i) {
        cin >> A;
        ans = gcd(ans, A);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var sum = 0
    var n = N
    while(true) {
      sum += n%10
      n /= 10
      if(n == 0){
        break
      }
    }
    if(N%sum != 0) {
      println("No")
    } else {
      println("Yes")
    }
}

Measured memory_bytes: 29644
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
#define INF INT_MAX
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();
int n;


int f(ll x,ll y){
    int ma=-1;
    rep(i,32){
        if((x%3)==1 and (y%3)==1)chmax(ma,(int)i);
        x/=3;y/=3;
    }
    if(ma==-1)return 0;
    ll res=1;
    rep(i,ma)res*=3;
    return res;
}
vec to_3(ll x){
    vec res;
    rep(i,32){
        res.pb(x%3);x/=3;
    }
    // reverse(all(res));
    return res;
}

vector<vec> ans;
void dfs(int n,int m,int s,vec &x){
    if(n==m)ans.pb(x);
    else
    rep(i,s+2){
        vec tmp=x;
        tmp.pb(i);
        dfs(n+1,m,max((int)i,s),tmp);
    }
}
main(){
    ios
    int n=in();
    vec v;
    dfs(0,n,-1,v);
    sort(all(ans));
    for(auto e:ans){
        for(auto c:e){
            cout<<(char)('a'+c);
        }
        cout<<endl;
    }
}




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

using namespace std;

typedef long long ll;

// mod calc
const ll MOD = 1e9 + 7;

ll powmod(ll a, ll b){
  if(b == 0) return 1;
  if(b % 2 == 1) {
    return a * powmod(a, b - 1) % MOD;
  } else {
    ll d = powmod(a, b / 2) % MOD;
    return d * d % MOD;
  }
}

ll inv(ll a){
	return powmod(a, MOD - 2);
}

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

ll LCM(ll a, ll b){
	ll d = gcd(a, b);
	ll t = a * inv(d);
	t %= MOD;
	t *= b;
	t %= MOD;

	return t;
}

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

	int n;
	cin >> n;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	if(n == 1){
		cout << 1 << endl;
		return 0;
	}

	unordered_map<ll, ll> mp[n];	
	rep(i, n){
		int x = a[i];
		for(int d = 2; d * d <= x; d++){
			while(x % d == 0){
				if(mp[i].count(d) == 0) mp[i][d] = 0;				
				mp[i][d]++;
				x /= d;
			}
		}

		if(x > 1){
			if(mp[i].count(x) == 0) mp[i][x] = 0;
			mp[i][x]++;
		}
	}

	unordered_map<ll, ll> mp_all;
	rep(i, n){
		for(auto p : mp[i]){
			ll k = p.first;
			ll v = p.second;
			if(mp_all.count(k) == 0) mp_all[k] = 0;
			mp_all[k] = max(mp_all[k], v);
		}
	}

	ll ans = 0;
	rep(i, n){
		ll t = 1;
		for(auto p : mp_all){
			ll k = p.first;
			ll v = p.second;

			if(mp[i].count(k) > 0){
				v -= mp[i][k];
			}

			t *= powmod(k, v);
			t %= MOD;
		}

		ans += t;
		ans %= MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3328
//Solution for aoj:0212 Highway Express Bus
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
typedef pair<int, int>P;
typedef pair < P, int > PP;
#define f first
#define s second

//struct S {
//	int cost, to, num;
//	S(int c, int t, int n) : cost(c), to(t), num(n){}
//	bool operator>(const S &s) const {
//		return cost > s.cost;
//	}
//};

const int INF = 1 << 29;
int c, n, m, s, d, ans;
int tocost[1000][11];
vector<P> town[1000];
priority_queue<PP, vector<PP>, greater<PP> > pq;


void dijkstra(){
	while (!pq.empty()){
		PP a = pq.top();
		pq.pop();
		for (int i = 0; i < town[a.f.s].size(); i++){
			int tt = town[a.f.s][i].f, cc = town[a.f.s][i].s;
			if (tocost[tt][a.s] > cc + a.f.f){
				tocost[tt][a.s] = cc + a.f.f;
				pq.push({ { cc + a.f.f, tt }, a.s });
			}
			if (a.s&&tocost[tt][a.s-1] > cc/2 + a.f.f){
				tocost[tt][a.s-1] = cc/2 + a.f.f;
				pq.push({ { cc / 2 + a.f.f, tt }, a.s - 1 });
			}
		}
	}
}
	int main(){
		while (cin >> c >> n >> m >> s >> d&&c&&n&&m&&s){
			for (int i = 0; i < 1000; i++)
				fill(tocost[i], tocost[i] + 11, INF);
			tocost[s][c] = 0;
			ans = INF;
			while (pq.size())
				pq.pop();
			for (int i = 0; i < 1000; i++)
				town[i].clear();
			for (int i = 0; i < m; i++){
				int a, b, c;
				cin >> a >> b >> c;
				town[a].push_back({ b, c });
				town[b].push_back({ a, c });
			}
			pq.push({ { 0, s }, c });
			dijkstra();
			for (int i = 0; i <= c; i++)
				ans = min(ans, tocost[d][i]);
			cout << ans << endl;
		}
		return 0;
	}

Measured memory_bytes: 1296
#include<bits/stdc++.h>
using namespace std;
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();
const int mod = 1e9 + 7;
int dp[(1 << 21)];
bool ok[22][22];
int main () { _read(); 

      int n;
      cin >> n;
      for( int i = 0; i < n; ++i) {
            for( int j = 0; j < n; ++j) {
                  cin >> ok[i][j];
            }
      }
      dp[0] = 1;
      for( int mask = 0; mask < ( 1 << n ) - 1; mask++) {
            int man = __builtin_popcount(mask);
            for( int bit = 0; bit < n; bit++) {
                  if((mask >> bit) &1 ) continue;
                  if(!ok[man][bit]) continue;
                  (dp[mask|(1 << bit)] += dp[mask]) %= mod;
            }
      }
      cout << dp[(1 << n) - 1] << '\n';
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


Measured memory_bytes: 11792
#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>;

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.length() - 1; i++)
    {
        if (S[i] == S[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
        
    }
    cout << "Good" << endl;
  return 0;
}


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

int main() {
  string S;
  cin >> S;

  if ((S[0] == S[1] && S[2] == S[3]) || (S[0] == S[3] && S[1] == S[2]) ||
      (S[0] == S[2] && S[1] == S[3])) {
    if (S[0] == S[1] && S[1] == S[2] && S[2] == S[3]) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
def knapsack(N,W,weight,value):
  dp=[[999999999999 for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1):
    dp[0][i]=0
 
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w:
        if dp[i][w-weight[i]]+value[i]>dp[i][w]:
          dp[i+1][w]=dp[i][w-weight[i]]+value[i]
        else:
          dp[i+1][w]=dp[i][w]
      else:
        dp[i+1][w]=dp[i][w]
  return dp
 
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
a=[];b=[]
for i in range(n):
  a.append(l[i][0])
  b.append(l[i][1])
dp=knapsack(n,t-1,a,b)
ans=[]
for i in range(n):
  if i!=n:
    ans.append(dp[i][t-1]+b[i])
  else:
    ans.append(dp[n][t])
print(max(ans))

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

const ll mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    // init struct with "n" of "nCk" (maximum number in other words)
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    // c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
    // i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }

    // nPk - permutation
    mint p(int n, int k) {
        return fact[n] * ifact[n - k];
    }
};

int n;
vector<int> adj[200200];

mint ans;
int dfs(int cur, int prev = -1) {
    int res = 1;
    vector<int> ts;
    for (int to : adj[cur]) {
        if (to == prev) continue;
        int t = dfs(to, cur);
        res += t;
        ts.push_back(t);
    }
    if (prev != -1) {
        ts.push_back(n - res);
    }
    mint now = mint(2).pow(n - 1) - 1;
    for (int t : ts) {
        now -= mint(2).pow(t) - 1;
    }
    ans += now;
    return res;
}

int main() {
    cin >> n;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(0);
    ans /= mint(2).pow(n);
    cout << ans.x << endl;
}

Measured memory_bytes: 32572
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a, b;
	cin >> a >> b;
	cout << (b - a) * (b - a - 1) / 2 - a << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	if(a<0)
	{
		x=a*-1*c+d;
		x+=b*e;
	}
	else
	x=(b-a)*e;
	printf("%d\n", x);
	
	return 0;
}


Measured memory_bytes: 2108
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/abc165/tasks/abc165_b
import math

input_x = input()
x = int(input_x)

zandaka = 100
nen = 0

while zandaka < x:
    nen += 1
    zandaka = math.floor(zandaka * 1.01)

print(nen)


Measured memory_bytes: 9144
import math
n=int(input())
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
if is_prime(n)==True:
    print(int(n-1))
else:
    N=int(math.sqrt(n))
    for i in reversed(range(N)):
        if n%(i+1)==0:
            print(int((n/(i+1))+i-1))
            break

Measured memory_bytes: 3064
#!/usr/bin/env python3
#ABC143 E

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
  
n,m,l = LI()
graph = [[] for _ in range(n)]
d = [[inf]*n for _ in range(n)]
for _ in range(m):
    a,b,c = LI()
    graph[a-1].append((b-1,c))
    graph[b-1].append((a-1,c))
    d[a-1][b-1] = c
    d[b-1][a-1] = c

for i in range(n):
    d[i][i] = 0

d = warshall_floyd(d)

d2 = [[inf]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if d[i][j] <= l:
            d2[i][j] = 1

d2 = warshall_floyd(d2) 
q = I()
for _ in range(q):
    s,t = LI()
    if d2[s-1][t-1] == inf:
        print(-1)
    else:
        print(d2[s-1][t-1]-1)


Measured memory_bytes: 127964
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

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

  int ans = 0;
  int count;
  for(int i = 101; i<N+1; i=i+2){
    count = 0;
    for(int j=1; j<i/3+1; j=j+2){
      if(i%j==0) {
        ++count;
      }
    }
    ++count;
    if(count == 8) ++ans;
  }

  cout << ans <<endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

const int MAX_N = 101;

ll ans = 0;
vl cnt(MAX_N,0);

int main() {
  int n; cin >> n;
  for (int i = 2; i <= n; i++) {
    int num = i;
    for (int j = 2; j <= n; j++) {
      while (num % j == 0) {
        cnt[j]++;
        num /= j;
      } 
    }
  }
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      for (int k = j+1; k < MAX_N; k++) {
        if (i == j || j == k || k == i) continue;
        if (cnt[i] >= 2) if (cnt[j] >= 4) if (cnt[k] >= 4) ans++;
      }
    }
  }
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      if (i == j) continue;
      if (cnt[i] >= 2) if (cnt[j] >= 24) ans++;
      if (cnt[i] >= 4) if (cnt[j] >= 14) ans++;
    }
  }
  for (int i = 0; i < MAX_N; i++) {
    if (cnt[i] >= 74) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int a, b, x;
	cin >> a >> b >> x;
	if(a <= x && x <= a+b) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int count = 0, a , b;
	cin >> a >> b;
	for (int i = 1; i <= 12&&i<=a; i++) {
		if (i == a) {
			if (i == 2) {
				for (int j = 1; j <= 28 && j <= b; j++) {
					if (i == j) {
						count++;
					}
				}
			}
			else if (i == 4 || i == 6 || i == 9 || i == 11) {
				for (int k = 1; k <= 30 && k <= b; k++) {
					if (i == k) {
						count++;
					}
				}
			}
			else {
				for (int l = 0; l <= 31 && l <= b; l++) {
					if (i == l) {
						count++;
					}
				}
			}
		}
		else {
			if (i == 2) {
				for (int j = 1; j <= 28; j++) {
					if (i == j) {
						count++;
					}
				}
			}
			else if (i == 4 || i == 6 || i == 9 || i == 11) {
				for (int k = 1; k <= 30; k++) {
					if (i == k) {
						count++;
					}
				}
			}
			else {
				for (int l = 0; l <= 31; l++) {
					if (i == l) {
						count++;
					}
				}
			}
		}
	}
	cout << count << endl;
	int x;
	cin >> x;
	return 0;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

const ll NMAX = 1000000000000001;

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

  vector<ll> dm(14,0);

  int nd = 0;
  ll mul = 26;
  for (int i = 1; i <= 13; ++i){
    if (i == 1) {
      dm[i] = mul;
    } else {
      dm[i] = mul + dm[i-1];
    }
    if (dm[i-1] < n && n <= dm[i]) {
      nd = i;
    }
    mul*=26;
  }
  n -= dm[nd-1] + 1;
  string s;
  rep(i,nd) {
    s += (char)('a');
  }
  int i = 0;
  while(n > 0) {
    int m = n % 26;
    n /= 26;
    s[i] += m;
    i++;
  }
  std::reverse(s.begin(), s.end());
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
    int label[6], tmp;
    char order;
    for(int i=0; i<6; i++) scanf("%d", &label[i]);
    while(scanf("%c", &order)!=EOF){
        if(order=='N'){
            tmp = label[0];
            label[0] = label[1];
            label[1] = label[5];
            label[5] = label[4];
            label[4] = tmp;
        }
        else if(order=='E'){
            tmp = label[0];
            label[0] = label[3];
            label[3] = label[5];
            label[5] = label[2];
            label[2] = tmp;
        }
        else if(order=='S'){
            tmp = label[0];
            label[0] = label[4];
            label[4] = label[5];
            label[5] = label[1];
            label[1] = tmp;
        }
        else if(order=='W'){
            tmp = label[0];
            label[0] = label[2];
            label[2] = label[5];
            label[5] = label[3];
            label[3] = tmp;
        }
    }
    printf("%d\n", label[0]);
    return 0;
}


Measured memory_bytes: 2072
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

permu3 :: Int -> Int -> Int -> Int
permu3 a b c
    | a==b && b==c         = 1
    | a==b || b==c || c==a = 3
    | otherwise            = 6

main :: IO ()
main = do 
    n <- fst . fromJust <$> ( BS.readInt <$> BS.getLine ) :: IO Int
    let t1 = 
            [ permu3 a b c * foldl1 gcd [a,b,c]
            | a <- [1..n], b <- [a..n], c <- [b..n]
            ]
    print $ sum t1


Measured memory_bytes: 4844
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        n: usize,
        k: usize,
        a: [usize;n],
    }

    if n-k==0 {
        println!("{}", 1);
        return;
    } else {
        println!("{}", 1.0+((n-k) as f64 /(k-1) as f64).ceil());
    }

}


Measured memory_bytes: 3608
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    H = read_ints()
    if K >= N:
        return 0
    H.sort(reverse=True)
    return sum(H[K:])


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 98444
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,k,x,y,z;
string s;

int main(){
	cin>>n>>k>>x>>y>>z>>s;
	int res=0;
	for(int i=0;i<n;i++){
		if(i>=k&&s[i-k]==s[i]){
			s[i]='?';
			continue;
		}
		if(s[i]=='s') res+=x;
		if(s[i]=='p') res+=y;
		if(s[i]=='r') res+=z;
	}
	cout<<res<<endl;
}

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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

#define chmin(x, y) x = min(x, y)

const i64 INF = 1e18;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  i64 C;
  cin >> n >> C;
  vector<i64> H(n);
  REP(i, n) cin >> H[i];

  vector<i64> dp(n);
  vector<tuple<i64, i64, int>> lines;

  auto jumpto = [&](int i) -> int {
    const i64 x = H[i];
    int l = 0, r = int(lines.size()) - 1;
    while (l + 2 < r) {
      int j1 = l + (r - l) / 3;
      int j2 = r - (r - l) / 3;
      auto [a1, b1, _1] = lines[j1];
      auto [a2, b2, _2] = lines[j2];
      i64 y1 = a1 * x + b1;
      i64 y2 = a2 * x + b2;
      if (y1 < y2) {
        r = j2;
      } else {
        l = j1;
      }
    }
    i64 ans = INF;
    int mj = -1;
    for (int k = l; k <= r; ++k) {
      auto [a, b, j] = lines[k];
      if (ans > a * x + b) {
        ans = a * x + b;
        mj = j;
      }
    }
    return mj;
  };

  auto add_line = [&](int i) -> void {
    i64 a = -2 * H[i];
    i64 b = H[i] * H[i] + dp[i];
    while (lines.size() > 1) {
      int m = lines.size();
      auto [a1, b1, _1] = lines[m - 1];
      auto [a2, b2, _2] = lines[m - 2];
      if ((a2 - a1) * (b - b2) + (b1 - b2) * (a - a2) < 0) {
        break;
      }
      lines.pop_back();
    }
    lines.emplace_back(a, b, i);
  };

  dp[n - 1] = 0;
  add_line(n - 1);

  for (int i = n - 2; i >= 0; --i) {
    int j = jumpto(i);
    assert(j < n);
    assert(j >= 0);
    assert(H[j] > H[i]);
    i64 hd = H[j] - H[i];
    dp[i] = hd * hd + C + dp[j];
    add_line(i);
  }
  cout << dp[0] << endl;
}


Measured memory_bytes: 12648
local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end

X=io.read"*n"
N=io.read"*n"
if(N==0)then print(X)return end

A=reada(N)
table.sort(A)

for i=1,N do
	if(A[i]>=X)then a=i break end
end
if(A[a]~=X)then print(X)return end
i=0
while(true)do
	if(A[a-i]~=X-i)then print(X-i)return end
	if(A[a+i]~=X+i)then print(X+i)return end
	i=i+1
end


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	int n;cin>>n;
	vector<int> a(n-1);
	int i;
	rep(i,n-1)cin>>a[i];
	vector<int> num(n,0);
	rep(i,n-1)
	{
		num[a[i]-1]++;
	}
	for(i=0;i<n;i++)cout<<num[i]<<endl;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n),aa(n);
    rep(i,n){
        std::cin >> a[i];
        aa[i]=a[i];
    }
    sort(all(a));
    int c=a[n/2];
    rep(i,n){
        if(aa[i]>=c)std::cout << a[n/2-1] << std::endl;
        else std::cout << a[n/2] << std::endl;
    }
}


Measured memory_bytes: 3712
#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-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

constexpr ll INF=1e18;
int n, k;
ll a[252521];

bool isok(ll mid){
  ll cnt=0;
  REP(i, n){
    cnt+=(a[i]-1)/mid;
    if(cnt>k){
      return false;
    }
  }
  return cnt<=k;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  cin>>n>>k;
  REP(i, n){
    cin>>a[i];
  }
  ll lb=0, ub=INF;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(isok(mid)){
      ub=mid;
    }
    else{
      lb=mid;
    }
  }
  cout<<ub<<'\n';
  return 0;
}


Measured memory_bytes: 5172
n = int(input())
info = [tuple(map(int, input().split())) for _ in range(n)]

for cx in range(101):
    for cy in range(101):
        h = -1
        for i in range(n):
            if info[i][2] != 0:
                h = info[i][2] + abs(info[i][0] - cx) + abs(info[i][1] - cy)
                break
        ok = True
        for i in range(n):
            v = max(h - abs(info[i][0] - cx) - abs(info[i][1] - cy), 0)
            ok &= v == info[i][2]
        if ok:
            print(cx, cy, h)
            exit()


Measured memory_bytes: 9200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
#include<atcoder/all>
using namespace atcoder;
int n,m;
int calc(int i,int j){
    return m*i+j;
}

int main(){
    cin >> n >> m;
    vector<string> s(n);
    mcf_graph<int,int> mcf(n*m+2);
    int S = n*m;
    int T = n*m+1;
    rep(i,n){
        cin >> s[i];
    }
    int sm = 0;
    rep(i,n){
        rep(j,m){
            if(s[i][j]=='.'){
                if(i+1!=n){
                    if(s[i+1][j]!='#'){
                        mcf.add_edge(calc(i,j),calc(i+1,j),3000,0);
                    }
                }
                if(j+1!=m){
                    if(s[i][j+1]!='#'){
                        mcf.add_edge(calc(i,j),calc(i,j+1),3000,0);
                    }
                }
                int K = abs(n-i) + abs(m-j);
                mcf.add_edge(calc(i,j),T,1,K);
            }else if(s[i][j]=='o'){
                if(i+1!=n){
                    if(s[i+1][j]!='#'){
                        mcf.add_edge(calc(i,j),calc(i+1,j),3000,0);
                    }
                }
                if(j+1!=m){
                    if(s[i][j+1]!='#'){
                        mcf.add_edge(calc(i,j),calc(i,j+1),3000,0);
                    }
                }

                int K = abs(n-i) + abs(m-j);
                sm += K;
                // cerr << K << endl;
                mcf.add_edge(S,calc(i,j),1,K);
                mcf.add_edge(calc(i,j),T,1,K);
            }
        }
    }
    // cerr << sm << endl;
    auto res = mcf.flow(S,T);
    // cout << res.first << " " << res.second << endl;
    cout << 2*sm - res.second  << endl;
    return 0;
}

Measured memory_bytes: 4160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		int idx1 = -1;
		int idx2 = -1;
		
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c == 'A') {
				idx1 = i;
				break;
			}
		}
		
		for (int i = s.length() - 1; i >= 0; i--) {
			char c = s.charAt(i);
			if (c == 'Z') {
				idx2 = i;
				break;
			}
		}
		System.out.println(idx2 - idx1 + 1);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 25044