akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<lint, int> pli;
typedef complex<double> xy_t;
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;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 1000010;

template<typename T> struct SegTree{
    using F=function<T(T, T)>;
    int sz=1;
    T et;
    F f, g;
    vector<T> node;

    SegTree(int sz_, T et_, F f_, F g_): et(et_), f(f_), g(g_){
        while(sz<sz_) sz<<=1;
        node.resize(sz<<1, et);
    }

    void update(int i, T x){
        i+=sz;
        node[i]=g(node[i], x);
        i>>=1;
        while(i){
            node[i]=f(node[i<<1], node[(i<<1)+1]);
            i>>=1;
        }
    }

    T query(int l, int r){
        T vl=et, vr=et;
        for(l+=sz, r+=sz; l<r; l>>=1, r>>=1){
            if(l&1) vl=f(vl, node[l++]);
            if(r&1) vr=f(node[--r], vr);
        }
        return f(vl, vr);
    }

    int lower_bound(T x, function<bool(T, T)> cmp){
        if(cmp(node[1], x)) return sz;
        int i=1;
        T L=et;
        while(i<sz){
            if(cmp(f(L, node[i<<1]), x)){
                L=f(L, node[i<<1]);
                i=(i<<1)+1;
            }
            else i<<=1;
        }
        return i-sz;
    }
};

int main(){
    int n;
    scanf("%d", &n);
    lint a[n];
    vector<pli> b[2];
    rep(i, n){
        scanf("%lld", &a[i]);
        b[i%2].emplace_back(a[i], i);
    }

    int p=0;
    rep(i, 2) sort(b[i].begin(), b[i].end(), greater<>());
    lint sum[2];
    rep(i, 2){
        sum[i]=b[i][0].fi;
        For(j, 1, (int)b[i].size())if(b[i][j].fi>0) sum[i]+=b[i][j].fi;
    }
    p=(sum[0]>sum[1] ? 0 : 1);
    printf("%lld\n", sum[p]);

    SegTree<int> st(n, 0, plus<>(), plus<>());
    rep(i, n) st.update(i, 1);

    vector<int> ans;
    For(i, 1, (int)b[p].size())if(b[p][i].fi<0){
        int idx=b[p][i].se;
        int num=st.query(0, idx+1);
        ans.push_back(num);
        st.update(idx, -1);
        if(st.query(0, idx+1)>0){
            int next=st.lower_bound(num, less<>());
            if(next<n) st.update(next, -1);
        }
    }
    p^=1;
    rep(i, (int)b[p].size()){
        int idx=b[p][i].se;
        if(!st.query(idx, idx+1)) continue;
        int num=st.query(0, idx+1);
        ans.push_back(num);
        st.update(idx, -1);
        if(st.query(0, idx+1)>0){
            int next=st.lower_bound(num, less<>());
            if(next<n) st.update(next, -1);
        }
    }
    printf("%d\n", ans.size());
    for(int i: ans) printf("%d\n", i);
}

Measured memory_bytes: 256
solve :: [Int] -> Int
solve (d:n:_) =
    (filter (\x -> div100 d x) [1..]) !! (n - 1)

div100 :: Int -> Int -> Bool -- bが100で丁度a回割り切れるか
div100 a b = b `mod` 100^a == 0 && b `mod` 100^(a + 1) > 0

main :: IO ()
main = do
    n <- fmap (read :: String -> Int) . words <$> getLine
    (putStrLn . show . solve) n

