akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

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 < 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 < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Unionfind{
  vector<int> size, par;
  Unionfind(){}
  Unionfind(int n) :  size(n, 1), par(n){
    for(int i = 0; i < n; i++){
      par[i] = i;
    }
  }
  int find(int x){
    if(par[x] == x){
      return x;
    }
    return par[x] = find(par[x]);
  }
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y){
      return false;
    }
    par[x] = y;
    size[y] += size[x];
    return true;
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
};


using pl = pair<ll, ll>;

set<ll> as[100010];
set<ll> bs[100010];

int main(){

  ll n = in();
  REP(i, n-1){
    ll x = in() - 1;
    ll y = in() - 1;
    as[x].insert(y);
    as[y].insert(x);
  }
  REP(i, n-1){
    ll x = in() - 1;
    ll y = in() - 1;
    bs[x].insert(y);
    bs[y].insert(x);
  }
  Unionfind uf(n);
  queue<pl> que;
  REP(i, n){
    YYS(w, as[i]){
      if(bs[i].find(w) != bs[i].end()){
        que.emplace(i, w);
      }
    }
  }
  while(!que.empty()){
    ll x = uf.find(que.front().fi);
    ll y = uf.find(que.front().se);
    que.pop();
    if(x == y){
      continue;
    }
    if(SZ(as[x]) + SZ(bs[x]) < SZ(as[y]) + SZ(bs[y])){
      swap(x, y);
    }
    uf.unite(y, x);
    YYS(w, as[y]){
      as[w].erase(as[w].find(y));
      if(w == x){
        continue;
      }
      as[w].insert(x);
      as[x].insert(w);
      if(bs[w].find(x) != bs[w].end()){
        que.emplace(w, x);
      }
    }
    YYS(w, bs[y]){
      bs[w].erase(bs[w].find(y));
      if(w == x){
        continue;
      }
      bs[w].insert(x);
      bs[x].insert(w);
      if(as[w].find(x) != as[w].end()){
        que.emplace(w, x);
      }
    }
  }

  if(uf.size[uf.find(0)] == n){
    puts("YES");
  } else {
    puts("NO");
  }
  
  return 0;
}


Measured memory_bytes: 31744
var lines = []; var result = Infinity;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var N = Number(lines[0]);
    var T = Number(lines[1].split(" ")[0]);
    var A = Number(lines[1].split(" ")[1]);

    var H = lines[2].split(" ").map(value => Number(value));

    for (var i = 0; i < N; i++) {
        if (Math.abs(result - A) > Math.abs(T - H[i] * 0.006 - A)) {
            result = T - H[i] * 0.006;
            cnt = i;

        }
    }
    console.log(cnt + 1);
});

Measured memory_bytes: 7756
N = int(input())
S = list(input())

ans = []
count = 0
addFlag = True
for i in range(N):
    if addFlag:
        if S[i] == ')':
            ans.append(')')
            ans.insert(0,'(')
        else:
            ans.append('(')
            count += 1
            addFlag = False
    else:
        if S[i] == '(':
            ans.append('(')
            count += 1
        else:
            ans.append(')')
            count -= 1
            if count == 0:
                addFlag = True

for _ in range(count):
    ans.append(')')

print(''.join(ans))

Measured memory_bytes: 61952
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"4
1 4 6 3"# => r#"5"#,
}


fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        a: [usize; n],
    }

    (a.iter().max().unwrap() - a.iter().min().unwrap()).to_string()
}

Measured memory_bytes: 4352
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	string  a, b;
	string ans="No";
	cin >> a >> b;
	a += b;
	int x = stoi(a);
	if ((int)pow((int)sqrt(x), 2.0) == x) ans = "Yes";
	cout << ans << endl;
}

Measured memory_bytes: 256
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad.State (State, evalState, gets, modify)
import Data.Map (Map, lookup, insert, empty)
import Data.Maybe (maybe)
import Control.Monad

main = breadIs >>= main'
    where
        main' [n, w] = replicateM n breadIs >>= print . solve w

solve :: Int -> [[Int]] -> Int
solve w xs = run calc (w, xs)

