akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int ans = 0, i;
	n *= 7;
	for (i = 1; i <= n % 693; i++)
		if (i % 7 > 1)
			if (9 * i % 11 == k)
				ans++;
	long long int count = 0;
	for (i = 1; i <= 693; i++)
		if (i % 7 > 1)
			if (9 * i % 11 == k)
				count++;
	ans += count * (n / 693);
	for (i = 1; i <= 7; i++)
		if (i % 7 > 1)
			if (9 * i % 11 == k)
				ans--;
	for (i = n - 6; i <= n; i++)
		if (i % 7 > 1)
			if (i * 9 % 11 == k)
				ans--;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint moe=992186091;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int ya,ma,da,yb,mb,db;cin>>ya>>ma>>da>>yb>>mb>>db;
	da+=ma*100;
	db+=mb*100;
	if(ya*10000+da<yb*10000+db){swap(ya,yb);swap(da,db);}
	int ans=ya-yb;
	if(da>db){ans++;}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>
int main(void){
  int a,b;
  scanf("%d%d",&a,&b);

  if(a < b){  
    printf("a < b\n"); 
 } else if( a > b) {
   printf("a > b\n");
 } else {
  printf("a == b\n");
 }
  return 0;
}

Measured memory_bytes: 580
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int w = int.Parse(input[0]);
        int a = int.Parse(input[1]);
        int b = int.Parse(input[2]);
        if(Abs(a-b) <= w){
            WriteLine("0");
        }else{
            WriteLine(Abs(a-b)-w);
        }
    }
}


Measured memory_bytes: 11092
N = int(input())

if N == 3:
    ans = {2, 3, 25}
elif N == 4:
    ans = {2, 3, 4, 9}
elif N == 5:
    ans = {2, 3, 4, 6, 9}
else:
    ans = set()
    sumAns = 0
    num = 0
    # 2の倍数もしくは3の倍数を、小さい順に追加する
    for i in range(1, 30001):
        if i % 2 == 0 or i % 3 == 0:
            ans.add(i)
            sumAns += i
            num += 1

        if num == N: break

    # [合計が6の倍数]になるように調整する
    if sumAns % 6 == 2:
        ans.remove(8)
        ans.add(((i + 6) // 6) * 6) # 次の6の倍数
    elif sumAns % 6 == 3:
        ans.remove(9)
        ans.add(((i + 6) // 6) * 6) # 次の6の倍数
    elif sumAns % 6 == 5:
        ans.remove(9)
        ans.add(((i + 2) // 6) * 6 + 4) # 次の6k+4形式の数

print(' '.join(map(str, ans)))


Measured memory_bytes: 5472
#include "bits/stdc++.h" 
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9

typedef long long unsigned int ll;

int A,B,C;

void solve(){
  int res = C -(A - B);
  if(res < 0){
    res = 0;
  }
  cout << res << endl;
}


int main(){
  cin >> A >> B >> C;
  solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    ll N, K;
    cin >> N >> K;
    ll q = N / K;
    ll smaller = min(abs(N - q*K), abs(N - (q+1)*K));
    cout << smaller << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int h, w;
  cin >> h >> w;
  vector< vector< int > > a(h, vector< int >(w));
  for (int i=0; i<h; ++i) {
    for (int j=0; j<w; ++j) cin >> a[i][j];
  }
  vector< string > ans;
  for (int i=0; i<h; ++i) {
    for (int j=0; j<w; ++j) {
      int fi=i;
      int fj = (i%2==0 ? j : w-j-1);
      if (a[fi][fj]%2==0) continue;
      int tj = (i%2==0 ? fj+1 : fj-1);
      int ti = fi;
      if (tj<0) {
        tj=0;
        ti++;
      } else if (w<=tj) {
        tj=w-1;
        ti++;
      }
      if (h<=ti) continue;
      a[fi][fj]--;
      a[ti][tj]++;
      string ans_line = to_string(fi+1) + " " + to_string(fj+1) + " " + to_string(ti+1) + " " + to_string(tj+1);
      ans.push_back(ans_line);
    }
  }
  cout << ans.size() << endl;
  for (ul i=0; i<ans.size(); ++i) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 11892
N = int(input())
ans = N
for i in range(N + 1):
    cnt = 0
    t = i
    while t > 0:
        cnt += t % 6
        t //= 6
    j = N - i
    while j > 0:
        cnt += j % 9
        j //= 9
    ans = min(ans, cnt)
print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<int64_t>hari(n);
  for(int i=0;i<n;i++)
    cin >> hari.at(i);
  sort(hari.begin(),hari.end(),greater());
  int64_t ans=hari.at(0);
  for(int i=1;i<n;i++){
    if(ans%hari.at(i)!=0){
      int64_t a=ans;
      while(ans%hari.at(i)!=0)
        ans+=a;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
    int H, N;
    cin >> H >> N;
    int a[10000], b[10000];
    for (int i = 0; i < N; ++i) cin >> a[i] >> b[i];
    vector<vector<long long>> dp(N + 1, vector<long long>(H + 1, 1000000000));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= H; ++j) {
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][min(j + a[i], H)], dp[i + 1][j] + b[i]);
        }
    }
    cout << dp[N][H] << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	for(int i=1;true;++i){
		int x; cin>>x;
		if(x==0)break;
		cout<<"Case "s<<i<<": "s<<x<<"\n"s;
	}
}


Measured memory_bytes: 3132
#include<bits/stdc++.h> 
typedef int LL;
typedef long double DL;
const LL maxn=1e6+9;
//const DL mod=998244353;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3)+(x<<1)+c-'0'; c=getchar();
	}return x*f;
}
bool Check(LL x){
	return x>=1 && x<=9;
}
int main() {
	LL a(Read()),b(Read());
	if(Check(a) && Check(b)) printf("%d\n",a*b);
	else puts("-1");
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let h: i64 = read();
    let n: usize = read();
    let a: Vec<i64> = read_n(n);

    if a.iter().sum::<i64>() < h {
        println!("{}", "No");
    } else {
        println!("{}", "Yes");
    }
}


Measured memory_bytes: 13692
def isSS(s):
    n = len(s) // 2
    s1 = s[0:n]
    s2 = s[n:]
    return s1 == s2

s = input()

for _ in range(len(s)):
    s = s[:len(s)-1]
    if isSS(s):
        print(len(s))
        break

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		char current = 'A';
		while ((line = br.readLine()) != null) {
			if (line.charAt(0) == current || line.charAt(2) == current)
				current = line.charAt(0) == current ? line.charAt(2) : line
						.charAt(0);
		}
		System.out.println(current);
	}
}

