akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
    	ll n;
    	cin>>n;
    	vector<pair<int,int>>v;
    	for(ll i=0;i<n;i++)
    	{
    		ll a,b;
    		cin>>a>>b;
    		v.push_back({a,b});
    	}
    	ll ans=INT_MIN;
    	ll mn=INT_MAX;
    	ll mx=INT_MIN;
    	for(ll i=0;i<n;i++)
    	{
    		ll x=v[i].first;
    		ll y=v[i].second;
    		mn=min(mn,x+y);
    		mx=max(mx,x+y);
    		ans=max(ans,mx-mn);
    	}
    	mn=INT_MAX;
    	mx=INT_MIN;
    	for(ll i=0;i<n;i++)
    	{
    		ll x=v[i].first;
    		ll y=v[i].second;
    		mn=min(mn,x-y);
    		mx=max(mx,x-y);
    		ans=max(ans,mx-mn);
    	}
    	cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 5324
#include <bits/stdc++.h>
#define R register

const int MN = 8e5 + 5;

std::string s;

int n, m, d[MN];

struct Edge {
	Edge *nxt;
	int to;
	Edge(Edge *hd = nullptr, int v = 0){nxt = hd, to = v;}
}*hd[MN];

inline void ins(int u, int v) {hd[u] = new Edge(hd[u], v); ++d[v];}

int main() {
	std::ios::sync_with_stdio(false);
	
	std::cin >> n >> m >> s;
	
	for (R int i = 1, x, y; i <= m; ++i) {
		std::cin >> x >> y;
		if (x == y) {
			ins(x + n, x + n * 2);
			ins(x + n * 3, x);
			continue;
		}
		if (s[x - 1] == s[y - 1]) {
			ins(x + n, y + n * 2);
			ins(y + n, x + n * 2);
			ins(x + n * 3, y);
			ins(y + n * 3, x);
			ins(x + n, y);
			ins(y + n, x);
			ins(x + n * 3, y + n * 2);
			ins(y + n * 3, x + n * 2);
		} 
		else {
			ins(x, y + n);
			ins(x, y + 3 * n);
			ins(x + 2 * n, y + n);
			ins(x + 2 * n, y + 3 * n);
			ins(y, x + n);
			ins(y, x + 3 * n);
			ins(y + 2 * n, x + n);
			ins(y + 2 * n, x + 3 * n);
		}
	}

	std::queue<int> q;
	for (R int i = 1; i <= n * 4; ++i)
		if (!d[i]) q.push(i);
	
	while (!q.empty()) {
		R int u = q.front(); q.pop();
		for (Edge *e = hd[u]; e != nullptr; e = e -> nxt) 
			if (--d[e -> to] == 0) 
				q.push(e -> to);
	}

	for (R int i = 1; i <= n * 4; ++i) 
		if (d[i]) {
			std::cout << "Yes\n";
			return 0;
		}
	std::cout << "No\n";
	return 0;
}

Measured memory_bytes: 58448
#include<bits/stdc++.h>
#define rint register int
#define ivoid inline void
#define iint inline int
#define endll '\n'
#define ll long long
using namespace std;
const int N=5e5+5;
const int inf=0x3f3f3f3f;
int n,k,top,bot;

iint rad()
{
	int x=0,f=1;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}

struct Water{int v;double t;}sta[N],now;
int sumv;
double sumq;

signed main()
{
//	freopen("1.in","r",stdin);
//	freopen("water.out","w",stdout);
	n=rad();k=rad();
	for(rint i=1;i<=n;i++){
		now.t=rad();now.v=rad();
		while(sumv+now.v>k){
			int out=min(sumv+now.v-k,sta[bot].v);
			sta[bot].v-=out;
			sumv-=out;
			sumq-=out*sta[bot].t;
			if(!sta[bot].v)bot++;
		}
		sta[++top]=now;
		sumv+=now.v,sumq+=1ll*now.v*now.t;
		while(bot<top&&sta[top].t<sta[top-1].t){
			sta[top-1].t=(sta[top].t*sta[top].v+sta[top-1].t*sta[top-1].v)/(sta[top].v+sta[top-1].v);
			sta[top-1].v=sta[top-1].v+sta[top].v;
			top--;
		}
		printf("%.8lf\n",(double)sumq/k);
	}
}

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

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

typedef long long ll;