calc :: Memoizer (Int, [[Int]]) Int -> Memoizer (Int, [[Int]]) Int
calc f (w, [nw, nv] : xs)
    | w < nw = f (w, xs)
    | otherwise = max <$> f (w, xs) <*> ((+ nv) <$> f (w - nw, xs))
calc _ _ = return 0

breadIs :: IO [Int]
breadIs = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

type Memoizer a b = a -> State (Map a b) b

run :: (Ord a) => (Memoizer a b -> Memoizer a b) -> a -> b
run f = flip evalState empty . memoizeFix f

memoizeFix :: (Ord a) => (Memoizer a b -> Memoizer a b) -> Memoizer a b
memoizeFix f x = gets (Data.Map.lookup x) >>= maybe (f (memoizeFix f) x >>= ((<$) <*> (modify . Data.Map.insert x))) return


Measured memory_bytes: 25212
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  vector<string> s(3);
  rep(i, 3) cin >> s.at(i);
  vector<int> index(3, 0);
  int now = 0;
  while(1){
    if(index.at(now) == s.at(now).size()){
      char o = now + 'A';
      cout << o << endl;
      return 0;
    }
    char c = s.at(now).at(index.at(now));
    index.at(now)++;
    now = c - 'a';
  }
  return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int digs(int64 x) {
    int ans = 0;
    while (x > 0) {
        ++ans;
        x /= 10;
    }
    return ans;
}

int64 N;

