akhauriyash/Code-Regression huggingface dataset:
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}


//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll g(ll x, ll n) {
	if (n == -1) return 0;
	else return n / x + 1;
}
int main() {
	ll a, b, x; cin >> a >> b >> x;
	
	cout << g(x, b) - g(x, a - 1) << endl;
}

Measured memory_bytes: 8064
n=int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])
#print(ab)
k=0
answer=1
for t in range(n):
    k+=ab[t][0]
    #print([k,answer])
    if k>ab[t][1]:
        answer=answer*0
if answer==1:
    print('Yes')
else:
    print('No')

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

class segmentTree{
public:
  int size; //要素数
  int* seg; //実際に値を格納する配列(初期化の際は大きさをsize*2-1で)

  //コンストラクタ segの大きさに注意
  segmentTree(int n){
    size=1;
    while(size<n) size *= 2;
    seg = new int[size*2-1];

    for(int i=0; i<size*2-1; i++) seg[i]=INT_MAX;
  }

  //k番目値をaに変更
  void update(int k, int a){
    k += size-1;
    seg[k] = a;
    //木を登りながら更新
    while(k>0){
      k = (k-1)/2;
      seg[k] = min(seg[k*2+1], seg[k*2+2]);
    }
  }

  //クエリから最小値を得るための関数
  //[a, b)の最小値を節点番号k, 区間[l, r)を指定して返す
  int query(int a, int b, int k, int l, int r){
    //もし指定した範囲が[a, b)の範囲外ならばINT_MAXを返しておく
    if(r <= a || b <= l) return INT_MAX;

    //[a, b)が[l, r)を完全に含むならば、その節点の値を返す
    if(a <= l && r <= b) return seg[k];

    else{
      int vl = query(a, b, k*2+1, l, (l+r)/2);
      int vr = query(a, b, k*2+2, (l+r)/2, r);
      return min(vl, vr);
    }

  }

  //デストラクタ
  ~segmentTree(){
    delete[] seg;
  }
};

int main(){
  int n, q; cin >> n >> q;
  segmentTree st(n);

  int ope, x, y;
  int ans[q]; int j=0;
  for(int i=0; i<q; i++){
    cin >> ope >> x >> y;
    if(ope==0) st.update(x, y);
    else ans[j++] = st.query(x, y+1, 0, 0, st.size);
  }

  for(int i=0; i<j; i++) cout << ans[i] << endl;

  return 0;
}



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

ll absll(ll x){
  if(x<0){
    return x*-1;
  }
  else return x;
}