int main() {
    int A, B, C, X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    int count  =0;
    REP(i,A+1){
        REP(j,B+1) {
            REP(k,C+1) {
                if (i*500 + j*100 + k*50 == X) count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import math
mx = float("inf")
n = int(input())
for i in range(1,round(math.sqrt(n))+1):
  if n % i == 0:
    if max(len(str(i)),len(str(n//i))) < mx:
           mx = max(len(str(i)),len(str(n//i)))
print(mx)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import os
from sys import stdin, stdout

def solve(tc):
    n, k = map(int, stdin.readline().split())
    seq = list(map(int, stdin.readline().split()))

    for i in range(k,n):
        if seq[i]>seq[i-k]:
            print("Yes")
        else:
            print("No")
    return

tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1


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

int main() {
  int n,k,x = 0,sum = 0;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 1; i <= 1000; i++){
    for(int j = 0; j < n; j++){
      if(i == a[j]){
        x += 1;
        sum += a[j];
      }
      if(x == k){
        break;
      }
    }
    if(x == k){
      break;
    }
  }
  cout << sum << endl;
  return 0;
}

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

long long solve(string S) {
    int res = 0;
    for (int i = 0, j = S.size() - 1; i < j; ) {
        if (S[i] == S[j]) ++i, --j;
        else if (S[i] == 'x') ++res, ++i;
        else if (S[j] == 'x') ++res, --j;
        else return -1;
    }
    return res;
}

int main() {
    string S;
    while (cin >> S) cout << solve(S) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
 
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;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
 
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
int f(ll X){
    if(X == 0) return 0;
    return X%10 + f(X/10);
}
int main(void){
    int N; cin >> N;
    vector<ll> L(N+1);
    L[0] = 2, L[1] = 1;
    for(int i = 2; i < N + 1; i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[N] << endl;
}

Measured memory_bytes: 256
#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##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    string S;
    cin >> S;
    write(S[2] == S[3] && S[4] == S[5] ? "Yes" : "No");
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int N;

ll med(vll A){
    if(N % 2 == 1){
        return A.at((N + 1) / 2 - 1);
    } else{
        return A.at(N / 2) + A.at(N / 2 - 1);
    }
}

int main(){
    cin >> N;

    vll A(N), B(N);
    REP(i, N){
        int a, b;
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
    }
    sort(ALL(A));
    sort(ALL(B));

    auto a = med(A);
    auto b = med(B);

    cout << b - a + 1 << endl;

    

    return 0;
}


Measured memory_bytes: 7908
lC = ['a','b','c','d','e','f','g','h','i','j','k','l','m',',n','o','p','q','r','s','t',
'u','v','w,','x','y','z']

def solve(S):
    if not(S[0] == 'A'):
        return "WA"
    if S[-1] == 'C':
        return "WA"
    if not(S[1] in lC):
        return "WA"
    
    flag = False
    for i in range(1,len(S)):
        if S[i] == 'C':
            if flag:
                return "WA"
            flag = True
            continue
        if not(S[i] in lC):
            return "WA"
    if not(flag):
        return "WA"
    return "AC"
    

S = input()
print(solve(S))


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<float> x(n);
    vector<string> u(n);

    for(int i = 0; i < n; ++i){

        cin >> x[i] >> u[i];
        if(u[i] == "BTC")x[i] *= 380000;

    }

    float sum = 0;

    for(int i = 0; i < n; ++i){

        sum += x[i];

    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int128_t A, B;

int main(int argc, char **argv) {
    std::cin >> A >> B;
    
    if ((A + B) % 2 == 0) {
        std::cout << (A + B) / 2 << std::endl;
    } else {
        std::cout << "IMPOSSIBLE" << std::endl;
    }
    
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

// mod
int mod = 1e9 + 7;

struct mint {
    unsigned x;

    mint() : x(0) {}

    mint(signed sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }

    mint(signed long long sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }

    int get() const { return (int) x; }

    mint& operator+=(mint that) {
        if ((x += that.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(mint that) {
        if ((x += mod - that.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator*=(mint that) {
        x = (unsigned long long) x * that.x % mod;
        return *this;
    }

    mint& operator/=(mint that) { return *this *= that.inverse(); }

    mint operator+(mint that) const { return mint(*this) += that; }

    mint operator-(mint that) const { return mint(*this) -= that; }

    mint operator*(mint that) const { return mint(*this) *= that; }

    mint operator/(mint that) const { return mint(*this) /= that; }

    mint inverse() const {
        long long a = x, b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            std::swap(a, b);
            u -= t * v;
            std::swap(u, v);
        }
        return mint(u);
    }

    bool operator==(mint that) const { return x == that.x; }

    bool operator!=(mint that) const { return x != that.x; }

    mint operator-() const {
        mint t;
        t.x = x == 0 ? 0 : mod - x;
        return t;
    }
};

class CSumOfProductOfPairs {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);
        REP(i, N) cin >> A[i];
        mint sum = 0;
        REP(i, N) sum += A[i];

        mint res = 0;
        REP(i, N) {
            res += (sum - A[i]) * A[i];
            sum -= A[i];
        }
        cout << res.get() << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CSumOfProductOfPairs solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

const int MAX = 100010;
int n, q, k;
vector<vector<pli>> g;
ll dist[MAX];

int main() {
    cin >> n;
    g.resize(n+1);
    rep(i, n - 1) {
        int a, b; ll c;
        cin >> a >> b >> c;
        g[a].push_back(make_pair(c, b));
        g[b].push_back(make_pair(c, a));
    }

    cin >> q >> k;
    rep(i, MAX) dist[i] = LLINF;
    dist[k] = 0;
    priority_queue<pli, vector<pli>, greater<pli>> pq;
    pq.push(make_pair(0, k));
    while (!pq.empty()) {
        pli top = pq.top();
        pq.pop();
        int u = top.second;
        for (auto &e: g[u]) {
            int v = e.second;
            ll cost = e.first;
            if (chmin(dist[v], dist[u] + cost)) {
                pq.push(make_pair(dist[v], v));
            }
        }
    }

    rep(i, q) {
        int x, y; cin >> x >> y;
        cout << dist[x] + dist[y] + 2 * dist[k] << endl;
    }
}


Measured memory_bytes: 11120
from collections import defaultdict
def main():
    N = int(input())
    S = input()
    D = defaultdict(bool)
    cnt = 0
    all1 = 0
    all2 = 0
    for i in range(N):
        if S[i] == "1":
            D[i] = True
            cnt += 1
        else:
            D[i] == False

    for i in range(N):
        if S[i] == "1":
            all1 += pow(2, N-1-i, cnt+1)
            if cnt != 1:
                all2 += pow(2, N-1-i, cnt-1)

    for i in range(N):
        P = 0
        if S[i] == "1":
            if cnt == 1:
                print(0)
                continue
            else:
                P += all2-pow(2, N-1-i, cnt-1)
            ans = 1
            P = P % (cnt-1)
            while P:
                c = P
                mod = 0
                while c:
                    mod += c & 1
                    c = c >> 1
                P = P % mod
                ans += 1
            print(ans)
            continue
        else:
            P += all1+pow(2, N-1-i, cnt+1)
            ans = 1
            P = P % (cnt+1)
            while P:
                c = P
                mod = 0
                while c:
                    mod += c & 1
                    c = c >> 1
                P = P % mod
                ans += 1
            print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 100892
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
#include <list>
#include <bitset>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = long long;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

Int add(Int x, Int y){
    return (x + y) % INF;
}

Int mul(Int x, Int y){
    return (x * y) % INF;
}

Int solve(int n, V& xs){
    Int x = 0;
    for(int i = 0; i < n; i++){
        x = add(x, i * xs[i] - (n - i - 1) * xs[i]);
    }
    return x;
}

Int solve(int n, int m, V& xs, V& ys){
    return mul(solve(n, xs), solve(m, ys));
}


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

    int n, m;
    cin >> n >> m;
    V xs(n), ys(m);
    for(int i = 0; i < n; i++){
        cin >> xs[i];
    }
    for(int i = 0; i < m; i++){
        cin >> ys[i];
    }
    cout << solve(n, m, xs, ys) << "\n";

    return 0;
}


Measured memory_bytes: 1792
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x)
#define dump_l(x) dump(x) << endl
#else
const bool test = false;
#define dump(x)
#define dump_l(x)
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}

string reverse_str(string input) {
  string res = input;
  reverse(all(res));
  return res;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}

int H = 20, W = 30;

bool ng(int y, int x) {
  return y < 0 || H <= y || x < 0 || W <= x;
}

void solve();

class Solver {
public:
  string s, t;

  void solve() {
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    cout << (s < t ? "Yes" : "No") << endl;
  }
};
 
signed main()
{
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {
  //   auto ptr = new Solver();
  //   ptr->solve();
  //   delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'
 


Measured memory_bytes: 256
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

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

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
          x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

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

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def num_roots(self):
    return len([i for i, x in enumerate(self.parents) if x < 0])

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def num_members(self,x):
    return abs(self.parents[self.find(x)])

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, Q = map(int, input().split())
uf = UnionFind(N)
ans = []
for i in range(Q):
  t,u,v = map(int, input().split())
  if t==0:
    uf.union(u,v)
  else:
    if uf.same(u,v):
      ans.append(1)
    else:
      ans.append(0)
print(*ans, sep='\n')

Measured memory_bytes: 84084
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }

int N;
vector<int> C;
vector<vector<int>> to;

vector<int> stsz;
vector<lint> st2sum;
void dfs_st(int now, int par)
{
    stsz[now] = 1;
    for (auto nxt : to[now]) if (nxt != par)
    {
        dfs_st(nxt, now);
        stsz[now] += stsz[nxt];
        st2sum[now] += 1LL * stsz[nxt] * (stsz[nxt] + 1) / 2;
    }
}

vector<int> SZred;
vector<lint> ret;

void dfs1(int now, int par)
{
    int c = C[now];
    int M = N - SZred[c];
    ret[c] += 1LL * M * (M + 1) / 2 - st2sum[now] - 1LL * (M - stsz[now]) * (M - stsz[now] + 1) / 2;
    for (auto nxt : to[now]) if (nxt != par)
    {
        int pp = SZred[c];
        SZred[c] = N - stsz[nxt];
        dfs1(nxt, now);
        SZred[c] = pp;
    }
    SZred[c] += stsz[now];
}

int main()
{
    cin >> N;
    C.resize(N);
    cin >> C;
    for (auto &c : C) c--;
    to.resize(N);
    for (int e = 0; e < N - 1; e++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    stsz.resize(N);
    st2sum.resize(N);
    dfs_st(0, -1);
    SZred.assign(N, 0);
    ret.resize(N);
    dfs1(0, -1);
    for (auto x : ret) cout << x << '\n';
}


Measured memory_bytes: 35388
#include <iostream>
using namespace std;
int main(void){
  string S,T;
  cin>>S;
  cin>>T;
  int count=0;
  for(int i=0;i<3;i++){
      if(S[i]==T[i]){
          count+=1;
      }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b){
        if((a+b)%2==0) cout<<(a+b)/2<<endl;
        else{
            int c=(a+b)/2;
            if(a+b-2*c<=1) cout<<c+1<<endl;
            else cout<<c<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n,T = map(int,input().split())
ct = [map(int, input().split()) for _ in range(n)]
c,t = [list(i) for i in zip(*ct)]
ans = 1000000
for i in range(n):
  if(T >= t[i]):
    ans = min(ans,c[i])
if(ans == 1000000):
  print('TLE')
else:
  print(ans)

Measured memory_bytes: 62612
import sys
import re

S=str(input())
ans=0
for i in range(1<<(len(S)-1)):
  start=0
  score=0
  for j in range(len(S)-1):
    if (i>>j)&1==0:
      score+=int(S[start:j+1])
      start=j+1
  score+=int(S[start:len(S)])
  ans+=score

print(ans)

Measured memory_bytes: 39920
d,g=map(int,input().split())
p=[[int(i) for i in input().split()] for j in range(d)]

v=g//100+1
for i in range(2**d):
  c=m=s=0
  for j in range(d):
    if i & 2**j > 0:
      s += p[j][0]*(j+1)*100+p[j][1]
      c += p[j][0]
    else:
      m = j
    if s >= g:
      v=min(v,c)
    elif s+(p[m][0]-1)*(m+1)*100 >=g:
      v=min(v,c+(g-s+100*(m+1)-1)//(100*(m+1)))
print(v)


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

int main(){
    string s;
    cin >> s;
    int a,b;

    for(int i=0;i<s.length();i++){
        if(s[i]=='A') {
            a=i;
            break;
        }
    }

    for(int i=s.length()-1;i>=0;i--){
        if(s[i]=='Z') {
            b=i;
            break;
        }
    }

    cout << b-a+1 << endl;
    
}

Measured memory_bytes: 640
/*
一次魔法，走k个没锁的房间，解锁k个房间。
如果周围是.一次魔法直接走过去，然后解锁后面自己想走的方向。
如果周围是#，先需要魔法解锁，然后走过去
因此：走完第一次k，整个棋盘就解锁了。
所以只需要跑一次dfs，看第一次的k步走到哪里是距离边界最近的点。
*/
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <queue>
using namespace std;

const int INF=0x7ffffff,N=810;

int ans=INF;
int movee[4][2]= {1,0,-1,0,0,1,0,-1};
bool visited[N][N];
int r,c,k;
int sx,sy;
int a[N][N];
char s[N];
queue<int> q;

void bfs(int x,int y,int step) {
	q.push(x);
	q.push(y);
	q.push(0);
	int cur_ans,cx,cy,cd,xx,yy,dd;
	visited[x][y]=true;
	while (!q.empty()) {
		cx=q.front();
		q.pop();
		cy=q.front();
		q.pop();
		cd=q.front();
		q.pop();
		//cout<<cx<<" "<<cy<<" "<<cd<<endl;
		cur_ans=cx-1;
		cur_ans=min(cur_ans,cy-1);
		cur_ans=min(cur_ans,r-cx);
		cur_ans=min(cur_ans,c-cy);
		ans=min(ans,cur_ans);//看向哪个跑最近
		if (cd==k) continue;//只需要走k步，后面的就想怎么走就怎么走，后面直接计算魔法步数
		for (int i=0; i<4; i++) {
			xx=cx+movee[i][0];
			yy=cy+movee[i][1];
			if (xx<1 || xx>r || yy<1 || yy>c) continue;
			if (a[xx][yy]==1 || visited[xx][yy]) continue;//#不过去
			visited[xx][yy]=true;
			q.push(xx);
			q.push(yy);
			q.push(cd+1);//到.上去 ，最多走k步
		}
	}
}

int main () {
	int i,j;
	scanf("%d%d%d",&r,&c,&k);
	for (i=1; i<=r; i++) {
		scanf("%s",s);
		for (j=1; j<=c; j++) {
			if (s[j-1]=='#') a[i][j]=1;
			if (s[j-1]=='S')
				sx=i,sy=j;
		}
	}
	bfs(sx,sy,0);
	int fans=1+(ans+k-1)/k;
	printf("%d\n",fans);
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a - b) <= d && abs(b - c) <= d) {
    cout << "Yes";
    return 0;
  }

  if(abs(a - c) <= d) { cout << "Yes"; return 0;}
  cout << "No";
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int N = 2019;
int cnt[N+5];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	int n = s.length();
	int cur = 0;
	int mult = 1;
	ll ans = 0;
	cnt[0] = 1;
	for(int i = n-1;i>=0;--i){
		cur = (cur + mult*(s[i]-'0')) % N;
		ans += cnt[cur];
		mult = (mult*10) % N;
		++cnt[cur];
	}
	cout << ans << '\n'; 
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1000000007;



int main()
{
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    int n,m;
    cin>>n>>m;

    if(m>=n)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;

    
}

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

# define endl "\n"
# define io_boost std::ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
typedef unsigned long long int ulli;
typedef long long int lli;
typedef unsigned int ui;
typedef vector<int> vector_i;
typedef vector<long long int> vector_lli;
typedef vector<unsigned int> vector_ui;
typedef vector<unsigned long long int> vector_ulli;
typedef set<int> set_i;
typedef set<long long int> set_lli;
typedef set<unsigned int> set_ui;
typedef set<unsigned long long int> set_ulli;
typedef unordered_set<int> u_set_i;
typedef unordered_set<long long int> u_set_lli;
typedef unordered_set<unsigned int> u_set_ui;
typedef unordered_set<unsigned long long int> u_set_ulli;

vector<int> g[100000];
int n, m, p[100000], U, V, arr[100000];
bool visited[100000];


int f(vector<int> &a, vector<int> &b){
	for(const int &e: a)
		arr[e] = 1;
	int ret = 0;
    for(const int &e: b)
		ret += arr[e];
	for(const int &e: a)
		arr[e] = 0;
	return ret;
}

void dfs(int v, vector<int> &a, vector<int> &b){
	if(visited[v]) return;
	visited[v] = true;
	a.push_back(v);
	b.push_back(p[v]);
	for(const int &u: g[v])
		dfs(u, a, b);
}

int main() {
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
    }

    for(int i = 0; i < m; i++){
        cin >> U >> V;
        U--; V--;
        g[U].push_back(V);
        g[V].push_back(U);
    }
    int r = 0;
    for(int i = 0; i < n; i++){
        if(!visited[i]){
            vector<int> a, b;
            dfs(i, a, b);
            r += f(a, b);
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 11556
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int r = 0;
    for (int i = 1; i <= N; i++) {
        int c = 0, t = i;
        while (t > 0) {
            c += t % 10;
            t /= 10;
        }
        if (A <= c&&c <= B)r += i;
    }
    cout << r << endl;
}

Measured memory_bytes: 256
#!ruby -na
f=->n,m,a,b{a/m*n*~-n/2+(b-=m*y=(b+n*a%=m)/m
y>0?f[y,a,m,b%a]+y*=n+b/a:0)}
eval"p f[#{$F*?,}]"if/ /

Measured memory_bytes: 14592
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std;
int ai[28];
int bi[1000];
int main()
{
    string a,b;
    cin>>a>>b;
    memset(ai,0,sizeof(ai));
    memset(bi,0,sizeof(bi));
    for(int i=0;i<a.length();i++)
    {
        int t = a[i] - 'a';
        ai[t]++;
    }
    for(int i=0;i<b.length();i++)
    {
        int t = b[i] - 'a';
        bi[t]++;
    }
    int flag = 0;
    for(int i=0;i<26;i++)
    {
        int x = ai[i];
        int fla = 0;
        for(int j=0;j<26;j++)
        {
            if(bi[j]==x)
            {
                fla = 1;
                bi[j] = -1;ai[i] = -1;
                break;
            }
        }
        if(fla==0){
            flag = 1;
            break;
        }
    }
    if(flag)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 776
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	
	string s;
	cin >> s;

	int n = s.size();
	int num = (n + 1) / 2;

	REP(i, num) {
		cout << s[2 * i];
	}
	cout << endl;

	return 0;
}



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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<vector<pair<unsigned long, unsigned long>>> K(N);
    for(auto& v : K){
        unsigned long A;
        cin >> A;
        for(unsigned long i{0}, x, y; i < A; ++i){
            cin >> x >> y;
            v.emplace_back(x - 1, y);
        }
    }
    unsigned long ans{0};
    for(unsigned long i{0}; i < 1UL << N; ++i)[&]{for(unsigned long j{0}; j < N; ++j)if((i >> j) & 1){
        for(const auto& c : K[j])if((i >> c.first & 1) != c.second)return ;
    }ans = max<unsigned long>(ans, __builtin_popcountl(i));}();
    cout << ans << endl;
    return 0;
}

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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second
#define mod 1073741824

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

void solve()
{
	int a;
	cin >> a;

	int res = a + a * a + a * a * a;

	cout << res << "\n";
}

int main() {

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

	int t = 1;
	//cin >> t;

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

	return 0;
}





Measured memory_bytes: 3640
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	h  := make([]int, n)
	for i := 0; i <n ; i++ {
		fmt.Scan(&h[i])
	}

	for i := 0; i < n; i++ {
		if i == 0 {
			continue
		}
		if h[i] > h[i-1] {
			h[i]--
		}

		if h[i] < h[i-1] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 6316
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
main(){
  int n;
  set<int>s;
  cin>>n;
  while(n--){
    int t;
    cin>>t;
    s.insert(t);
  }
  cout<<s.size()<<endl;
}

Measured memory_bytes: 256
object Main extends App {
  import java.{ util => ju }
  import scala.annotation._
  import scala.collection._
  import scala.collection.{ mutable => mu }
  import scala.collection.JavaConverters._
  import scala.math._
  import scala.io.StdIn.readLine

  val sc = new ju.Scanner(System.in)

  val n = sc.nextInt()
  val nums = Array.fill(n)(sc.nextInt())

  var maxV = nums(1) - nums(0)
  var minV = Integer.MAX_VALUE

  for (s <- nums) {
    maxV = max(maxV, s - minV)
    minV = min(minV, s)
  }
  println(maxV)
}

Measured memory_bytes: 208960
MOD = int(1e9+7)

def power(b, e):
    res = 1
    while e > 0:
        if e % 2 == 1:
            res = res * b % MOD
        b = b * b % MOD
        e //= 2
    return res

def mod_inverse(n):
    return power(n, MOD-2)

def mul(x, y):
    return (x % MOD) * (y % MOD) % MOD
def multiply(x, y, z):
    return mul(mul(x, y), z)

def nCr(n, r):
    if r == 0:
        return 1
    fac = [1] * (n+1)
    for i in range(1, n+1):
        fac[i] = fac[i-1] * i % MOD
    return multiply(fac[n], mod_inverse(fac[r]), mod_inverse(fac[n-r]))

x, y = map(int, input().split())
n = (2*x-y) // 3
m = (2*y-x) // 3
if min(n, m) < 0 or (x+y)%3 != 0:
    print(0)
    exit()
print(nCr(n+m, m))


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n, m, q; cin >> n >> m >> q;
	vector<vector<int>> trains(n + 1, vector<int>(n + 1));
	for(int i =  0; i < m; i++){
		int a, b; cin >> a >> b;
		trains[a][b]++;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			trains[i][j] += trains[i][j -1];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			trains[i][j] += trains[i - 1][j];
		}
	}
	for(int i = 0; i < q; i++){
		int l, r; cin >> l >> r;
		cout << trains[r][r] + trains[l - 1][l -1] - trains[r][l -1] - trains[l - 1][r] << endl;
	}
	return 0;	
}





  

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=2e5+100,inf=1e18,LOG=23,mod=1e9+7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll

int n, k, c, a[maxn], dpl[maxn], dpr[maxn], suff[maxn], pref[maxn], can[maxn];
multiset <int> st;

main()
{
	cin >> n >> k >> c;
	forn(1, i, n)
	{
		char ch;
		cin >> ch;
		if(ch == 'o')
		{
			a[i] = 1;
		}
	}
	forn(1, i, n)
	{
		if(i - c - 1 < 0) dpl[i] = 1;
		else
			dpl[i] = pref[i - c - 1] + 1;
		if(a[i] == 0)
		{
			dpl[i] = 0;
		}
		pref[i] = max(pref[i - 1], dpl[i]);
	}
	nfor(1, i, n)
	{
		dpr[i] = suff[i + c + 1] + 1;
		if(a[i] == 0)
		{
			dpr[i] = 0;
		}
		suff[i] = max(suff[i + 1], dpr[i]);
	}
	forn(1, i, n)
	{
		if(i - 1 > 0 && a[i - 1] == 1)
		{
			st.insert(dpl[i - 1] + suff[i + c]);
		}
		if(i - c - 1 > 0 && a[i - c - 1] == 1)
		{
			st.erase(st.find(dpl[i - c - 1] + suff[i]));
		}
		if(st.size() && *st.rbegin() >= k)
		{
			can[i] = 1;
		}
	}
	forn(1, i, n)
	{
		if(i - c - 1 >= 0 && pref[i - c - 1] + suff[i + 1] >= k)
		{
			can[i] = 1;
		}
		if(i - c - 1 < 0 && suff[i + 1] >= k)
		{
			can[i] = 1;
		}
	}
	forn(1, i, n)
	{
		if(!can[i] && a[i] == 1)
		{
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 9728
// 入力関数
use std::str::FromStr;

use std::fmt::Debug;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

//
fn main() {
    let init: Vec<i32> = read_line();
    let n = init[0];
    let m = init[1];
    let c = init[2];

    let b: Vec<i32> = read_line();

    let mut count: u32 = 0;

    for _i in 0..n {
        let a: Vec<i32> = read_line();
        let mut judge: i32 = 0;
        for j in 0..m {
            let index = j as usize;
            judge = judge + b[index] * a[index];
        }
        judge = judge + c;

        if judge > 0 {
            count = count + 1;
        }
    }

    println!("{}", count);
}


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

int arr[10010], n, r, c, mat[101][101];


int main()
{

       cin >> r >> c;

       cin >> n;

       for(int i = 1; i <= n; i ++) cin >> arr[i];
       int p = 1;

       for(int j = 1; j <= c; j ++){
                if(j % 2 == 1){
                        for(int i = 1; i <= r; i ++){
                                if(arr[p] == 0) p ++;
                                mat[i][j] = p;
                                arr[p] --;
                        }
                }
                else{
                        for(int i = r; i > 0; i --){
                                if(arr[p] == 0) p ++;
                                mat[i][j] = p;
                                arr[p] --;
                        }
                }
       }

       for(int i = 1; i <= r; i ++){
                for(int j = 1; j <= c; j ++){
                        cout << mat[i][j] <<" ";
                }
                cout << endl;
       }


        return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

const ll INF = 1e15;
int main(){

  int n;
  cin >> n;
  ll dp[n+10];
  dp[0] = 0;

  FOR(i,1,n+10) dp[i] = INF;
  ll h[n+2];
  rep(i,n) cin >> h[i];

  rep(i,n){
    dp[i+1] = min<ll>(dp[i] + abs(h[i+1]-h[i]),dp[i+1]);
    dp[i+2] = min<ll>(dp[i] + abs(h[i+2]-h[i]),dp[i+2]);
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
### constant

COLORS = [
  ["black",     "00", "00", "00"],
  ["blue",      "00", "00", "ff"],
  ["lime",      "00", "ff", "00"],
  ["aqua",      "00", "ff", "ff"],
  ["red",       "ff", "00", "00"],
  ["fuchsia",   "ff", "00", "ff"],
  ["yellow",    "ff", "ff", "00"],
  ["white",     "ff", "ff", "ff"]
]

### subroutines

def get_color(r, g, b)
  min_dd = 3 * 256 ** 3
  min_col = ''

  for col in COLORS
    dd = (r - col[1].hex) ** 2 + (g - col[2].hex) ** 2 + (b - col[3].hex) ** 2
    if min_dd > dd
      min_dd = dd
      min_col = col[0]
    end
  end

  min_col
end

### main

while true
  line = gets.strip
  break if line == '0'

  r = line[1, 2].hex
  g = line[3, 2].hex
  b = line[5, 2].hex

  puts get_color(r, g, b)
end

Measured memory_bytes: 6104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
	int A, B, soma = 0, i;
	scanf("%d %d", &A, &B);
	for(i = 0; i < 2; i++){
		if(A >= B){
			soma += A;
			A--;
		}
		else{
			soma += B;
			B--;
		}
	}
	printf("%d\n", soma);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    bool dp[k+1]={false};
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-a[j]<0)
                break;
            else{
                if(dp[i-a[j]]==false)
                    dp[i]=true;
            }
        }
    }
    if(dp[k])
        cout<<"First"<<endl;
    else
    {
         cout<<"Second"<<endl;
    }
    
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define siz 200007
#define ll  long long int
int main()
{
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0;i<s.size();i++)
        if(s[i]!=t[i])
        cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3924
#include<cstdio>
#define reg register
char s[110];
int R()
{
	reg int x=0;reg char ch=getchar();reg bool f=0;
	for(;ch<48||ch>57;ch=getchar())if(ch=='-')f=1;
	for(;ch>=48&&ch<=57;ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
	return f?-x:x;
}
int main()
{
	scanf("%s",s);
	reg int i;
	for(i=0;s[i]&&s[i]!='C';++i);
	if(s[i]=='C')  {
		for(;s[i]&&s[i]!='F';++i);
		if(s[i]=='F') {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

struct UnionFind{
	vector<int> d;
	UnionFind(int n) : d(n, -1){}
	int find(int x){
		if(d.at(x) < 0) return x;
		return d.at(x) = find(d.at(x));
	}
	bool unite(int x, int y){
		x = find(x); y = find(y);
		if(x == y) return false;
		if(d.at(x) > d.at(y)) swap(x, y);
		d.at(x) += d.at(y);
		d.at(y)= x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d.at(find(x)); }
};

int main(){
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	vector<ll> ans(m+1);
	vector<pair<int, int>> br(m);
	ans.at(m) = (ll)n*(n-1)/2;
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		br.at(i) = make_pair(a, b);
	}
	rrep(i, m){
		int a, b;
		tie(a, b) = br.at(i);
		ll dec = 0;
		if(uf.same(a, b) == false){
			int tas = uf.size(a), tbs = uf.size(b);
			uf.unite(a, b);
			if(uf.same(a, b)){
				dec = (uf.size(a) - tas)*(uf.size(b) - tbs);
			}
		}
		ans.at(i) = ans.at(i+1) - dec;
	}
	rep2(i, 1, m+1){
		cout << ans.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 3328
N = int(input())
paths = []

for i in range(N - 1) :
    paths.append(list(map(int, input().split())))
    
for i in range(N) :
    if i == N -  1:
        print("0")
    else :
        t = paths[i][1] + paths[i][0]
        
        for j in range(i + 1, N - 1) :
            wait = paths[j][1]
            
            if wait < t :
                wait += paths[j][2] * ((t - wait) // paths[j][2] - 1)
            
            while wait < t :
                wait += paths[j][2]
                
            # t = wait + paths[j][2] + paths[j][0]
            t = wait + paths[j][0]
        print(t)
            
    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  cout << A[0] + A[1] + A[2]*10 << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()

    for i in range(1, 10):
        m = N / i
        if m.is_integer() and 1 <= m <= 9:
            print("Yes")
            break
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
use utf8;

binmode STDOUT, ':utf8';

chomp($N = <STDIN>);

%words;
$max = 0;
for( $count = 0; $count<$N; $count++ ) {
	chomp( $word = <STDIN> );
	$words {$word} ++;
	if( $max < $words{$word} ) {
		$max++;
	}
}

foreach $word (sort %words) {
	if ( $words{$word} == $max ) {
		print "$word\n"
	}
}
	

Measured memory_bytes: 52480