int main() {
    cin >> N;
    int ans = digs(N);
    for (int64 x = 1; x * x <= N; ++x) {
        if (N % x == 0) {
            ans = min(ans, max(digs(x), digs(N/x)));
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N, N1;
    cin >> N;
    N1 = N;

    int sum = 0;

    while (N1>0) {
        sum += N1 % 10;
        N1 /= 10;
    }

    if (N % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;
#define mod 1000000007

struct req{
    LL l,r,x;
};

int dp[312][312][312],N,M;

vector<req> a[312];

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

    int i,j,k,t; req req_aux;
    for (i=1; i<=M; i++){
        cin >> req_aux.l >> req_aux.r >> req_aux.x;
        a[req_aux.r].push_back(req_aux);
    }


    for (i=N; i>=0; i--)
        for (j=0; j<=i; j++)
            for (k=0; k<=i; k++){
                dp[i][j][k]=dp[j][i][k]=dp[j][k][i]=0;

                bool ok=1;
                for (int t=0; t<a[i].size(); t++){
                    req r=a[i][t];
                    int cnt=1;
                    if (j>=r.l) cnt++;
                    if (k>=r.l) cnt++;
                    if (r.x!=cnt) ok=0;
                }

                if (!ok) continue;

                dp[i][j][k]=(1LL*dp[i+1][j][k]+dp[i][i+1][k]+dp[i][j][i+1])%mod;
                dp[j][i][k]=(1LL*dp[i+1][i][k]+dp[j][i+1][k]+dp[j][i][i+1])%mod;
                dp[j][k][i]=(1LL*dp[i+1][k][i]+dp[j][i+1][i]+dp[j][k][i+1])%mod;

                if (i==N) dp[i][j][k]=dp[j][i][k]=dp[j][k][i]=1;
            }


    cout << dp[0][0][0] << "\n";

    return 0;
}


Measured memory_bytes: 114816
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;

typedef tree<double,null_type,less<double>,rb_tree_tag,tree_order_statistics_node_update> Tree;

#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}


int n;
pair<pi,int> ps[40005];


typedef pair<double,double> pd;
pd event[40005];
lint count(double X){
  REP(i,n){
    double y=(ps[i].sc-(ps[i].fr.fr*X))/ps[i].fr.sc;
    double ang=-ps[i].fr.fr/(double)ps[i].fr.sc;
    event[i]={y,ang};
  }
  Tree T;
  sort(event,event+n);
  lint res=0;
  T.insert(1e100);
  REP(i,n){
    T.insert(event[i].sc);
    res+=T.order_of_key(event[i].sc);
  }
  return res;
}
double solve(){
  const double MX=1e9;
  double lb=-MX,ub=MX;

  lint all=n*(lint)(n-1)/2;
  lint half=(all+1)/2;
  REP(hoge,80){
    double md=(lb+ub)/2;
    if(count(md)<half) lb=md;
    else ub=md;
  }
  return lb;
}
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>n;
  REP(i,n){
    cin>>ps[i].fr.fr>>ps[i].fr.sc>>ps[i].sc;
  }
  double X=solve();
  REP(i,n) swap(ps[i].fr.fr,ps[i].fr.sc);
  double Y=solve();

  printf("%.15f %.15f\n",X,Y);

  return 0;
}






Measured memory_bytes: 5888
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  string s;
  scan(s);
  vector<string> a = {"Sunny", "Cloudy", "Rainy"};
  if (s == a[0]) {
    print(a[1]);
  } else if (s == a[1]) {
    print(a[2]);
  } else {
    print(a[0]);
  }
  return 0;
}


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

#define F first
#define S second
#define pb push_back
#define mp make_pair

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

ll lcm(ll a, ll b){
	return (a/gcd(a, b))*b;
}

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

	string s,t;

	cin >> s >> t;

	ll mi = 1e9 , cnt = 0 , i ,j;
	ll len = s.size();
	ll len1 = t.size();

	for(i=0;i<len-len1+1;i++)
	{
		cnt = 0;

		for(j=0;j<len1;j++)
		{
			if(s[i+j] != t[j])
				cnt++;
		}

		mi = min(mi , cnt);
	}

	cout << mi << endl;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		double x1, y1, x2, y2;
		while (in.hasNext()) {
			x1 = -in.nextDouble();
			y1 = -in.nextDouble();
			x1 += in.nextDouble();
			y1 += in.nextDouble();
			x2 = -in.nextDouble();
			y2 = -in.nextDouble();
			x2 += in.nextDouble();
			y2 += in.nextDouble();
			System.out.println((x1 * x2 + y1 * y2 == 0) ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

typedef long long ll;

int main(void)
{
    int n, k, h;
    
    cin >> n >> k;
    
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))

bool isOK(ll *v,ll n){
    for(int i=0;i<n;i++){
        if (*(v+i)<*(v+i+1))return false;
    }
    return true;
}

bool breakdown(ll *v,ll n){
    bool flag=false;
    for(int i=n-1;i>=0;i--){
        if (*(v+i)==0)continue;
        if(*(v+i)>*(v+i+1)+1){
            //まとめられるならまとめる
            /*
            ll sum=0;
            ll j=n+1;
            while(j>i+1){
                j--;
                if (*(v+j)==0){
                    continue;
                }
                sum+=*(v+j);
            }
            */
            //if(*(v+i)>sum){
            ll j=n;
            while(j>i+1){
                if (*(v+j)==0){
                    j--;
                    continue;
                }
                *(v+j-1)+=*(v+j);
                *(v+j)=0;
            }
            //}
            //崩す
            *(v+i)=*(v+i)-1;
            *(v+i+1)=*(v+i+1)+1;
            flag=true;
        }else if(*(v+i)==2&&*(v+i+1)==1){
            ll j=i;
            while(*(v+j)!=0){
                j++;
            }
            *(v+i)=*(v+i)-1;
            *(v+j)=*(v+j)+1;
            flag=true;
        }
        if (flag)break;
    }
    return flag;

}


int main(){
    ll ans;
    ll n;
    ll v[31];
    for(int i=0;i<31;i++)v[i]=0;

    while(true){
        cin >>n;
        if(n==0)break;
        for(int i=0;i<31;i++)v[i]=0;
        v[0]=n;
        cout <<n<<endl;
        while(breakdown(v,n)){
            if(isOK(v,n)){
                for(int i=0;i<n&&v[i]!=0;i++){
                    cout <<v[i];
                    if(i<n&&v[i+1]!=0)cout <<" ";
                }
                cout <<endl;
            }
        }
        
    }

    return 0;

}


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

#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
using namespace std;

template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << ": " << arg1 << endl;
}

template<typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = (int) 5e5 + 2;
int ar[NN];
int b[NN];
int n, m, k;
string s;



integer main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++){
        cin >> ar[i];
    }
    sort(ar, ar+n);

    ans = ar[n-1];
    int rem = n-2;
    for (int i = n-2; i >= 0 && rem; i--){
//        cout << ar[i] << rem << endl;
        int f = min(rem, 2ll);
        ans += f * ar[i];
        rem -= f;
    }
    cout << ans;

}



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