Measured memory_bytes: 16856
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x,k;
    string s;
    cin>>x>>s>>k;
    k--;
    char a=s[k];
    for (int i=0;i<x;i++){
        if (s[i]!=a)
            cout<<'*';
        else
            cout<<a;
    }
    return 0;
}


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

vector<int> G[100010];
vector<int> T[100010];
int target[100010];
bool used[100010];
void dfs(int v) {
    used[v] = true;
    for (auto to: G[v]) {
        if (used[to]) continue;
        T[v].push_back(to);
        T[to].push_back(v);
        dfs(to);
    }
}

typedef pair<int, int> P;
map<P, int> mp;

vector<P> ans;
int edge[100010];
void dfs2(int v, int p) {
    for(auto to: T[v]) {
        if (to == p) continue;
        dfs2(to, v);
    }
    if (p == -1) return;
    if (edge[v] % 2 == target[v] % 2) {
        edge[p]++;
        ans.push_back({v, p});
    } else {
        edge[v]++;
        ans.push_back({p, v});
    }
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int A[100010], B[100100];
    if (M % 2 != 0) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        if (A[i] > B[i]) swap(A[i], B[i]);
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    dfs(0);
    
    rep(i, N) {
        for(auto to: G[i]) {
            int u = i, v = to;
            if (u > v) swap(u, v);
            mp[{u, v}]++;
        }
        for(auto to: T[i])   {
            int u = i, v = to;
            if (u > v) swap(u, v);
            mp[{u, v}]--;
        }
    }
    for(auto itr = mp.begin(); itr != mp.end(); itr++ ) {
        if (itr->second > 0) {
            //cout << itr->first.first + 1 << " " << itr->first.second + 1<< endl;
            target[itr->first.second] += itr->second/2;
            ans.push_back(itr->first);
        }
    }
    dfs2(0, -1);
    for(auto e: ans) {
        cout << e.second + 1 << " " << e.first + 1 << endl;
    }


    return 0;
}


Measured memory_bytes: 26996
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007




