akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;

vector<int> V[105], color(105, 1), d(105), f(105);
int t = 0;

void func(int a) {
	t++;
	d[a] = t;
	color[a] = 2;
	Loop(i, V[a].size()) {
		if (color[V[a][i]] == 1) {
			func(V[a][i]);
		}
	}
	t++;
	f[a] = t;
	color[a] = 3;
}

int main() {
	int n;
	cin >> n;
	Loop(i, n) {
		int u, k;
		cin >> u >> k;
		Loop(j, k) {
			int v;
			cin >> v;
			V[u].push_back(v);
		}
	}
	Loop1(i, n) {
		if (color[i] == 1) func(i);
	}
	Loop1(i, n) {
		cout << i << " " << d[i] << " " << f[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    int D; cin >> D;
    vector<int> c(26);
    rep(i, 26) cin >> c.at(i);
    vector<vector<int>> s(D, vector<int>(26));
    rep(i, D){
        rep(j, 26){
            cin >> s.at(i).at(j);
        }
    }
    vector<int> t(D);
    rep(i, D) cin >> t.at(i);

    vector<int> last(26);

    ll sc = 0;
    rep(i, D){
        int n = t.at(i)-1;
        sc += s.at(i).at(n);
        last.at(n) = i+1;
        rep(j, 26){
            sc -= c.at(j) * (i - last.at(j) + 1);
        }
        cout << sc << endl;
    } 
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(all(l));
    ll ans=0;
    rep(i,n){
        repi(j,i+1,n){
            int k=l[i]+l[j];
            int x=lower_bound(l.begin(),l.end(),k)-l.begin();//k<=l[x]となるx
            ans+=x-j-1;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	while (1)
	{
		int a,b;
		char op;
		cin >> a >> op >> b;
		if(op=='?')break;
		if(op=='+')cout<<a+b<<endl;
		if(op=='-')cout<<a-b<<endl;
		if(op=='/')cout<<a/b<<endl;
		if(op=='*')cout<<a*b<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3088
s = str(input())
n = len(s)
cnt = 0
l = []
for i in range(n):
    l.append(cnt)
    if s[i] == '<':
        cnt += 1
    else:
        cnt = 0
else:
    l.append(cnt)
#print(l)

r = []
cnt = 0
for i in reversed(range(n)):
    r.append(cnt)
    if s[i] == '>':
        cnt += 1
    else:
        cnt = 0
else:
    r.append(cnt)
r.reverse()
#print(r)

A = [0]*len(l)
for i in range(len(A)):
    A[i] = max(l[i], r[i])
print(sum(A))


Measured memory_bytes: 77800
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll l, r, d;
    cin >> l >> r >> d;
    cout << r / d - (l - 1) / d << endl;
    return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(int argc, char *argv[])
{
  string input;
  stack<int> backes; // バックスラッシュのスタック(\\を認識した時点でのバックスラッシュの座標を格納する)
  stack<pair<int, int > > areas;		// 面積を示すスタック
  int area = 0;
  int back = 0;
  int sum = 0;
  list<pair<int, int> >answer;
  // areas.push(make_pair(-1,0));
  cin >> input;
  for (int i = 0; i < (int)input.size(); i++) {
    // cout << i  << " "<< input[i]<< "\n";

    if (input[i] == '\\') {
      if (backes.size() == 0) {
	// 追記later
      }
      backes.push(i);
    }else if (input[i] == '/') {
      if (backes.size() == 0) {

      }else {
	back = backes.top();
	backes.pop();

	area = i-back;
	sum = sum + area;
	while ((areas.size() != 0) && (areas.top().first > back)) {
	  area = area + areas.top().second ;
	  areas.pop();
	}
	areas.push(make_pair(back, area));
      }
      

    }
  }
  cout << sum << "\n";
  
  for (; areas.size() != 0; ) {
    answer.push_front(make_pair(areas.top().first, areas.top().second));
    areas.pop();
  }


  if (sum != 0) {
    cout << answer.size() << " ";
    auto itr = answer.begin();  
    for (; itr != --(answer.end()); itr++) {
      cout << (*itr).second << " ";      
    }
    cout << (*itr).second << "\n";
  }else {
    cout << answer.size() << "\n";
  }


  return 0;
}



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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int n,m;
vector<vector<int>> edges;
vector<bool> vst;
vector<int> l;


void dfs(int i) {
    for (int j : edges[i]) if (!vst[j]) {
        vst[j] = true;
        dfs(j);
    }
    l.push_back(i);
}

int main() {
    cin >> n >> m;
    edges.resize(n);
    vector<bool> used(n,false);
    for (int i = 0;i < m+n-1;++i) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        edges[a].push_back(b);
        used[b] = true;
    }
    int par = 0;
    for (int i = 0;i < n;++i) if (!used[i]) par = i;

    vst = vector<bool>(n,false);
    vst[par] = true;
    dfs(par);

    reverse(l.begin(),l.end());
    vector<int> d(n);
    for (int i = 0;i < n;++i) d[l[i]] = i;

    vector<int> pars(n,-1),dist(n,-1);

    for (int i : l) {
        for (int j : edges[i]) {
            if (pars[j] == -1 || d[pars[j]] < d[i]) {
                pars[j] = i;
            }
        }
    }
    //p_ary(pars,0,n,i);
    for (int i : pars) cout << i+1 << "\n";
    return 0;
}

Measured memory_bytes: 12664
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...

    
    int n;
    int a,b;
 
    
    cin >> n >> a >> b ;
    int total = 0;


    for(int j=0; j<=n ; j++){
        int tmp = 0;
        int num = j;
        for(int i=0; i<5; i++){
            tmp += num%10;
            num /= 10;
        }
        
        if((tmp>=a) && (tmp<=b))
            total += j;
    }
    
    
    
    cout << total;
    
    
    return 0;
    
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

template<class T> void gc (T& x) {
    char c;
    int s = 0;
    x = 0;
    c = getchar_unlocked();
    if (c == '-')
        s = 1;
    else if ('0' <= c && c <= '9')
        x = c - '0';
    while (true) {
        c = getchar_unlocked();
        if (c < '0' || '9' < c)
            break;
        x = x * 10 + (c - '0');
    }
    if (s)
        x = -x;
}

int main() {
    int N, M;
    gc (N);
    gc (M);
    int accum = 0;
    REP (i, M) {
        int Ai;
        gc (Ai);
        accum += Ai;
    }
    cout << (N < accum ? -1 : N - accum) << endl;
    return 0;
}


Measured memory_bytes: 3604
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>
#include <iostream>
#include <set>
using namespace std;

int main()
{
    int N;
    cin >> N;
    set<int > st;
    
    for (int i = 0; i<N; i++)
    {
        int x;
        cin >>x;
        st.insert(x);
    }
    
    if (st.size() == N) cout << "YES" <<endl;
    else cout <<"NO" <<endl;
    return 0;
}


Measured memory_bytes: 9600
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N;cin>>N;
	bool ok=true;

	int pt,px,py;
	pt=0;
	px=0;
	py=0;
	for (int i = 0; i < N; ++i) {
		int t,x,y;cin>>t>>x>>y;

		int nt=t;
		int nx=x;
		int ny=y;
		t=t-pt;
		x=x-px;
		y=y-py;
		x=abs(x);y=abs(y);
		if(x+y>t)ok=false;
		if(t%2!=(x+y)%2)ok=false;

		pt=nt;
		px=nx;
		py=ny;
	}
	if (ok) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void map_add(map<int,int> & mp, int A)
{
  auto itr = mp.find(A);
  if(itr != mp.end())
  {
    itr->second++;
  }
  else
  {
    mp[A] = 1;
  }
  return;
}
void solve(void)
{
  int X;
  cin>>X;
  int I = 1;
  while(true)
  {
    X -= I;
    if( X <= 0) break;
    I++;
  }
  cout<<(X == 0 ? I:I)<<endl;
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
import itertools
N =int(input())
X = [list(map(int,input().split())) for i in range(N)]
dist = 0
counter = 0
perm = list(itertools.permutations(list(range(N)),N))
for s in perm:
    idist = 0
    for i in range(N-1):
        idist +=( (X[s[i]][0]-X[s[i+1]][0])**2 + (X[s[i]][1]-X[s[i+1]][1])**2)**0.5
    dist += idist
    counter += 1
print(dist/counter)


Measured memory_bytes: 13912
/**
 * B - Homework
 * https://atcoder.jp/contests/abc163/tasks/abc163_b
 */
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // 高橋君の夏休みは N 日間です。
    // 夏休みの宿題が M 個出されており
    int N, M;
    cin >> N >> M;

    // i 番目の宿題をやるには Ai 日間かかります。
    int A;
    for (int i = 0; i < M; i++) {
        // 宿題にA日かかるため、夏休みの遊べる日数がA日減る
        cin >> A;
        N -= A;

        // 夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください
        if (N < 0) {
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << N << endl;
}
 

Measured memory_bytes: 3636
#coding:utf-8
import fileinput

for row in fileinput.input():
    N = int(row.strip())
    L = 2
    R = 1
    for i in range(N-1):
        L_N = L + R
        L = R
        R = L_N
    if N>1:
        print L_N
    elif N==1:
        print R
    elif N==0:
        print L
    
    


Measured memory_bytes: 2688
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, i, sum;
    int[] c;

    c = new int[6];
    c[0] = 1; c[1] = 5; c[2] = 10; c[3] = 50; c[4] = 100; c[5] = 500;

    for(;;out.println(sum)){
      n = sc.nextInt(); if(n == 0)break;
      sum = 0; n = 1000 - n;
      for(i = 5;i > -1;i--)if(c[i] <= n){
        sum += n / c[i]; n %= c[i];
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

int main() {
  char C;
  cin >> C;

  if (C == 'a' || C == 'e' || C == 'i' || C == 'o' || C == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


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

struct Req {
    int deb, fin, add;
};

struct Node {
    int max, add, d, f;
};

const int M = 1 << 18, N = 2*M, MOD = 1e9 + 7, INF = 1e18;

Node node[N];
int n, m, val[N];
vector<Req> req[M];

int applyOp(int i, int add) {
    node[i].add += add;
    return (node[i].max += add);
}

int getMax(int i, int deb, int fin, int add) {
    if(fin <= node[i].d || node[i].f <= deb)
        return -INF;
    if(deb <= node[i].d && node[i].f <= fin)
        return applyOp(i, add);
    int j1 = i*2, j2 = j1+1;
    applyOp(j1, node[i].add);
    applyOp(j2, node[i].add);
    node[i].add = 0;
    
    int max1 = getMax(j1, deb, fin, add),
        max2 = getMax(j2, deb, fin, add);
    node[i].max = max(node[j1].max, node[j2].max);
    return max(max1, max2);
}

void afficher(int i, int prof)
{
  if (i < M) afficher(i * 2 + 1 , prof + 1);
  for (int j = 0 ; j < prof ; j++) cout << "        ";
  cout << node[i].max << ' ' << node[i].add << '\n';
  if (i < M) afficher(i * 2 , prof + 1);
}

signed main() {
    /*
    freopen("exercise.in", "r", stdin);
    freopen("exercise.out", "w", stdout);
    */
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    for(int i = 0; i < M; i++) {
        node[i+M].d = i;
        node[i+M].f = i+1;
    }
    for(int i = M-1; i > -1; i--) {
        node[i].d = node[i*2].d;
        node[i].f = node[i*2+1].f;
    }
    for(int i = 0; i < N; i++)
        node[i].max = node[i].add = 0;
    
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int l, r, a;
        cin >> l >> r >> a;
        r++;
        req[l].push_back({l, r, a});
        req[r].push_back({l, r, -a});
    }
    
    int sum = 0;
    for(int i = 1; i <= n+1; i++) {
        for(Req j : req[i]) {
            sum += j.add;
            getMax(1, j.deb, j.fin, -j.add);
        }
        val[i] = getMax(1, 0, i, 0) + sum;
        getMax(1, i, i+1, val[i]);
    }
    int maxi = 0;
    for(int i = 0; i <= n+1; i++)
        maxi = max(maxi, val[i]);
    cout << maxi;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main() {

  	// 入力
	int ans, N, A, B;

	cin >> N >> A >> B;

	if( N * A > B){
		ans = B;
	} else {
		ans = N * A;
	}

  	cout << ans  << endl;
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  REP(i,n) cin >> a[i];
  REP(i,n) cin >> b[i];
  REP(i,n) cin >> c[i];
  sort(ALL(a)), sort(ALL(b)), sort(ALL(c));
  ll cnt=0;
  REP(i,n){
    ll x = (ll)(lower_bound(ALL(a), b[i]) - a.begin());
    ll y = (ll)(c.end() - upper_bound(ALL(c), b[i]));
    cnt += x*y;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d[330];
ll dd[110000];

long long gcd(long long a, long long b){
	if(a==0)return b;
	if(b==0)return a;
	return b == 0LL ? a : gcd(b, a % b);
}

int main() {
	clr(dd,0);
	ll n;
	cin>>n;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		dd[i] = a;
	}
	rep(i,0,330){
		ll a = dd[330*i];
		rep(j,1,330){
			gcd(a,dd[330*i+j]);
		}
		d[i] = a;
	}
	ll mx = 1;
	rep(i,0,n){
		ll a = 0;
		rep(j,0,330){
			if(i<j*330||(j+1)*330<=i){
				a = gcd(a,d[j]);
			}
			else{
				ll index = j*330;
				rep(k,0,330){
					if(i==index+k)continue;
					a = gcd(a,dd[index+k]);
				}
			}
		}
		mx = max(mx,a);
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
 
int main(){
    int N;cin>> N;
    int T,A;cin >> T >> A;
    int H[1001];
    rep(i,N){
        cin >> H[i];
    }

    A *= 1000;

    T *= 1000;
    int tmp = INT32_MAX;
    int tmp_i = 0;
    rep(i,N){
        int tm = T - H[i]*6;
        if(abs(tm-A)<tmp){
            tmp = abs(tm-A);
            tmp_i = i;
        }
    }

    cout << tmp_i + 1 << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
/**/int a[maxn<<1],mid,n;
int up(int x,int y){
	return a[x]>mid&&a[y]>mid;
}
int down(int x,int y){
	return a[x]<=mid&&a[y]<=mid;
}
int ck(){
	for(int i=n-1;i>=1;--i){
		if(up(i,i+1)||up(2*n-1-i,2*n-i))return 1;
		if(down(i,i+1)||down(2*n-1-i,2*n-i))return 0;
	}
	return up(1,1);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n*2-1;++i){
		scanf("%d",&a[i]);
	}
	int l=1,r=2*n-1,ans;
	while(l<=r){
		mid=(l+r)>>1;
		if(ck())l=mid+1;
		else r=mid-1,ans=mid;
	}
	cout<<ans<<endl;
	return 0;
}
/*
题意：
给一个n层的金字塔，给出底部的方块数字，其他未知，要求每一个方块都是其下方，下左方和下右方的中位数，输出顶层数字。

思路：
第二次看见这种套路了。
题目条件中，有对于大小的要求（中位数），且是求一个序列中满足条件的一个数，想到二分答案转01串。
由上一题可知当两个相同的数挨在一起时，可以一直上去
*/

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
		cin>>a[i],sum+=a[i];
	ll cnt=0;
	for(ll i=0;i<n;i++)
	{
		if(i%2==1)
			cnt+=a[i];
	}
	ll ans[n]{};
	ans[0]=sum-2*cnt;
	for(ll i=1;i<n;i++)
	{
		ans[i]=2*a[i-1]-ans[i-1];
	}
	for(ll i=0;i<n;i++)
		cout<<ans[i]<<" ";
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    unordered_map<string,bool> si;
    int n;
    cin >> n;
    string s;
    char e;
    bool out = 0;
    rep(i,n){
        cin >> s;
        if (i == 0) e = s[0];
        if (si[s]) out = 1;
        if (s[0] != e) out = 1;
        si[s] = 1;
        e = s[s.length()-1];
    }
    if (out) PRINT("No");
    else PRINT("Yes");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		String[] b = x.split(" ");
		int a = Integer.parseInt(b[0]);
		int c = Integer.parseInt(b[1]);
		int d=Integer.parseInt(b[2]);
		if (a<c&&c<d) {System.out.println("Yes");}
		 else {System.out.println("No");}
			

	}
}

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

int main() {
	int i, j, n, count = 0, a[100];
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (i = 0; i < n; i++) {
		for (j = n - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				count++;
			}
		}
	}

	for (i = 0; i < n; i++) {
		cout << a[i];
		if (i != n - 1)cout << " ";
		else cout << endl;
	}

	cout << count << endl;
	
	return 0;
}

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

#define pb push_back

const int MAXN=2005;

int n,a[MAXN*2],pos[2][MAXN],dp[MAXN][MAXN];
bool c[MAXN*2];
vector <int> q[2][MAXN];

void add(vector <int> q[],int x,int p)
{
	for (;x<=n;x+=x&-x)
		q[x].pb(p);
}

int query(vector <int> q[],int x,int p)
{
	int ret=0;
	for (;x;x-=x&-x)
	{
		ret+=q[x].end()-upper_bound(q[x].begin(),q[x].end(),p);
	}
	return ret;
}

int cal(int p,int a,int b)
{
	int now=p+query(q[0],a,p)+query(q[1],b,p);
	return now-(a+b+1);
}

void update(int &a,int b)
{
	if (a>b)
		a=b;
}

int main()
{
	//freopen("read.txt","r",stdin);
	scanf("%d",&n);
	char s[5];
	for (int i=1;i<=2*n;i++)
	{
		scanf("%s%d",s,&a[i]);
		if (s[0]=='W')
		{
			c[i]=true;
			pos[1][a[i]]=i;
			add(q[1],a[i],i);
		}
		else
		{
			pos[0][a[i]]=i;
			add(q[0],a[i],i);
		}
	}
	for (int j=0;j<2;j++)
		for (int i=1;i<=n;i++)
			sort(q[j][i].begin(),q[j][i].end());
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=n;j++)
		{
			if (i<n)
			{
				update(dp[i+1][j],dp[i][j]+cal(pos[0][i+1],i,j));
			}
			if (j<n)
			{
				update(dp[i][j+1],dp[i][j]+cal(pos[1][j+1],i,j));
			}
		}
	printf("%d",dp[n][n]);
	return 0;
}

Measured memory_bytes: 16256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
#define int ll
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=400010;
struct node
{
	int x,h;
	bool operator<(const node &b)const{return x<b.x;}
}p[N];
int c[N<<2],n,A,d,o[N];
int lowbit(int x){return x&(-x);}
void Add(int x,int d){while(x<=n){c[x]+=d;x+=lowbit(x);}}
int ask(int x){int ret=0;while(x){ret+=c[x];x-=lowbit(x);}return ret;}
signed main()
{
	n=gi();d=gi();A=gi();
	for(int i=1;i<=n;i++)p[i].x=o[i]=gi(),p[i].h=gi();
	sort(o+1,o+n+1);int tot=unique(o+1,o+n+1)-o-1;
	for(int i=1;i<=n;i++)p[i].x=lower_bound(o+1,o+tot+1,p[i].x)-o,p[i].h=p[i].h/A+(p[i].h%A?1:0);
	sort(p+1,p+n+1);ll ans=0;
	for(int i=1;i<=n;i++)
	{
		int nd=p[i].h-ask(i);if(nd<=0)continue;
		int P=upper_bound(o+1,o+tot+1,o[p[i].x]+2*d)-o-1;
		ans+=nd;Add(i,nd);Add(P+1,-nd);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 12032
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXLEN = 1000000;

char s[MAXLEN + 1]; int slen;

int up[2], dn[2];
int any[2];

int solve() {
	{
		up[0] = up[1] = 0;
		int bal = 0;
		REP(i, slen) {
			if (s[i] == '1') ++bal; else --bal;
			bal = max(bal, 0);
			int par = (bal + i) % 2;
			up[par] = max(up[par], bal);
		}
	}
	{
		dn[0] = dn[1] = 0;
		int bal = 0;
		REP(i, slen) {
			if (s[i] == '0') ++bal; else --bal;
			bal = max(bal, 0);
			int par = i % 2;
			dn[par] = max(dn[par], bal);
		}
	}
	//printf("%d %d | %d %d\n", up[0], up[1], dn[0], dn[1]);
	REP(i, 2) any[i] = max(up[i], dn[i]);
	return any[0] == any[1] ? any[0] + 1 : max(any[0], any[1]);
}

void run() {
	scanf("%s", s); slen = strlen(s);
	printf("%d\n", solve());
}

int solvestupid() {
	vector<int> unknown; REP(i, slen) if (s[i] == '?') unknown.PB(i);
	int ret = INT_MAX;
	REP(mask, 1 << SZ(unknown)) {
		int mn = 0, mx = 0, at = 0, bal = 0;
		REP(i, slen) {
			int val;
			if (s[i] == '0') val = 0; else if (s[i] == '1') val = 1; else val = (mask >> (at++)) & 1;
			if (val == 0) --bal; else ++bal;
			mn = min(mn, bal); mx = max(mx, bal);
		}
		ret = min(ret, mx - mn);
	}
	return ret;
}

void stress() {
	int mxlen = 50;
	REP(rep, 1000) {
		slen = rnd() % mxlen + 1;
		REP(i, slen) s[i] = "01?"[rnd() % 3];
		s[slen] = '\0';
		int have = solve();
		int want = solvestupid();
		if (have == want) { printf("."); continue; }
		printf("err\n");
	}
}

int main() {
	run();
	//stress();
	return 0;
}


Measured memory_bytes: 4772
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};
const constexpr ll MOD = 1e9 + 7;
struct NODE{
    ll to, cost;
};
ll N, M, R;

ll d[210][210]; //点Kからある点に到着するのにかかるコスト
vector<vector<NODE> > g(30010);

int main() {
    cin >> N >> M >> R;
    ll root[R]={0};
    REP(i, R) {
        ll r; cin >> r; r--;
        root[i] = r;
    }
    REP(i, M){
        ll a, b, c; cin >> a >> b >> c;
        a--; b--; 
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }
    for(int i=0; i<N; ++i){
        for(int j=0; j<N; ++j){
            d[i][j] = INF;
        }
    }
    for(int i=0; i<N; ++i){
        d[i][i] = 0;
    }
    for(int i=0; i<N; ++i){
        priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > que;
        que.push({0, i});
        
        while(!que.empty()){
            pair<ll, ll> p = que.top(); que.pop();
            ll v = p.second; // 現在見ている点
            if(d[i][v] < p.first) continue;
            
            for(int j=0; j<g[v].size(); ++j){
                NODE e = g[v][j];
                if(d[i][e.to] > d[i][v] + e.cost){
                    d[i][e.to] = d[i][v]+e.cost;
                    que.push({d[i][e.to], e.to});
                }
            }
        }  
    }
    sort(root, root+R);
    ll ans=INF;
    do{
        ll t=0;
        for(int i=1; i<R; ++i)t+=d[root[i-1]][root[i]];
        ans = min(ans, t);
    }while(next_permutation(root, root+R));
    
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 60) - 1;
int MOD = 1e9+7;
main(){
    ll N;
    vector<ll> V(5);
    cin >> N;
    rep(i,0,5)cin >> V[i];
    ll mini = INF;
    rep(i,0,5)mini = min(mini, V[i]);
    ll ans = 4 + (N + mini - 1) / mini;
    cout << ans << endl;
}


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

using ll = long long;

ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m%n);
}

ll lcm(ll m, ll n) {
  return (m*n)/gcd(m,n);
}

bool judge(std::string const& s, std::string const& t, ll l) {
  ll step_s = l / t.length();
  ll step_t = l / s.length();

  for (ll is=0, it=0; is<s.length(); is+=step_s, it+=step_t) {
    if (s[is] != t[it]) return false;
  }

  return true;
}

int main() {
  size_t N, M;

  std::cin >> N >> M;

  std::string S, T;

  std::cin >> S >> T;

  ll L = lcm(M, N);

  std::cout << (judge(S, T, L) ? L : -1) << std::endl;

  return 0;
}


Measured memory_bytes: 512
from collections import Counter

N = int(input())
As = list(map(int, input().split()))

cnt = Counter(As)
As.sort(reverse=True)

Ps = [2]
for i in range(58):
    Ps.append(Ps[-1] * 2)
Ps = Ps[::-1]

ans = 0
for A in As:
    if cnt[A] <= 0: continue
    cnt[A] -= 1
    for P in Ps:
        if cnt[P - A] > 0:
            ans += 1
            cnt[P - A] -= 1
            break
print(ans)


Measured memory_bytes: 113492
#include <iostream>
#include <iomanip>
#include <vector>
#include <math.h>
#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define FOR(i,m,n) for(int (i)=(m);(i)<(n); i++)
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
	ll H,A;cin>>H>>A;
	cout<<ceil(H*1.0/A);
	return 0;
}


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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int a, b, k;
set<int, greater<int>> st;

int main(){
    cin >> a >> b >> k;
    int n = min(a, b);
    rep2(i, 1, n+1){
        if(a % i == 0 && b % i == 0) st.insert(i);
    }
    auto iter = st.begin();
    rep(i, k-1) iter++;
    cout << *iter << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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


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

    string S;
    cin >> S;
    int cnt_x = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == 'x'){
            cnt_x++;
        }
    }

    if(cnt_x > 7){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    
    int[] L = new int[N];
    int[] R = new int[N];
    
    L[0] = 0;
    for (int i = 1; i < N; i++) {
      L[i] = gcd(L[i-1], A[i-1]);
    }
    R[N-1] = 0;
    for (int i = N-2; i >= 0; i--) {
      R[i] = gcd(R[i+1], A[i+1]);
    }

    int maxGcd = 1;
    for (int i = 0; i < N; i++) {
      int val = gcd(L[i], R[i]);
      if (val > maxGcd) {
        maxGcd = val;
      }
    }

    System.out.println(maxGcd);
  }
  
  private static int gcd(int i, int j) {
    int a, b;
    if (i > j) {
      a = i;
      b = j;
    } else {
      a = j;
      b = i;
    }

    // a > b
    if (b == 0) {
      return a;
    }

    return gcd(b, a % b);
  }
}

Measured memory_bytes: 52372
#include<iostream>
#include<vector>
using namespace std;
main(){
  int n,res,v;
  cin>>n;
  res=n;
  vector<int> x(n),y(n);
  for(int i=0;i<n;++i)cin>>x[i]>>y[i];
  for(int i0=0;i0<n;++i0)for(int i1=0;i1<n;++i1){
    if(i0==i1)continue;
    v=0;
    int p=x[i0]-x[i1],q=y[i0]-y[i1];
    for(int j0=0;j0<n-1;++j0)for(int j1=j0+1;j1<n;++j1){
      if(j0==j1)continue;
      if((x[j0]-x[j1]==p&&y[j0]-y[j1]==q)||(x[j0]-x[j1]==-p&&y[j0]-y[j1]==-q))v++;
    }
    res=min(res,n-v);
  }
  cout<<res;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
      	int n = sc.nextInt();
      	int s = n * (int)Math.pow(100,d);
 		
      	if(n == 100) s += (int)Math.pow(100,d);
          
      	System.out.println(s);
        
	}
}


Measured memory_bytes: 35772
A, B, C, D = map(int, input().split())

import fractions
CD = C * D // fractions.gcd(C, D)

A_C = (A-1) // C
B_C = B // C
A_D = (A-1) // D
B_D = B // D
A_CD = (A-1) // CD
B_CD = B //CD

ans =(B-A+1) - ((B_C - A_C) + (B_D - A_D) - (B_CD - A_CD))
print(ans)

Measured memory_bytes: 66028
#include <stdio.h>
long long MOD = 1000000007;
int main() {
    int n;
    scanf("%i", &n);

    long long a10 = 1, a9 = 1, a8 = 1;
    for (int i = 0; i < n; i++) {
        a10 = (10 * a10) % MOD;
        a9 = (9 * a9) % MOD;
        a8 = (8 * a8) % MOD;
    }
    printf("%lli", ((a10 - 2 * a9 + a8) % MOD + MOD) % MOD);
}


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

int main() {
  // KEYENCE String
  string s; cin >> s;
  string ans = "NO";
  int sn = s.size();
  rep(i,7) {
    string t;
    t += s.substr(0, i) + s.substr(sn - (7 - i));
    //cout << t << endl;
    if (t == "keyence") {
      ans = "YES";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
int main(){
	int a,b,c,aa[100],n,i,temp;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a > c){
            temp = c;
            c = a;
            a = temp;
        }
        if(b > c){
            temp = c;
            c = b;
            b = temp;
        }
		
		if(c*c==a*a+b*b){ printf("YES\n");
		}else{ printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "cstring"
#include "cstdio"
#include "cmath"
using namespace std;
const double INF = 1E10;
const double eps = 1e-8;
const int N = 110;
double d[N], g[N][N], a[N][N];
int pre[N], flag[N], mark[N];
int visit[N];
double sqr(double x){return x * x;}
double gao(int x, int y, int n)
{
	double va = 0, vb = 0, vc = 0;
	for(int i = 1; i <= n; ++ i){
		va += sqr(a[x][i]);
		vc += sqr(a[y][i]);
		vb += -2.0 * a[x][i] * a[y][i];
	}
	if(fabs(va) < eps) return INF;
	return (4.0 * va * vc - vb * vb) / (4.0 * va);
}

double ZhuLiu(int root, int n)
{
	int i, j, k;
	double res = 0;
	memset(flag, 0, sizeof(flag));
	while(1){
		for(i = 1; i <= n; ++ i){
			if(flag[i] || i == root) continue;
			pre[i] = i;
			g[i][i] = INF;
			for(j = 1; j <= n; ++ j){
				if(!flag[j] && g[j][i] < g[pre[i]][i])
					pre[i] = j;
			}
		}
		for(i = 1; i <= n; ++ i){
			if(flag[i] || i == root) continue;
			memset(mark, 0, sizeof(mark));
			mark[root] = 1;
			j = i;
			do{
				mark[j] = 1;
				j = pre[j];
			}while(!mark[j]);
			if(j == root) continue;
			i = j;
			res += g[pre[i]][i];
			for(j = pre[i]; j != i; j = pre[j]){
				flag[j] = 1;
				res += g[pre[j]][j];
			}
			for(j = 1; j <= n; ++ j){
				if(!flag[j] && g[j][i] < INF){
					g[j][i] -= g[pre[i]][i];
				}
			}
			for(j = pre[i]; j != i; j = pre[j]){
				for(k = 1; k <= n; ++ k){
					if(!flag[k]){
						g[i][k] = min(g[i][k], g[j][k]);
						if(g[k][j] < INF){
							g[k][i] = min(g[k][i], g[k][j] - g[pre[j]][j]);
						}
					}
				}
			}
			break;
		}
		if(i > n){
			for(j = 1; j <= n; ++ j){
				if(!flag[j] && j != root){
					res += g[pre[j]][j];
				}
			}
			break;
		}
	}
	return res;
}
int main(void)
{
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m + 1; ++ i){
		for(int j = 1; j <= m + 1; ++ j){
			g[i][j] = INF;
		}
	}	
	for(int i = 1; i <= m; ++ i){
		g[m + 1][i] = 0;
	}
	for(int i = 1; i <= m; ++ i){
		for(int j = 1; j <= n; ++ j){
			scanf("%lf", &a[i][j]);
			g[m + 1][i] += sqr(a[i][j]);
		}
	}
	for(int i = 1; i <= m; ++ i){
		for(int j = 1; j <= m; ++ j){
			if(i == j) continue;
			g[i][j] = gao(i, j, n);
		}
	}
	printf("%.10f\n", ZhuLiu(m + 1, m + 1));
	return 0;
}

Measured memory_bytes: 1424
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;
LL p[55];
LL all[55];

LL f(LL n,LL x){
	if(n==0){
		return 1;
	}else{
		if(x==1){
			return 0;
		}else if(x<=all[n-1]+1){
			return f(n-1,x-1);
		}else if(x==all[n-1]+2){
			return f(n-1,x-1)+1;
		}else if(x<=2*all[n-1]+2){
			return p[n-1]+1+f(n-1,x-(all[n-1]+2));
		}else{
			return p[n];
		}
	}
}

int main(){
 	LL n,x;
	cin>>n>>x;
	all[0]=p[0]=1;
	FOR(i,0,n){
		all[i+1]=2*all[i]+3;
		p[i+1]=2*p[i]+1;
	}
	cout<<f(n,x)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h,w,x;
	cin>>h>>w>>x;
	ll s=max(h,w);
	ll ans=0,cnt=0;
	while(cnt<x){
		cnt+=s;
		ans++;
	}
	puta(ans);
}


Measured memory_bytes: 256
# seishin.py
N, A = map(int, input().split())

ans = N
if N > 1:
    for k in range(1, 41):
        left = 0; right = N+1
        while left+1 < right:
            mid = (left + right) // 2
            if mid**(k+1) < N:
                left = mid
            else:
                right = mid
        m = right
        v = (m-1)**(k+1)
        for i in range(k+1):
            v //= m-1
            v *= m
            if N <= v:
                ans = min(ans, A*k + (m-1)*(k+1) + (i+1))
                break
print(ans)

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code

int main(int argc, char const* argv[])
{
    int n,m;
    cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
    return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N, K; cin >> N >> K;
    // combinationを計算
    vector<vector<ll>> comb(N+1, vector<ll>(N+1,1));
    for (int i = 2; i <= N; i++)
    {
        for (int j = 1; j <= i - 1; j++)
        {
            comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % mod;
        }
        
    }
    
    for (int i = 1; i <= K; i++)
    {
        ll ans = (N - K + 1 >= i) ? (comb[K - 1][i - 1] * comb[N - K + 1][i]) % mod : 0;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, sum = 0, x, max;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> x;
		if(i == 1){
			max = x;
		}
		else{
			if(max < x){
				max = x;
			}
		}
		sum = sum + x;
	}
	cout << sum - (max / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long x,k,d,s;
int main ()
{
	cin >> x >> k >> d;
	if (x<0) x=0-x;
	if (1000000000000000000/k>d && (x-k*d>0 || (x-k*d<=0 && 0-(x-k*d)<=d))) cout<<max(x-k*d,0-(x-k*d));
		else
		{
			s=k-(x/d+1);
			if (s%2==1) cout<<x-d*(x/d);
			else
			cout<<0-(x-d*(x/d+1));
		}
	

}



Measured memory_bytes: 3648
//
//  C - Takahashi's Information.cpp
//  AtCoder Beginner Contest 088
//
//  Created by Huang,Zhiqiang on 2018/2/18.
//  Copyright © 2018年 Huang,Zhiqiang. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int c11, c12, c13;
    int c21, c22, c23;
    int c31, c32, c33;
    cin >> c11 >> c12 >> c13;
    cin >> c21 >> c22 >> c23;
    cin >> c31 >> c32 >> c33;
    if (c12 - c11 == c22 - c21 && c32 - c31 == c22 - c21 &&
        c13 - c12 == c23 - c22 && c23 - c22 == c33 - c32 &&
        c21 - c11 == c22 - c12 && c22 - c12 == c23 - c13 &&
        c31 - c21 == c32 - c22 && c32 - c22 == c33 - c23) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256