int V[50],n;

int solve(int i,int m){
  if(m == 0) return 1;
  if(i >= n) return 0;

  int res = solve(i+1,m) || solve(i+1,m - V[i]);
  return res;
}
int main(){
  int q,M;
  cin>>n;for(int i=0;i<n;i++)cin>>V[i];
  cin>>q;for(int i=0;i<q;i++){
    cin>>M;
    if(solve(0,M))cout<<"yes"<<endl;
    else cout<<"no"<<endl;

  }
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10;
int n, k;
double sum[N];
double p[N];

signed main() {
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        sum[i] = sum[i - 1] + p[i] * (1 + p[i]) / 2 / p[i];
    }
    double maximum = -1;
    for (int i = 1; i + k - 1 <= n; i++) {
        maximum = max(maximum, sum[i + k - 1] - sum[i - 1]);
    }
    cout << fixed << setprecision(12) << 1.0 * maximum << endl;
    return 0;
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline
from pprint import pprint
N, M = map(int, input().split())
A = [-1]*M
B = [-1]*M
C = [-1]*M

for i in range(M):
    A[i], B[i] = map(int, input().split())
    ls = list(map(int, input().split()))
    c = 0
    for j in range(len(ls)):
        c += 2 ** (ls[j]-1)
    C[i] = c


dp = [[float('inf')]*(2**N) for _ in range(M)]

j = 0
for i, di in enumerate(C):
    if i == 0:
        dp[i][di] = A[i]
        dp[i][0] = 0
        continue
    for j in range(2**N):
        stay = dp[i - 1][j | di]
        buy = dp[i - 1][j] + A[i]
        now = dp[i][j | di]
        dp[i][j | di] = min(stay, buy, now)
    for j in range(2**N):
        dp[i][j] = min(dp[i][j], dp[i-1][j])

ans = dp[-1][2**N-1]
if ans > sum(A):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 133128
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int l=sc.nextInt();
        int sum=0;
        int min=Integer.MAX_VALUE;
        int ind=0;
        for (int i=1;i<=n;i++){
            sum+=(l+i-1);
            if (Math.abs(l+i-1)<min){
                min=Math.abs(l+i-1);
                ind=i;
            }
        }
        System.out.println(sum-(l+ind-1));
    }

}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
int n,q,k;
vector<pll> adj[MAX];
ll len[MAX];
void dfs(int u,int v,ll l){
	len[u]=l;
	for(pll ii:adj[u]){
		if(ii.F==v)	continue;
		dfs(ii.F,u,l+ii.S);	
	}
}
int main(){
	IOS;
	cin>>n;
	for(int i=1;i<n;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		adj[a].pb({b,c});
		adj[b].pb({a,c}); 
	}
	cin>>q>>k;
	dfs(k,k,0);
	while(q--){
		int a,b;
		cin>>a>>b;
		cout<<len[a]+len[b]<< '\n';
	}
	return 0;
}

Measured memory_bytes: 14336
from collections import deque
S=deque(input())
Q=int(input())
isForward = True
for _ in range(Q):
  v = input().split()
  if v[0] == '1':
    isForward = (isForward == False)
    continue
  if isForward:
    if v[1] == '1':
      S.appendleft(v[2])
    else:
      S.append(v[2])
  else:
    if v[1] == '1':
      S.append(v[2])
    else:
      S.appendleft(v[2])
if isForward == False:
  S = reversed(S)
print(''.join(S))

Measured memory_bytes: 8564
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

const int inf=1<<9;
int h,w;
char lab[50][50];
int ans,white=0;
int d[50][50];