Measured memory_bytes: 892
#include <stdio.h>
int main(void) {
  int N, i, j, sum, count;
  while(scanf("%d",&N),N) {
    count = 0;
    for(i = 1; i <= N/2; i++ ) {
      sum = 0;
      for(j = i; sum < N; j++) {
	sum += j;
      }
      if(sum == N) count++;
    }
    printf("%d\n",count);
  }
  return(0);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(ALL(a));
    int ans = 0;
    rep(i, K) ans += a[i];
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include "stdio.h"
#include "math.h"
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <iostream>

using namespace std;

/** string stream
	lexical-cast **/

/** Problem0087 : Strange Mathematical Expression **/
int main()
{
	stack<double> stk;
	string s;
	int tmp;
	
	while (1) {
		getline(cin, s);
		if (cin.eof()) break;
		
		s.push_back(' ');
		
		tmp=0;
		for (int i=0; i<s.length(); i++) {
			if ('0' <= s[i] && s[i] <= '9') {
				if (tmp >= 0) {
					tmp*=10;
					tmp+=s[i]-'0';
				} else {
					tmp*=10;
					tmp-=s[i]-'0';
				}
			} else if (tmp != 0 && s[i] == ' ') {
				stk.push(tmp);
				tmp=0;
			} else if (s[i] == '+') {
				double a = stk.top(); stk.pop();
				double b = stk.top(); stk.pop();
				stk.push(a+b);
			} else if (s[i] == '-') {
				if (s[i+1] == ' ') {
					double a = stk.top(); stk.pop();
					double b = stk.top(); stk.pop();
					stk.push(b-a);
				} else {
					tmp*=10; tmp += -(s[i+1]-'0');
					i++;
				}
			} else if (s[i] == '*') {
				double a = stk.top(); stk.pop();
				double b = stk.top(); stk.pop();
				stk.push(a*b);
			} else if (s[i] == '/') {
				double a = stk.top(); stk.pop();
				double b = stk.top(); stk.pop();
				stk.push(b/a);
			}
		}
		printf("%.6f\n", stk.top());
	}
}

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

#define vi vector<int>

int main() {

    int n, q;
    vi S, T;
    int tmp;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        S.push_back(tmp);
    }

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> tmp;
        T.push_back(tmp);
    }

    int count = 0;
    S.push_back(0);
    for (int i = 0; i < q; i++) {
        S[n] = T[i];
        int j = 0;
        while (S[j] != T[i]) {
            j++;
        }
        if (j < n) count++;
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3160
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}
macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}

