akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
signed main() {
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 764
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        A: [u64; n],
    }
    let mut tot = 0;
    let mut acc = 0;

    for a in A.iter() {
        if &acc > a {
            tot += acc - a;
        } else {
            acc = *a;
        }
    }
    println!("{}", tot);
}


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

long long int gcd(long long int l, long long int r) {
	assert(l > 0 && r > 0);
	if (l > r)return gcd(r, l);
	else {
		const long long int num = r%l;
		if (num) {
			return gcd(l, num);
		}
		else {
			return l;
		}
	}
}
long long int lca(long long int l, long long int r) {
	return l / gcd(l, r)*r;
}
int main() {
	long long int a, b;
	while (cin >> a >> b) {
		cout << gcd(a, b) << " " << lca(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<int> > dp(h+1, vector<int>(w,0)); dp[0][0] = 1;

  rep(i,h) {
    rep(j,w) {
      for (int k = 0; k < 1 << (w - 1); ++k) {
        bool ok = true;
        for (int l = 0; l < w-2; ++l) {
          if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
            ok = false;
          }
        }

        if (ok) {
          if (j >= 1 && ((k >> (j - 1)) & 1)) {
            dp[i+1][j-1] += dp[i][j];
            dp[i+1][j-1] %= MOD;
          } else if (j <= w - 2 && ((k >> j) & 1)) {
            dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1] %= MOD;
          } else {
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;
          }
        }
      }
    }
  }

  cout << dp[h][k-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N,A,T;
	cin>>N>>T>>A;
	T--;A--;
	vector<vector<int>>g(N);
	REP(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	auto distT = mv(N),distA = distT;
	FILL(distA,INF);
	FILL(distT,INF);
	auto bfs = [&](int s,vector<int>&dist){
		queue<int>que;
		que.push(s);
		dist[s]=0;
		while(que.size()){
			int now = que.front();
			que.pop();
			for(auto e:g[now]){
				if(dist[e]!=INF)continue;
				dist[e]=dist[now]+1;
				que.push(e);
			}
		}
	};
	bfs(A,distA);
	bfs(T,distT);
	int ans = 0;
	REP(i,N)if(distA[i]>distT[i])CHMAX(ans,distA[i]-1);
	OUT(ans);
}

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


public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String[] columns;
        int ZENKI = 0;
        int KOUKI = 1;
        int SAITEST = 2;

        int score1 = 0;
        int score2 = 0;
        int score3 = 0;

        while (true) {

            String line = reader.readLine();
            columns = line.split(" ");
            if (Integer.parseInt(columns[ZENKI]) == -1
                    && Integer.parseInt(columns[KOUKI]) == -1
                    && Integer.parseInt(columns[SAITEST]) == -1) {
                break;
            }
            score1 = Integer.parseInt(columns[ZENKI]);
            score2 = Integer.parseInt(columns[KOUKI]);
            score3 = Integer.parseInt(columns[SAITEST]);

            if (score1 == -1 || score2 == -1 || score1 + score2 < 30) {
                builder.append("F");
            } else if ((score1 + score2) >= 80) {
                builder.append("A");
            } else if (score1 + score2 < 80 && score1 + score2 >= 65) {
                builder.append("B");
            } else if (score1 + score2 < 65 && score1 + score2 >= 50) {
                builder.append("C");
            } else if (score1 + score2 < 50 && score1 + score2 >= 30) {
                if (score3 >= 50) {
                    builder.append("C");
                }
                else {
                    builder.append("D");
                }
            }
            builder.append("\n");
        }
        System.out.print(builder);
    }
}

Measured memory_bytes: 24344
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  int res = 0;
  while (n--) {
    int a; cin >> a;
    res = __gcd(res, a);
  }
  cout << res << '\n';
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define mp make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front 
#define pb push_back
#define pp push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

ll a,b,c; 