int bfs()
{
  queue<P> que;
  rep(i,h)
  rep(j,w) d[j][i]=inf;

  que.push(P(0,0));
  d[0][0]=1;

  while(que.size())
  {
    P p=que.front();
    que.pop();
    if(p.first==w-1 && p.second==h-1) break;

    rep(i,4)
    {
      int dx[4]={-1,0,0,1},dy[4]={0,-1,1,0};
      int nx=p.first+dx[i],ny=p.second+dy[i];

      if(nx>=0 && nx<w && ny>=0 && ny<h && lab[nx][ny]=='.' && d[nx][ny]==inf)
      {
        que.push(P(nx,ny));
        d[nx][ny]=d[p.first][p.second]+1;
      }
    }
  }
  return d[w-1][h-1];
}

 int main()
 {
   cin>>h>>w;
   rep(i,h)
   rep(j,w)
   {
     cin>>lab[j][i];
     if(lab[j][i]=='.') white++;
   }

   ans=bfs();
   if(ans==inf) ans=-1;
   else ans=white-ans;

   cout<<ans<<endl;

 }


Measured memory_bytes: 256
t1, t2 = [ int(v) for v in input().split() ]
a1, a2 = [ int(v) for v in input().split() ]
b1, b2 = [ int(v) for v in input().split() ]
t = t1 + t2

if a1*t1 + a2*t2 == b1*t1 + b2*t2:
    ans = -1
else:
    if a1 >= b1 and  a2 >= b2:
        ans = 0
    elif a1 <= b1 and  a2 <= b2:
        ans = 0
    else:
        if a1*t1 + a2*t2 < b1*t1 + b2*t2:
            a1, b1 = b1, a1
            a2, b2 = b2, a2

        mind = a1*t1 - b1*t1
        if mind > 0:
            ans = 0
        else:
            lastd = a1*t1 + a2*t2 - b1*t1 - b2*t2
            mind = abs(mind)
            if mind % lastd == 0:
                ans = 2 * (mind // lastd) 
            else:
                ans = 2 * (mind // lastd) + 1
    
print(ans if ans != -1 else "infinity")

Measured memory_bytes: 38384
import java.io.*;
import java.text.*;
import java.util.*;

public class Main {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.solve();
            t--;
        }
        out.close();
    }

    static class InputReader {

        public BufferedReader br;
        public StringTokenizer token;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream), 32768);
            token = null;
        }

        public String sn() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int ni() {
            return Integer.parseInt(sn());
        }

        public String snl() throws IOException {
            return br.readLine();
        }

        public long nlo() {
            return Long.parseLong(sn());
        }

        public double nd() {
            return Double.parseDouble(sn());
        }

        public int[] na(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.ni();
            return a;
        }

        public long[] nal(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nlo();
            return a;
        }
    }

    static int inf = 5000013;

    static class solver {
        DecimalFormat df = new DecimalFormat("0.00000000");
        int maxi = 200000000;

        void solve() {
            int n = sc.ni();
            int W = sc.ni();
            long dp[][] = new long[n + 1][W + 1];
            long a[][] = new long[n][2];
            for (int i = 0; i < n; i++) {
                long w = sc.ni();
                long v = sc.ni();
                a[i][0] = w;
                a[i][1] = v;
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= W; j++) {
                    if (j >= a[i - 1][0])
                        dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - (int) a[i - 1][0]] + a[i - 1][1]);
                    else
                        dp[i][j] = dp[i - 1][j];
                }
            }
            out.println(dp[n][W]);
        }
    }
}


Measured memory_bytes: 126036
#include <bits/stdc++.h>
const int MOD = 1e9+7;
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define ll long long
#define ar array
using namespace std;
using P = pair<int,int>;

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

	int AB,BC,CA;
	cin >> AB >> BC >> CA;

	cout << AB*BC/2 << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    vector<int> num(3);

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

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



    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 256
S = input()
T = input()

def normalize(s):
    pos = {}
    for i, c in enumerate(s):
        if not c in pos:
            pos[c] = i
        yield pos[c]

if all(x == y for x, y in zip(normalize(S), normalize(T))):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
int main()
{
	long long a = 0, b = 0, c = 0, tower[1000] = {0}, last = 0, k = 0, ansa = 0, ansb = 0, x = 0, y = 0, mi[1000] = {};
	
	int snow=0;
		int one = 0, ten = 0, hun = 0, thou = 0,man=0;
	std::cin >>a>>b;
	
	bool okada = true;
	for (int i = 1; i <= 999; i++) {
		tower[i] = tower[i-1]+i;
		mi[i] = i;
		if (b - a == mi[i]) {
			snow = tower[i] - b;
			
		}
	}
	std::cout << snow << std::endl;
}







Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;


