akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll A, B, Q;
    cin >> A >> B >> Q;
    vec s(A), t(B);
    rep(i, A) cin >> s[i];
    rep(i, B) cin >> t[i];

    rep(_, Q){
        ll x;
        cin >> x;
        ll ans = 1e18;

        auto s1 = lower_bound(ALL(s), x);
        auto s2 = s1 - 1;
        auto t1 = lower_bound(ALL(t), x);
        auto t2 = t1 - 1;

        vec X = {*s1, *s2}, Y = {*t1, *t2};
        if(s1 == s.begin()) X[1] = INF;
        if(t1 == t.begin()) Y[1] = INF;
        if(s1 == s.end()) X[0] = INF;
        if(t1 == t.end()) Y[0] = INF;

        for(auto S : X) for(auto T : Y){
            if(S == INF or T == INF) continue;
            chmin(ans, abs(S - x) + abs(T - S));
            chmin(ans, abs(T - x) + abs(S - T));
        }
        print(ans);
    }



    return 0;
}

Measured memory_bytes: 2944
module Main where

import Control.Applicative

getInt :: IO Int
getInt = head <$> getInts

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  {[a, b] <- getInts
  ; if a < b then putStrLn "a < b"
    else if a == b then putStrLn "a == b"
         else putStrLn "a > b"
  }


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

 
int main() {
    fastio
    ll n, d;
    cin>>n>>d;
    ll x[n], y[n];
    for(int i = 0; i<n; ++i)
    	cin>>x[i]>>y[i];

    int cnt = 0;
    d *= d;
    for(int i = 0; i<n; ++i) {
    	ll dist = x[i]*x[i] + y[i]*y[i];
    	if(dist <= d)
    		cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 6764
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

struct UnionFind {
    vector<int> node;

    UnionFind() = default;
    UnionFind(int x) {init(x);}

    void init(int x) {
        node.assign(x,-1);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (node[x] > node[y]) swap(x,y);
        node[x] += node[y];
        node[y] = x;
        return true; 
    }

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

    int root(int x) {
        if (node[x] < 0) return x;
        return node[x] = root(node[x]);
    }

    int size(int x) {
        return -node[root(x)];
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<vector<int>> G(N);
    UnionFind uf(N);
    rep(i,M) {
        int x,y; cin >> x >> y;
        uf.merge(x,y);
    }

    if (M == N-1) {
        cout << 0 << ln;
        return 0;
    }
    int cnt = 2*(N-M-1);
    if (cnt > N) {
        cout << "Impossible" << ln;
        return 0;
    }

    rep(i,N) {
        G[uf.root(i)].emplace_back(A[i]);
    }
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    ll ans = 0;
    rep(i,N) {
        if (G[i].empty()) continue;
        sort(all(G[i]));
        rep(j,G[i].size()) {
            if (j) pq.emplace(G[i][j]);
            else {
                ans += G[i][j];
                --cnt;
            }
        }
    }
    rep(_,cnt) {
        ans += pq.top(); pq.pop();
    }

    cout << ans << ln;

}

Measured memory_bytes: 6264
import java.util.Scanner 
import scala.math.sqrt
import scala.math.floor
object Main extends App{
	val scanner = new Scanner(System.in)
	val a = scanner.next
	val b = scanner.next
	val ab = a + b
	scanner.close
	val num = ab.toInt
	if(sqrt(num) ==  floor(sqrt(num))){
		println("Yes")
	}else{
		println("No")
	}
	
}

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

const ll MOD = 1e9+7;
ll N;
vector<ll> a;
vector<ll> b;
int main() {
    cin >> N; a.resize(N);
    for (int i = 0; i < N; i++) scanf("%Ld", &a[i]);
    for (int i = N-1; i>=0 ; i-=2) {
        b.push_back(i);
        if (i!=0)b.push_back(i);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (!(equal(a.begin(), a.end(), b.begin(), b.end()))) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    for (int i = 0; i < N/2; i++) {
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<list>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll dp[1001][11]={};

int main() {

	int d,p[11];
	ll g,c[11];
	cin>>d>>g;

	rep(i,d)cin>>p[i+1]>>c[i+1];
	for(int i=1; i<p[1]+1; i++){
		dp[i][1]=100*i;
		if(i==p[1])dp[i][1]+=c[1];
	}
	for(int i=2; i<d+1; i++){
		for(int k=1; k<p[i]+1; k++){
			dp[k][i]=100*i*k;
			if(k==p[i])dp[k][i]+=c[i];
		}
		for(int j=1; j<1001; j++){
			dp[j][i]=max(dp[j][i],dp[j][i-1]);
			if(dp[j][i-1]==0)continue;
			for(int m=1; m<p[i]+1; m++){
				if(j+m>1000)break;
				dp[j+m][i]=max(dp[j][i-1]+100*i*m,dp[j+m][i]);
				if(m==p[i])dp[j+m][i]=max(c[i]+dp[j][i-1]+100*i*m,dp[j+m][i]);
			}
		}
	}
	rep(i,1001){
		if(dp[i][d]>=g){
			cout<<i<<endl;
			return 0;
		}
	}

	return 0;
}


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

#define F first
#define S second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define did_you_calis_enough ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long

using namespace std;

const int INF =  4294967295;
const int  N = 2e6 + 667;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double PI = acos(-1.0);


main() {
	did_you_calis_enough
	int d, t, s;
	cin >> d >> t >> s;
	cout << ((t * s >= d) ? "Yes" : "No"); 
}

//Coded by LoliThief



Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <string>	

using namespace std;

int main(){
	int m, h;
	string s;
	while (1){
		cin >> s;
		if (s == "-") break;
		cin >> m;
		for (int i = 0; i < m; i++){
			cin >> h;
			s = s.substr(h, s.size() - 1) + s.substr(0, h);
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3140
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	ll a[500];
	FAST;
	int n;
	cin >> n;

	a[0] = 2;
	a[1] = 1;
	
	for(int i=2 ; i<=n ; i++)
		a[i] = a[i-1] + a[i-2];

	cout << a[n];

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, L, a[1000000], pos;
int main()
{
    cin >> n >> L;
    for(int i = 1;i <= n; ++ i){
        cin >> a[i];
    }
    for(int i = 1;i < n; ++ i){
        if(a[i] + a[i + 1] >= L)pos = i;
    }
    if(!pos){
        cout << "Impossible";
        return 0;
    }
    cout << "Possible\n";
    for(int i = 1;i < pos; ++ i)cout << i << endl;
    for(int i = n - 1;i >= pos; -- i)cout << i << endl;
    return 0;
}


Measured memory_bytes: 1152
N = int(input())
sum_ = 0
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        a = "FizzBuzz"
    elif i % 3 == 0:
        a = "Fizz"
    elif i % 5 == 0:
        a = "Buzz"
    else:
        a = i

    if type(a) == int:
        sum_ += a

print(sum_)

Measured memory_bytes: 9188
// https://atcoder.jp/contests/abc158/tasks/abc158_b
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    lli n,a,b,res;
    cin>>n>>a>>b;
    res = (n/(a+b))*a;
    n -= (n/(a+b))*(a+b);
    res += min(a,n);
    cout<<res<<"\n";
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int P, Q, R; cin >> P >> Q >> R;
    cout << P + Q + R - max(P, max(Q, R)) << endl;
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll A, B;
    cin >> A >> B;
    cout << std::max(A + B, std::max(A - B, A * B)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> 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));
    vector<LL> As(N);
    vector<LL> Cl(N);

    LL ans = 0;
    rep(i,N){
        int b = B[i];

        if(A[0] >= B[i])As[i] = 0;
        else if(A[N-1]<B[i])As[i] = N;
        else{
            int lb = 0; int ub = N-1;
            while(ub - lb > 1){
                int mid = (ub+lb)/2;
                if(A[mid] < B[i])lb = mid;
                else ub = mid;
            }

            As[i] = ub;
        }

        if(C[N-1]<=B[i])Cl[i] = 0;
        else if(C[0]>B[i])Cl[i] = N;
        else{
            int lb = 0; int ub = N-1;
            while(ub - lb > 1){
                int mid = (ub+lb)/2;
                if(C[mid] > B[i])ub = mid;
                else lb = mid;
            }

            Cl[i] = N-ub;
        }
    }

    rep(i,N)ans += As[i]*Cl[i];
    cout << ans << endl;
}

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

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define int long long

const int M = 2e6;
vi graph[M], sorted;
int valid[M] = {0}, n, m, visited[M] = {0};

void stringMatching(string s, string t)
{
    string a = t + '#' + s;
    int n = a.size();
    int z[n]; z[0] = 0;

    int l = 0, r = 0;
    FOR(i,1,n)
    {
        if (i > r)
        {
            l = r = i;
            while (r < n and a[r] == a[r-l]) ++r;
            z[i] = r-l; --r;
        }

        else
        {
            if (z[i-l] < r-i+1) z[i] = z[i-l];

            else
            {
                l = i;
                while (r < n and a[r-l] == a[r]) ++r;
                z[i] = r-l; --r;
            }
        }
    }

    FOR(i,0,n)
    {
        if (z[i] == t.size()) 
            valid[i-t.size()-1] = 1;
    }
}

bool isCycle(int curr, int code)
{
    visited[curr] = code;
    int next = (curr + m)%n;
    if (not valid[next])
    {
        sorted.pb(curr); 
        return false;
    }

    if (visited[next] == code) return true;
    if (visited[next] == 0 and isCycle(next, code)) return true;
    
    sorted.pb(curr);
    return false;
}

int dfs(int curr, int len)
{
    visited[curr] = 1;
    int next = (curr + m)%n;
    if (not valid[next]) return len;

    return dfs(next, len+1);
}

int solve(string x, string y)
{
    n = x.size(); m = y.size(); int req = n+m;
    string t = y, s = x;

    while (s.size() < req) s += x; 
    stringMatching(s,t);

    int code = 1;
    FOR(i,0,n)
    {
        if (valid[i] and visited[i] == 0)
        {
            if (isCycle(i,code)) return -1;
            ++code;
        }
    }
    if (sorted.size() == 0) return 0;

    int ans = 0;
    FOR(i,0,n) visited[i] = 0;
    FORR(i,sorted.size()-1,-1)
    {
        int curr = sorted[i];
        if (valid[curr] and not visited[curr]) ans = max(ans, dfs(curr, 1));
    }

    return ans;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t; cin >> s >> t;
    cout << solve(s,t);
    return 0;
}


Measured memory_bytes: 84164
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    IOS
    ll n,k;
    cin>>n>>k;
    int ctr=1;
    ll temp=k;
    while(n>=temp){
        temp=temp*k;
        ctr++;
    }
    cout<<ctr;
    return 0;
}


Measured memory_bytes: 256
using System;

class AOJ{
  static void Main(string[] args)
  {
    string s;

    while ((s = Console.ReadLine()) != null){

      int n = int.Parse(s);
      int ans = 0;

      for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
          for (int k = 0; k < 10; k++) {
            for (int l = 0; l < 10; l++) {
              if (i + j + k + l == n) ans++;
            }
          }
        }
      }

      Console.WriteLine(ans);
    }
  }
}

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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n;
    cin >> n;
    vector<vii> edges(n+1);
    ll u, v, w;
    REP(i, 1, n) {
        cin >> u >> v >> w;
        edges[u].pb({v, w});
        edges[v].pb({u, w});
    }
    queue<ll> q;
    vi col(n+1), vis(n+1, 0);
    col[1] = 0;
    vis[1] = 1;
    q.push(1);
    while (!q.empty()) {
        auto cur = q.front();
        q.pop();
        REP(i, 0, edges[cur].size()) {
            auto v = edges[cur][i];
            if (!vis[v.first]) {
                q.push(v.first);
                vis[edges[cur][i].first] = 1;
                if ((edges[cur][i].second)%2)
                    col[edges[cur][i].first] = (col[cur] + 1)%2;
                else
                    col[v.first] = col[cur];
            }
        }
    }
    REP(i, 1, n+1)
        cout << col[i] << endl;
    return 0;
}


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

vector<vector<string>> memo(11);
vector<string> dfs(ll x){
    if(memo[x].size()!=0) return memo[x];
    for (auto e : dfs(x-1)) {
        ll ma = 0;
        for (auto ee : e) {
            ma = max(ma,(ll)(ee-'a'));
        }
        for (int i = 0; i <= ma+1; i++) {
            memo[x].push_back(e+(char)('a'+i));
        }
    }
    return memo[x];
}

int main() {
    ll n;
    std::cin >> n;
    memo[1].push_back("a");
    
    for (auto e : dfs(n)) {
        std::cout << e << std::endl;
    }
}


Measured memory_bytes: 12364
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		System.out.println(calcWorstCount(n));
	}
	
	static int calcWorstCount(int n){
		if(n == 2){
			return 1;
		}
		
		int count = 0;
		while(n >= 2){
			n = (int)Math.ceil(n / 3.0);
//			System.out.println("now n = "+n);
			count++;
		}
		
		return count;
	}

}


Measured memory_bytes: 26148
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define N 524288
#define MOD 924844033
struct edge{int nx,t;}e[N+5];
int h[N+5],en,s[N+5],w[2][N+5],R[N+5],f[N+5],rf[N+5],a[N+5],b[N+5];
inline void ins(int x,int y)
{
	e[++en]=(edge){h[x],y};h[x]=en;
	e[++en]=(edge){h[y],x};h[y]=en;
}
inline int pw(int x,int y)
{
	int r=1;
	for(;y;y>>=1,x=1LL*x*x%MOD)if(y&1)r=1LL*r*x%MOD;
	return r;
}
void dfs(int x,int fa)
{
	s[x]=1;
	for(int i=h[x];i;i=e[i].nx)if(e[i].t!=fa)
		dfs(e[i].t,x),s[x]+=s[e[i].t];
}
void init()
{
	int g=pw(5,(MOD-1)/N),i,j,k;
	for(w[0][0]=i=1;i<N;++i)w[0][i]=1LL*w[0][i-1]*g%MOD;
	for(w[1][0]=i=1;i<N;++i)w[1][i]=w[0][N-i];
	for(i=j=0;i<N;R[++i]=j)for(k=N>>1;(j^=k)<k;k>>=1);
}
inline int mod(int x){return x<MOD?x:x-MOD;}
void fft(int*x,int v)
{
	int i,j,k,p;
	for(i=0;i<N;++i)if(i<R[i])swap(x[i],x[R[i]]);
	for(i=1;i<N;i<<=1)for(j=0;j<N;j+=i<<1)for(k=0;k<i;++k)
	{
		p=1LL*x[i+j+k]*w[v][N/(i<<1)*k]%MOD;
		x[i+j+k]=mod(x[j+k]+MOD-p);x[j+k]=mod(x[j+k]+p);
	}
	if(v)for(i=0,p=pw(N,MOD-2);i<N;++i)x[i]=1LL*x[i]*p%MOD;
}
int main()
{
	int n=read(),i; 
	for(i=1;i<n;++i)ins(read(),read());
	dfs(1,0);
	for(i=2;i<=n;++i)++a[s[i]],++a[n-s[i]];
	for(i=f[0]=1;i<=n;++i)f[i]=1LL*f[i-1]*i%MOD;
	for(rf[i=n]=pw(f[n],MOD-2);i--;)rf[i]=1LL*rf[i+1]*(i+1)%MOD;
	for(i=1;i<=n;++i)a[i]=1LL*a[i]*f[i]%MOD,b[i]=rf[n-i];
	init();fft(a,0);fft(b,0);
	for(i=0;i<N;++i)a[i]=1LL*a[i]*b[i]%MOD;
	fft(a,1);
	for(i=1;i<=n;++i)printf("%d\n",(1LL*n*f[n]%MOD*rf[i]%MOD*rf[n-i]+MOD-1LL*a[i+n]*rf[i]%MOD)%MOD);
}

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

long long toIntSum(string s)
{
    long long sum=0,tmp=0;
    for (int i=0;i<s.size();i++)
    {
        if(s[i]=='+')
        {
           sum+=tmp;
           tmp=0;
        }
        else
            tmp=tmp*10+s[i]-'0';

    }
    return sum+tmp;
}
int main ()
{
    string str;
    cin>>str;
    int len =str.size()-1,a[11]={0};//加号最多=串长-1;a[i]==0表示i处没有加号，a[i]==1表示i处有加号.
    long long sum=0;
    while(true)
    {
        string s;
        for (int i=0;i<len;i++)
        {
            a[i+1]+=a[i]/2;
            a[i]%=2;
        }
        if(a[len])
            break;
        for (int i=0;i<len;i++)//把加号和数字合成一个串
        {
            s+=str[i];
            if(a[i])
                s+="+";
        }
        s+=str[len];
        sum+=toIntSum(s);
        a[0]++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long N;
  cin >> N;
  long long a[80];

  vector<long long> v;
  vector<long long> s;

  long long key = a[0];
  long long cand = 0;
  bool f = false;
  rep(i, N) {
    cin >> a[i];
    if(i == 0) key = a[i];
    else {
      if(key <= a[i]) {
        f = true;
        key = a[i];
      } else {
        if(f) {
          v.push_back(cand);
          s.push_back(i-1);
        }
        f = false;
        cand = i;
        key = a[i];
      }
    }
  }
  if(f) {
    v.push_back(cand);
    s.push_back(N-1);
  }

  // rep(i, v.size()) {
  //   cout << v[i] << " ";
  // }
  // cout << endl;
  // rep(i, s.size()) {
  //   cout << s[i] << " ";
  // }
  // cout << endl;

  long long now = 1000;
  long long stk = 0;
  f = false;
  rep(i, N) {
    if(s.size() != 0) {
      if(i == s[0]) {
        s.erase(s.begin());
        now += stk * a[i];
        stk = 0;
        f = false;
      }
    }
    if(v.size() != 0 ) {
      if(i == v[0]) {
        v.erase(v.begin());
        stk += now / a[i];
        now %= a[i];
        f = true;
      }
    }
  }
  cout << now << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long int
//#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<n-k;i++)
    {
        if(a[i]<a[i+k])
        cout<<"Yes"<<endl;
        else
        {
            cout<<"No"<<endl;
        }
    }
}

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

int main(){
  int p,q,r;
  cin >> p >> q >> r;
  if(p>=q && p>=r) cout << q+r << endl;
  else if(q>=p && q>=r) cout << p+r << endl;
  else cout << p+q << endl;
  
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String a = inp.next();
        String b = inp.next();
        String c = inp.next();
        inp.close();
        int k = Integer.parseInt(a + b + c);
        if (k % 4 == 0) {
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 20820
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

int h,w,c;

int p[7][10][10];
int cp[10][10];

int cal_dfs(int x,int y){
	int res=1;
	cp[x][y]=-1;
	if(x+1<h&&cp[x+1][y]==c){
		res+=cal_dfs(x+1,y);
	}
	if(x-1>=0&&cp[x-1][y]==c){
		res+=cal_dfs(x-1,y);
	}
	if(y+1<w&&cp[x][y+1]==c){
		res+=cal_dfs(x,y+1);
	}
	if(y-1>=0&&cp[x][y-1]==c){
		res+=cal_dfs(x,y-1);
	}
	return res;
}

int cal(){
	int res=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cp[i][j]=p[5][i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i*j==0&&cp[i][j]==c)res=max(res,cal_dfs(i,j));
		}
	}
	return res;
}

void change_dfs(int x,int y,int t,int k,int col){
	if(k==col)return;
	p[t][x][y]=col;
	if(x+1<h&&p[t][x+1][y]==k){
		change_dfs(x+1,y,t,k,col);
	}
	if(x-1>=0&&p[t][x-1][y]==k){
		change_dfs(x-1,y,t,k,col);
	}
	if(y+1<w&&p[t][x][y+1]==k){
		change_dfs(x,y+1,t,k,col);
	}
	if(y-1>=0&&p[t][x][y-1]==k){
		change_dfs(x,y-1,t,k,col);
	}
}

void change(int t,int col){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			p[t+1][i][j]=p[t][i][j];
		}
	}
	change_dfs(0,0,t+1,p[t+1][0][0],col);
}

