akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 200020
#define M 1e18
#define F -1e6
#define E 1e6

using namespace std;

int main() {
 	int n, k;
	cin >> n >> k;
	int cnt = 0;
	while( n ) {
		n /= k;
		cnt++;
	}
	pfd(cnt);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    char A[H][W];
    rep(i, H) rep(j, W) cin >> A[i][j];
    rep(i, H-1) rep(j, W-1) {
        if (A[i+1][j] == '#' && A[i][j+1] == '#'){
            cout << "Impossible" << endl;
            return 0;
        }
        if (j - 1 >= 0 && i - 1 >= 0){
            if (A[i][j] == '#' && (A[i][j-1] == '#' && A[i-1][j] == '#')){
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;

    return 0;
}


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

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll a = 0, n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0;
string s;
char c;
bool flag;

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


int main(void) {
  ll F[205][40];
  ll P[205][40];

  cin >> n;

  FOR(i, 0, n) {
	FOR(j, 0, 10) {
	  cin >> F[i][j];
	}
  }

  FOR(i, 0, n) {
	FOR(j, 0, 11) {
	  cin >> P[i][j];
	}
  }

  m = -10000000000;

  FOR(bit, 1, 1024) {
	sum = 0;
	FOR(i, 0, n) {
	  cnt = 0;
	  FOR(j, 0, 10) {
		if (((bit >> j) & 1) && F[i][j] == 1) {
		  cnt++;
		}
	  }
	  sum += P[i][cnt];
	}
	if (m < sum) {
	  m = sum;
	}
  }

  cout << m << endl;

  return 0;
}

Measured memory_bytes: 256
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun, 19th Jan 2020                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

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

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

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

//___________________________________________________________________________________________________

int n;
vi a;
vi b;
vector<pii> p;

bool P(int num){

	int ans = 1;
	int cur = p[0].F;

	rep(i,1,n){
		if(cur <= p[i].S){
			cur = p[i].F;
			ans++;
		}
	}

	if(ans >= num) return false;
	else return true;
}

void solve() {

	cin >> n;
	
	rep(i,0,n){
		int c,l;
		cin >> c >> l;
		// a.pb(c-l);
		// b.pb(c+l);
		p.pb({c+l, c-l});
	}

	sort(all(p));

	int l = 1;
	int r = n;

	while(l < r){
		int m = l + (r-l+1)/2;
		if(P(m)) r = m-1;
		else l = m;
	}

	// rep(i,1,n+1) printf("%d ", P(i));
	// printf("\n");

	assert(!P(l));
	ret(l);
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

double n;

int main() {
	cin >> n;
	ll k = 1;
	ll cnt = 1;
	while (1) {
		if (k < n&&n <= k * 3) {
			cout << cnt << endl;
			break;
		}
		cnt++;
		k *= 3;
	}
}

Measured memory_bytes: 3208
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var s = new string[n];
        var s2 = new string[n];
        for (int i = 0; i < n; i++) s[i] = Console.ReadLine().Trim();
        for (int i = 0; i < n; i++) s2[i] = Console.ReadLine().Trim();
        getAns(s, s2, n, m);
    }
    static void getAns(string[] s, string[] s2, int n, int m)
    {
        var ans = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                if (s[i][j] != s2[i][j]) ans++;
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 43272
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int fac[100005];
int mod=1e9+7;

int modInverse(int a, int m) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        int q = a / m; 
        int t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
} 

int cal(int n,int r)
{
   if(n<=0||n<r)
      return 0;
   int z=fac[n];
   z=(z*modInverse(fac[n-r],mod))%mod;
   z=(z*modInverse(fac[r],mod))%mod;
   return z;
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n,k;
   cin>>n>>k;
   int a[n+1];
   fac[0]=1;
   for(int i=1;i<=n;i++)
   {
      fac[i]=(fac[i-1]*i)%mod;
   }
   for(int i=1;i<=n;i++)
         cin>>a[i];

   sort(a+1,a+n+1);
   int ans1=0,ans2=0;
   for(int i=1;i<=n;i++)
   {
      if(a[i]<0)
      {
         a[i]+=mod;
      }
      a[i]%=mod;
      ans1=(ans1+((cal(i-1,k-1)*a[i]))%mod)%mod;
      if(n>=i)
         ans2=(ans2+((cal(n-i,k-1)*a[i]))%mod)%mod;
      // cout<<ans1<<" "<<ans2<<"\n";
   }
   cout<<(ans1-ans2+mod)%mod;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    int t = sqrt(n) + 1;
    cout << n << ":";
    FOR(i,2,t){
        while(n%i == 0){
            cout << " " << i;
            n /= i;
        }
        t = sqrt(n)+1;
    }
    if(n!=1){cout << " " << n << endl;}
    else{
        cout << endl;
    }

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3120
N = int(input())
S = input()

A = []
w = 0
for si in S:
    if si == 'W':
        w += 1
    A.append([w, 100])

E = []
e = 0
for si in S[::-1]:
    if si == 'E':
        e += 1
    E.append(e)

E = E[::-1]
for i in range(N):
    A[i][1] = E[i]

ans = N
for ai in A:
    ans = min(ans, ai[0] + ai[1] - 1)
print(ans)

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

using namespace std;

int main(){
    long N;
    cin>>N;
    vector<long> w(N);
    long a=0, b=0;
    for(int i=0; i<N; ++i){
        cin>>w[i];
        b+=w[i];
    }

    long ans = b;
    for(int i=0; i<N; ++i){
        a+=w[i];
        b-=w[i];
        if(abs(a-b) < ans){
            ans = abs(a-b);
        }
    }


    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main (){
    int a, b, x;
    cin >> a >> b >> x;
    if (a+b < x) cout << "NO" << endl;
    else if (a > x) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
    }
    


Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// 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)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        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)*}
    };
}

#[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<_>>()
    };

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

fn main() {
    input! {
        n: usize,
        m: usize,
        abs: [(usize1, usize1); m],
    }
    let mut islands = vec![0; n];
    for ab in abs.into_iter() {
        if ab.0 == 0 {
            if islands[ab.1] == 2 {
                println!("POSSIBLE");
                return;
            } else {
                islands[ab.1] = 1;
            }
        } else if ab.1 == n - 1 {
            if islands[ab.0] == 1 {
                println!("POSSIBLE");
                return;
            } else {
                islands[ab.0] = 2;
            }
        }
    }
    println!("IMPOSSIBLE");
}

Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  string s;
  ll ans = 0;
  cin >> s;
  bool f = false;
  int w_cnt = 0;
  REP(i, s.size()) {
    if (s[i] == 'W') {
      ans += i - w_cnt;
      w_cnt++;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

const ll x[10] = { 1,2,4,7,12,20,33,54,88,143 };

int N;
ll a[10][10], b;

int main() {
	cin >> N;
	b = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			a[i][j] = a[j][i] = x[j - i - 1] * b + 1;
		}
		b *= x[9 - i] - 1;
	}
	a[9][8] = a[8][9] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			cout << a[i][j];
			if (j != N - 1)cout << sp;
		}
		cout << endl;
	}
	/*
	vector<int>v{ 0,1,2,3,4,5,6,7,8,9 };
	map<ll, vector<int>>mp;
	do {
		if (v.front() > v.back())continue;
		ll t = 0;
		for (int i = 0; i < 9; ++i) {
			t += a[v[i]][v[i + 1]];
		}
		if (t > 1e11) {
			cout << t << endl;
			for (int i : v) {
				cout << i << sp;
			}
			cout << endl;
		}
		if (mp.find(t) != mp.end()) {
			cout << t << endl;
			for (int i : mp[t]) {
				cout << i << sp;
			}
			cout << endl;
			for (int i : v) {
				cout << i << sp;
			}
			cout << endl;
		}
		else {
			mp[t] = v;
		}
	} while (next_permutation(v.begin(), v.end()));*/
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split(" ")]
x = [int(i) for i in input().split(" ")]