int main(){
    int a[3];
    for(int i=0; i<3; i++)
    {
        cin >> a[i];
    }
    sort(a,a+3);
    cout<<a[2]-a[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n, s; cin >> n >> s;
	VI a(n); REP(i,n) cin >> a[i];
	ll dp[3001][3001][3]={0};
	REP(i,n) dp[i][0][0]=1;
	REP(i,n){
		REP(j,s+1){
			dp[i+1][j][1]+=dp[i][j][1]+dp[i][j][0];
			if(j-a[i]>=0) 
				dp[i+1][j][1]+=dp[i][j-a[i]][1]+dp[i][j-a[i]][0];
			dp[i+1][j][2]+=dp[i][j][2]+dp[i+1][j][1];
			dp[i+1][j][1]%=MOD;
			dp[i+1][j][2]%=MOD;
		}
	}
	cout << dp[n][s][2] << endl;
	return 0;
}

Measured memory_bytes: 211456
#D
from collections import deque
n=int(input())
a=deque(list(map(int,input().split())))
a.appendleft(0)
b=[0 for i in range(n+1)]
c=[]
m=0
for i in range(n):
    k=2
    sum=0
    while (n-i)*k<=n:
        sum+=b[(n-i)*k]
        k+=1
    if sum%2!=a[n-i]:
        b[n-i]=1
        c.append(n-i)
        m+=1
print(m)
c.sort()
c=list(map(str,c))
print(" ".join(c))

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, Q, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    A.resize(100005,0);
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A[a]++;
        ans += a;
    }
    cin >> Q;
    for(int i=0;i<Q;i++) {
        ll b, c;
        cin >> b >> c;
        ans += (c-b)*A[b];
        A[c] = A[c]+A[b];
        A[b] = 0;
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
    long long int n,q,sum = 0,j = 0;
    cin >> n;
    vector<long long int> arr(100001,0);
    for (int i = 0; i < n; i++)
    {
        long long int a;
        cin >> a;
        sum += a;
        arr[a]++;
    }
    cin >> q;
    for (int i = 0;i<q;i++)
    {
        long long int b,c;
        cin >> b >> c;
        sum += (c - b) * arr[b];
        arr[c]+=arr[b];
        arr[b]=0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 4004
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] tmp = br.readLine().split(" ");
        int n = Integer.parseInt(tmp[0]);
        int k = Integer.parseInt(tmp[1]);
        char[] s = br.readLine().toCharArray();

        List<Integer> list = new ArrayList<>();
        boolean b = true;
        int i;
        int count = 0;
        for(i = 0; i < n; i++) {
            if(b != (s[i] == '1')) {
                list.add(count);
                count = 1;
                b = !b;
            }else {
                count++;
            }
        }
        list.add(count);
        if(list.size() % 2 == 0) list.add(0);


        int ans = 0;
        int j = 0;
        do {
            int y = 0;
            for(int x = 2 * j; x < list.size() && x <= 2 * j + 2 * k; x++) {
                y += list.get(x);
            }
            j++;
            ans = Math.max(ans, y);
        }while(j < list.size() / 2);

        System.out.println(ans);
    }
}

Measured memory_bytes: 27092
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c[3];
    cin >> a >> b;
    c[0]=a+b;
    c[1]=a-b;
    c[2]=a*b;
    sort(c,c+3);
    cout << c[2] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int s;
scanf("%d",&s);
if((s/100==0||s/100>12)&&(s%100==0||s%100>12)){
    printf("NA\n");
}
else if(s/100==0||s/100>12){
    printf("YYMM\n");
}
else if(s%100==0||s%100>12){
    printf("MMYY\n");
}
else printf("AMBIGUOUS\n");

}


Measured memory_bytes: 128
#include <stdio.h>
//#define DEBUG