int solve(int t){
	if(t==5)return cal();
	int res=0;
	for(int i=1;i<=6;i++){
		change(t,i);
		res=max(res,solve(t+1));
	}
	return res;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(cin >> h >> w >> c,c){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> p[0][i][j];
			}
		}
		printf("%d\n",solve(0));
	}
}


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

int main(void) {
	int N;
	long x = 1, y = 1;
	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		long T, A;
		std::cin >> T >> A;
		//(x_prev, y_prev)という点がy=A/T*xという直線の上下どちらにあるか判定
		if(static_cast<double>(y) * T >= A * static_cast<double>(x)) {//直線上または上にあるとき
			//yを，y_prev以上のAの倍数のうち最小のものにする
			y = (y - 1) / A * A + A;
			x = y / A * T;
		} else {//下にあるとき
			//xを，x_prev以上のTの倍数のうち最小のものにする
			x = (x - 1) / T * T + T;
			y = x / T * A;
		}
	}
	std::cout << (x + y) << '\n';
	return 0;
}



Measured memory_bytes: 384
n=int(input())
lst=[]
for i in range(n-1):
  c,s,f=map(int,input().split())
  lst.append([c,s,f])
for j in range(n-1):
  time=lst[j][0]+lst[j][1]
  ind=j
  for k in range(n-j-2):
    if time<=lst[ind+1][1] :
      time=lst[ind+1][0]+lst[ind+1][1]
      ind+=1
    elif (time-lst[ind+1][1])%lst[ind+1][2]==0:
      time+=lst[ind+1][0]
      ind+=1
    else:
      time+=lst[ind+1][0]+lst[ind+1][2]-(time-lst[ind+1][1])%lst[ind+1][2]
      ind+=1
  print(time)