if n < m:
    x.sort()
    d = [x[i] - x[i - 1] for i in range(1, len(x))]
    d.sort()

    sum = 0
    for i in range(0, m - n):
        sum += d[i]
    print(sum)
else:
    print(0)


Measured memory_bytes: 13840
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tp;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<LL, pii> plpii;
typedef pair<LD, LD> pdd;
typedef pair<LD, int> pdi;
typedef pair<LD, LL> pdl;
typedef pair<int, LD> pid;
typedef pair<LL, LD> pld;
const int mod = 1e9 + 7;
const int hf = 999983;
const int N = 1e6;
int cnt[4];
LD dp[305][305][305];
bool vis[305][305][305];
int n;
LD dfs(int a, int b, int c){
    if(a == 0 && b == 0 && c == 0) return 0;
    if(vis[a][b][c]) return dp[a][b][c];
    vis[a][b][c] = 1;
    int sum = a+b+c;
    LD rem = (LD)n/sum - 1;
    LD ans = 0;
    if(a > 0){
        LD prob = (LD)a/sum;
        ans += prob*(dfs(a-1, b, c) + 1 + rem);
    }
    if(b > 0){
        LD prob = (LD)b/sum;
        ans += prob*(dfs(a+1, b-1, c) + 1 + rem);
    }
    if(c > 0){
        LD prob = (LD)c/sum;
        ans += prob*(dfs(a, b+1, c-1) + 1 + rem);
    }
    return dp[a][b][c] = ans;
}
int main(){
    int a;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", &a);
        cnt[a]++;
    }
    printf("%.10Lf\n", dfs(cnt[1], cnt[2], cnt[3]));
}


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