int main() {
  ll x,k,d;
  cin>>x>>k>>d;
  if(absll(x%d)<=absll(x%d)-d){
    if(k>=x/d){
      k-=absll(x/d);
      if(k%2==0){
        cout<<absll(x%d)<<endl;
      }else{
        cout<<absll(absll(x%d)-d)<<endl;
      }
    }else{
      cout<<absll(absll(x)-absll(k*d))<<endl;
    }
  }else{
    if(k>absll(x/d)){
      k-=absll(x/d)+1;
      if(k%2==0){
        cout<<absll(absll(x%d)-d)<<endl;
      }else{
        cout<<absll(x%d)<<endl;
      }
    }else{
      cout<<absll(absll(x)-absll(k*d))<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3644
#[allow(unused_macros)]
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 , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }

#[allow(dead_code)]
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
#[allow(dead_code)]
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    input! {
        n: usize,
        t: [u64; n],
    }
    let mut ret = 1;
    for ti in t {
        ret = lcm(ret, ti);
    }
    println!("{}", ret);
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
const string YES = "YES";
const string NO = "NO";

void solve(long long X) {
    if (X == 3 or X == 5 or X == 7) cout << YES << endl;
    else cout << NO << endl;
}

int main() {
    bool test_samples = false;
    if (not test_samples) {
        long long X;
        std::cin >> X;
        solve(X);
    } else {
        const char *samples[] = {
            "5",
            "6",
        };
        REP(i, std::distance(ALL(samples))) {
            cerr << "[*] sample " << i << endl;
            istringstream iss(samples[i]);
            long long X;
            iss >> X;
            solve(X);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
//Dinic O(EV^2)
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<limits>
template<typename T>
struct MF{
	vector<vector<pair<pair<int,int>,T> > >G;
	vector<int>level,iter;
	MF(int n_=0):G(n_),level(n_),iter(n_){}
	void add_edge(int from,int to,T cap)
	{
		G[from].push_back(make_pair(
			make_pair(to,G[to].size()),cap
		));
		G[to].push_back(make_pair(
			make_pair(from,G[from].size()-1),0
		));
	}
	T dfs(int u,int t,T f)
	{
		if(u==t)return f;
		for(;iter[u]<G[u].size();iter[u]++)
		{
			pair<pair<int,int>,T>&e=G[u][iter[u]];
			if(e.second>0&&level[u]<level[e.first.first])
			{
				T d=dfs(e.first.first,t,min(f,e.second));
				if(d>0)
				{
					e.second-=d;
					G[e.first.first][e.first.second].second+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s,int t)
	{
		T ret=0;
		for(;;)
		{
			fill(level.begin(),level.end(),-1);
			queue<int>P;
			level[s]=0;
			P.push(s);
			while(!P.empty())
			{
				int u=P.front();P.pop();
				for(pair<pair<int,int>,T>&e:G[u])
				{
					if(e.second>0&&level[e.first.first]<0)
					{
						level[e.first.first]=level[u]+1;
						P.push(e.first.first);
					}
				}
			}
			if(level[t]<0)return ret;
			fill(iter.begin(),iter.end(),0);
			for(T f;(f=dfs(s,t,numeric_limits<T>::max()))>0;)ret+=f;
		}
	}
};
main()
{
	int N,E;
	cin>>N>>E;
	MF<int>mf(N);
	for(int i=0;i<E;i++)
	{
		int u,v,c;cin>>u>>v>>c;
		mf.add_edge(u,v,c);
	}
	cout<<mf.max_flow(0,N-1)<<endl;
}


Measured memory_bytes: 3116
public class Main {

  private static void solve() {
    int n = ni();
    long[] a = nal(n);

    long ret = dfs(a, 0, n - 1, 1, 1);
    System.out.println(ret + a[0] + a[n - 1]);

  }

  private static long dfs(long[] a, int l, int r, int nl, int nr) {
    if (r - l == 1) {
      return 0;
    }
    long ret = Long.MAX_VALUE;
    for (int i = l + 1; i <= r - 1; i++) {
      long now = dfs(a, l, i, nl, nr + nl) + dfs(a, i, r, nl + nr, nr) + a[i] * (nl + nr);
      ret = Math.min(ret, now);
    }
    return ret;
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

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

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 25044
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int i;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    int ans = 0;
    for(i=0;i<n;i++){
        if(a[a[i]-1]== (i+1) ){
            ans ++;
        }
    }
    ans = ans/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N=gets.to_i
NN=100000

min_withdraw_num = []
min_withdraw_num[0] = 0

can_withdraw_moneys = []
can_withdraw_moneys[0] = [0]

sixes = (1..99).map {|i| 6**i }
nines = (1..99).map {|i| 9**i }

for i in 1..N
  moneys = can_withdraw_moneys[i-1]

  a = []

  moneys.each do |m|
    b = [1]
    b += sixes.take_while {|s| s+m<=NN }
    b += nines.take_while {|s| s+m<=NN }
    b.each do |bb|
      new_money = m+bb
      unless min_withdraw_num[new_money]
        min_withdraw_num[new_money] = i
        a << new_money
      end
    end
  end

  can_withdraw_moneys[i] = a
end

puts min_withdraw_num[N]

Measured memory_bytes: 12024
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

struct node{int key; node *prev, *next;};

node *nil;

void insert(int key){
     node *x = (node *)malloc(sizeof(node));
     x->key = key;
     x->next = nil->next;
     nil->next->prev = x;
     nil->next = x;
     x->prev = nil;
}

node* listsearch(int key){
    node *cur = nil->next;
    while(cur != nil && cur->key != key){
        cur = cur->next;
    }
    return cur;
}

void deletenode(node *t){
    if(t == nil) return;
    t->next->prev = t->prev;
    t->prev->next = t->next;
    free(t);
}

void init(){
    nil = (node *)malloc(sizeof(node));
    nil->prev = nil;
    nil->next = nil;
}

int main(){
    int key, n;
    int size = 0, np = 0, nd = 0;
    char com[20];
    scanf("%d", &n);
    init();
    rep(i, n){
        scanf("%s%d", com, &key);
        if(com[0] == 'i'){
            insert(key);
            size++;
            np++;
        }
        else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F') deletenode(nil->next);
                else if(com[6] == 'L') deletenode(nil->prev);
            }else{
                deletenode(listsearch(key));
                nd++;
            }
            size--;
        }
    }
    node *cur = nil->next;
    int len = 0;
    while(1){
        if(cur == nil) break;
        if(len > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
        len++;
    }
    printf("\n");
}





Measured memory_bytes: 34456
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

class AOddsOfOddness {
public:
	void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    out << ceil((D)n / 2) / n << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);
	AOddsOfOddness solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
// g++ -o a a.cpp -Wall -lm -std=c++14
int s[10],c[10];
bool ok(string str,int n,int m){
    if((int)str.size()!=n)return false;
rep(i,m)if(str[s[i]-1]!=(char)(c[i]+'0'))return false;
return true;
}
int main(){
    int n,m;cin>>n>>m;
    rep(i,m){
        cin>>s[i]>>c[i];
    }
    for(int i=0;i<pow(10,3);i++){
        string str=to_string(i);
        if((ok)(str,n,m)){
            cout<<str<<endl;
            return 0;
        }
        }
        cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int H=1, W=1;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0)break;
        for (int i = 0; i < H; i++) {
            if (i % 2 == 0) {
                for (int j = 0; j < W; j++) {
                    if (j % 2 == 1)cout << ".";
                    else cout << "#";
                }
            }
            else {
                for (int j = 0; j < W; j++) {
                    if (j % 2 == 1)cout << "#";
                    else cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

#define MAX 3000

int main() {
    //変数の宣言
    int x[MAX], y[MAX];
    int i=0, j; //処理用
    
    //入力
    while (1) {
        scanf("%d %d", &x[i], &y[i]);
        if (x[i] == 0 && y[i] == 0) {
            break;
        }
        i++; //カウント
    }
    
    //出力
    for (j=0; j<i; j++) {
        if (x[j] < y[j]) {
            printf("%d %d\n", x[j], y[j]);
        }else{
            printf("%d %d\n", y[j], x[j]);
        }
    }
    
    return 0;
}



Measured memory_bytes: 2044
open Printf open Scanf
open Array

let iia k = init k (fun _ -> scanf " %d" @@ fun v -> v)
let binary_search ng ok f = let d = if ng <= ok then 1 else -1 in
  let rec f0 ng ok =
    if abs (ok - ng) <= 1 then ok
    else let mid = ng + (ok - ng) / 2 in if f mid then f0 ng mid else f0 mid ok
  in f0 (ng-d) (ok+d)
let right a v = binary_search 0 (length a - 1) (fun i -> a.(i) > v)
let left  a v = binary_search (length a - 1) 0 (fun i -> a.(i) < v)

let inf = 1000000000000

let () = scanf " %d %d %d" @@ fun a b q ->
  let s = iia a in
  let t = iia b in
  let x = iia q in
  sort compare s;
  sort compare t;
  let gs i dir =
    if i<0 || i >= a then (
      if dir=`L then -inf else inf
    ) else s.(i) in
  let gt i dir =
    if i<0 || i >= b then (
      if dir=`L then -inf else inf
    ) else t.(i) in
  iter (fun x ->
    let ls,rs = left s x, right s x in
    let lt,rt = left t x, right t x in
    let ls,rs,lt,rt =
      (gs ls `L),(gs rs `R),
      (gt lt `L),(gt rt `R)
    in
    (* printf ":::::: %16d %16d ; %16d %16d\n"
      ls rs lt rt; *)
    let res = [|
      abs (x - min ls lt);
      abs (x-ls) + abs (rt-ls);
      abs (max rs rt - x);
      abs (rs-x) + abs (rs-lt);
      abs (x-lt) + abs (rs-lt);
      abs (rt-x) + abs (rt-ls);
    |] in
    (* iter (printf "%d ") res;
    printf " :: "; *)
    printf "%d\n" @@ fold_left min inf res
    (* let c1 = abs (x - min ls lt) in
    let c2 = abs (x-ls) + abs (rt-ls) in
    let c3 = abs (x + max rs rt) in
    let c4 = abs (rs-x) + abs (rs-rt) in
    printf "%d %d %d %d ::"
      c1 c2 c3 c4;
    printf "%d\n" @@ fold_left min inf [|c1;c2;c3;c4|] *)
  ) x




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

/*
For an integer sequence of length n:
Number of ways to pick any value from 0 to 9 = 10^n
Number of ways to not pick 0 = Number of ways to pick any value from 1 to 9 = 9^n
Number of ways to not pick 9 = Number of ways to pick any value from 0 to 8 = 9^n
Number of ways to not pick 0 and 9 = Number of ways to pick any value from 1 to 8 = 8^n

Number of ways that a sequence does not contains at least either 0 or 9 will be (9^n + 9^n),
however, it double counts the number of ways to pick any value from 1 to 8, so subtract 8^n gives:
Number of ways that a sequence does not contains at least either 0 or 9 = (9^n + 9^n - 8^n)
Therefore, the number of ways to pick any value from 0 to 9 and also contains 0 and 9 can be calculated by:
10^n - (9^n + 9^n - 8^n)
*/

const int mod = 1000000007;

// add mod if the calculation result produced negative value
ll minus_mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

int main() {
  int n;
  cin >> n;
  ll a = 1, b = 1, c = 1;
  rep(i, n) {
    a = (a * 10) % mod;  // 10^n
    b = (b * 9) % mod;   // 9^n
    c = (c * 8) % mod;   // 8^n
  }
  cout << minus_mod((a - (b + b - c)), mod) << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int s1s2s3;
        cin >> s1s2s3;
      
      int A = (s1s2s3)/100;
      int B = ((s1s2s3)%100)/10;
      int C = (((s1s2s3)%100)%10)/1;
      
      cout << A+B+C << endl;
    }

Measured memory_bytes: 256
#include <stdio.h>
    int main(){
    	int n;
    	int a[100000];
    	scanf("%d",&n);
    	for (int i=1;i<=n;i++)
    		scanf("%d",&a[i]);
    	int ans=0;
    	for (int i=1;i<=n;i++)
    		for (int j=1;j<=n;j++)
    			if (a[i]-a[j]>ans)ans=a[i]-a[j];
    	printf("%d",ans);
    	return(0);
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define mset(s, _) memset(s, _, sizeof s)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main(void) {
  vector<ll> a;
  int n;
  cin >> n;
  ll A;
  rep(i, 0, n - 1) {
    cin >> A;
    if (A == 0) {
      cout << 0 << endl;
      return 0;
    }
    a.push_back(A);
  }

  ll ans = 1;
  rep(i, 0, n - 1) {
    // if (a[i] * ans <= pow(10, 18)) {
    if (a[i] <= 1000000000000000000 / ans) {
      ans *= a[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slow
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;

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

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  char c;
  cin >> c;

  char tmp[2] = {char(c+1), 0};
  cout << string(tmp) << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a=0;

    string s;
    cin>>s;
    int l=s.size();
    if(l==1)
    {
        cout<<a<<endl;
    }
    else
    {
        for(int i=1; i<l; i++)
        {
            if(s[i-1]==s[i])
            {
                a++;
                if(s[i]=='0')
                {
                    s[i]='1';
                }
                else
                {
                    s[i]='0';
                }
                //s[i] = '1' + '0' - s[i];
            }
        }
        cout<<a<<endl;
    }

}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
using namespace std;

struct UnionFind
{
	vector<int> par;
	vector<int> sizes;

	UnionFind(int n) : par(n), sizes(n, 1) {
		for (int i = 0; i < n; i++) par[i] = i;
	}

	int find(int x) {
		if (x == par[x])return x;
		return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);

		if (x == y) return;

		if (sizes[x] < sizes[y]) swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	int size(int x) {
		return sizes[find(x)];
	}
};


#define INF 1e9+7
struct RMQ {
	int n;
	vector<pair<int,int>>node;

	RMQ(int N) {
		n = 1; while (n < N)n *= 2;
		node.resize(2 * n - 1);
		for (int i = 0; i < 2*n-1;i++)node[i] = make_pair(INF, i-n+1);
	}

	void update(int x, int val) {
		x += n - 1;

		node[x].first = val;
		while (x > 0) {
			x = (x - 1) / 2;
			if (node[2 * x + 1].first < node[2 * x + 2].first) {
				node[x] = node[2 * x + 1];
			}
			else node[x] = node[2 * x + 2];
		}
	}
};

int main()
{
	int N, M; cin >> N >> M;
	vector<int>a(N);
	for (int i = 0; i < N; i++)cin >> a[i];
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		int x, y; cin >> x >> y;
		uf.unite(x, y);
	}

	RMQ rmq(N);

	vector<vector<int>>island(N);
	vector<char>used(N);
	vector<int>index;
	for (int i = 0; i < N; i++) {
		int x = uf.find(i);
		if (used[x] == false) {
			used[x] = true;
			index.push_back(x);
		}
		island[x].push_back(i);
	}

	vector<pair<int,int>>info;
	for (int j = 0; j < index.size();j++) {
		int ind = index[j];
		info.push_back(make_pair(island[ind].size(), ind));
	}

	sort(info.begin(), info.end(), greater<pair<int,int>>());

	long long ans = 0;

	for (int j = 0; j < island[info[0].second].size(); j++) {
		int ind = island[info[0].second][j];
		rmq.update(ind, a[ind]);
	}

	for (int i = 1; i < info.size(); i++) {
		if (rmq.node[0].first==INF) {
			cout << "Impossible" << endl;
			return 0;
		}

		ans += rmq.node[0].first;
		rmq.update(rmq.node[0].second, INF);
		
		int mina = INF;
		int inda = -1;
		for (int j = 0; j < island[info[i].second].size(); j++) {
			int ind = island[info[i].second][j];
			rmq.update(ind, a[ind]);
			if (mina > a[ind]) {
				inda = ind;
				mina = a[ind];
			}
		}
		rmq.update(inda, INF);
		ans += mina;
	}

	cout << ans << endl;

    return 0;
}



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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    REP(i, N) cin >> a[i];

    bool ok = true;
    for (int i=N; i>=1; --i)  {
        int j = 2;
        int mod = 0;
        while (i * j <= N) {
            mod ^= b[i * j-1];
            ++j;
        }
        if (mod != a[i-1]) {
            b[i-1] = 1;
        }
    }
    int m = 0;
    vector<int> out;
    REP(i, N) {
        if (b[i]) {
            out.push_back(i+1);
            ++m;
        }
    }
    print(m);
    if (m > 0) {
        REP(i, m) {
            cout << out[i];
            if (i == m-1) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 4980
times = int(input())
num_li = list(map(int,input().split(" ")))
cou = ans = 0
lim = 1

while lim:
    lim -= 1
    for i in range(times):
        if num_li[i] % 2 == 0:
            cou += 1
            num_li[i] = num_li[i]/2
        
    if cou == times:
        ans += 1
        lim += 1
        cou = 0
    else:
        print(ans) 

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);cout.tie(NULL);
        long long int n,i,k;
        cin>>n>>k;
        vector<long long int> h(n);
        for(i=0;i<n;i++){
                cin>>h[i];
        }
        vector<long long int> cost(n);
        cost[n-1]=0;
        cost[n-2]=abs(h[n-1]-h[n-2]);
        for(i=n-3;i>=0;i--){
                long long int j,temp,min;
                min=cost[i+1]+abs(h[i+1]-h[i]);
                for(j=i+1;j<=i+k && j<n;j++){
                        temp=cost[j]+abs(h[j]-h[i]);
                        if(temp<min){
                                min=temp;
                        }
                }
                cost[i]=min;
      
        }
        cout<<cost[0];
        
return 0;
}
/*

        creation time:  16.09.2020 10:56:33

*/                      



Measured memory_bytes: 4764
class Rsum():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [0] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Add(self, x, val):
		x += self.n-1
		self.node[x] += val
		while x > 0:
			x = (x-1)//2
			self.node[x] = self.node[2*x+1] + self.node[2*x+2]
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = 0
		while L<R:
			if R & 1:
				R -= 1
				s += self.node[R-1]
			if L & 1:
				s += self.node[L-1]
				L += 1
			L >>= 1
			R >>= 1
		return s

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 200
for bit in range(1<<n):
	if sum(list(map(int, list(bin(bit)[2:])))) %2 == 1:
		continue
	if sum([(i%2) ^ ((bit>>i)&1) for i in range(n)]) != n//2:
		continue
	c = [[b[i], i, (i%2) ^ ((bit>>i)&1)] if (bit>>i)&1 == True else [a[i], i, (i%2) ^ ((bit>>i)&1)] for i in range(n)]
	#print(bit, c)
	even = 0
	odd = 1
	c.sort(key=lambda x: (x[0], x[1]))
	#print(c)
	goal = [-1 for _ in range(n)]
	for i, p in enumerate(c):
		x, y, z = p
		if z == 0:
			goal[even] = [x, y]
			even += 2
		else:
			goal[odd] = [x, y]
			odd += 2
	#print(goal)
	ok = True
	for i in range(n-1):
		if goal[i][0] > goal[i+1][0]:
			ok = False
			break
	if not ok:
		continue

	tmp = 0
	st = Rsum(n)
	for x, y in goal:
		tmp += st.Get(y, n)
		st.Add(y, 1)
	ans = min(ans, tmp)

if ans == 200:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 72936
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
int a[Max];
vector<int>s;
int main()
{
    int n,l;
    int sum=0;
    scanf("%d%d",&n,&l);
    for(int i=1;i<=n;i++){
        a[i]=l+i-1;
        sum+=a[i];
    }
    for(int i=1;i<=n;i++){
        int sums=0;
        for(int j=1;j<=n;j++)
            if(j!=i)
                sums+=a[j];
      s.push_back(sums);
     // printf("%d %d\n",sums,sum);
    }
    sort(s.begin(),s.end());
    int ans=s[0];
    for(int i=1;i<n;i++)
        if(s[i]<=sum)
            ans=s[i];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
while True:
    H, W =[int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            if h == 0 or h == H - 1 or w == 0 or w == W - 1:
                print('#', end='')
            else:
                print('.', end='')

        print()

    print()

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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define NL '\n'
#define modn 1000000007
#define EPS 1e-9

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< lli > vli;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< bool > vb;
typedef set< int > si;
typedef set< ii > sii;

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

	#ifdef LOCAL_TEST
		ifstream h("in");
		ofstream g("out");
		clock_t z = clock();
	#else
		#define h cin
		#define g cout
	#endif//LOCAL_TEST

	string s, t;
	h >> s >> t;
	int n1 = s.size(), n2 = t.size();
	int ans = INT_MAX;
	f(i, 0, n1 - n2 + 1, 1){
		int cnt = 0;
		f(j, 0, n2, 1)
			cnt += (t[j] != s[i + j]);
		ans = min(ans, cnt);
	}
	g << ans;

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif//LOCAL_TEST
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct team {
  string name;
  int win;
  int lose;
};

class winner {
public:
  bool operator() (const team& a, const team& b) {
    if(a.win != b.win) {
    return a.win > b.win;
    }
    else {
      return a.lose > b.lose;
    }
  }
};

vector<team> T;

int main() {
  int n,res;
  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      team temp;
      temp.win = 0;temp.lose = 0;
      cin >> temp.name;
      for(int j=0;j<n-1;j++) {
        cin >> res;
        if(res == 0) temp.win++;
        if(res == 1) temp.lose--;
        if(res == 2) continue;
      }
      //      cout << temp.name << " " << temp.win << " " << temp.lose << endl;
      T.push_back(temp);
    }

    sort(T.begin(),T.end(), winner());
    for(int i=0;i<n;i++) {
      cout << T[i].name << endl;
      }
    T.clear();
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
constexpr int mod=1e9+7;
signed main(){
    int N;cin>>N;
    vector<vector<int>> a(N,vector<int>(N));
    REP(i,N) REP(j,N) cin>>a[i][j];
    vector<vector<int>> dp(N+1,vector<int>(1<<N,0));
    //dp[i][j]:男iまでにマッチングした女の集合がjになるような場合の数
    dp[0][0]=1;
    REP(i,N) REP(j,1<<N){
        if(__builtin_popcount(j)!=i+1) continue;
        REP(k,N) if((j>>k&1)&&a[i][k]) dp[i+1][j]+=dp[i][j^(1<<k)];
        dp[i+1][j]%=mod;
    }
    cout<<dp[N][(1<<N)-1]<<endl;
}

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

#define MAXN 2000
struct Edge{
    int v,u;
}E[MAXN+5];
int N,K;
vector<int> G[MAXN+5];

//How many points need to be deleted?
int dfs(int u,int f,int MaxD,int D){
    int ret=0;
    if(D>MaxD)
        ret++;
    for(int i=0;i<int(G[u].size());i++){
        int v=G[u][i];
        if(v!=f)
            ret+=dfs(v,u,MaxD,D+1);
    }
    return ret;
}

int main(){
    scanf("%d%d",&N,&K);
    for(int i=1;i<N;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
        E[i]=(Edge){u,v};
    }
    int Ans=N;
    if(K&1)//Two cases
        for(int i=1;i<N;i++)
            Ans=min(Ans,dfs(E[i].u,E[i].v,K/2,0)+dfs(E[i].v,E[i].u,K/2,0));
    else
        for(int i=1;i<=N;i++)
            Ans=min(Ans,dfs(i,-1,K/2,0));
    printf("%d",Ans);
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll K;

void solve() {
    cin >> K;
    if (K < 10) {
        cout << K << "\n";
        return;
    }

    queue<ll> q;
    for (ll i = 1; i <= 9; i++) {
        q.emplace(i);
        --K;
    }

    while (true) {
        ll a = q.front();
        q.pop();
        ll d = a % 10;
        for (ll i = -1; i <= 1; i++) {
            if (d + i < 0 || d + i > 9) continue;
            ll an = a * 10 + d + i;
            --K;
            if (K == 0) {
                cout << an << "\n";
                return;
            }
            q.emplace(an);
        }
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

int main() {
	int k,s;
	cin >> k >> s;
	int kai = 0;
	for(int x = 0;x <= k;x++)
	{
		for(int y = 0;y <= k;y++)
		{
			if(s - x - y >= 0 && s - x - y <= k)
			{
				kai++;
			}
		}
	}
    cout << kai << endl;
}


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

int main(){
  string S;
  cin >> S;
  int n = S.size();
  int tmpmin = 1000;
  
  for(int i = 0; i < n-2; i++){
    int tmp = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0');
    int diff = abs(753 - tmp);
    if(diff < tmpmin){
      tmpmin = diff;
    }
  }
  cout << tmpmin << endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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; }

bool comp(pair<ll,ll> a, pair<ll,ll> b){
    return a.second < b.second;
}
int main(void){
    ll N; cin >> N;
    vector<pair<ll,ll>> v(N);
    REP(i,N){
        ll x,l; cin >> x >> l;
        v[i].first = x-l; v[i].second = x+l;
    }
    sort(ALL(v), comp);
    ll e = -1e9;
    ll ans=0;
    REP(i,N){
        if(e <= v[i].first){
            ans++;
            e = v[i].second;
        }
    }

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

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  LL x, y;
  scanf("%lld%lld", &x, &y);
  int ans = 0;
  while (x <= y) ++ans, x <<= 1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int X,Y,Z;
  cin >> X >> Y >> Z;
  int ans=0;
  for(int i=0;;i++){
    if(i*Y+i*Z+Z<=X)  ans=i;
    else  break;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main()
{
  int N,M,i,j,t,ans;
  while(cin>>N>>M,N|M){
    vector<int>h(N),w(M);
    map<int,int>m;
    for(i=0;i<N;i++)cin>>h[i];
    for(i=0;i<M;i++)cin>>w[i];

    for(i=0;i<N;i++){
      t=0;
      for(j=i;j<N;j++){
	t+=h[j];
	m[t]++;
      }
    }
    ans=0;
    for(i=0;i<M;i++){
      t=0;
      for(j=i;j<M;j++){
	t+=w[j];
	if(m.count(t))ans+=m[t];
      }
    }

    cout<<ans<<endl;
  }
}

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

int main() {
  int a,b,c; cin>>a>>b>>c;
  if (a==b&&b==c) cout<<1<<endl;
  else if (a!=b&&b!=c&&a!=c) cout<<3<<endl;
  else cout<<2<<endl;
}


Measured memory_bytes: 256
package main

import "fmt"

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

func main() {
	var h, w int
	var dp [10][10]int
	fmt.Scan(&h, &w)
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			fmt.Scan(&dp[i][j])
		}
	}
	for k := 0; k < 10; k++ {
		for i := 0; i < 10; i++ {
			for j := 0; j < 10; j++ {
				dp[i][j] = min(dp[i][k]+dp[k][j], dp[i][j])
			}
		}
	}
	set := make(map[int]int, 0)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			var v int
			fmt.Scan(&v)
			if v != -1 && v != 1 {
				set[v]++
			}
		}
	}
	ans := 0
	for k, v := range set {
		ans += dp[k][1] * v
	}
	fmt.Println(ans)
}


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

using namespace std;

using edge = pair<int, pair<int, int>>;

int INF = 1 << 30;

int Edmonds(const vector<edge> &G, int V, int r) {
    vector<pair<int, int>> MIN(V, pair<int, int>(INF, -1));
    for (auto &e : G) {
        MIN[e.second.second] = min(MIN[e.second.second],
                                   pair<int, int>(e.first, e.second.first));
    }

    MIN[r] = {-1, -1};

    vector<int> group(V, 0);
    vector<bool> isCycle(V, false);
    int count = 0;

    vector<bool> used(V, false);

    for (int i = 0; i < V; i++) {
        if (used[i]) continue;
        vector<int> chain;
        int now = i;
        while (now != -1 && !used[now]) {
            used[now] = true;
            chain.push_back(now);
            now = MIN[now].second;
        }
        if (now != -1) {
            bool inCycle = false;
            for (int j : chain) {
                group[j] = count;
                if (j == now) {
                    isCycle[count] = true;
                    inCycle = true;
                }
                if (!inCycle)
                    count++;
            }
            if (inCycle)
                count++;
        } else {
            for (int j : chain) {
                group[j] = count;
                count++;
            }
        }
    }
    int res = 0;
    if (count == V) {
        for (int i = 0; i < V; i++) {
            if (i == r) continue;
            res += MIN[i].first;
        }
        return res;
    }

    for (int i = 0; i < V; i++) {
        if (i == r) continue;
        if (isCycle[group[i]])
            res += MIN[i].first;
    }

    vector<edge> nG;
    for (auto &e : G) {
        int to = e.second.second;
        int gfrom = group[e.second.first];
        int gto = group[e.second.second];
        if (gfrom == gto) continue;
        else if (isCycle[gto])
            nG.push_back({e.first - MIN[to].first, {gfrom, gto}});
        else {
            nG.push_back({e.first, {gfrom, gto}});
        }
    }
    return res + Edmonds(nG, count, group[r]);
}


int main() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<edge> G;

    for (int i = 0; i < E; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        G.push_back({w, {s, t}});
    }
    auto res = Edmonds(G, V, r);
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 3460
import copy
N,M=map(int,input().split())
A=[]
L=[[1000for i in range(N)]for j in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    A.append([a,b])
    L[a-1][b-1]=1
    L[b-1][a-1]=1
    
for j in range(N):
    L[j][j]=0

#print(L)
l=copy.deepcopy(L)

cnt=0
for k in range(M):
    L=copy.deepcopy(l)
    L[A[k][0]-1][A[k][1]-1]=1000
    L[A[k][1]-1][A[k][0]-1]=1000
    for x in range(N):
        for y in range(N):
            for z in range(N):
                if L[y][z]>L[y][x]+L[x][z]:
                    L[y][z]=L[y][x]+L[x][z]
    #print(L[A[k][0]-1][A[k][1]-1])
    if L[A[k][0]-1][A[k][1]-1]>=1000:
        cnt+=1
    L[A[k][0]-1][A[k][1]-1]=1
    L[A[k][1]-1][A[k][0]-1]=1
#print(L)   
print(cnt)

Measured memory_bytes: 3572
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;cin>>s;
  rep(i,s.size()){
    if(i%2==1){
      if(s[i]=='R'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    if(i%2==0){
      if(s[i]=='L'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#a, b=map(int,input().split())

a, b=input().split()
n=len(b)
na = int(a)
nb = int(b)
A=na*(10**n)+nb
 
T=(int(A**0.5))**2
 
if A==T:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    X = int(input())
    for A in range(-100,10000):
        for B in range(-100,A+1):
            if A**5-B**5==X:
                print(A, B)
                sys.exit()


if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int R;
    cin >> R;
    printf("%.10Lf\n", (ld)2 * PI * R);
    return 0;
}


Measured memory_bytes: 3780