int main (void){

	/*????????????????????????????????\?????§?????¢??°?????§??????????????§
	 main??¢??°?????§2?¬????????????¨?????????????????????*/


		char str[12] = {};
		int map[14][14] = {{}};
		int i = 0 ;
		int j = 0 ;

		char ch = 0 ;

	while (1){
		int flag[74] ={};
		int label = 1;
		int counter = 0 ;
		/*??°??????????????????*/
/*		if(scanf("%c",&ch) == EOF){
			return 0;
		}*/

		for( i = 0 ; i < 12 ; i++){
				if(scanf("%s",str) == EOF){
					return 0;
				}
				for ( j = 0 ; j < 12 ; j++){
					map[i+1][j+1] = str[j] - '0';
				}
		}



		for(i = 0 ; i < 14 ; i++){
			for( j = 0 ; j < 14 ; j++){
				if(map[i][j]){			//?????°?????£??????
					if(!map[i-1][j] && !map[i][j-1]){	//????????????????????£?????????
						label++;					//??????????????´??°????????????????????£??\??????
						map[i][j] = label ;
						flag[label] = 1 ;				//??????????????¨????????°????????????
					}
					else if(map[i-1][j] && !map[i][j-1]){ //???????????????
						map[i][j] = map[i-1][j];
					}
					else if(!map[i-1][j] && map[i][j-1]){	//???????????????
						map[i][j] = map[i][j-1];
					}else if(map[i-1][j] && map[i][j-1]){	//????????????????????£??????
						map[i][j] = map[i-1][j];			//?????¨?????????????????¨
						if(map[i-1][j] < map[i][j-1]){		//?????????????°?????????´???
							flag[(map[i][j-1])] = 0;				//???????????£?????????????????????????????°????¶????
						}
						if(map[i-1][j] > map[i][j-1]){		//?????????????°?????????´???
							flag[(map[i-1][j])] = 0;				//???????????£?????????????????????????????°????¶????
							}
						/*???????????????????????????????????????????????§nop*/
					}

				}
			}
		}


#ifdef DEBUG
		//??°????????¶????????¨????????????
		for(i = 0 ; i < 14 ; i++){
			for( j = 0 ; j < 14 ; j++){
				printf("%2d",map[i][j]);
			}
			printf("\n");
		}
#endif
		/*????????°?????°??????*/
		for( i = 0 ; i < 74 ; i++){
			if(flag[i]){
				counter++;
			}
		}
		printf("%d\n",counter);




	}
	return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i = 0;i < n;i ++)cin >> vec.at(i);
  
  int count = 0;
  for(int i = 0;i < n;i ++){
    count += min(vec.at(i),k - vec.at(i)) * 2;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3628
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

  	ll k,a,b;
  	cin>>a>>b>>k;

  	ll diff = min(a,k);
  	a -= diff;
  	k -= diff;

  	diff = min(b,k);
  	b -= diff;

  	cout<<a<<" "<<b<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;vector<pair<int,int>>A(N);
  for(int i=0;i<N;i++){int t;cin>>t;A[i]=pair<int,int>(t,i%2);}
  sort(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<N;i++){
    if(i%2!=A[i].second)ans++;
  }cout<<ans/2;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };



int main() {
	fastIO;
	int n, k;
	cin >> n >> k;
	vector<ld> e;
	for (int i = 0; i < n; i++) {
		ld x;
		cin >> x;
		e.push_back((x+1)/2);
	}
	ld sum = 0, ans = 0;
	vector<ld> accum;
	for (int i = 0; i < n; i++) {
		sum += e[i];
		accum.push_back(sum);
	}
	for (int i = k-1; i < n; i++) {
		int prev = i - k;
		if (prev >= 0)
			ans = max(ans, accum[i] - accum[prev]);
		else
			ans = max(ans, accum[i]);
	}

	cout << fixed << setprecision(6) << ans;

}


Measured memory_bytes: 12396
#include <stdio.h>

int main( void ) {

	int n, i, s[100], max, min, sum;

	while ( scanf( "%d", &n ) && n > 0 ) {

		max = 0;
		min = 1000;
		sum = 0;

		for ( i = 0; i < n; i++ ) {

			scanf( "%d", &s[i] );

			if ( s[i] > max ) { max = s[i]; }
			if ( s[i] < min ) { min = s[i]; }

			sum += s[i];

		}

		printf( "%d\n", ( sum - max - min ) / ( n - 2 ) );

	}

	return 0;

}