string date[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main()
{
	string s;
	cin >> s;
	int j = 0;
	
	if(date[0] == s)
	{
		cout << 7 << endl;
		return 0;
	}
	
	for(int i = 0; i < 7; i++)
	{
		if(date[i] == s)
			j = i;
	}
	
	cout << 7 - j << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
using qll = queue<ll>;
using vb = vector<bool>;
using sll = stack<ll>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
ll INF = 1LL << 60;

const string YES = "YES";
const string NO = "NO";


void dfs(vector<vll> &G, vb &checked, ll u){
    checked[u] = true;
    for(auto v: G[u]){
        if(!checked[v])
            dfs(G, checked, v);
    }
}

void dfs_driver(vector<vll> &G, vb &checked){
    ll N = G.size();
    fill(ALL(checked), false);
    REP(i, N){
        if(!checked[i]){
            dfs(G, checked, i);
        }
    }
}

int main(){
    ll N, M;
    cin >> N >> M;
    vector<vll> G(M+N);
    REP(i, N){
        ll len, lang;
        cin >> len;
        REP(j, len){
            cin >> lang;
            lang += N-1;
            G[i].push_back(lang);
            G[lang].push_back(i);
        }
    }

    vb checked(M+N, false);
    dfs(G, checked, 0);
    REP(i, N){
        if(!checked[i]){
            cout << NO << endl;
            return 0;
        }
    }
    cout << YES << endl;
    return 0;
}


Measured memory_bytes: 8820
#include<stdio.h>
 
int main() {
    while (1) {
        int m, nmin, nmax, p[201], maxg = 0, n;
        scanf("%d %d %d", &m, &nmin, &nmax);
        for (int i = 1; i <= m; i++) {
            scanf("%d", &p[i]);
        }
        for (int j = nmin; j <= nmax; j++) {
            if (p[j] - p[j+1] >= maxg) {
                maxg = p[j] - p[j+1];
                n = j;
            }
        }
        if (m == 0 && nmin == 0 && nmax == 0) {
            return 0;
        }
        else {
            printf("%d\n", n);
        }
    }
}


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

int main()
{
    int x,n;cin>>x>>n;
    int a[102];
    for(int i=0;i<102;i++)a[i]=1;

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

    for(int i=0;;i++)
    {
        if(a[x-i]==1)
        {
            cout<<x-i<<endl;return 0;
        }
        if(a[x+i]==1)
        {
            cout<<x+i<<endl;return 0;
        }
    }

}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long UL; // ULLONG_MAX, %llu
typedef unsigned int UI; //UINT_MAX %u
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

const int N = 200005;
LL num[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    LL ans = 0;
    FOR(i, 0, n-1) cin >> num[i];
    sort(num,num+n,greater<int>());
    ans = num[0];
    FOR(i, 2, n-1){
        ans += num[i>>1];
    }
    cout << ans;
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


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

int main(){
    int n,m;
    cin >> n >> m;
    string ans;
    if(m == n)ans = "Yes";
    else ans = "No";

    cout << ans << endl;
}

Measured memory_bytes: 256
#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 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 int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n;
	cin >> n;
	int ans;
	if(n == 0) ans = 1;
	else if(n == 1) ans = 2;
	else if(n == 2) ans = 1;
	else ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3100
M = (1 .. 12)
S = gets.chomp
s1,s2 = [0,2].map{|s| S[s,2].to_i }

if M.include?(s1) && M.include?(s2)
  puts "AMBIGUOUS"
elsif M.include?(s1) && !M.include?(s2)
  puts "MMYY"
elsif !M.include?(s1) && M.include?(s2)
  puts "YYMM"
else
  puts "NA"
end



Measured memory_bytes: 1788
def handan(a,b):
  return max(len(str(a)),len(str(b)))
def yakusu(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
N=int(input())
L=yakusu(N)
maxa=10**10
for i in range(len(L)):
  s=L[i]
  t=N//s
  maxa=min(maxa,handan(s,t))
print(maxa)

Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Abc166F
    {
        public static void Main()
        {
            var nabc = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var n = nabc[0];
            var abc = new long[] { nabc[1], nabc[2], nabc[3] };
            var s = new char[n, 2];

            for (int i = 0; i < n; i++)
            {
                var xy = Console.ReadLine();
                s[i, 0] = xy[0];
                s[i, 1] = xy[1];
            }

            var ans = new char[n];
            for (int i = 0; i < n; i++)
            {
                var x = s[i, 0] - 'A';
                var y = s[i, 1] - 'A';
                bool selectX = false;
                if (abc[x] == abc[y])
                {
                    if (abc[x] == 0)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                    else if (i < n - 1 &&
                        (s[i, 0] == s[i + 1, 0] || s[i, 0] == s[i + 1, 1]))
                        selectX = true;
                }
                else if (abc[x] < abc[y])
                    selectX = true;

                if (selectX)
                {
                    abc[x]++;
                    abc[y]--;
                    ans[i] = s[i, 0];
                }
                else
                {
                    abc[x]--;
                    abc[y]++;
                    ans[i] = s[i, 1];
                }
            }
            Console.WriteLine("Yes");
            foreach (var c in ans)
                Console.WriteLine(c);
        }
    }
}


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

int main()
{
    int N, ans;
    string S;
    cin >> N;
    int ct[4] = {};
    for (int i = 0; i < N; ++i)
    {
        cin >> S;
        if (S == "P") ct[0] = 1;
        else if (S == "W") ct[1] = 1;
        else if (S == "G") ct[2] = 1;
        else if (S == "Y") ct[3] = 1;
    }
    for (int i = 0; i < 4; ++i) if (ct[i] == 1) ans++;
    if (ans == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll h,n;
  
  cin>>h>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  ll sum=0;
  for(ll j=0;j<n;j++)
     sum =sum+a[j];
  if(sum>=h)
    cout<<"Yes"<<endl;
  else
    cout<<"No";
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll t[1000000];
string s[10000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};

typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
int main() {
	cin>>W>>H;
	string A;
	ll a=0;
	string B;
	ll b=0;
	rep(i,0,H){
		string tmp;
		rep(j,0,W){
			char c;
			cin>>c;
			tmp.push_back(c);
		}
		if(A.empty() || A == tmp){
				A=tmp;
				a++;
			}else if(B.empty() || B == tmp){
				B=tmp;
				b++;
			}else{
				cout<<"no"<<endl;
				return 0;
			}
	}
	if(abs(a-b)>1){
		cout<<"no"<<endl;
		return 0;
	}
	ll count[]={0,0};
	rep(i,0,W){
		count[A[i]-'0']++;
		if(A[i]==B[i]){
			cout<<"no"<<endl;
			return 0;
		}
	}
	if(abs(count[0]-count[1])<=1){
		cout<<"yes"<<endl;
	}else{
		cout<<"no"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3296
n = gets.chomp.to_i
xy = []
0.upto(n-1) do |i|
  x, y = gets.chomp.split.map(&:to_i)
  xy[i] = [x,y]
end

def dis(a,b)
  x = (a[0] - b[0]) ** 2
  y = (a[1] - b[1]) ** 2
  return Math.sqrt(x+y)
end

dis_total =  xy.combination(2).to_a.map{|a,b| dis(a,b)}.reduce(&:+)

p dis_total * 2 / n


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int p[n];
int sum = 0;
int max = 0;
for(int i = 0;i < n;i++){
  cin >> p[i];
  sum += p[i];
  if(p[i] >= max){
    max = p[i];
  }

}
  cout << sum - max/2 <<endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,t=0,a[64],k,s,i,j;
	while(1){
		scanf("%d %d",&n,&s);
		if(n==0&&s==0)break;
		k=s;
		for(i=0;i<64;i++)a[i]=0;
		for(i=0;i<n;i=(i+1)%n){
			//for(j=0;j<n;j++)printf("%d ",a[j]);
			//printf("\n");
			if(k){
				a[i]++;
				k--;
			}else if(a[i]){
				k=a[i];
				a[i]=0;
			}
			for(t=0,j=0;j<n;j++)if(!a[j])t++;
			if(t==n-1&&a[i]==s)break;
		}
		printf("%d\n",i);
	}	
	return 0;
}

Measured memory_bytes: 1028
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a,b;
int ans; 
bool Check(int x) {
	if(x%10!=x/10000)
		return 0;
	if(x/10%10!=x/1000%10)
		return 0;
	return 1;	
}
int main() {
	scanf("%d%d",&a,&b);
	for(int i=a;i<=b;i++)
		if(Check(i))
			ans++;
	printf("%d\n",ans);
}

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

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;

int ans = MOD, lef[2000], ri[2000], tmp[2000], N;
string A,B; 

void test(int x) {
    memset(tmp,0,sizeof tmp);
    int num = 0;
    F0R(i,N) if (A[i] != B[(i+x)%N]) {
        if (lef[i]) tmp[lef[i]-1] = max(tmp[lef[i]-1],ri[i]);
        num++;
    }
    F0Rd(i,N-1) tmp[i] = max(tmp[i],tmp[i+1]);
    F0R(i,N) {
        // go right first
        int t = tmp[i]*2+i; // -i
        int dist = (x+i) % N;
        dist = min(dist,N-dist);
        ans = min(ans,t+dist+num);
        
        // go left first
        t = i*2+tmp[i]; // -i
        dist = (x-tmp[i]+N) % N;
        dist = min(dist,N-dist);
        ans = min(ans,t+dist+num);
    }
}

void gen() {
    F0R(i,N) if (B[i] == '1') {
        lef[i] = 0;
        FOR(j,1,N) if (B[(i+j)%N] == '1') lef[(i+j)%N] = 0;
                else lef[(i+j)%N] = lef[(i+j-1)%N]+1;
                
        ri[i] = 0;
        FOR(j,1,N) if (B[(i-j+N)%N] == '1') ri[(i-j+N)%N] = 0;
                else ri[(i-j+N)%N] = ri[(i-j+1+N)%N]+1;
        break;
    }
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> A >> B; N = A.length();
	
	bool ok = 0;
	for (char c: B) if (c == '1') ok = 1;
	if (!ok) {
	    for (char c: A) if (c == '1') {
	        cout << -1;
	        return 0;
	    }
	    cout << 0;
	    return 0;
	}
	
	gen();
	F0R(i,N) test(i);
	if (ans == MOD) cout << -1;
	else cout << ans;
}

// read!
// ll vs. int!

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

int main(){
    int N,v;
    cin>>N;
    int A[N];

    for(int i=0;i<N;i++){
        cin>>A[i];
        if(i!=N-1){
            cout<<A[i]<<" ";
        }else{
            cout<<A[i]<<endl;
        }
    }

    for(int i=1;i<N;i++){
        v = A[i];
        int j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
            A[j+1]=v;
        }
        for(int k=0;k<N;k++){
            if(k!=N-1){
                cout<<A[k]<<" ";
            }else{
                cout<<A[k]<<endl;
            }
        }
    }
}


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

int main() {
	int n, m;
	while (cin >> n >> m, n, m) {
		vector<int>v;
		for (int i = 1;i <= n;i++)v.push_back(i);

		int now = 0;
		for (int i = 0;i < n - 1;i++) {
			for (int j = 0;j < m - 1;j++) {
				now++;
				now %= n-i;
			}
			v.erase(v.begin() + now);
		}
		cout << v[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 2956
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int n;
vector<lint> d;
void input(){
    cin >> n;
    d.resize(n);
    REP(i, n){
        cin >> d[i];
    }
    return;
}

void solve(){
    map<lint, lint> m;
    lint ans = 0;
    REP(i, n){
        if(i == 0 && d[0] == 0){
            ans = 1;
        }
        else if(i != 0){
            if(d[i] == 0){
                ans = 0;
            }
            m[d[i]]++;
        }
    }
    lint prev = 1;
    int k = 1;
    for (auto e : m){
        //debugpair(e.fst, e.snd);
        if(k != e.fst){
            ans = 0;
        }
        k++;
        ans *= power(prev, e.snd, 998244353);
        ans %= (lint)998244353;
        prev = e.snd;
    }
    cout << ans << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 7416
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::string x;
    std::cin >> n;
    std::vector<std::string> s(n);
    std::vector<int> v(n);
    for (int i = 0; i < n; i++) std::cin >> s[i] >> v[i];
    std::cin >> x;

    bool f = false;
    int ret = 0;
    for (int i = 0; i < n; i++) {
        if (f) ret += v[i];
        else if (s[i] == x) f = true;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    long long q;
    cin>>q;
    vector <int> b;
    while(q--)
    {
        int a;
        cin>>a;
        if(a==0)
        {
            long long x;
            cin>>x;
            b.push_back(x);
        }
        else if(a==1)
        {
            long long p;
            cin>>p;
            cout<<b.at(p)<<endl;
        }
        else
        {
            b.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 3920
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = list(input())
N = len(S)
tmp = ["A","G","C","T"]
ans = 0
for s in range(N):
    for t in range(s,N+1):
        # print(s,t,S[s:t])
        flag = True
        for x in S[s:t]:
            if x not in tmp:
                flag = False

        if flag:
            ans = max(ans,t-s)


print(ans)


Measured memory_bytes: 4076
N,W=map(int,input().split())

# dp用配列
dp=[]
for k in range(N+1):
    dp.append([0]*(W+1))


for i in range(N):
    w_i,v_i = map(int,input().split())
    for w in range(W+1):
        if w>=w_i:
            dp[i+1][w] = max(dp[i][w-w_i] + v_i , dp[i][w])
        else:
            dp[i+1][w] =dp[i][w]

# print(*dp,sep="\n")

print(dp[N][W])
        


Measured memory_bytes: 119916
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;

int a[N];
int b[N];
int c[N];
int n,m,q,x,y;

signed main()
{
    //freopen("file.inp","r",stdin);
    cin >> x >> y >> n >> m >> q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1, greater<int>());
    for (int i = 1; i <= m; i++)
    {
        cin >> b[i];
    }
    sort(b + 1, b + m + 1, greater<int>());
    for (int i = 1; i <= q; i++)
    {
        cin >> c[i];
    }
    sort(c + 1, c + q + 1, greater<int>());
    int sum = x + y;
    int res = 0;
    int i = 1;
    int j = 1;
    int k = 1;
    while (sum)
    {
        if (y == 0) j = 0;
        if (x == 0) i = 0;
        int mx = max(a[i], max(b[j], c[k]));
        res += mx;
        if (c[k] == mx) k++;
        else if (b[j] == mx) {
            j++;
            y--;
        } else {
            i++;
            x--;
        }
        sum--;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include <functional>
using namespace std;

int main(void) {
	string s, t;
	int ch[26] = { 0 };
	cin >> s >> t;
	for (int i = 0;i < 26;i++)
		ch[i] = -1;
	for (int i = 0;i < t.length();i++) {
		if (ch[s[i]-'a'] != -1 && ch[ s[i] -'a'] != t[i] - 'a' ) {
			cout << "No" << endl;
			return 0;
		}
		else if(ch[s[i] - 'a'] == -1)
			ch[s[i] - 'a'] = t[i] - 'a';
	}
	sort(ch, ch + 26);
	for (int i = 1;i < 26;i++) {
		if (ch[i - 1] == ch[i] && ch[i - 1] != -1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;

}


Measured memory_bytes: 776
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
int main()
{
	int a,b;cin>>a>>b;
	cout<<b+(b-a)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  map<map<char, ll>, ll> mp;

  rep(i, n){
    map<char, ll> tmp;
    rep(j,10){
      tmp[s[i][j]]++;
    }
    mp[tmp]++;
  }

  auto choose  = [&](ll n){
    return n * (n-1)/ 2;
  };

  ll cnt =0;
  for (auto m : mp){
    if (m.second > 1){
      cnt += choose(m.second);
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 67840
#include<cstdio>
using namespace std;
int a[200005];
int main(){
	int n,maxn=0,i;
	long long ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
	    scanf("%d",&a[i]);
	    if(maxn<=a[i]){
	    	maxn=a[i];
		}
		else{
			ans+=maxn-a[i];
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   
    long long int n1,m1,t;
   //cin>>t;
 t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,o=0;
       double pie=3.141592653589793238;
    long long int c=0,n,m=0,l=0,r=0,k=0,min1=10000000000000,max2=0,ans=0;
      map<long long int,long long int>mp,mp1;
 cin>>n>>k;
 long long int a[n];
 for(i=0;i<n;i++)
 cin>>a[i];
 p=1;
 for(i=0;i<k;i++)
 {
    // p=p*a[i];
 }
 for(i=k;i<n;i++)
 {
   		//p=c;
     //c=p/(a[i-k]);
   //c=c*a[i];
     if(a[i]>a[i-k])
     cout<<"Yes"<<"\n";
     else
     cout<<"No"<<"\n";
     //p=c;
 }
 
 
 
    }
 return 0;
}


Measured memory_bytes: 5156
def main():
    n = int(input())
    A = list(map(int,input().split()))

    A.sort(reverse = True)

    # print(A)
    B = [A[0]]
    for i in A[1:]:
        B.append(i)
        B.append(i)

    print(sum(B[:n-1]))


main()

Measured memory_bytes: 31496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
ll a[200006],b[200006];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a,a+n); sort(b,b+n);
    if(n%2==0){
        ll x=a[n/2-1]+a[n/2];
        ll y=b[n/2-1]+b[n/2];
        cout<<y-x+1<<endl;
    }else{
        cout<<b[n/2]-a[n/2]+1<<endl;
    }

}



Measured memory_bytes: 6692
import itertools

n,m=map(lambda x: int(x), input().split())

path={}
for i in range(n+1):
    path[i]=[]

for _ in range(m):
    a,b=map(lambda x: int(x), input().split())
    path[a].append(b)
    path[b].append(a)

node_list=list(itertools.permutations(range(2, n+1)))
ans=0
for node_tup in node_list:
    flag=True
    if node_tup[0] not in path[1]:
        continue
    for i in range(n-2):
        if node_tup[i+1] not in path[node_tup[i]]:
            flag=False
            break
    ans+=flag
print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <string>

std::string s;

int main()
{
	std::cin >> s;

	bool fl = s.size() % 2;

	if (s[0] == s.back())
		fl ^= true;

	std::cout << (fl ? "First" : "Second") << std::endl;

	return 0;
}

Measured memory_bytes: 512
-- Question B

import Data.List
import Control.Applicative
import Control.Monad

main = do
  n <- readLn ::IO Int
  putStrLn $ show ( check n)

check :: Int -> Int
check n 
  | n == 1  = 1
  | n < 4 = 2
  | n < 8 = 4
  | n < 16 = 8
  | n < 32 = 16
  | n < 64 = 32
  | otherwise =64  


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define LL long long
#define M 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	fastio
	LL a, b, i, cnt=0;
	cin>>a>>b;
	LL max = __gcd(a, b);
	if(max%2==0){
		cnt++;
		while(max%2==0)
			max/=2;
	}
	for(i=3; i*i<=max; i+=2){
		if(max%i==0){
			cnt++;
			while(max%i==0)
				max/=i;
		}
	}
	if(max>2)
		cnt++;
	cout<<cnt+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;
int memo[11][400];

void recursive(int depth, int sum, bool flag[10])
{
	++memo[depth][sum];
	for(int i = 0; i < 10; ++i)
	{
		if(flag[i])
		{
			continue;
		}
		flag[i] = true;
		recursive(depth + 1, sum + (depth + 1) * i, flag);
		flag[i] = false;
	}
}

void solve()
{	
	bool flag[10];
	memset(flag, 0, sizeof(flag));
	recursive(0, 0, flag);
	int n, s;
	while(cin >> n >> s)
	{
		if(s >= 331)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << memo[n][s] << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1176
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){}
void jury(){}
void solve(){
  int n = scan!int, m = scan!int;
  long k = scan!long;
  long[] as = scan!long(n);
  long[] bs = scan!long(m);
  
  long[] asum = [0], bsum = [0];
  foreach(a; as) asum ~= asum[$ - 1] + a;
  foreach(b; bs) bsum ~= bsum[$ - 1] + b;

  int ans;
  foreach(int i; 0 .. n + 1){
    if(asum[i] > k) break;
    int tmpans = i + uplimit(0, m, (int j) => asum[i] + bsum[j] <= k);
    ans.raiseTo(tmpans);
  }
  
  ans.writeln;
}


// 二分探索

// a 以上 c 以下の範囲で f(x) をみたす最大の x
// ただし、a がみたさない場合は a - 1 を返す ※範囲外エラーに注意
// f は単調減少であること
T uplimit(T)(T a, T c, bool delegate(T) f){
	if(f(c)) return c; if(! f(a)) return a - 1;
	while(a + 1 < c){ T b = (a + c) / 2; if(f(b)) a = b; else c = b; }
	return a;
}

// a 以上 c 以下の範囲で f(x) をみたす最小の x
// ただし、c がみたさない場合は c + 1 を返す ※範囲外エラーに注意
// f は単調増加であること
T downlimit(T)(T a, T c, bool delegate(T) f){
	if(f(a)) return a; if(! f(c)) return c + 1;
	while(a + 1 < c){ T b = (a + c) / 2; if(f(b)) c = b; else a = b; }
	return c;
}



Measured memory_bytes: 22640