signed main(){

	string s;
	cin >> s;
	int N = s.length();
	set<char> k;

	for (int i = 0; i < N; i++){
		k.insert(s[i]);
	}

	int ans = INF;
	for (auto m = k.begin(); m != k.end(); m++){
		int m_gap = -1;
		char c = *m;
		for (int i = 0; i < N; i++){
			int gap = 0;
			while (i < N && s[i] != c){
				i++;
				gap++;
			}
			m_gap = max(m_gap, gap);
		}
//		cout << c << " " << m_gap << endl;
		ans = min(ans, m_gap);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;





int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n;
    string s;
    cin >> s;
    vvll dp(n+1,vll(n+1,0));
    dp[0][1]=1;
    for(int i=1; i<=n; i++){
        dp[0][i]+=dp[0][i-1];
    }
    for(int i=0; i<n-1; i++){
        if(s[i]=='>'){
            for(int j=1; j<=i+2; j++){
                dp[i+1][j]=dp[i][n]-dp[i][j-1];
            }
        }
        else{
            for(int j=1; j<=i+2; j++){
                dp[i+1][j]=dp[i][j-1];
            }
        }
        for(int j=1; j<=n; j++){
            dp[i+1][j]+=dp[i+1][j-1];
            dp[i+1][j]%=mod;
        }
    }
    cout << (dp[n-1][n]+mod)%mod << el;
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>

using namespace std;

int i = 0;
int x;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (true) {
		cin >> x;
		if (x == 0)	break;
		cout << "Case " << i + 1 << ": " << x << "\n";
		i++;
	}

	return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int K;
    cin >> K;
    long long sum = 0;
    rep(a, 1, K + 1) {
        rep(b, 1, K + 1) {
            int ab = GCD(a, b);
            rep(c, 1, K + 1) {
                // cout << GCD(ab, c) << endl;
                sum += GCD(ab, c);
            }
        }
    }
    cout << sum << endl;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    n %= 10;
    string ans;
    switch (n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        ans = "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        ans = "pon";
        break;
    case 3:
        ans = "bon";
        break;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3628
N = int(input())
B = list(map(int, input().split()))

A = []
for i in range(N):
  if i == 0:
    A.append(B[0])
  elif i == N - 1:
    A.append(B[-1])
  else:
    A.append(min(B[i], B[i - 1]))
print(sum(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  ll ans;
  if (N == 1) {
    if (M == 1)
      ans = 1;
    else if (M == 2)
      ans = 0;
    else
      ans = M - 2;
  } else if (N == 2) {
    ans = 0;
  } else {
    if (M == 1)
      ans = N - 2;
    else if (M == 2)
      ans = 0;
    else
      ans = (N - 2) * (M - 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())
ans = []
for i in range(a, min(a + k, b + 1)):
    ans.append(i)
for i in range(b, max(b - k, a - 1), -1):
    if i not in ans:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)


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

using namespace std;
using ll = long long;

int main () {
	ll n;
	cin >> n;
	int sol = 0;

	for (ll i = 2; i * i <= n; i++) {
		if (n % i) continue;
		int cur = 0;

		while (n % i == 0) {
			cur++;
			n /= i;
		}

		for (int j = 1; j <= cur; j++) {
			cur -= j;
			sol++;
		}

	}

	sol += (n > 1);

	cout << sol << '\n';
}


Measured memory_bytes: 3620
from networkx import*
(N,M,*S),*t=[map(int,t.split())for t in open(0)]
G=Graph()
for u,v,a,b in t:G.add_edge(u,v,y=a,s=b)
b=m=10**15
y,s,*r=map(eval(dir()[761]),(G,G),S,(m,m),'ys')
while N:b=min(b,y[N]+s[N]);r+=m-b,;N-=1
print(*r[::-1])

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

#define REP(i,n) for(ll i=0; i<n; i++)
#define REPN(i,n) for(ll i=0; i<n; i++,cout<<"\n")
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod1 1000000007
#define ll long long
#define clr0(arr) memset(arr,0,sizeof(arr))
#define clrval(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

void solve(){
	ll n,k;
	cin>>n>>k;

	ll a[n];
	REP(i,n) cin>>a[i];

	ll dp[n];
	clr0(dp);

	dp[1]=abs(a[1]-a[0]);

	for(ll i=2; i<n; i++){
		ll tempAns=INT_MAX;
		for(ll j=1; j<=k; j++){
			if(i-j>=0){
				ll val = dp[i-j] + abs(a[i]-a[i-j]);
				tempAns=min(tempAns,val);
			} else break;
		}

		dp[i]=tempAns;
	}

	cout<<dp[n-1]<<"\n";
}

int main(){
	// int t;
	// cin>>t;

	// while(t--){
		solve();
	// }

	return 0;
}


Measured memory_bytes: 5104
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B;
    scan(A, B);
    foreach (x; 1 .. 10_000)
    {
        // writeln(x, " ", (x * 108) / 100);
        if (A == (x * 108) / 100 - x && B == (x * 110) / 100 - x)
        {
            writeln(x);
            return;
        }
    }
    writeln(-1);
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef set<int> si;
typedef set<ll, ll> sll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<int, int> mii;
typedef map<int, ll> mil;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;

#define FOR(i, a, b) for(int i = (a), loop_end_##i=(b); i < (loop_end_##i); i++)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort((c).begin(),(c).end())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define PB push_back

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

#define rep(v,n) for(int v=0;v<n;v++)
#define input(t,v) t v;cin>>v;
#define input2(t,v1,v2) t v1,v2;cin>>v1>>v2;
#define input3(t,v1,v2,v3) t v1,v2,v3;cin>>v1>>v2>>v3;

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}
char table[10][10]={"Close","Close","Close","Open","Open","!","!","!","!","!"};
int main(){
	input3(int,b1,b2,b3);
	int z=b1+2*b2+4*b3;
	cout<<table[z]<<endl;
	
}

Measured memory_bytes: 1156
import itertools
D, G = map(int,input().split())
plist = [ list( map(int ,input().split())) for i in range(D)]

#print(plist)

bit = [0,1]
'''
(0, 0, 0, 0, 0)
(0, 0, 0, 0, 1)
(0, 0, 0, 1, 0)
(0, 0, 0, 1, 1)
(0, 0, 1, 0, 0)
(0, 0, 1, 0, 1)
(0, 0, 1, 1, 0)
(0, 0, 1, 1, 1)
(0, 1, 0, 0, 0)
(0, 1, 0, 0, 1)
(0, 1, 0, 1, 0)
(0, 1, 0, 1, 1)
(0, 1, 1, 0, 0)
(0, 1, 1, 0, 1)
(0, 1, 1, 1, 0)
(0, 1, 1, 1, 1)
(1, 0, 0, 0, 0)
(1, 0, 0, 0, 1)
(1, 0, 0, 1, 0)
(1, 0, 0, 1, 1)
(1, 0, 1, 0, 0)
(1, 0, 1, 0, 1)
(1, 0, 1, 1, 0)
(1, 0, 1, 1, 1)
(1, 1, 0, 0, 0)
(1, 1, 0, 0, 1)
(1, 1, 0, 1, 0)
(1, 1, 0, 1, 1)
(1, 1, 1, 0, 0)
(1, 1, 1, 0, 1)
(1, 1, 1, 1, 0)
(1, 1, 1, 1, 1)

'''
answerList = []
for i in range(D):
    answerList.append([plist[i][0], 100 * (i+1) * plist[i][0] + plist[i][1]])


solutionList = itertools.product(bit, repeat=D)
result = []

for i,solutionTupple in enumerate(itertools.product(bit, repeat=D)):
    if i == 0:
        for j in range(answerList[D-1][0]-1):
            a = j + 1
            result.append([j+1, D * 100 * (j + 1)])
        continue

    tmp = [0,0]
    maxIndex = -1
    for i in range(D):
        if solutionTupple[i] == 1:
            tmp[0] += answerList[i][0]
            tmp[1] += answerList[i][1]
        if solutionTupple[i] == 0:
            maxIndex = max(maxIndex, i)

    result.append(tmp)
    #print(solutionTupple)

    if maxIndex == -1:
        break
    for i in range(answerList[maxIndex][0]-1):
        a = tmp[0] + i + 1
        b = tmp[1] + (i + 1) * (maxIndex+1) * 100
        result.append([a,b])
#print(answerList)
#print(result)
answer = float('inf')
for r in result:
    if r[1] >= G:
        answer = min(answer,r[0])

print(answer)


Measured memory_bytes: 19916
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 100000007
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define FOR(i,k,n) for(int i=k;i<n+k;i++)
#define ALL(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);
#define deg(x) cout<<"--"<<x<<endl;
int II(){int q;scanf("%d",&q);return q;}
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};
int dxx[]={0,-1,-1,-1,0,1,1,1};
int dyy[]={-1,-1,0,1,1,1,0,-1};
#define int ll
const int N=1000005;

void solve(){
	int n,m;cin>>n>>m;
	string s="";
	for(int i=1; i<=n; i++) s+='#';
	bool bo=0;
	for(int i=1; i<=m; i++){
		int x,y;cin>>x>>y;
		if(s[x-1]!='#' && s[x-1]!=(y+'0')){
			bo=1;
			break;
		}
		s[x-1]=(y+'0');
	}
	if(bo==1){
		cout<<-1<<endl;
		return;
	}
	for(int i=1; i<n; i++) if(s[i]=='#') s[i]='0';
	if(n==1){
		if(m==0){
			cout<<0<<endl;
			return;
		}else cout<<s<<endl;
	}else{
		if(s[0]=='#') s[0]='1';
		if(s[0]=='0'){
			cout<<-1<<endl;
			return;
		}
		cout<<s<<endl;
	}
}
 
main(){
    
    int tt; tt=1;
    int cas=1;
    while(tt--){
        //printf("Case %d: ",cas++);
        solve();
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto n = readNum!int;
  auto a = readNums!int;
  auto b = readNums!int;
  auto c = readNums!int;

  int prev, ret;
  foreach(i; 0 .. n){
    ret += b[a[i]-1];
    if(i != 0 && a[i] == prev+1) ret += c[a[i]-2];
    prev = a[i];
  }

  writeln(ret);
}


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

int main() {
  int k,x;
  cin >> k >> x;
  if( 500*k >= x ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int x[100010][2];
int ans[100010];
int n,a[3];

void f(int i,int p,int q){
	ans[i]=p;
	a[p]++;
	a[q]--;
}

int main(){
	scanf("%d%d%d%d",&n,a,a+1,a+2);

	for(int i=0;i<n;i++){
		char s[3];
		scanf("%s",s);
		x[i][0]=s[0]-'A';
		x[i][1]=s[1]-'A';
	}

	for(int i=0;i<n;i++){
		int p=x[i][0],q=x[i][1];
		if(!a[p]&&!a[q]){
			puts("No");
			return 0;
		}
		else if(!a[p])f(i,p,q);
		else if(!a[q])f(i,q,p);
		else{
			if(i!=n-1&&p==3-x[i+1][0]-x[i+1][1])f(i,q,p);
			else f(i,p,q);
		}
	}
	puts("Yes");
	for(int i=0;i<n;i++)printf("%c\n",ans[i]+'A');
}


Measured memory_bytes: 2880
parseInt(x) = parse(Int, x)
function bsearch(a,x)
	l,r = 1, length(a)
	while l <= r
		m = l+div(r-l,2)
		if a[m] < x
			l = m+1
		else
			r = m-1
		end
	end
	return(l-1)
end
function bsearchg(a,x)
	l,r = 1, length(a)
	while l <= r
		m = r-div(r-l,2)
		if a[m] > x
			r = m-1
		else
			l = m+1
		end
	end
	return(l-1)
end

function main()
	n = readline() |> parseInt
	a = map(parseInt, split(readline()))
	a = sort(a)
	minim = minimum(a)
	range = maximum(a)-minim
	ans = 1
	for i in 0:n
		left = bsearch(a,minim+i)
		right = bsearchg(a,minim+i+2)
		ans = max(right-left,ans)
	end
	print(ans)
end

main()

Measured memory_bytes: 171932
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>
# include <set>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

int main(){

    ios :: sync_with_stdio(false);
    int N;
    cin >> N;
    set<int> s;
    FOR(i,N){
        int x;
        cin >> x;
        s.insert(x);
    }

    cout << (int)s.size() << endl;

    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
Bp = 1
Rp = N-K+1
 
for k in range(K):
  print(Bp*Rp%(10**9+7))
  Bp = Bp*(K-k-1)//(k+1)
  Rp = Rp*(N-K-k)//(k+2)

Measured memory_bytes: 9252
n = int(input())
s = int(input())
if n == s:
    print(n + 1)
    exit()

m = abs(n-s)

a = set()
i = 1
while i * i <= m:
    if m % i == 0:
        a.add(i)
        a.add(m // i)
    i += 1

for i in sorted(list(a)):
    i += 1
    su = 0
    nn = n
    while nn:
        su += nn % i
        nn //= i
    if su == s:
        print(i)
        break
else:
    print(-1)

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int a,b;
int main()
{
   

    cin>>a>>b;
    if(a>b)
        rep(i,1,a)
            cout<<b;
    else
        rep(i,1,b)
            cout<<a;
}




Measured memory_bytes: 256
n, m = list(map(int, input().split(' ')))
arr  = set()
for _ in range(m):
    x = int(input())
    arr.add(x)


MOD = int(1e9) + 7

w = [0 for _ in range(n + 1)]
w[0] = 1
for i in range(1, n+1):
    if i in arr:
        continue

    if i - 1 >= 0 and i - 1 not in arr:
        w[i] += w[i-1]

    if i - 2 >= 0 and i - 2 not in arr:
        w[i] += w[i-2]
    
    w[i] %= MOD


# print(w)
print(w[n])


Measured memory_bytes: 56536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifdef local
	#include "debug/debug.h"
#endif


#ifndef local
	#define deb(x...) ;	
#endif

#define int long long  
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846 

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///*X.find_by_order("index")
///X.order_of_key("key")

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

void solve()
{
	int n;
	cin >> n;
	
	vi arr(n);
	int ans = 0;
	rep(i,0,n) cin >> arr[i];
	rep(i,0,n) rep(j,i+1, n) rep(k, j+1, n) 
	{
		if (arr[i] == arr[j] || arr[j] == arr[k] || arr[i] == arr[k]) continue;
		vi temp = vi({arr[i], arr[j], arr[k]});
		sort(all(temp));
		if (temp[1] + temp[0] > temp[2]) ans++;
	}
	cout << ans<<"\n";
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif
	
	int t = 1;
	//cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
		cout << "\n";
		#endif

	}
	
	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

Measured memory_bytes: 3652
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e6+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n,k;
    cin>>n>>k;
    ll a[n];
    lp(i,0,n)
        cin>>a[i];
    ll beg=1,end=1e9,mid;
    while(beg<=end){
        mid=(beg+end)/2;
        ll cnt=0;
        lp(i,0,n)
            cnt+=(a[i]-1)/mid;
        if(cnt<=k)
            end=mid-1;
        else
            beg=mid+1;
    }
    cout<<end+1;
}

Measured memory_bytes: 5116
import math
n = int(input())
res = 0
for i in range(int(math.sqrt(n))+2):
    if i >= 1 and i <= n and n%i==0:
        if i>2 and n//i==n%(i-1):
            res+=(i-1)
        j = n//i
        if j>2 and j!=i and n//j==n%(j-1):
            res+=(j-1)
print(res)



Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string o, e;
	cin >> o >> e;
	string res = "";
	REP(i, e.size()) {
		res += o[i];
		res += e[i];
	}
	if (o.size() != e.size()) {
		res += o[o.size()-1];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
int p[50],m[50],tot;//p[]记录质数,m[]记录幂次
int main(){
	LL n;
	int i,j,ans=0;
	scanf("%lld",&n);
	for(i=2;(LL)i*i<=n;i++)//注意此处不能写成for(i=2;i*i<=n;i++)
		if(n%i==0){
			p[++tot]=i;
			while(n%i==0)n/=i,m[tot]++;
		}
	if(n>1)p[++tot]=n,m[tot]=1;
	for(i=1;i<=tot;i++){
		j=1;
		while(1){
			if(m[i]>=j)ans++,m[i]-=j;
			else break;
			j++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cerr<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define ERROR  1e-9
#define pi (2*acos(0))
const ll mod = 998244353;
const int N = 2e5 +5;

void SOLVE(int cas)
{
    ll n;
    scanf("%lld",&n);
    vector< ll >v(3*n);
    for(int i=0;i<3*n;i++)
    {
        scanf("%lld",&v[i]);
    }
    sort(v.begin(),v.end());
    ll sum =0;
    ll cnt =0;
    for(ll i = 3*n-2;;i-=2)
    {
        sum+=v[i];
        cnt++;
        if(cnt==n)
            break;
    }
    printf("%lld\n",sum);










}


/*


*/



int main()
{
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        SOLVE(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

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

const int N = 1e5 + 5;
int v[N];
int n;

int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#endif

    sfi1(n);
    int x;
    loop(i,n){
        sfi1(x);
        v[x]++;
    }

    int mx = 0;
    loop(i,N-1){
        if(!i)continue;
        mx = max(mx ,v[i-1] + v[i] + v[i+1]);
    }

    printf("%d\n",mx);



    return 0;
}


Measured memory_bytes: 640
n = int(input())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i >= 1 and b_li[i-1]>0:
        ans += min(a_li[i], b_li[i-1])
        a_li[i] = max(0, a_li[i] - b_li[i-1])

    if b_li[i] > 0:
        temp = min(a_li[i], b_li[i])
        ans += temp
        a_li[i] = max(0, a_li[i] - b_li[i])
        b_li[i] -= temp


    
ans += min(a_li[n], b_li[n-1])
a_li[i] = max(0, a_li[n] - b_li[n-1])
print(ans)

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

int main() {
    int A, B, C;
    int K;
    cin >> A >> B >> C;
    cin >> K;
    for (int i = 0; i < K; ++i) {
        if (A >= B) B *= 2;
        else if (B >= C) C *= 2;
        else break;
    }
    if (A < B && B < C) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
using Int = long long;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    vector<int> A(n);
    list<int> res;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    if(n%2==0){
        for(int i=0;i<n;i++){
            if(i%2==0)res.push_back(A[i]);
            else res.push_front(A[i]);
        }
    }
    else{
        for(int i=0;i<n;i++){
            if(i%2==0)res.push_front(A[i]);
            else res.push_back(A[i]);
        }
    }
    for(auto a:res){
        cout<<a<<' ';
    }
    cout<<endl;
}

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


int main() {
    int N; cin >> N;
    int M; cin >> M;
    multiset<long long int> items;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        items.insert(-x);
    }

    while (M--) {
        int num = *items.begin();
        if (num == 0) break;
        items.erase(items.begin());
        num /= 2;
        items.insert(num);
    }

    cout << -accumulate(items.begin(), items.end(), 0LL) << endl;

    return 0;
}


Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const LL MOD = 1000000007LL;
vector<int> v;
int cnt[1 << 11][1 << 11];
map<P, int> memo;
int m, n;
int solve(int q, int a) {
	if (cnt[q][a] == 1) return 0;
	if (memo.find(P(q, a)) != memo.end()) return memo[P(q, a)];
	int ans = 1 << 30;
	for (int i = 0; i < m; i++) {
		int nq = q | (1 << i);
		if (nq == q || cnt[nq][a] == 0 || cnt[nq][a | (1 << i)] == 0) continue;
		int t = solve(nq, a) + 1;
		t = max(t, solve(nq, a | (1 << i)) + 1);
		ans = min(ans, t);
	}
	return memo[P(q, a)] = ans;
}
int main() {
	while (cin >> m >> n, m) {
		v.clear();
		for (int i = 0; i < n; i++) {
			string s;
			cin >> s;
			int bit = 0;
			for (int i = 0; i < s.size(); i++) {
				bit <<= 1;
				if (s[i] == '1') bit |= 1;
			}
			v.push_back(bit);
		}
		memset(cnt, 0, sizeof(cnt));
		for (int i = 0; i < (1 << m); i++) {
			for (int j = 0; j < n; j++) {
				cnt[i][i&v[j]]++;
			}
		}
		memo.clear();
		cout << solve(0, 0) << endl;
	}
}


Measured memory_bytes: 22748
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int ans = 0; 
  int memo = 0;
  for (int i = 0; i < 5; i++) {
    int dish;
    cin >> dish;
    int memo2 = ((dish - 1) / 10 + 1) * 10;
    ans += memo2;
    memo = max(memo, memo2 - dish);
  }
  cout << ans - memo << endl;
}
    

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i, d = 0, x, ans = 1;
    cin >> n >> x;
    vll a(n);
    for(i = 0; i < n; i++)
        cin >> a[i], d += a[i], ans += (d <= x ? 1 : 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline())
parent = [-1 for _ in range(n)]
children = [[] for _ in range(n)]
nodes = []
for _ in range(n):
    ll = list(map(int, sys.stdin.readline().split()))
    nodes.append(ll[0])
    children[ll[0]] = ll[2:]
    for i in range(ll[1]):
        parent[ll[2+i]] = ll[0]

for n in sorted(nodes):
    p = parent[n]
    if p==-1:
        type='root'
    else:
        if len(children[n])==0:
            type='leaf'
        else:
            type='internal node'
        
    depth = 0
    k=n
    while parent[k]>=0:
        k = parent[k]
        depth+=1
        
    print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(n, p, depth, type, children[n]))


Measured memory_bytes: 24732
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int[][] c = new int [3][3];
		for (int i = 0;i < 3; ++i){
			for (int k = 0;k < 3; ++k){
				c[i][k] = Integer.parseInt(scan.next());
			}
		}

		int[] x = new int [3];
		int[] y = new int [3];
		x[0] = 0;

		for (int i = 0;i < 3; ++i){
			y[i] = c[0][i]-x[0];
		}

		for (int i = 0;i < 3; ++i){
			x[i] = c[i][0]-y[0];
		}
		boolean ok = true;
		for (int i = 0;i < 3; ++i){
			for (int k = 0;k < 3; ++k){
				if (c[i][k] != x[i]+y[k]){
					ok = false;
				}
			}
		}

		System.out.print(ok?"Yes":"No");
	}
}

//end

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

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

int main() {

	int N;
	cin >> N;

	vector<pair<int, int>>a(N);

	rep(i, N) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}

	sort(a.begin(), a.end());

	rep(i, N)
		cout << a[i].second << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
#include <map>
 
using namespace std;

typedef long long ll;

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

    string S;

    cin >> S;

    vector<int> A(S.length());

    int c = 0;

    for(int i = 0; i < S.length(); i++) {
        if(S[i] == 'R') {
            c++;
        } else {
            if(S[i - 1] == 'R') {
                if(c % 2 == 0) {
                    A[i] += c / 2;
                    A[i - 1] += c / 2;
                } else {
                    A[i] += c / 2;
                    A[i - 1] += c / 2 + 1;
                }
                c = 0;
            }
        }
    }

    for(int i = S.length() - 1; i >= 0; i--) {
        if(S[i] == 'L') {
            c++;
        } else {
            if(S[i + 1] == 'L') {
                if(c % 2 == 0) {
                    A[i] += c / 2;
                    A[i + 1] += c / 2;
                } else {
                    A[i] += c / 2;
                    A[i + 1] += c / 2 + 1;
                }
                c = 0;
            }
        }
    }

    for(int i = 0; i < S.length(); i++) {
        cout << A[i] << " ";
    }
}


Measured memory_bytes: 1104
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>

#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 1000000;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> P;
typedef long long ll;


void zerofill(int *inp, int size){
    for(auto i= 0; i< size; i++){
        inp[i] = 0;
    }
}

int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int getDigit(int num){
    return log10(abs(num))+1;
}


long long fac[MAX];
long long finv[MAX];
long long inv[MAX];

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

long long binom(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;
}


int mypush(queue<int> &candidate,int inp, int N){
    
    if (inp <= pow(10,getDigit(N)-1)){
        candidate.push(inp);
    }

    return (inp <= N);
    
}


int consistent(int inp,int N){
    
    string s = to_string(inp);
    
    sort(s.begin(),s.end());
    s.erase(unique(s.begin(),s.end()),s.end());
    
    if (s[0] != '3') return 0;
    if (s[1] != '5') return 0;
    if (s[2] != '7') return 0;
    
    return (inp <= N);
    
}

int main() {
    
    int N = in();

    queue<int> candidate;
    
    mypush(candidate,3,N);
    mypush(candidate,5,N);
    mypush(candidate,7,N);

    vector<int> ans;


    int digit = 1;
    while(candidate.size()!=0){
        
        auto front = candidate.front();
        candidate.pop();
        
        if (front*10 + 3 > N) break;
        
        mypush(candidate,10*front + 3,N);
        mypush(candidate,10*front + 5,N);
        mypush(candidate,10*front + 7,N);

        
        if (consistent(10*front + 3,N)){
            ans.push_back(10*front + 3);
        }
        if (consistent(10*front + 5,N)){
            ans.push_back(10*front + 5);
        }
        if (consistent(10*front + 7,N)){
            ans.push_back(10*front + 7);
        }
        
        
        
        digit++;
        
    }
    

    
    cout << ans.size() << endl;
    return 0;
}







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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> queries(m);
	for(int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		queries[i] = {a - 1, b - 1};
	}

	sort(queries.begin(), queries.end());

	pair<int, int> segment = queries[0];
	int count = 0;
	for(int i = 1; i < m; i++)
	{
		if(queries[i].first < segment.second)
		{
			segment.first = queries[i].first;
			if(queries[i].second < segment.second)
			{
				segment.second = queries[i].second;
			}
		}else{
			count++;
			segment = queries[i];
		}
	}
	count++;
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 1024