Measured memory_bytes: 596
S = input()

prev = S[0]
start = 0
ans = [0]
for i in range(len(S)):
    if S[i]==prev:
        if S[i]=="<":
            ans.append(ans[-1]+1)
        else:
            ans.append(ans[-1]-1)
    else:
        #print(ans)
        if prev==">":
            for j in range(start,i+1):
                if j==start:
                    ans[start] = max(ans[start],ans[start]-ans[-1])
                else:
                    ans[j]-=ans[-1]
        start = i
        prev = S[i]
        if S[i]=="<":
            ans.append(ans[-1]+1)
        else:
            ans.append(ans[-1]-1)

if prev==">":
    for j in range(start,len(S)+1):
        if j==start:
            ans[start] = max(ans[start],ans[start]-ans[-1])
        else:
            ans[j]-=ans[-1]


print(sum(ans))

Measured memory_bytes: 78156
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int S;
    int a[9], b[9];
    scanf("%d", &S);
    for(;S--;){
        for(int x = 0; x < 9; x++){
            scanf("%d", a+x);
        }
        sort(a, a+9);
        for(int x = 0; x < 9; x++){
            scanf("%d", b+x);
        }
        int win, total;
        win = total = 0;
        do{
            int point = 0;
            for(int x = 0; x < 9; x++){
                if(a[x] > b[x]){
                    point += a[x] + b[x];
                }
            }
            if(point > 171/2) ++win;
            ++total;
        }while(next_permutation(a, a+9));
        double prob = (double)win/total;
        printf("%.5f %.5f\n", prob, 1-prob);
    }
    return 0;
}

Measured memory_bytes: 1080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static int f(int n)
        {
            if( n == 0){ return 1; }
            return n * f(n - 1);
        }
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int n = a[0];
            int m = a[1];

            int even;
            int odd;

            if( n >= 2)
            {
                even = n * (n - 1) / 2;
            }
            else
            {
                even = 0;
            }

            if( m >= 2)
            {
                odd = m * (m - 1) / 2;
            }
            else
            {
                odd = 0;
            }


            Console.WriteLine(even + odd);


        }
    }
}


Measured memory_bytes: 13396
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10**9+7
a_list.sort()
ans = 1
if k % 2 == 1 and a_list[-1] < 0:
    for i in range(k):
        ans *= a_list[n - 1 - i]
        ans %= mod
else:
    l = 0
    r = -1
    mlt1 = a_list[0] * a_list[1]
    mlt2 = a_list[-2] * a_list[-1]
    count = 0
    while True:
        if count == k:
            break
        elif count == k - 1:
            ans *= a_list[r] % mod
            ans %= mod
            break
        if mlt1 >= mlt2:
            ans *= mlt1 % mod
            l += 2
            count += 2
            if l <= n - 2:
                mlt1 = a_list[l + 1] * a_list[l]
        else:
            ans *= a_list[r] % mod
            r -= 1
            count += 1
            if r >= - n + 1:
                mlt2 = a_list[r - 1] * a_list[r]
        ans %= mod
print(ans)

Measured memory_bytes: 93692
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int s=scan.nextInt();
        int h,m;
        m=s/60;
        h=m/60;
        m-=h*60;
        s-=(h*60*60+m*60);
        System.out.println(h + ":" +m+":"+s);
    }
}


Measured memory_bytes: 26140
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define PI acos(-1.0)
#define eps 1e-9

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

ll f(ll n)
{
    ll cnt = 0;
    for(ll i = 5; n/i>=1; i*=5)
        cnt+=(n/i);
    return cnt;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    ll n;
    cin>>n;
    if(n&1LL)
    {
        cout<<0<<endl;
        return 0;
    }
    n = n / 2LL;
    cout<<f(n)<<endl;

    //End();
    return 0;
}


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

long long n,dp[87];

int main(){
	cin>>n;
	dp[0]=2;
	dp[1]=1;
	for(int i=2;i<=n;i++){
		dp[i]=dp[i-2]+dp[i-1];
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 256