print(0)


Measured memory_bytes: 3188
#include <iostream>
#include <queue>
#include <map>
using namespace std;
 
class Point2{
public:
    int tx;
    int ty;
    int kx;
    int ky;
};
 
int mk(Point2 p)        
{
    return (((p.tx-1)*50+(p.ty-1))*50+(p.kx-1))*50+(p.ky-1);
}
 
int main()
{
    while(true){
        int W, H;
        cin >> W >> H;
 
        if(W==0 && H==0)
            break;
 
        Point2 p;
        cin >> p.tx >> p.ty;
        cin >> p.kx >> p.ky;
 
        int d[52][52];
        for(int y=0; y<=H+1; y++){
            for(int x=0; x<=W+1; x++){
                d[y][x] = 1;           
            }
        }
 
        for(int y=1; y<=H; y++){
            for(int x=1; x<=W; x++){
                cin >> d[y][x];
            }
        }
 
        queue<Point2> que;        
        que.push(p);
 
        map<int, int> n;        
        n[mk(p)] = 0;
 
        while(true){
            if(que.empty()){           
                cout << "NA" << endl;
                break;
            }
 
            p = que.front();
            que.pop();
 
            if(n[mk(p)]>=100){      
                cout << "NA" << endl;
                break;
            }
 
            if(p.tx==p.kx && p.ty==p.ky){       
                cout << n[mk(p)] << endl;
                break;
            }
 
            Point2 q;
 
            q = p;
            if(d[q.ty][q.tx+1]==0){
                q.tx = q.tx+1;
            }
            if(d[q.ky][q.kx-1]==0){
                q.kx = q.kx-1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
 
            q = p;
            if(d[q.ty][q.tx-1]==0){
                q.tx = q.tx-1;
            }
            if(d[q.ky][q.kx+1]==0){
                q.kx = q.kx+1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
 
            q = p;
            if(d[q.ty+1][q.tx]==0){
                q.ty = q.ty+1;
            }
            if(d[q.ky-1][q.kx]==0){
                q.ky = q.ky-1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
 
            q = p;
            if(d[q.ty-1][q.tx]==0){
                q.ty = q.ty-1;
            }
            if(d[q.ky+1][q.kx]==0){
                q.ky = q.ky+1;
            }
            if(n.find(mk(q))==n.end()){
                que.push(q);
                n[mk(q)] = n[mk(p)]+1;
            }
        }
    }
 
    return 0;
}


Measured memory_bytes: 11388
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200005;
int a[MAXN];
int ans[MAXN];
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",a+i);
		ans[a[i]]=i;
	}
	for(int i=1;i<=N;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 1664
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000, MD = 1000000007;

int kk[N + 1];
char mobius[N + 1];

int power(long long a, int k) {
	long long p = 1;
	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int main() {
	int m, n; cin >> m >> n;
	fill(mobius, mobius + n + 1, 2);
	mobius[1] = 1;
	for (int a = 2; a <= n; a++) {
		if (mobius[a] != 2)
			continue;
		for (int b = a; b <= n; b += a)
			if (mobius[b] == 2)
				mobius[b] = -1;
			else
				mobius[b] *= -1;
		if (a <= n / a) {
			int a2 = a * a;
			for (int b = a2; b <= n; b += a2)
				mobius[b] = 0;
		}
	}
	for (int a = 1, b = n; a <= n / a; a++) {
		kk[a] = power(n / a, m);
		int p = power(a, m);
		while (b > n / (a + 1))
			kk[b--] = p;
	}
	long long ans = 0;
	for (int a = 1; a <= n; a++) {
		int k = 0;
		for (int b = 1; b <= n / a; b++)
			k = (k + kk[a * b] * mobius[b]) % MD;
		ans = (ans + (long long) k * a) % MD;
	}
	if (ans < 0)
		ans += MD;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4136
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def count(self, x):
        return -self.table[self._root(x)]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


n, m, k = map(int, sys.stdin.buffer.readline().split())
abcd = list(map(int, sys.stdin.buffer.read().split()))
uft = UnionFind(n)
friends = [0 for _ in range(n)]
blocks = [set() for _ in range(n)]
for a, b in zip(abcd[0:2 * m:2], abcd[1:2 * m:2]):
    a -= 1
    b -= 1
    uft.union(a, b)
    friends[a] += 1
    friends[b] += 1
for c, d in zip(abcd[2 * m::2], abcd[2 * m + 1::2]):
    c -= 1
    d -= 1
    blocks[c].add(d)
    blocks[d].add(c)
ans = []
for i in range(n):
    ans.append(uft.count(i) - 1 - friends[i] - sum(uft.find(i, j) for j in blocks[i]))
print(*ans)


Measured memory_bytes: 60740
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
//printf("%.yf\n",x); xを小数点以下y桁で
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << "a == b" << endl;
    }
    else {
        cout << (a > b ? "a > b" : "a < b") << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();

        int result = B/2;

        if (A >= 13){
            result = B;
        }else if(A <= 5){
            result = 0;
        }

        System .out.println(result);

    }
}

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

#define int long long

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

	int x;
	cin >> x;

	int i = 0, y = 100;
	while (y < x) {
		y = y * 1.01;
		++i;
	}
	cout << i;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF (1<<29)

int main() {
	int N, W, ans = 0;
	cin >> N >> W;
	int v[110], w[110], t[10001];
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}
	for (int i = 0; i <= W; i++) t[i] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = W - w[i]; j >= 0; j--) {
			t[j + w[i]] = max(t[j + w[i]], t[j] + v[i]);
			ans = max(ans, t[j + w[i]]);
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<unordered_set>
#include<math.h>
#include<utility>
#include<iomanip>

using namespace std;

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

	int n;
	cin >> n;
	unordered_set<int> s;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.insert(a);
	}

	if (s.size() == n) cout << "YES";
	else cout << "NO";
}

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

using namespace std;

int dx[2] = { 1, 0 };
int dy[2] = { 0, 1 };
const int mod = 1e9 + 7;

int main(void) {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> mat(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mat[i][j];
        }
    }

    vector<vector<int>> dp(h + 1, vector<int>(w + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < 2; k++) {
                int new_row = i + dy[k];
                int new_col = j + dx[k];
                if (new_row >= 0 && new_row < h && new_col >= 0 && new_col < w && mat[new_row][new_col] == '.') {
                    dp[new_row][new_col] = (dp[new_row][new_col] + dp[i][j]) % mod;
                }
            }
        }
    }

    cout << dp[h - 1][w - 1] << endl;

    return 0;
}