fn main() {
    let (A, B) = get!(f64, f64);
    let n = ((B - 1f64) / (A - 1f64)).ceil() as usize;
    println!("{}", n);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll r;
int main(){FAST;
dofloat;  
cin>>r;
cout<<2*PI*r;
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 3764
#include <stdio.h>
#include <algorithm>

int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  // printf("%d, %d, %d", n, m, q);
  
  int end[m][2], query[q][2]; 
  for(int i=0;i<m;i++){
    int n1, n2;
    scanf("%d %d", &n1, &n2);    
    end[i][0] = n1;
    end[i][1] = n2;
  }
  for(int i=0;i<q;i++){
    int n1, n2;
    scanf("%d %d", &n1, &n2);    
    query[i][0] = n1;
    query[i][1] = n2;
  }

  int a[n][n];
  for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
    a[i][j] = 0;
  }
  }
  
  for(int i=0;i<m;i++){
    a[end[i][0]-1][end[i][1]-1] +=1;
    // printf("%d", a[end[i][0]-1][end[i][1]-1]);
  }
  // for(int i=0;i<n;i++)for(int j=0;j<n;j++)
  //   printf("%d", a[i][j]);
  // printf("\n");
  // fflush(stdout);

  for(int j=0;j<n;j++){
    for(int i=n-2;i>=0;i--) a[i][j] += a[i+1][j];
  }
  // printf("q1: %d\n", q);
  
  for(int i=0;i<n;i++){
    for(int j=1;j<n;j++) a[i][j] += a[i][j-1];
  }

  // printf("q2: %d\n", q);
  // for(int i=0;i<n;i++)for(int j=0;j<n;j++)
  //   printf("%d", a[i][j]);
  // printf("\n");
  // fflush(stdout);
    
  for(int i=0;i<q;i++){
    // int sum = 0;
    // for(int n1=query[i][0]-1;n1<n;n1++){
    // for(int n2=0;n2<query[i][1];n2++){
    //   sum += a[n1][n2];
    // }
    // }
    // printf("%d %d\n", query[i][0],query[i][1]);    
    printf("%d\n", a[query[i][0]-1][query[i][1]-1]);
  }
  fflush(stdout);
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int main(void)
{
  int n,l;
  cin >> n >> l;
  
  int l2 = l;
  int ans = 0;
  for(int i=0;i<n;i++){
    ans += l2;
    l2++;
  }
  l2--;
  
  if(l>=0) ans -= l;
  
  else if(l2 >= 0) ans;
  
  else if(l2 < 0) ans -= l2;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

#define say(args) cout << (args) << endl
#define rep(i, a) for (int i = 0; i < a; i++)

using namespace std;

typedef struct point {
  int x;
  int y;
} Point;

string make_key(int x, int y) {
  char xx = x + '0', yy = y + '0';
  char orig[] = {xx, ',', yy};
  return string(orig, end(orig));
}

void exec(string& jfen) {
  int nums[4];
  rep(i, 4) {
    int n;
    cin >> nums[i];
  }
  Point before = { nums[1] - 1, nums[0] - 1 };
  Point next   = { nums[3] - 1, nums[2] - 1 };

  map<string, int> board;

  int x = 0, y = 0;
  int x_limit;
  for (auto c : jfen) {
    if (c == '/') {
      y += 1;
      x_limit = x;
      x = 0;
    }
    else if (c == 'b') {
      board[ make_key(x, y) ] = 1;
      x += 1;
    }
    else if (c <= '9' && c >= '1') {
      // char to int
      for (int i = 0; i < c - '0'; i++) {
        board[ make_key(x, y) ] = 0;
        x += 1;
      }
    }
  }
  int y_limit = y + 1;

  board[ make_key(before.x, before.y) ] = 0;
  board[ make_key(next.x, next.y) ]     = 1;

  for (int y = 0; y < y_limit; y++) {
    for (int x = 0; x < x_limit; x++) {
      if (board[ make_key(x, y) ] == 1) {
        cout << "b";
      } else {
        int count = 1;
        while (board[ make_key(x + 1, y)] == 0 && x < x_limit - 1) {
          count += 1;
          x += 1;
        }
        cout << count;
      }
    }
    if (y < y_limit - 1) {
      cout << "/";
    }
  }
  puts("");
}

int main() {
  string jfen;
  cin >> jfen;
  while (jfen[0] != '#' && jfen.length() != 1) {
    exec(jfen);
    cin >> jfen;
  }
}

Measured memory_bytes: 3184
#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 debug = 0;

int main(){
    int k, n;
    vector<double> ex;

    cin >> n >> k;

    rep(i,n){
        int p;
        double tmp;
        cin >> p;
        // n*(n+1)/2
        tmp = p * (p + 1) / 2.0 / p;
        ex.push_back(tmp);
        if(debug)
            printf("%.12f,", tmp);
    }

    // cout << endl;

    double sum;
    vector<double> sum2;

    sum = 0;
    for (int i = 0; i < k;i++){
        sum += ex[i];
    }

    sum2.push_back(sum);

    if(debug)
        printf("%.12f\n", sum);

    for (int i = 0; i < n - k;i++){
        sum -= ex[i];
        sum += ex[i + k];
        sum2.push_back(sum);
        if(debug)
            printf("%.12f\n", sum);
    }

    sort(sum2.begin(), sum2.end(), greater<double>());

    
    printf("%.12f\n",sum2[0]);


}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  long long x,y;
  cin>>x>>y;
  if(x>=0 && y>=0){
    if(x<y){
      cout<<y-x<<endl;
    }else{
      cout<<min(x+y+1,x-y+2)<<endl;
    }
  }else if(x>=0 && y<0){
    if(x<abs(y)){
      cout<<abs(y)-x+1<<endl;
    }else{
      cout<<x-abs(y)+1<<endl;
    }
  }else if(x<0 && y>=0){
    if(abs(x)<y){
      cout<<min(y-x,y-abs(x)+1)<<endl;
    }else{
      cout<<min(y-x,abs(x)-y+1)<<endl;
    }
  }else{
    if(abs(x)<abs(y)){
      cout<<abs(y)-abs(x)+2<<endl;
    }else{
      cout<<abs(x)-abs(y)<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max(0, min(B, D) - max(A, C)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define all(v) v.begin(), v.end()
#define rep(i, from, to) for (ll i = from; i < ll(to); ++i)
vector<vii> comp;
vector<bool> vis;
vector<vi> adj;
vi a;
void dfs(ll x){
    vis[x]=true;
    comp[comp.size()-1].push_back({a[x],x});
    for(auto& f : adj[x]){
        if (!vis[f]){
            dfs(f);
        }
    }
}




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

    ll n,m;
    cin>>n>>m;
    a.resize(n);
    vii ss;
    rep(i,0,n) {
        cin>>a[i];
        ss.push_back({a[i],i});
    }
    vis.resize(n,false);
    adj.resize(n);
    rep(i,0,m){
        ll x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    rep(i,0,n){
        if(vis[i])continue;
        comp.push_back(vii());
        dfs(i);
    }
    if (comp.size()==1){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    sort(all(ss));
    rep(i,0,comp.size()){
        sort(comp[i].begin(),comp[i].end());
    }
    vector<bool> ch(n);
    ll ns = comp.size()-2;
    for(auto& d : comp){
        ans += d[0].first;
        ch[d[0].second]=true;
    }
    rep(i,0,n){
        if(ns <= 0)break;
        if (ch[ss[i].second])continue;
        ans+=ss[i].first;
        ns--;
    }
    if (ns > 0) {
        cout << "Impossible"<<endl;
    }else{
        cout<<ans<<endl;
    }







    return 0;
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S, T;
    cin >> S >> T;
    vector<int> s(26,-1),e(26,-1);
    for (int i=0;i<S.size();i++){
        int a = S[i] - 'a';
        int b = T[i] - 'a';
        if (s[a] != -1 || e[b] != -1){
            if (s[a] != b || e[b] != a){
                cout << "No" << "\n";
                return 0;
            }
        }
        s[a] = b;
        e[b] = a;
    }
    cout << "Yes" << "\n";
    return 0;
}

Measured memory_bytes: 916
#include <iostream>
#include <string>
#include <algorithm>

int main() {
    std::string str;
    std::cin >> str;

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        std::string op;
        int a, b;
        std::cin >> op >> a >> b;

        if (op == "print") {
            std::cout << str.substr(a, b - a + 1) << std::endl;
        } else if (op == "reverse") {
            std::reverse(str.begin() + a, str.begin() + b + 1);
        } else if (op == "replace") {
            std::string p;
            std::cin >> p;
            for (int i = a; i <= b; i++) {
                str[i] = p[i - a];
            }
        }
    }
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define MOD 1000000007
#define mod 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 1e8

map<pair<lli,lli>,int>m1,m2,m3,m4;


int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int mul(int a, int b) {
	return a * 1LL * b % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int main()
{
    int n;
    cin >> n;
    int n1=0,n2=0;
    int z1=0,z2=0,z3=0;
    for(int i=0;i<n;i++)
    {
        lli a,b;
        cin >> a >> b;
        if(abs(a)==0 and abs(b)==0)
        {
            z3+=1;
            continue;
        }
        else if(abs(a)==0)
        {
            z1+=1;
            continue;
        }
        else if(abs(b)==0)
        {
            z2+=1;
            continue;
        }
        int sign=(a/abs(a))*(b/abs(b));
        if(abs(a)>abs(b))
        {
            a=abs(a);b=abs(b);
            lli g=__gcd(a,b);
            a=a/g;b=b/g;
            if(sign>0)
                m1[{a,b}]+=1;
            else
                m2[{a,b}]+=1;
        }
        else if(abs(a)<abs(b))
        {
            a=abs(a);b=abs(b);
            lli g=__gcd(a,b);
            a=a/g;b=b/g;
            if(sign>0)
                m3[{b,a}]+=1;
            else
            {
                m4[{b,a}]+=1;
            }
        }
        else
        {
            if(sign==-1)
                n1+=1;
            else
                n2+=1;
        }
    }
    int ans=(binpow(2,n1)*1LL+binpow(2,n2)*1LL-1)%MOD;
    ans=(ans*1LL*((binpow(2,z1)*1LL+binpow(2,z2)*1LL-1)%MOD))%MOD;
    map<pair<lli,lli>,int>:: iterator itr,itr1;
    for(itr=m1.begin();itr!=m1.end();itr++)
    {
        int a1=itr->second,a2=0;
        if(m4.find(itr->first)!=m4.end())
        {
            itr1=m4.find(itr->first);
            a2=itr1->second;
            m4.erase(itr1);
        }
        int t=(binpow(2,a1)*1LL+binpow(2,a2)*1LL-1)%MOD;
        ans=ans*1LL*t%MOD;
    }
    for(itr=m2.begin();itr!=m2.end();itr++)
    {
        int a1=itr->second,a2=0;
        if(m3.find(itr->first)!=m3.end())
        {
            itr1=m3.find(itr->first);
            a2=itr1->second;
            m3.erase(itr1);
        }
        int t=(binpow(2,a1)*1LL+binpow(2,a2)*1LL-1)%MOD;
        ans=ans*1LL*t%MOD;
    }
    for(itr=m3.begin();itr!=m3.end();itr++)
    {
        int a1=itr->second;
        int t=binpow(2,a1);
        ans=ans*1LL*t%MOD;
    }
    for(itr=m4.begin();itr!=m4.end();itr++)
    {
        int a1=itr->second;
        int t=binpow(2,a1);
        ans=ans*1LL*t%MOD;
    }
    ans-=1;
    ans=(ans*1LL+z3)%MOD;
    ans=(ans+MOD)%MOD;
    cout << ans << endl;
}

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

int main(){
    unsigned long N, Q;
    cin >> N >> Q;

    vector<unsigned long> A(N), AS(N + 2), S(N + 1), X((N - 1) / 2), a((N + 1) / 2);
    for(auto& i : A)cin >> i;
    partial_sum(A.begin(), A.end(), S.begin() + 1);
    for(unsigned long i{0}; i < N; ++i)AS[i + 2] = A[i] + AS[i];
    for(unsigned long i{1}; i <= (N + 1) / 2; ++i)a[i - 1] = S[N] - S[N - i] + AS[N - i * 2 + 1];
    for(unsigned long i{1}; i <= (N - 1) / 2; ++i)X[i - 1] = A[N - i - 1] + A[N - i * 2 - 1];

    reverse(a.begin(), a.end());
    reverse(X.begin(), X.end());

    auto beg = begin(X), edn = end(X);
    for(long long i{0}, x; i < Q; ++i){
        cin >> x;
        cout << a[lower_bound(beg, edn, x * 2) - beg] << endl;
    }
    return 0;
}

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

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

int main() {
    int N; cin>>N;
    vector<pair <string, int>> sp(N), index(N);
    for (int i=0; i<N; i++) {
      string s; int p; cin >> s >> p;
      sp.at(i) = make_pair(s, p);
      index.at(i) = make_pair(s, p);
    }
    //sort(sp.begin(), sp.end());
    sort(sp.begin(), sp.end(), sort_b);
    for (int i=0; i<N; i++) {
      for (int j=0; j<N; j++) {
        if (sp.at(i).first == index.at(j).first && sp.at(i).second == index.at(j).second) cout << j+1 << endl;
      }
    }
  }



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
s = input()
if 'A' in s[k-1]:
    char = 'a'
elif 'B' in s[k-1]:
    char = 'b'
else:
    char = 'c'
ans = s[:k-1]+char+s[k:]
print(ans)

Measured memory_bytes: 3060
x = int(input())

def hantei(x):
  p = []
  for i in range(2,int(x**(1/2))+1):
    if (x % i) == 0:
      return False
  else:
    return True
  
while 1:
  if hantei(x):
    print(x)
    break
  else:
    x+=1


Measured memory_bytes: 9388
#include <iostream>
#include <algorithm>
using namespace std;
int B[100005];
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i=0; i<N-1; i++) cin >> B[i];
  ll ret = B[0] + B[N-2];
  for (int i=0; i<N-2; i++) {
    ret += min(B[i], B[i+1]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
W, H, N = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]

hdot = [1 for h in range(H)]
wdot = [1 for w in range(W)]

for a in A:
    if a[2] == 1:
        for w in range(W):
            if w < a[0]:
                wdot[w] = 0
    elif a[2] == 2:
        for w in range(W):
            if w >= a[0]:
                wdot[w] = 0
    elif a[2] == 3:
        for h in range(H):
            if h < a[1]:
                hdot[h] = 0
    elif a[2] == 4:
        for h in range(H):
            if h >= a[1]:
                hdot[h] = 0

print(sum(hdot)*sum(wdot))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define Rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n<=0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}



//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

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

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n

ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


////////////////////////////////////////////////////////////////////


int main() {

ll n;
cin>>n;
ll a[n+1];
for(int i=1;i<=n;i++){
	cin>>a[i];
}

sort(a+1,a+n+1,greater<ll>());

ll ans=0;
for(ll i=1;i<=n;i++){
ll val=0;
if(i>=2){val=(i+(ll)1)*modpow(2,i-2,MOD);
val%=MOD;
val*=a[i];
val%=MOD;
val*=modpow(2, n-i, MOD);
val%=MOD;
ans+=val;
ans%=MOD;}
else{
	val=1;
	val*=a[i];
	val%=MOD;
	val*=modpow(2,n-1,MOD);
	val%=MOD;
	ans+=val;
	ans%=MOD;
}


}
ans*=modpow(2,n,MOD);
ans%=MOD;
cout<<ans<<endl;
return 0;


}






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

int main() 
{
    ll n, m;
    cin >> n >> m;
    vector<bool> v(n+1,false);
    vector<int> pen(n+1, 0);
    ll acc = 0, penal = 0;
    for (ll i=0; i<m; i++)
    {
        ll p; string s;
        cin >> p >> s;
        if (v[p]) continue;
        if (s=="AC")
        {
            v[p] =true;
            acc++;
            penal+=pen[p];
        }
        else 
            pen[p]++;
    }
    cout << acc << " " << penal;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
vector<vector<int>> d(1000,vector<int>(1000,INF));
vector<vector<char>> maze;
P start;
int R,C,N;
int bfs(){
  queue<P> que;
  que.push(P(0,0));
  d[0][0]=0;
  while(que.size()){
    P p=que.front();que.pop();
    if(p.first==R-1&&p.second==C-1)break;
    rep(i,4){
      int nx = p.first+dx[i];
      int ny = p.second+dy[i];
      if(0<=nx && nx<R && 0<=ny && ny<C && maze[nx][ny] != '#' && d[nx][ny]==INF){
        que.push(P(nx,ny));
        d[nx][ny] = d[p.first][p.second]+1;
      }
    }
  }
  return d[R-1][C-1];
}
      
int main(){
  cin >> R >> C;
  maze.resize(R);
  int walls = 0;
  rep(i,R){
    rep(j,C){
      char c;
      cin >> c;
      if(c=='#'){
        walls++;
      }
      maze[i].push_back(c);
    }
  }
  
  //cout << start.first << "," << start.second << endl;
  /*rep(i,N){
    cout << goals[i].first << "," << goals[i].second << endl;
  }*/
  int path = bfs();
  if(path==INF){
    cout << "-1"<< endl;
  }else{
    cout << R*C -walls -path -1 << endl;
  }
  //cout << walls << endl;
  //cout << path << endl;
                                                                   
  
  //int res = bfs();
  //cout << res << endl;


  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<vector<int> > a;
		rep(i,5001)
		{
			vector<int> temp(5);
			rep(j,5) temp[j] = 0;

			a.push_back(temp);
		}

		int d,p,q,ans = 0;
		
		rep(i,n)
		{
			cin >> d >> p >> q;
			q--;
			if(d == 1)
			{
				int ny = 5000;
				
				while(true)
				{
					bool flag = true;
					REP(j,q,q+p)
					{
						if(a[ny][j] != 0) flag = false;
					}

					if(flag) 
					{
						if(ny == 0) break;
						else
						{
							bool flag_2 = true;
							REP(j,q,q+p)
							{
								if(a[ny-1][j] != 0) flag_2 = false;
							}

							if(!flag_2) break;
						}
					}

					ny--;
				}

				REP(j,q,q+p)
				{
					a[ny][j] = 1;
				}
			}
			else if(d == 2)
			{
				int ny = 5000;

				while(true)
				{
					bool flag = true;

					for(int j=ny;j>ny-p;j--)
					{
						if(a[j][q] != 0) flag = false;
					}

					if(flag) 
					{
						if(ny-p+1 == 0) break;
						else
						{	
							bool flag_2 = true;

							for(int j=ny-1;j>ny-1-p;j--)
							{
								if(a[j][q] != 0) flag_2 = false;
							}

							if(!flag_2) break;
						}
					}
					
					ny--;
				}

				for(int j=ny;j>ny-p;j--)
				{
					a[j][q] = 1;
				}
			}

			rep(j,a.size())
			{
				bool flag = true;

				rep(k,5)
				{
					if(a[j][k] != 1) flag = false;
				}

				if(flag) 
				{
					a.erase(a.begin() + j);
					j--;
				}
			}
			
		}

		rep(j,5001) rep(k,5) if(a[j][k] == 1) ans++;
		
		cout << ans << endl;
	}
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll X, Y;
    cin >> X >> Y;
    cout << (abs(X-Y)<=1?"Brown":"Alice") << endl;
    return 0;
}

Measured memory_bytes: 256
#include"iostream"
#include"vector"
using namespace std;
vector<int> A;
void maxHeapify(int i)
{
  int l=i*2+1;
  int r=i*2+2;
  int largest;
  if(l<A.size()&&A[l]>A[i])largest=l;
  else largest=i;
  if(r<A.size()&&A[r]>A[largest])largest=r;
  if(largest!=i)
    {
      l=A[largest];
      A[largest]=A[i];
      A[i]=l;
      maxHeapify(largest);
    }
}
void buildMaxHeap()
{
  for(int i=A.size()/2;i>=0;i--)
    {
      maxHeapify(i);
    }
}
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
    {
      int m;
      cin>>m;
      A.push_back(m);
    }
  buildMaxHeap();
  for(int i=0;i<n;i++)
    {
      cout<<" "<<A[i];
    }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll p;

bool f = false;
ll modPow(ll x, ll n) {
    ll ret = 1;
    while(n) {
        if(n&1LL) {
            if((double)x > 1e12 || (double)ret * x > 1e12) f = true;
            (ret *= x);
        }
        n >>= 1;
        if(n > 0 && (double)x*x > 1e12) f = true;
        (x *= x);
    }
    return ret;
}

int main(){
    ll n;
    cin >> n >> p;
    if(n == 1 || p == 1) {
        cout << p << endl;
        return 0;
    }
    ll ans = 1LL;
    ll x = 2;
    while(1) {
        f = false;
        ll tmp = modPow(x, n);
        if(f || tmp > p || tmp <= 0) break;
        if(p%tmp == 0) ans = x;
        ++x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///const int mod = 1000000007;
///const int INF = 1000000000;
///const double EPS = 1e-9;
///long long a[200005];
///long long b[200005];
///long long c[200005];
int main ()
{
    ///cin.tie(0);
    ///ios::sync_with_stdio(false);
    long long int a,b, c,d,e,f,g,h,i,j,k,t,sum=0,x,y,z,sum2=0,n,m;
    cin >> n>>m;

    if (n<10)
    {
        cout << (  (100 *(10-n))+m )<<"\n";
    }

    else if (n>=10)
        cout << m<<"\n";


}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>

using namespace std;
const int Max_N(75);
const int Max_K(75);
const int MOD(1000000000 + 7);

constexpr int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

void exgcd(int a, int b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(int a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

int N, K, Ans, All[Max_N], Cnt[Max_N], Fac[1001], Inv[1001];
char S[Max_K];

bool check()
{
	queue<int> Q;
	int satisfy(0), need(0);
	for (int i = 1;i <= K;++i)
		if (S[i] == 'r' && satisfy < All[0])
		{
			if (All[++satisfy])
				Q.push(All[satisfy] - 1);
		}
		else
			if (S[i] == 'b' && Q.empty() == false)
				need += Q.front(), Q.pop();
			else
				need = max(0, need - 1);
	return satisfy == All[0] && Q.empty() && need == 0;
}

int F[2][Max_N];

inline int Com(int n, int m)
{
	return 0 <= m && m <= n ? Mult(Fac[n], Mult(Inv[m], Inv[n - m])) : 0;
}

int calc()
{
	memset(Cnt, 0, sizeof(Cnt));
	int Ret(Fac[All[0]]);
	for (int i = 1;i <= All[0];++i)
		++Cnt[All[i]];
	for (int i = 0;i <= N;++i)
		Ret = Mult(Ret, Inv[Cnt[i]]);
	int can_0(2), other(0);
	for (int i = 1;i <= All[0];++i)
	{
		if (i + 1 <= All[0])
			++other;
		if (All[i] == 0)
			++other;
		else
			can_0 += 2, other += (All[i] - 1) + All[i];
	}
	return Mult(Ret, Com(N + can_0 - 1, can_0 + other - 1));
}

void dfs(int last, int less)
{
	if (All[0])
		if (check())
			upd(Ans, calc());
		else
			return;
	for (int n = last, _less;n >= 0;--n)
	{
		if ((_less = less + (n == 0 ? 1 : n + (n - 1)) + (All[0] != 0)) > N)
			continue;
		All[++All[0]] = n, dfs(n, _less), --All[0];
	}
}

int main()
{
	Fac[0] = 1;
	for (int i = 1;i <= 1000;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[1000] = inverse(Fac[1000]);
	for (int i = 1000 - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	scanf("%d%d", &N, &K);
	scanf("%s", S + 1);
	Ans = 1, dfs(N, 0), printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    //--<for debugging>
    #define whatis(x) cout << #x << " is " << x<<" ";
    #define whatisl(x) cout << #x << " is " << x<<"\n";
    #define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
    #define lline cout<<"\n";
    #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
     
    void err(istream_iterator<string> it) {}
    template<typename T, typename... Args>
    void err(istream_iterator<string> it, T a, Args... args) {
    	cout << *it << " = " << a <<" , ";
    	err(++it, args...);
    }
    //--</for debugging> 
    #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
    #define testcase ll tt; cin >> tt; while(tt--)
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define pb push_back 
    #define vars ll h,i,j,k,d,l,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
    #define vll vector<ll>
    #define pll pair<ll,ll>
    #define sll set<ll>
    #define pint pair<int,int>
    const ll INF=1e9+7;
    const ll MOD=1e9+7;
    int main()
    {
        boost vars 
        cin>>n>>k;
        ll arr[n];
        s=0;
        for(i=0;i<n;i++)
        {
            cin>>arr[i];
            s+=arr[i];
        }
        sort(arr,arr+n);
        ans=0;
        double dvar=s/((double)(4*k));
        for(i=n-1;i>=0;i--)
        {
            if(arr[i]*4*k>=s)ans++;
            else break;
            if(ans>k)break;
        }
        if(ans>=k)cout<<"Yes";
        else cout<<"No";
    }

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(void){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A,A+N);
    long int ans=A[N-1];
    for(int i=2;i<N;i++){
        ans+=A[N-1-i/2];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    vector<int> as(n);
    rep(i, n) cin>>as[i];

    int q;
    cin>>q;
    rep(i, q) {
        int k;
        cin>>k;
        if (k == *lower_bound(as.begin(), as.end(), k)) cout<<1<<endl;
        else cout<<0<<endl;
    }
}


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

pair < long long , long long > Range[40] ;

queue < int > ans ;

bool have ;

int main(){
	#define NAME "Medium"
	//freopen( NAME".inp" , "r" , stdin ) ; freopen( NAME".out" , "w" , stdout ) ;
	
	Range[0] = make_pair(0, 1) ;

	for (int i = 1; i <= 31; ++ i){
		Range[i] = Range[i - 1] ;
		if(i % 2) Range[i].first -= (1ll << i) ;
		else Range[i].second += (1ll << i) ;
	}

	long long x ; cin >> x ;

	for (int i = 31; i >= 1; -- i){
		long long foo = x ;
		if(i % 2) foo += (1ll << i) ;
		else foo -= (1ll << i) ;
		int bar ;
		if(foo >= Range[i - 1].first && foo <= Range[i - 1].second) bar = 1, x = foo ;
		else bar = 0 ;
		if(bar) ans.push(bar), have = true ;
		else if(have) ans.push(bar) ;
	}

	ans.push(x) ;

	while(!ans.empty()) cout << ans.front(), ans.pop() ;

	return 0 ;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a,b,c=[],[],[]
for i in range(n):
    a.append(list(map(int,input().split())))
    c.append([])
for i in range(m):
    b.append(list(map(int,input().split())))
for i in range(n):
    for j in range(m):
        c[i].append(abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1]))
for i in range(n):
    print(c[i].index(min(c[i]))+1)

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

int main(void){
    int i;
    int n;
    scanf("%d", &n);
    printf("%d\n", 24-n+24);

    return 0;
}


Measured memory_bytes: 128
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

var nums = readIntSplit(by: " ")
let K = readInt()!
for _ in 0..<K {
    nums.sort()
    nums[2] *= 2
}
print(nums.reduce(0){$0+$1})


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    s.pb('R');
    int n = s.size();
    vi ans(n);
    int l=0,r=0;
    int offset=0;
    rep(i,n-1){
        if (s[i]=='R') r++;
        if (s[i]=='L') l++;
        if (s[i]=='L' && s[i+1]=='R'){
            ans[r+offset-1] = (r+1)/2+l/2;
            ans[r+offset] = (l+1)/2+r/2;
            offset += l+r;
            l = r = 0;
        }
    }
    rep(i,n-1){
        if (i>0) cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1104
using System;
using System.Collections.Generic;
class ITP1
{
    static void Main(string[] args)
    {
        Q2_C();
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //System.Console.SetIn(exStdIn);

        //int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));
    }

    static void Q1()
    {
        int input = int.Parse(Console.ReadLine());

        int h = input / 3600;
        int m = input % 3600 / 60;
        int s = input % 3600 % 60;

        Console.WriteLine(String.Format("{0}:{1}:{2}", h, m, s));
    }

    static void Q2_A()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));

        String sign = a[0] - a[1] > 0 ? ">" : a[0] - a[1] == 0 ? "==" : "<";

        Console.WriteLine(String.Format("a {0} b",sign));
    }

    static void Q2_B()
    {
        int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s)));
        String answer = a[2] - a[1] > 0 ? a[1] - a[0] > 0 ? "Yes" : "No" : "No";

        Console.WriteLine(answer);
    }

    static void Q2_C()
    {
        List<int> a = new List<int>(Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<String, int>(s => int.Parse(s))));
        a.Sort();

        Console.WriteLine(String.Format("{0} {1} {2}",a[0],a[1],a[2])); 
    }
}

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

int A[1000000], n;

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

  int q, k, sum = 0;
  cin >> q;
  for ( int i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( *lower_bound(A, A + n, k) == k ) sum++;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3484
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;

vector<vector<long long>> dp;

void solve()
{
	int n, w;
	cin >> n >> w;

	dp.assign(2, vector<long long>(w + 1, 0));

	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;

		for (int k = 1; k <= w; k++)
		{
			
			dp[i & 1][k] = max(dp[i & 1][k], dp[(i + 1) & 1][k]);

			if (k - a >= 0)
			{
				dp[i & 1][k] = max(dp[i & 1][k], dp[(i + 1) & 1][k - a] + b);
			}
			
		}
	}

	cout << dp[(n - 1) & 1][w];
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 2560