int main() {
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>a>>b>>c;
    if(c<=a+b)
    {
    	cout<<"No"<<endl;
	}
	else
	{
		if(4LL*a*b<(c-a-b)*(c-a-b))
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
    /* end code */
	return 0;
}
/*

*/

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>

using namespace std;

int main(){
    int N, K ;
    cin >> N >> K;
    int D[N];

    for(int i=0; i<N; i++){
        cin >> D[i];
    }

    int L[N]; L[0] = 0;
    int R[N]; R[0] = 0;
    
    for(int i =1 ;i<=N; i++){
        L[i] = L[i-1] + D[i-1];
        R[i] = R[i-1] + D[N - i];
    }

    int ans = 0;
    for(int i = 0; i<=N; i++){
        for(int j = 0; j < N-i+1;j++){
            int tmp = 0;
            if(i + j > K){
                ;
            }
            else{
                tmp = L[i] + R[j];
                int rest = K - (i + j);
                priority_queue<int> q;
                for(int k =0; k<i; k++){
                    if(D[k]<0) q.push(-D[k]);
                }
                for(int k =0 ; k<j; k++){
                    if(D[N-1-k] < 0) q.push(-D[N-1-k]);
                }
                int cnt = 0;
        
                while(!q.empty() && cnt < rest){
                    cnt ++;
                    tmp += q.top(); q.pop();
                }
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  while(true){
    s = s.substr(0, s.size()-1);
    if(s.size()%2 == 1) continue;
    if(s.substr(0, s.size()/2) == s.substr(s.size()/2)){
      cout << s.size() << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
using System;

class SortNumbers{
        static void Main(string[] args){
	  string[] str = Console.ReadLine().Split(' ');
	  int a = int.Parse(str[0]);
	  int b = int.Parse(str[1]);
	  int c = int.Parse(str[2]);
	  int t;
	  if(a > b){
	    t = a;
            a = b;
            b = t;
          }
	  if(b > c){
	    t = b;
	    b = c;
	    c = t;
	  }
	  if(a > b){
	    t = a;
            a = b;
            b = t;
          }
	  Console.WriteLine("{0} {1} {2}",a,b,c);
	}
}

Measured memory_bytes: 9160
#include <set>
#include <iostream>
#include <utility>
#include <vector>

int main() {
    std::set< std::pair<char, int > > st;

    int n;
    std::cin >> n;

    for (int i = 0; i < n; ++i) {
        char c;
        int a;
        std::cin >> c >> a;

        st.insert(std::make_pair(c, a));
    }

    std::vector< char > cs({'S', 'H', 'C', 'D'});

    for (const auto &c: cs) {
        for (int i = 1; i <= 13; ++i) {
            if (st.count(std::make_pair(c, i)) == 0) {
                std::cout << c << " " << i << std::endl;
            }
        }
    }
}


Measured memory_bytes: 3092
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<int,int> P;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

long long dp[100010][4]={};
int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> A(N+1,0);
    map<ll,ll>same;
    ll ans=0;

    rep(i,N){
        ll a;
        cin >> a;
        A[i+1]+=(A[i]+a)%M;
    }

    rep(i,N+1){
        same[A[i]]++;
    }

    for(auto x: same){
        ans+=x.second*(x.second-1)/2;
    }

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



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main() {
    int N,M;
    cin >> N>>M;
    if(N%2==0){
        int preR=(int)((M+1)/2);
        int posR=(int)(M/2);
        REP(i,min(preR,M)) cout<<i+1<<" "<<preR*2-i<<endl;;
        REP(i,min(posR,M-preR)) cout<<preR*2+1+i<<" "<<N-i-1<<endl;        
    } else{
        REP(i,M){
            cout<<i+1<<" "<<M*2+1-(i+1)<<endl;
        }
    }
    return 0;
}

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

int main(){
	int a, b, k, x;
	cin >> a >> b >> k;
	x = max(a, b);
	while(k--){
		while(!(a%x==0 && b%x==0)){
			x--;
		}
		x--;
	}
	x++;
	cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  int N = S.size() + 1;

  vector<pair<long long, long long>> CS;
  CS.push_back(make_pair(S[0], 0));
  rep(i, N - 1)
  {
    if (CS.back().first == S[i])
      CS.back().second++;
    else
      CS.push_back(make_pair(S[i], 1));
  }
  vector<long long> number;
  number.push_back(0);
  rep(i, CS.size())
  {
    if (CS[i].first == '<')
    {
      rep(j, CS[i].second)
      {
        number.push_back(j + 1);
      }
    }
    else if (CS[i].first == '>')
    {
      number.back() = max(CS[i].second, number.back());
      rep(j, CS[i].second)
      {
        number.push_back(CS[i].second - j - 1);
      }
    }
  }
  //  printVector(number);
  long long ans = 0;
  for (long long n : number)
    ans += n;

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

Measured memory_bytes: 12148
def IsKaibun(str):
    n = len(str)
    for i in range(n//2):
        if str[i]!=str[n-1-i]:
            return False
    return True

S = input()
N = len(S)
ans = "Yes" if IsKaibun(S) and IsKaibun(S[:(N-1)//2]) and IsKaibun(S[(N+3)//2-1:]) else "No"
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

const double eps = 1e-7;
const int MOD = 1000000007;
const int MOD_MAX = 200000;

using ll = long long;
using vi = vector<int>; using vi2 = vector<vi>; using vi3 = vector<vi2>;
using vll = vector<ll>; using vll2 = vector<vll>; using vll3 = vector<vll2>;
using vd = vector<double>; using vd2 = vector<vd>; using vd3 = vector<vd2>;
using pi = pair<int, int>; using pll = pair<ll, ll>;
using vpi = vector<pi>; using vpll = vector<pll>;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)
#define looplleq(i, n) for (ll i = 0; i <= (ll)n; i++)
#define rloopi(i, a, b) for(int i = (int)a - 1; i >= (int)b; i--)
#define rloop(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define rloopeq(i, n) for (int i = (int)n - 1; i >= 1; i--)
#define rloopll(i, n) for (int i = (ll)n - 1; i >= 0; i--)
#define rlooplleq(i, n) for (int i = (ll)n - 1; i >= 1; i--)
#define all(a) (a).begin(), (a).end()

int main() {
	string s; cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
	else cout << "Yes" << endl;
}


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

	int main(){
      int N,M;
      cin >> N >> M;
      int a[M]={},b[M]={},r[N]={};
      for (int i=0;i<M;i++){
        cin >> a[i] >> b[i];
        r[a[i]-1]+=1;
        r[b[i]-1]+=1;
      }
     for (int i=0;i<N;i++){
       cout << r[i] << endl;
     }
    }

Measured memory_bytes: 256
using System;

namespace ABC161A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            c = int.Parse(ss[2]);
            Console.WriteLine(c + " " + a + " " + b);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(){
  string o,e;
  cin >> o >> e;
  string ans;
  for(int i = 0; i < o.length(); i++){
    ans.push_back(o[i]);
    if(i < e.length())
      ans.push_back(e[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def negaternary(i: int) -> str:

    if i == 0:
        digits = ['0']
    else:
        digits = []
        while i != 0:
            i, remainder = divmod(i, -2)
            if remainder < 0:
                i, remainder = i + 1, remainder + 2
            digits.append(str(remainder))
    return ''.join(digits[::-1])

n=int(input())
print(negaternary(n))

Measured memory_bytes: 61584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<p2> v(n);
    for(ll i=0;i<n;i++){
        cin>>v[i].first;
        v[i].second=i;
    }
    sort(v.begin(),v.end());
    for(ll i=0;i<n;i++)
    if(v[n-1].second!=i)
    cout<<v[n-1].first<<endl;
    else 
    cout<<v[n-2].first<<endl;
}


Measured memory_bytes: 4736
#include <cstdio>
#include <vector>
#include <cmath>
#include <string>
#include <iostream>

using namespace std;



int main(){
	
	string S;
	string T;
	int size;
	int i;
	char a;
	
	cin >> S;
	cin >> T;
	size = T.length();
	
	for(i=0; i<size; i++){
		
		a = S[0];
		S.erase(S.begin());
		S.push_back(a);
		
		if(S == T){
			printf("Yes\n");
			return 0;
		}
		
	}
	
	printf("No\n");
	return 0;
	
}

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

int main(){
  int N;
  cin >> N;
  string S;
  int A=0, W=0, T=0, R=0;
  for(int i=0; i<N; i++){
    cin >> S;
    if(S=="AC"){
      A++;
    }
    else if(S=="WA"){
      W++;
    }
    else if(S=="TLE"){
      T++;
    }
    else{
      R++;
    }
  }
  cout << "AC x " << A << endl;
  cout << "WA x " << W << endl;
  cout << "TLE x " << T << endl;
  cout << "RE x " << R << endl;
}

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

using namespace std;

int main()
{
    //system("chcp 65001");

    char S[3];
    int i;
    int a=0,b=0,c=0;
    for(i = 0;i <= 2;i++)
    {
        cin >> S[i];
        if(S[i] == 'a')
        {
            a += 1;
        }
        else if(S[i] == 'b')
        {
            b += 1;
        }
        else
        {
            c += 1;
        }
        
    }

    if(a == 1 && b == 1 && c == 1)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    

    //cout << N;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

e = 0
for a in A:
    l = 0
    over = a.bit_length()
    while over - l > 1:
        m = (l+over) // 2
        if a & ((1<<m)-1) == 0: l = m
        else: over = m
    e += l
print(e)

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

int n;

int t, a;

int ans;

int main(void) {
    // Here your code !

    scanf("%d", &n);
    scanf("%d %d", &t, &a);

    int ho;
    scanf("%d", &ho);

    double cur = t - ho * 0.006;

    double tmp = abs(cur - a);
    ans = 1;

    for (int i = 2; i <= n; ++i) {
      int h;
      scanf("%d", &h);

      double cur = t - h * 0.006;

      if (abs(cur - a) < tmp) {
        tmp = abs(cur - a);
        ans = i;
      }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
const int MOD = 1e9+7;
int a[MAXN],may[MAXN],mst[MAXN];
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif	
	int n,m;
	cin>>n>>m;
	for (int i = 0; i < n; ++i)
	{
		a[i] = 1;
	}
	may[0] = 1;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		if(may[x])
		{
			may[y] = 1;
			if(a[x]==1)
				may[x] = 0;
		}
		a[x]--;
		a[y]++;
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if(may[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(x == 0 && y == 0){
                break;
            }
            if(x < y){
                System.out.println(x + " " + y);
            } else {
                System.out.println(y + " " + x);
            }
        }
    }
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t a, b, c, k;
  std::cin >> a >> b >> c >> k;
  int64_t ans = 0;

  ans += std::min(a, k);
  k -= std::min(a, k);
  k -= std::min(b, k);
  ans -= std::min(c, k);
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 3552
import java.util.Scanner;

class Main {
    void solve() {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt(), w= in.nextInt(); in.nextLine();
        int[] c = new int[26];
        for(int i = 0; i < h; i++) {
            String s = in.nextLine();
            for(char ch : s.toCharArray()) {
                c[ch - 'a']++;
            }
        }
        int four = 0, tow = 0, one = 0;
        for(int i: c) {
            four += i / 4;
            i = i % 4;
            tow += i / 2;
            one += i % 2;
        }
        //System.out.println("f: " + four + " tow: " + tow + " one: " + one);
        int a = (h / 2) * (w / 2);
        //System.out.println("a: " + a);
        if(four >= a) {
            //if(h != 1 && w != 1)
            tow += (four - a) * 2;
            if(h%2 == 1 && w %2 == 1) {
                int b = h/2 + w/2;
                if(b == tow) {
                    System.out.println("Yes");
                }else {
                    System.out.println("No");
                }
            }else if(h%2 == 1) {
                if(tow == w/2) {
                    System.out.println("Yes");
                }else {
                    System.out.println("No");
                }
            }else if(w%2 == 1) {
                if(tow == h/2) {
                    System.out.println("Yes");
                }else {
                    System.out.println("No");
                }
            }else {
                System.out.println("Yes");
            }
        }else {
            System.out.println("No");
        }
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}

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

int main(void){
	string str;
	cin >> str;
	if(str.size()==1){
		cout << str[0] << endl;
	}else{
		if(str[0]=='o' && str[str.size()-1]=='o')cout << "o" << endl;
		if(str[0]=='x' && str[str.size()-1]=='x')cout << "x" << endl;
		if(str[0]!=str[str.size()-1])cout << "o" << endl;
	}
    return 0;
}

Measured memory_bytes: 1180
#include <cstdio>
#include <set>
#include <queue>
#include <vector>

void assignGroup(const std::vector<std::set<int>>& firend_relationships, std::vector<int>& group)
{
  int current_group = 1;
  std::queue<int> next_queue;
  std::set<int> searched_set;

  for (int i = 0; i < (int)firend_relationships.size(); ++i)
  {
    // Any group is the id assigned, then skip it
    if (searched_set.count(i) != 0)
      continue;

    group[i] = current_group;
    next_queue.push(i);

    while (!next_queue.empty())
    {
      // Remove from waiting list
      int current_id = next_queue.front();
      next_queue.pop();
      // Add to searched list
      searched_set.insert(current_id);

      // Add to waiting list which is not serached yet
      std::set<int>::const_iterator itr;
      for (itr = firend_relationships[current_id].begin();
           itr != firend_relationships[current_id].end();
           ++itr)
      {
        // Ignore searched ones
        if (searched_set.count(*itr) != 0)
          continue;

        group[*itr] = current_group;
        next_queue.push(*itr);
      }
    }

    // Assign the different group number
    ++current_group;
  }
}

bool isConnected(const int& id_from, const int& id_to, const std::vector<int>& group)
{
  return group[id_from] == group[id_to];
}

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);

  std::vector<std::set<int>> firend_relationships;
  std::vector<int> group;
  firend_relationships.resize(n);
  group.resize(n);
  for (int i = 0; i < m; ++i)
  {
    int id1, id2;
    scanf("%d%d", &id1, &id2);
    firend_relationships[id1].insert(id2);
    firend_relationships[id2].insert(id1);
  }

  assignGroup(firend_relationships, group);

  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i)
  {
    int id1, id2;
    scanf("%d%d", &id1, &id2);
    if (isConnected(id1, id2, group))
      printf("yes\n");
    else
      printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 21456
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
 ll a,b; cin >> a >> b;
 if(a+b==15) cout << "+" << endl;
 else if(a*b==15) cout << "*" << endl;
 else cout << "x" << endl; 
}

Measured memory_bytes: 768
map$q[$_]+=$q[$N]/@$N,@{/ /,push@
$`,$' for<>;$N=$_}for++$q[1]..<>;$e[$N]=${$b=1;$b+=$_/@@for@@=sort@e[@$N];b},$a<($~=$q[$N]*=$#@&&($b-1-$@[-1])/$#@)or$a=$~while--$N;print$b+$a

Measured memory_bytes: 42368
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s; cin >> s;
    ll k; cin >> k;
    set<string> st;
    for (int size = 1; size <= k; size++)
    {
        for (int i = 0; i < s.size() - size + 1; i++) {
            st.insert(s.substr(i, size));
        }
    }

    // for (auto elem : st) cout << elem << " "; cout << endl;

    vector<string> ks(st.begin(), st.end());
    // for (auto elem : ks) cout << elem << " "; cout << endl;

    cout << ks[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int sl=s.length();
    string ans="NO";
    rep(i,sl){
        for(int j=0; j<sl; ++j){
            string s1=s;
            s1.erase(i,j);
            if(s1=="keyence"){
                ans="YES";
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main(){
	int n;
	while(cin>>n,n){
		int data[2];
		int ans[2]={0,0};
		for(int i=0;i<n;++i){
			cin>>data[0]>>data[1];
			if(data[0]>data[1]){
				ans[0]+=data[0]+data[1];
			}else if(data[0]<data[1]){
				ans[1]+=data[0]+data[1];
			}else if(data[0]==data[1]){
				ans[0]+=data[0];
				ans[1]+=data[1];
			}
		}
		cout<<ans[0]<<" "<<ans[1]<<endl;
	}
}

Measured memory_bytes: 1160
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(M)]
P = [int(i) for i in input().split()]

ans = 0
for i in range(2 ** N):
    flg = True
    for j in range(M):
        c = 0
        for k in S[j][1:]:
            if ((i >> k-1) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                c += 1
        if c % 2 != P[j]:
            flg = False
    if flg:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n;cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    ll sub=0;
    rep(i,n){
        sub-=b[i];
    }
    vl ab(n);
    rep(i,n){
        ab[i]=a[i]+b[i];
    }
    sort(ab.rbegin(),ab.rend());
    int time=(n+1)/2;
    ll ans=0;
    int i=0;
    while(time>0){
        ans+=ab[i];
        i+=2;
        time--;
    }
    ans+=sub;
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

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

int main() {
  vector<int> x(4), y(4);
  for (int i = 0; i < 2; ++i) {
    cin >> x[i] >> y[i];
  }

  int l1, l2;
  l1 = x[1] - x[0];
  l2 = y[1] - y[0];

  x[2] = x[1] - l2;
  y[2] = y[1] + l1;

  x[3] = x[2] - l1;
  y[3] = y[2] - l2;

  cout << x[2] << " ";
  cout << y[2] << " ";
  cout << x[3] << " ";
  cout << y[3] << " ";
  cout << endl;

  return 0;
}


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

int
main(int argc, char **argv)
{
	char *weakday[] = {"","SAT","FRI","THU","WED","TUE","MON","SUN"};
	char input[4];
	int i;

	scanf("%s", input);
	for (i = 0; i <= 7; i++) {
		if (strcmp(weakday[i], input) == 0)
			break;
	}
	printf("%d\n", i);
}


Measured memory_bytes: 128
H, W = map(int, raw_input().split())
N = input()
a = map(int, raw_input().split())

ans = [[0]*W for _ in range(H)]
c = 0
for i in range(N):
  for j in range(a[i]):
    ans[c/W][c%W if c/W%2==0 else -c%W-1] = i
    c += 1

for a in ans:
  for x in a:
    print x+1,
  print


Measured memory_bytes: 3076
#include <iostream>
using namespace std;
int main () {
int a,b,c;
  cin>>a>>b>>c;
  int d=0;
  int e=0;
  if (a==5){
  d++;
  }
  if (b==5){
  d++;
  }
  if (c==5){
  d++;
  }
  if (a==7){
  e++;
  }
  if (b==7){
  e++;
  }
  if (c==7){
  e++;
  }
  if (d==2 && e==1){
  cout<<"YES";
  }
  else cout<<"NO";
}

Measured memory_bytes: 256
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

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

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

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

const ll mod = 1e9+7;
const int maxn = 2e5+2;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

int n;
pll arr[maxn];
ll st[maxn << 2];

void update (ll pos, ll val, int node = 1, int l = 1, int r = n){
    if (pos < l || pos > r) return;

    if (l == r){
        st[node] = max(st[node], val);
    }
    else{
        int mid = (l + r) >> 1;
        update(pos, val, 2 * node, l, mid);
        update(pos, val, 2 * node + 1, mid + 1, r);
        st[node] = max(st[2 * node], st[2 * node + 1]);
    }
}

ll query (int x, int y, int node = 1, int l = 1, int r = n){
    if (x > r || y < l) return 0;

    if (x <= l && y >= r) return st[node];
    else{
        int mid = (l + r) >> 1;
        return max(query(x, y, 2 * node, l, mid),
        query(x, y, 2 * node + 1, mid + 1, r));
    }
}

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

    cin >> n;

    for (int i = 1; i <= 2; i++){
        for (int j = 1; j <= n; j++){
            if (i == 1) cin >> arr[j].f;
            else cin >> arr[j].s;
        }
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++){
        ll aux = query(1, arr[i].f - 1);
        ans = max(ans, aux + arr[i].s);
        update(arr[i].f, aux + arr[i].s);
    }

    cout << ans << "\n";

    return 0;
}


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

int a, b, c;
int d, e;
double f;

void divide(int *a, int *b){
    d = *a / *b;
    e = *a % *b;
    f = (double)*a / *b;
}

int main(int argc, const char * argv[]) {
    cin >> a >> b;
    divide(&a, &b);
    cout << d << " " << e << " " << fixed << setprecision(8) << f << endl;
    return 0;
}


Measured memory_bytes: 3300
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int begin=max(a,c), end=min(b,d);
	if(end>=begin)
		cout << end-begin << endl;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
def good(x,y):
    if (x>=0 and x<h) and (y>=0 and y<w):
        return (mat[x][y] != "#")
h, w = map(int,input().split())
sh, sw = map(int,input().split())
eh, ew = map(int,input().split())
mat = []
for _ in range(h):
    s = input()
    mat.append(s)
x = [1,-1,0,0]
y = [0,0,-1,1]
dist = [[float('inf') for i in range(w)]for j in range(h)]
sh -= 1
sw -= 1
eh -= 1
ew -= 1
dist[sh][sw] = 0
queue = deque()
queue.appendleft((sh,sw))
while queue:
    m = queue.popleft()
    for d in range(4):
        nx = m[0] + x[d]
        ny = m[1] + y[d]
        if good(nx,ny):
            if dist[nx][ny] > dist[m[0]][m[1]]:
                dist[nx][ny] =  dist[m[0]][m[1]]
                queue.appendleft((nx,ny))
    for i in range(m[0]-2,m[0]+3):
        for j in range(m[1]-2,m[1]+3):
            if good(i,j):
                if dist[i][j] > dist[m[0]][m[1]] + 1:
                    dist[i][j] = dist[m[0]][m[1]] + 1
                    queue.append((i,j))
if dist[eh][ew] == float('inf'):
    print(-1)
else:
    print(dist[eh][ew])


Measured memory_bytes: 99972
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int d, g;
    cin >> d >> g;
    vint p(d), c(d);
    rep(i, d) cin >> p[i] >> c[i];

    ll ans = LINF;
    rep(i, (1<<d)) {
        ll score = 0;
        ll tmp = 0;
        rep(j, d) {
            if (i & (1<<j)) {
                score += 100*(j+1)*p[j] + c[j];
                tmp += p[j];
            }
        }
        if (score >= g) {
            ans = min(ans, tmp);
            continue;
        }
        int add = 0;
        bool check = true;
        for (int j = d-1; j >= 0; --j) {
            if (i & (1<<j)) continue;
            int diff = g - score;
            add = diff / (100*(j+1)) + (diff % (100*(j+1)) != 0);
            if (add > p[j]) check = false;
            break;
        }
        if (!check) continue;
        ans = min(ans, tmp+add);
    }

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

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

int main() {
    int n;
    string m;
 
   cin >> n >> m;
  
 //  cout << n << endl;
 //  cout << m << endl;
  
int max = 0;
  
string temp = m;
  
for(int i = 1;i<n;i++){
  
  string mae = m.substr(0,i);
  vector<char> data;
  
   data.clear();   // データ
  
  
  
   for(int i = 0;i<mae.size();i++){
     data.push_back(mae[i]); 
   // maeb = maeb+data[i]; 
  }
  
   sort(data.begin(), data.end());
  
  // cout << data[0] << endl;
  
  string maeb;
  
  for(int i = 0;i<data.size();i++){
    
    maeb = maeb+data[i]; 
  }
  //sort(mae.begin(), mae.end()); 
  //cout << maeb << endl;
  
  maeb.erase(unique(maeb.begin(), maeb.end()), maeb.end());
  
 // cout << maeb << endl;
  
  
 
  
  string ato =  m.substr(i,n-i);
vector<char> datab;
  
   datab.clear();   // データ
 //  datab.push_back(ato); 
  
    for(int i = 0;i<ato.size();i++){
     datab.push_back(ato[i]); 
   // maeb = maeb+data[i]; 
  }
  
   sort(datab.begin(), datab.end());
  
  // cout << data[0] << endl;
  
  string atob;
  
  for(int i = 0;i<datab.size();i++){
    
    atob = atob+datab[i]; 
   // cout << atob << endl;
  }
  //sort(mae.begin(), mae.end()); 
  
 // cout << atob << endl;
  
  atob.erase(unique(atob.begin(), atob.end()), atob.end());
  
  
  //ato.erase(unique(ato.begin(), ato.end()), ato.end());
  
  //cout << atob << endl;
  
 
 
  
  int ans = 0;
  for(int j = 0;j<maeb.size();j++){
    
     
    
     for(int k = 0;k<atob.size();k++){
       
        if(maeb[j]==atob[k]){
          
          ans += 1;
          
         
          
          //break;
          
          //continue;
        }
       
    
     }
    
     //cout << ans << "ans" << endl;
    
  }

   if(max < ans){
            
            max = ans;
            
    }
  
   
  
}
  
 cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
int main()
{
    ll n,temp;
    map<ll,ll> m;
    cin>>n;
    bool x=0;
    rep(i,n)
    {
        cin>>temp;
        m[temp]++;
        if(m[temp]>1) x=1;
    }
    if(x) cout<<"NO";
    else cout<<"YES";
}


Measured memory_bytes: 12800
<?php
while(fscanf( STDIN, "%d %d", $a, $b )){

list( $x, $y ) = ( $a > $b )? [ $a, $b ] : [ $b, $a ];
#x>y, ab?????????
while( $y ) list( $x, $y ) = [ $y, $x % $y ];
#x:gcd, b:0????????£?????????
$gcd = $x;
$lcm = $a / $gcd * $b;

printf( "%d %d\n", $gcd, $lcm );
}

Measured memory_bytes: 15288
N = int(input())
ans = 10**10

def F(A,B):
    return max(len(str(A)), len(str(B)))

rootN = int(N**.5)
for i in range(1,rootN+1):
    if N%i == 0:
        ans = min(ans,F(N//i,i))

print(ans)


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<vector<int>> a(n);
    rep(i,0,n){
        a[i].resize(n-1);
        rep(j,0,n-1){
            scanf("%d",&a[i][j]);
            a[i][j]--;
        }
    }
    vector<vector<int>> g(n*n);
    int cnt[n*n]={},u,v; bool fl[n*n]={};
    rep(i,0,n)rep(j,0,n-2){
        u=min(i,a[i][j])*n+max(i,a[i][j]);
        v=min(i,a[i][j+1])*n+max(i,a[i][j+1]);
        fl[u]=1; fl[v]=1;
        g[u].push_back(v); cnt[v]++;
    }
    queue<P> q;
    rep(i,0,n*n)if(fl[i]&&cnt[i]==0)q.push({i,0});
    vector<P> b; set<int> lvl;
    while(q.size()){
        P p=q.front();q.pop();
        b.push_back(p); lvl.insert(p.second);
        for(int nxt:g[p.first]){
            cnt[nxt]--;
            if(cnt[nxt]==0)q.push({nxt,p.second+1});
        }
    }
    if(b.size()!=n*(n-1)/2){
        printf("-1"); return 0;
    }
    printf("%d",lvl.size());
    return 0;
}

Measured memory_bytes: 79592