akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N;
    cin >> N;
    vector<int> B(N-1);
    rep(i,N-1)cin >> B[i];
    int sum=0;
    sum+=B[0];
    rep(i,N-2){
        sum+=min(B[i],B[i+1]);
    }
  	sum+=B[N-2];
    cout << sum;


}

/*



 */



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

int main()
{
    string S;
    cin >> S;
    if(S.size() == 2) {
        cout << S << endl;
    } else {
        cout << S[2] << S[1] << S[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
#include <algorithm>
using namespace std;
int main(void){
    int n,q; cin >> n >> q;
    string S; cin >> S;
    vector<int> sum(n+1,0);
    int i = 0;
    while (i < n) {
        if (S[i] == 'A' && S[i+1] == 'C') {
            sum[i+1] = sum[i] + 1;
        } else{
            sum[i+1] = sum[i];
        } 
        i++;
    }
    i = 0;
    while (i < q) {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        tmp1--; tmp2--;
        cout << sum[tmp2] - sum[tmp1] << endl;
        i++;
    }
}


Measured memory_bytes: 3864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int[] ia = readNums();
		int n = ia[0];
		int m = ia[1];
		int x = ia[2];
		int[] ib = readNums();
		int c1 = 0;
		for (int i = 0; i < m; i++) {
			if (ib[i] < x)
				c1++;
		}
		int c2 = 0;
		for (int i = 0; i < m; i++) {
			if (ib[i] > x)
				c2++;
		}
		if (c1 < c2)
			pln(c1);
		else
			pln(c2);
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    string s, t, ans;
    cin >> s >> t;
    for (int i = s.size() - t.size(); i >= 0; i--)
    {
        for (int j = 0; j < t.size(); j++)
        {
            //cout << "i=" << i << " j=" << j << endl;
            if (s[i + j] == t[j] or s[i + j] == '?')
            {
                //cout << "same or ?" << endl;
                if (j == t.size() - 1)
                {
                    for (int k = 0; k < s.size(); k++)
                    {
                        if (k >= i && k < i + t.size())
                        {
                            //cout << 1 << endl;
                            ans += t[k - i];
                        }
                        else if (s[k] == '?')
                        {
                            //cout << 2 << endl;
                            ans += 'a';
                        }
                        else
                        {
                            //cout << 3 << endl;
                            ans += s[k];
                        }
                        //cout << ans << endl;
                    }
                    cout << ans << endl;
                    return 0;
                }
            }
            else
            {
                //cout << "dif" << endl;
                break;
            }
        }
    }
    cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
ll N;
ll M;
string s;
vector<ll > input1;  
vector<vector <ll > > input2;
//四角形の中点に座標がしていされていれば分け方はいっぱいある
//それ以外はNG
//基本的に座標が指定されても面積は二分割できる
int main(){
    
    //cin >> N;
    double W, H, x , y;
    cin >> W >> H >> x >> y;

    cout << fixed << setprecision(9)  << W * H / 2.0;

    if(W / 2 == x && H / 2 == y){
        cout << " 1"  << endl;
    }else{
        cout << " 0"  << endl;
    }

} 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long ans;
int N, M;
vector <int> G[100005];
int Colour[100005], cnt;
bool ok = 1;
void Read()
{
    cin >> N >> M;
    for(int i = 1; i <= M; i++)
    {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
}

void DFS(int node, int colour)
{
    Colour[node] = colour;
    ++cnt;
    for(int i = 0; i < G[node].size(); i++)
    {
        int neighb = G[node][i];
        if(Colour[neighb] == 0)
        {
            DFS(neighb, 3 - colour);
        }
        else
        {
            if(Colour[neighb] == colour)
                ok = 0;
        }
    }
}

void Solve()
{
    long long odd = 0, even = 0, isolate = 0;
    for(int i = 1; i <= N; i++)
    {
        ok = 1;
        cnt = 0;
        if(Colour[i] == 0)
        {
            DFS(i, 1);
            if(cnt == 1)
            {
                ++isolate;
                continue;
            }
            if(ok == 0)
                odd++;
            else
                even++;
        }
    }
    ans += even * 2 + odd;
    ans += odd * (odd - 1);
    ans += 2 * even * (even - 1);
    ans += 2 * even * odd;
    ans += isolate * (N - 1) * 2 + isolate;
    ans -= isolate * (isolate - 1);
    cout << ans << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

ll comb(int n, int k)
{
  if(n<0 || k<0 || n<k) return 0;
  ll table[n + 1][n + 1];
  for (int i = 0; i <= n; i++)
    table[i][0] = 1;
  for (int i = 1; i <= k; i++)
    table[i][i] = 1;

  for (int i = 2; i <= n; i++)
  {
    for (int j = 1; j < min(i, k + 1); j++)
    {
      table[i][j] = table[i - 1][j - 1] + table[i - 1][j];
    }
  }
  return table[n][k];
}

ll modpow(ll a, ll n ) {
  ll res = 1;
  while(n > 0) {
    if(n & 1) res = res * a;
    a = a * a;
    n >>= 1;
  }
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,p; cin >> n >> p;
  int even = 0;
  int odd = 0;
  REP(i,n){
    int a; cin >> a;
    if(a%2==0) even++;
    else odd++;
  }
  ll ans = 0;
  ll tmp = pow(2, even);
  if(p==0){
    ans += tmp;
    for(int i=2; i<=odd; i+=2) ans += comb(odd,i) * tmp;
  }else{    
    for(int i=1; i<=odd; i+=2) ans += comb(odd,i) * tmp;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int n;
	long long a;
	long long min=1000000;
	long long max=-1000000;
	long long S=0;

	cin>>n;

	for (int i=0;i<n;i++){
		cin>>a;
		if (a<min)min=a;
		if (a>max)max=a;
		S+=a;
	}

	cout<<min<<" "<<max<<" "<<S<<endl;

	return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define ld long double
using namespace std;
const int mod=1e9+7,N=1007;
int n,m;
char grid[N][N];int ans[N][N];
int main()
{cin>>n>>m;
  for(int i=0;i<n;++i)for(int j=0;j<m;++j)cin>>grid[i][j];
    ans[0][0]=1;
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            if(grid[i][j]=='#')continue;
            if(i)ans[i][j]+=ans[i-1][j];
            if(j)ans[i][j]+=ans[i][j-1];
        ans[i][j]%=mod;
        }
    }
    cout<<ans[n-1][m-1];
    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair< int64, int64 > Pi;
const int64 INF = 3000000000000000000LL;
    
int64 N, T, Q;
vector< Pi > data;
int64 dp[100002];
    
int64 rec(int idx, const int d)
{
  if(~dp[idx]) {
    return(dp[idx]);
  } else if(data[idx].second != data[idx + d].second) {
    return(dp[idx] = (data[idx].first + data[idx + d].first) / 2LL);
  } else {
    return(dp[idx] = rec(idx + d, d));
  }
}
    
int main()
{
  memset(dp, -1, sizeof(dp));
  scanf("%lld %lld %lld", &N, &T, &Q);
  data.push_back(Pi(-INF, 1));
  for(int i = 0; i < N; i++) {
    int64 A, D;
    scanf("%lld %lld", &A, &D);
    data.push_back(Pi(A, D));
  }
  data.push_back(Pi(INF, 2));
  while(Q--) {
    int64 X;
    scanf("%lld", &X);
    if(data[X].second == 1) printf("%lld\n", min(data[X].first + T, rec(X, +1)));
    else                    printf("%lld\n", max(data[X].first - T, rec(X, -1)));
  }
}

Measured memory_bytes: 4388
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int N, L;

int main() {
    scanf("%d%d", &N, &L);
    vector<string> strs(N);
    for (int i = 0; i < N; i++)
        cin >> strs[i];
    sort(strs.begin(), strs.end());

    string ans;
    for (int i = 0; i < N; i++)
        ans += strs[i];

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

Measured memory_bytes: 3712
fn main() {
    proconio::input! {
        n: usize,
        a: [u64; n],
    }

    let mut r = 1000u64;
    for i in 0..n - 1{
        if a[i] < a[i + 1] {
            r += (r / a[i]) * (a[i + 1] - a[i]);
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 2116
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    string A;
    cin >> A;
    int size = 'z'-'a'+1;
    vector<LL> cnt(size);
    REP(i, A.size())cnt[A[i]-'a']++;
    LL res = 0;
    REP(i, size)REP(j, i){
        res += cnt[i]*cnt[j];
    }
    cout << res+1 << endl;

    return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
#ARC071C
import sys

n=int(input())

alpnum=[]
alpnumtmp=[]
for i in range(0,26):
	alpnum.append(0)
	alpnumtmp.append(0)


tmp = input()
for j in range(0,len(tmp)):
	alpnum[ord(tmp[j])-ord("a")]+=1

for i in range(1,n):
	tmp = input()
	for j in range(0,26):
		alpnumtmp[j]=0
	for j in range(0,len(tmp)):
		alpnumtmp[ord(tmp[j])-ord("a")]+=1
	for j in range(0,26):
		alpnum[j]=min(alpnum[j],alpnumtmp[j])

ans=""
for i in range(0,26):
	for j in range(0,alpnum[i]):
		ans+=chr(97+i)

#print(alpnum)
print(ans)



Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	int n;
	cin >> n;
	bool a[8] = {};
	int free = 0;
	REP(i, n) {
		int score;
		cin >> score;

		if (score < 3200) {
			a[score / 400] = true;
		}
		else {
			free++;
		}

	}

	int colors = 0;

	REP(i, 8) {
		if (a[i] == true) {
			colors++;
		}
	}
	if (colors == 0) {
		cout << 1 << " " << free << endl;
	}
	else {
		cout << colors << " " << colors + free << endl;
	}





	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
Int K;
const int max_n = 100000+10;
vector<int> G[max_n];
bool visited[max_n];

Int dfs(int u, int p) {
    Int color;
    if(p == -1)
        color = K-1;
    else
        color = K-2;
    
    if(K < G[u].size())
        return 0;

    Int case_num = 1;
    for(auto v: G[u]) {
        if(v == p)
            continue;
        case_num = (case_num*color)%MOD;
        color--;
    }

    for(auto v: G[u]) {
        if(v == p)
            continue;
        case_num = (case_num*dfs(v, u))%MOD;
    }
    
    return case_num;
}

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

    for(int i = 0;i < N-1;i++) {
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    Int ans = dfs(0, -1)*K%MOD;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	map<string, vector<pair<int, int>>> MP;
	rep(i, N) {
		string S;
		int P;
		cin >> S >> P;
		MP[S].pb(mp(P, i + 1));
	}

	for (auto p : MP) {
		sort(MP[p.first].begin(), MP[p.first].end());
		reverse(MP[p.first].begin(), MP[p.first].end());
		for (auto i : MP[p.first]) {
			co(i.second);
		}
	}

	Would you please return 0;
}

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

int main(){
    int a,b;
    int k;
    cin >> a >> b >> k;
    int N = min(a, b);
    int count=0;
    for(int i=N; i>0; i--){
        if(a%i==0 && b%i==0){
            count++;
            if(count==k){
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,m;
    string str1,str2;
    while(1){
        cin>>str1;
        if(str1=="-"){
            break;
        }
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>m;
            str2=str1.substr(0,m);
            str1=str1.erase(0,m);
            str1=str1+str2;
        }
        cout<<str1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

ll n, a[110000], b[110000], c[110000];
ll dp[110000][3];

int main()
{
	fastio;		
	cin>>n;
	for (int i = 1; i <= n; i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}

	for (int i = 1; i <= n; i++)
	{
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];	
	}

	cout<<max(dp[n][0], max(dp[n][1], dp[n][2]))<<endl;

	return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r << endl;
    } else {
        cout << r + (10 - n) * 100 << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b;
    char ch;
    cin >> a >> ch >> b;
    if(ch == '+') cout << a + b << endl;
    else cout << a - b << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,d; cin>>n>>d;
  long long int x,y,count=0;
  for(int i=0;i<n;++i)
  {
    cin>>x>>y;
    double d1=sqrt(pow(x,2)+pow(y,2));
    if(d1<=d)
      count++;}
  cout<<count;
}

Measured memory_bytes: 3676
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

struct edge { LL to, cost; };
int start;
LL d[100100][3];
vector<edge> g[100100];

void dijkstra() {
	for (int i = 0; i < 100100; i++)REP(j, 3)d[i][j] = HINF<LL>();
	priority_queue<pair<int, pair<int, int>>, std::vector<pair<int, pair<int, int>>>, std::greater<pair<int, pair<int, int>>>> pq;
	d[start][0] = 0;
	pq.push(make_pair(d[start][0], make_pair(start, 0)));//cost,to
	while (!pq.empty()) {
		pair<int, pair<int, int>> p = pq.top();
		pq.pop();
		pair<int, int> i = p.second;
		if (d[i.first][i.second] < p.first)continue;
		for (int k = 0; k < (int)g[i.first].size(); k++) {
			edge e = g[i.first][k];
			if (d[e.to][(i.second + 1) % 3] <= d[i.first][i.second] + e.cost)continue;
			d[e.to][(i.second + 1) % 3] = d[i.first][i.second] + e.cost;
			pq.push(make_pair(d[e.to][(i.second + 1) % 3], make_pair(e.to, (i.second + 1) % 3)));
		}
	}
}

int n, m;
int a, b;
int to;
int main(){
    cin >> n >> m;
    REP(i, m){
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(edge{b, 1});
    }
    cin >> start >> to;
    start--, to--;
    dijkstra();
    cout << (d[to][0] == HINF<LL>() ? -1 : d[to][0]/3) << endl;
}


Measured memory_bytes: 8692
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int z = 0;

    if ( n % 2 == 0 ){
      z = n / 2;
    } else {
      z = n / 2 + 1;
    }
    
    System.out.print(z);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

vector<int> erat(int n) {
    vector<int> primes(n);
    for (int i = 2; i < n; ++i) primes[i] = i;
    for (int i = 2; i*i < n; ++i)
        if (primes[i])
            for (int j = i*i; j < n; j+=i) primes[j] = 0;
    // ?´???°?????????vector???????´?????????´????????\?????????????????? (0 ??§??????????´??????¨??????)
    primes.erase(remove(primes.begin(), primes.end(), 0), primes.end());
    return primes;
}

vector<int> primes;

signed main() {
    primes = erat(100010);
    int m, a, b;
    while(cin >> m >> a >> b, m||a||b) {
        int ma = 0, idx_a, idx_b;
        for(int i=0; primes[i]*primes[i] <= m; i++) {
            for(int j=i; primes[i]*primes[j] <= m; j++) {
                int p = primes[i], q = primes[j];
                if(a*q > b*p) break;
                if(ma < p*q) {
                    ma = p*q;
                    idx_a = p, idx_b = q;
                }
            }
        }
        printf("%lld %lld\n", idx_a, idx_b);
    }
    return 0;
}

Measured memory_bytes: 3424
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
	if(b&1)
		r=(r*a)%m;
	b=b/2;
	a=(a*a)%m;
	}
	return r%m;
}


int main()
{
    IOS
    string s,t;
    cin>>s>>t;
    ll count=0;
    rep(i,0,3)
    {
        if(s[i]==t[i])count++;
    }
    cout<<count<<"\n";


    return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int cnt = 0;
int a = 0;
int b = 0;

void permutation(int n, string seq, unsigned int contains, const string &p, const string &q) {
    if (seq.size() == n) {
        cnt += 1;
        if (seq == p) a = cnt;
        if (seq == q) b = cnt;
        return;
    }
    for (int i = 1; i <= n; i++) {
        if ((contains >> i) % 2 == 0) {
            permutation(n, seq + to_string(i), contains + (1 << i), p, q);
        }
    }
}

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;

    string p = "";
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        p += to_string(tmp);
    }

    string q = "";
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        q += to_string(tmp);
    }

    if (p == q) {
        cout << 0 << endl;
    } else {
        permutation(N, "", 0u, p, q);
        cout << abs(a - b) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, K int
	fmt.Scan(&n, &K)

	xs := make([]Point, n)
	ys := make([]Point, n)
	var x, y int
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		xs[i] = Point{i, x, y}
		ys[i] = Point{i, x, y}
	}

	sort.Slice(xs, func(i, j int) bool {
		return xs[i].x < xs[j].x
	})
	sort.Slice(ys, func(i, j int) bool {
		return ys[i].y < ys[j].y
	})

	ans := int(1e18 * 4)
	for x1 := 0; x1 < n; x1++ {
		for x2 := x1 + 1; x2 < n; x2++ {
			for y1 := 0; y1 < n; y1++ {
				for y2 := y1 + 1; y2 < n; y2++ {
					left, right, bottom, top := xs[x1].x, xs[x2].x, ys[y1].y, ys[y2].y
					cnt := 0
					for _, p := range xs {
						if left <= p.x && p.x <= right && bottom <= p.y && p.y <= top {
							cnt++
							if K <= cnt {
								ans = min(ans, (right-left)*(top-bottom))
								break
							}
						}
					}
				}
			}
		}
	}

	fmt.Println(ans)
}

// Point .
type Point struct {
	i, x, y int
}

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


Measured memory_bytes: 1884
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	ll N, A, x = 0;
	ll d2[61];
	d2[0] = 1;
	for (int i = 1;i < 61;i++) {
		d2[i] = d2[i - 1] * 2;
		d2[i] %= MOD;
	}

	cin >> N;
	vector<ll> bcnt(61, 0);
	for (int i = 0;i < N;i++) {
		cin >> A;
		x = 0;
		while (A) {
			if (A & 1)bcnt[x]++;
			x++;
			A /= 2;
		}
	}
	ll ans = 0;
	for (int i = 0;i < 61;i++) {
		ans += (bcnt[i] * (N - bcnt[i]) % MOD) * d2[i];
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

#define rep(i,n) for(int i = 0; i < 100; i++)
using namespace std;

int main(void){
  while(1){
    int r, w, c, rr;
    cin >> r >> w >> c >> rr;
    if(r+w+c+rr == 0)break;
    int X = 0;
    // r + Xrr = cw + cY
    while(1){
      int res = r + X*rr - c*w;
      if(res >=0){
        cout << X << endl;
        break;
      }
      X++;
    }
  }
  return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n" ,a ,b);
    }else if (a>b) {
        printf("a > b\n" ,a ,b);
    }else if (a==b){
        printf("a == b\n" ,a ,b);
    }
    return 0;
}

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

int main() {
   
   unordered_map<string,ll> m;
   
   string s;
   ll n;
   
   cin>>n;
   
   for(ll i=0;i<n;i++)
   {
       cin>>s;
       
       sort(s.begin(),s.end());//cout<<s<<"\n";
       m[s]++;
   }
   
   
   ll ans=0;
   for(auto x:m)
   ans+=(x.second*(x.second-1)/2);
   
   cout<<ans;
}

Measured memory_bytes: 10660
#include <stdio.h>
int main(){
	
	int N;
	scanf("%d", &N);
	long long int sum=0;
	for(int i=1;i<=N;i++){
		if(i%5==0 || i%3==0){
			
		} else {
			sum += i;
		}
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a))
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
void solve(){
    ll x;
    cin >> x;
    ll sum=100;
    if(x==sum){
        cout << 0 << endl;
        return;
    }
    for(int i=1; i<=4000; i++){
        sum+=(sum*1/100);
        if(sum>=x){
            cout << i << endl;
            return;
        }
    }
}
int main() {
    IOS;
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
	return 0;
}

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

#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define rep(a, b, i) for(int i = a; i < b; i++)
#define repi(a, b, i) for(int i = a; i > b; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define __ ios_base::sync_with_stdio(cin.tie(0) && 0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef double ld;

const ld pi = 3.141592653589793;
const ll inf = 1e18 + 5;
const int MOD = 1e9 + 7;
const int maxn = 2e5 + 5;
const int mxn = 1e5 + 5;
const int mx = 1000;

int main() {
  __;

  int d, t, s; cin >> d >> t >> s;
  if(1ll * s * t >= d) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}


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

int main () {
  char s[100010];
  cin >> s;
  bool app[26] = {false};
  char ans;
  for (int i = 0; s[i] != '\0'; ++i){
    app[s[i] - 'a'] = true;
  }
  for (int i = 0; i < 26; ++i) {
    if(!app[i]){
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
int a,j,c;
  c=0;
  scanf("%d",&a);
int b[a];  
  for(j=0;j<a;++j)
  {scanf("%d",&b[j]);
   
  if(b[j]%2==1) c=c+1;
  else if(b[j]%3==0) c=c+1;
  else if(b[j]%5==0) c=c+1;
  }
  if(c==a) printf("APPROVED");
  else printf("DENIED");
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <bitset>
#include <utility> 
using namespace std;

int main() {
   int A,B,C; cin >> A >> B >> C;
   if ((B-C)*(C-A)>0) cout << "Yes" << endl;
   else cout << "No" << endl; 
}

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

using namespace std;

const int MAXN = 212345;

string s;
int v[MAXN];


int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n, q;
	cin >> n >> q >> s;

	for (int i = 1; i < n; ++i) {
		v[i] += v[i - 1];
		if (s[i] == 'C' && s[i-1] == 'A') v[i]++;
	}

	while (q--) {
		int l, r;
		cin >> l >> r;

		--l; --r;
		cout << v[r] - v[l] << '\n';
	}
	






	return 0;
}


Measured memory_bytes: 1488
n = int(input())
a_list=[9]
a_list += list(map(int, input().split()))

ans_list=[0]*(n+1)
output=[]
for i in range(n,0,-1):
  #print("i",i)
  siji=a_list[i]
  num=n//i
  #print("num",num)
  tmp=0
  for j in range(1,num+1):
    #print("j",j,ans_list[i*j])
    tmp+=ans_list[i*j]
  #print("ans_list",ans_list)
  #print("siji",siji)
  #print(tmp)
  if tmp%2==siji:
    ans_list[i]=0
  else:
    ans_list[i]=1
    output.append(i)
    
print(sum(ans_list[1:]))
for i in range(len(output)):
    if i == len(output)-1:
      print(output[i])
    else:
      print(output[i],end=" ")

Measured memory_bytes: 69724
ans = 'Yes'
t = 0
n = int(input())
list_ab = [list(map(int, input().split())) for _ in range(n)]
# 期限の迫っている順に並べる
list_ab.sort(key=lambda val: val[1])

for i in range(n):
    t += list_ab[i][0]
    if t > list_ab[i][1]:
        ans = 'No'
        break

print(ans)


Measured memory_bytes: 53600
#include <stdio.h>
#include <stdlib.h>

static int comp(const void *p1, const void *p2){
    long long int *arr1 = (long long int *)p1;
    long long int *arr2 = (long long int *)p2;
    long long int diff1 = arr2[0] - arr1[0];
    if (diff1)
        return diff1;
    return 0;
}

int main(){
    long long int N;
    long long int M;
    long long int A[100000];
    long long int B[100000];
    long long int C[100000];
    scanf("%lld",&N);
    scanf("%lld",&M);
    long long int i;
    for(i=0;i<N;i++){
        scanf("%lld",&A[i]);
    }
    for(i=0;i<M;i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    long long int a[200000][2];
    for(i=0;i<N;i++){
        a[i][0]=A[i];
        a[i][1]=1;
    }
    for(i=0;i<M;i++){
        a[i+N][0]=C[i];
        a[i+N][1]=B[i];
    }
    for(i=N+M;i<200000;i++){
        a[i][0]=0;
        a[i][1]=0;
    }
    qsort(a,200000,2*sizeof(long long int),comp);
    long long int ans;
    ans=0;
    for(i=0;i<200000;i++){
        if(a[i][1]>N){
            ans=ans+a[i][0]*N;
            break;
        }else{
            ans=ans+a[i][0]*a[i][1];
            N=N-a[i][1];
        }
    }
    printf("%lld",ans);
}

Measured memory_bytes: 8700
#include <iostream>
using namespace std;
typedef long long int LLI;

int main()
{
	int n;
	cin >> n;
	int arr[n], ans[n];
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	for(int i = 0; i < n/2; i++)
	{
		ans[i] = arr[n-1-2*i];
		ans[n-1-i] = arr[n-2-2*i];
	}
	if( n % 2 == 1 )
		ans[n/2] = arr[0];
	for(int i = 0; i < n; i++)
		cout << ans[i] << " ";
}

Measured memory_bytes: 5144
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {


	lli A, B;
	cin >> A >> B;
	A--; B--;

	cout << A * B << endl;

	return 0;
}

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

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << ((a&1) && (b&1) ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int n,l,a[N];
vector <int> ans,v;
bool flag;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> l;
  for (int i = 1 ; i <= n ; i++)
    cin >> a[i];
  for (int i = 1 ; i < n ; i++)
    if (a[i] + a[i + 1] >= l)
      v.push_back(i);
  if (v.empty() == false) {
    for(int i = 0 ; i < v.size(); i++) {
      if (i == 0)
        for (int j = 1 ; j < v[0] ; j++)
          ans.push_back(j);
      else
        for (int j = v[i - 1] + 1 ; j < v[i] ; j++)
          ans.push_back(j);
    }
    for (int j = n - 1 ; j > v.back() ; j--)
      ans.push_back(j);
    for (auto i : v)
      ans.push_back(i);
    cout << "Possible\n";
    for (auto i : ans)
      cout << i << "\n";
  }
  else {
    cout << "Impossible";
  }
}

Measured memory_bytes: 2168
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
A = LI()
B = LI()

ans = 0
for i in range(n):
    if B[i] > A[i] + A[i+1]:
        ans += A[i] + A[i+1]
        A[i] = 0
        A[i+1] = 0
    else:
        ans += B[i]
        if B[i] > A[i]:
            A[i+1] -= B[i] - A[i]

print(ans)

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int h, a;
    cin >>h >> a;
    int t = h / a;
    if( h % a ) ++t;
    cout << t << endl;
    return 0;
}



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

typedef long long ll;
const int maxn = 3e5;
int n, m, x[maxn + 3];
bool l[maxn + 3], r[maxn + 3];
ll ans;

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &x[i]);
	}
	for (int i = 1, t; i <= n; i++) {
		scanf("%d", &t);
		if (t % (m * 2) == 0) {
			ans += t;
		} else {
			ans += (t / (m * 2) + 1) * (m * 2);
			t %= m * 2;
			l[i] = t <= x[i] * 2;
			r[i] = t <= (m - x[i]) * 2;
		}
	}
	int p = 0, q = 0;
	for (int i = 1; i < n; i++) {
		if (p && r[i]) {
			if (l[i]) {
				q++;
			}
			p--, ans -= m * 2;
		} else if (!l[i] && r[i]) {
			if (q) {
				p++, q--;
			}
		} else if (l[i]) {
			p++;
		}
	}
	if (!r[n]) {
		ans += m * 2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define REP(i,l,r) for(int i=l;i<r;++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int,int> P;
//other libs

signed main(int argc, char * argv[]) {
	int n;
	cin>>n;
	vector<double> v(n);
	rep(i,n)cin>>v[i];
	sort(v.begin(),v.end());
	REP(i,1,n){
		v[i]=(v[i]+v[i-1])/2;
	}
	printf("%.15f",v[n-1]);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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

	int n, x; cin >> x >> n;
	set<int> p;
	rep(i, n) {
		int a; cin >> a;
		p.insert(a);
	}

	for (int i = 0; ; ++i) {
		if (p.find(x - i) == p.end()) { cout << x - i << endl; return 0; }
		if (p.find(x+i) == p.end()) { cout << x+i << endl; return 0;}
	}
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

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


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

using namespace std;


int main(void){
  int count=0;
  string S,T;
 
  
  cin >> S >> T;

 for(int i =0; i < S.size() ;i++){
   if(S[i] != T[i]){
     count++;
   }
 }
 
  cout << count << endl;

  return 0;
}



Measured memory_bytes: 3912
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;
const int INF = 1001001001;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    set<int> s;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        if(s.find(a) == s.end())    s.insert(a);
        else    s.erase(a);
    }
    cout << s.size() << "\n";
}

Measured memory_bytes: 4992
from math import pow
l = []
l.append(1)
l.append(2 ** 2)
l.append(2 ** 3)
l.append(2 ** 4)
l.append(2 ** 5)
l.append(2 ** 6)
l.append(2 ** 7)
l.append(2 ** 8)
l.append(2 ** 9)
l.append(3 ** 2)
l.append(3 ** 3)
l.append(3 ** 4)
l.append(3 ** 5)
l.append(5 ** 2)
l.append(5 ** 3)
l.append(5 ** 4)
l.append(6 ** 2)
l.append(6 ** 3)
l.append(7 ** 2)
l.append(7 ** 3)
l.append(10 ** 2)
l.append(10 ** 3)
for i in range(11, 32):
    l.append(i ** 2)
def print_exponential(integer):
    while integer > 0:
        if integer in l:
            break
        else:
            integer -= 1
    print(integer)
X = int(input())
print_exponential(X)

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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T1, typename T2>
inline auto mini(T1 a, T2 b) { return (a < b ? a : b); }
template<typename T, typename... Args>
inline auto mini(T a, Args... args) { return mini(a, mini(args...)); }
template <typename T1, typename T2>
inline auto maxi(T1 a, T2 b) { return (a > b ? a : b); }
template<typename T, typename... Args>
inline auto maxi(T a, Args... args) { return maxi(a, maxi(args...)); }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // use mt19937_64 for 64 bit

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e5+3;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    int a;
    cin >> a;
    int ans = a + a*a + a*a*a;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3560