Measured memory_bytes: 5248
use std::io::*;
use std::str::FromStr;
use std::char::*;
use std::cmp::*;

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

//const MAX:usize = 100006;

fn main(){
    let n:i64 = read();
    let a:Vec<i64> = (0..n).map(|_| read()).collect();

    let sum:i64 = a.iter().sum();
    let mut crt:i64 = 0;
    let mut mn:i64 = 2020202021;
    for i in 0..n-1 {
        crt += a[i as usize];
        //println!("{}, {}", crt, sum);
        mn = min(mn, (sum-2*crt).abs());
    }
    println!("{}", mn);
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
bool cake[305][305];
bool okh[305];
int ans[305][305];

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    rep(i,h)rep(j,w){
        char c;
        cin >> c;
        if(c=='#') {
            okh[i] = true;
            cake[i][j] = true;
        }
    }
    int h2g[305];
    vector<int> g2h[305];
    int g = 0;
    bool start = true;
    rep(i,h){
        if(okh[i]){
            if(!start) g++;
            if(start) start = false;
        }
        h2g[i] = g;
        g2h[g].push_back(i);
    }
    // rep(i,h)rep(j,w){
    //     printf("%d%c",(int)cake[i][j],j==w-1?'\n':' ');
    // }
    rep(i,h){
        if(!okh[i]) continue;
        int nowg = h2g[i];
        bool start = true;
        rep(j,w){
            if(cake[i][j]){
                if(!start) nowg = ++g;
                if(start) start = false;
            }
            for(auto nh : g2h[h2g[i]]){
                ans[nh][j] = nowg+1;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            printf("%d%c", ans[i][j],j==w-1?'\n':' ');
        }
    }
    return 0;
}

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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
//const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int n, k;
int h[100010];

ll dp[100010];
const ll INF = 1LL << 60;

int main(void){
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>h[i];

	for(int i=0;i<100010;i++) dp[i] = INF;

	dp[0] = 0;
	for(int i=0;i<n;i++) {
		for(int j=1;j <= k;j++) {
			chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}

	cout<< dp[n - 1] <<endl;

	return 0;
}

Measured memory_bytes: 1408
a,b = map(int,input().split())
answer = 0
if a ==b:
    for i in range(a):
        answer += a*10**(i)
if a > b:
    for i in range(a):
        answer += b*10**(i)
if a < b:
    for i in range(b):
        answer += a*10**(i)
print(answer)

Measured memory_bytes: 3060
import collections

if __name__ == '__main__':
    n, k = map(int, input().split())
    counter = collections.defaultdict(int)

    for _ in range(n):
        a, b = map(int, input().split())
        counter[a] += b

    x = 0
    for i in sorted(counter):
        if x <= k <= x + counter[i]:
            print(i)
            break
        x += counter[i]


Measured memory_bytes: 10856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

signed main(){
  int x=0,y=0,z=0,w=0;
  string s;
  std::cin >> s;
  s.erase(s.size()-1,1);
  while(1){
    if(s.size()%2!=0){
      s.erase(s.size()-1,1);
    }else{
      rep(i,s.size()/2){
        if(s[i]!=s[i+s.size()/2]){
          x++;
        }
      }
      if(x==0)break;
      s.erase(s.size()-1,1);
      x=0;
    }
  }
  std::cout << s.size() << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashSet;
class Main
{
	private static int m, n;
	private static HashSet<Integer> sets;
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			m = sc.nextInt();
			if (m == 0) break;
			n = sc.nextInt();
			sets = new HashSet<Integer>();
			hammingCount(1);
			System.out.println(sets.size());
		}
	}
	private static void hammingCount(int x)
	{
		if (m <= x && x <= n)
		{
			sets.add(x);
		}
		else if (n < x)
		{
			return;
		}
		hammingCount(x * 2);
		hammingCount(x * 3);
		hammingCount(x * 5);
	}
}

Measured memory_bytes: 12000
import java.util.*;

class Main {

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			System.out.println(gcd(in.nextInt(), in.nextInt()));
		}
	}

	static int gcd(int x, int y){
		return (x==0)?y:gcd(y%x,x);
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n;
    cin >> n;
    vector<int> B(n-1);
    rep(i,n-1) cin >> B[i];
    vector<int> A(n);
    A[0]=B[0];
    for(int i=1;i<=n-2;i++){
        A[i]=min(B[i],B[i-1]);
    }
    A[n-1]=B[n-2];
    int ans=0;
    rep(i,n) ans+=A[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

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

    // input
    string str;
    cin >> str;
    
    // calculation
    string ans = str.front() + to_string(str.length() - 2) + str.back();
    cout << ans << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,sum=0;
	cin>>a>>b;
	sum =a+b;
	if(sum>=24)
	{
		cout<<(sum-24);
	}
	else
	{
		cout<<sum;
	}
	return 0;
}

Measured memory_bytes: 3624