akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a < c && c < b || a > c && c > b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3564
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};

struct UnionFind{
    vl par;
    vl rank;
    UnionFind(ll N) : par(N, 0), rank(N, 0){
        for(int i = 0; i < N; i++) par[i] = i;
    }
    
    ll root(ll x){
        if(par[x] == x) return x;
        else{
            par[x] = root(par[x]); // compression
            return par[x];
        }
    }
    
    void unite(ll x, ll y){
        ll rx = root(x); ll ry = root(y);
        if(rx == ry) return;
        if(rank[rx] < rank[ry]) swap(rx, ry);
        if(rank[rx] == rank[ry]) ++rank[rx];
        par[ry] = rx;
    }
    
    bool same(ll x, ll y){
        return root(x) == root(y);
    }
};
    
int main(){
    ll N, M; cin >> N >> M;
    vl as(M, 0), bs(M, 0);
    REP(i, M){
        ll a, b; cin >> a >> b;
        as[i] = a - 1;
        bs[i] = b - 1;
    }
    
    ll ret = 0;
    REP(i, M){
        auto uf = UnionFind(N);
        REP(j, M){
            if(j != i){
                uf.unite(as[j], bs[j]);
            }
        }
        bool ok = true;
        REP(j, N){
            if (!uf.same(0, j)) {
                ok = false; break;
            }
        }
        if(!ok) ret++;
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
 
using namespace std;
int main(void){
    // Your code here!
    int A ,B;
    cin >> A >> B;
    cout << max(A-(2*B), 0) << endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int N, T; cin >> N >> T;
    vector<int> a(N);
    for (int& ai : a) cin >> ai;
    vector<int> rangeMin(N);
    rangeMin[0] = a[0];
    for (int i = 1; i < N; i++) {
        rangeMin[i] = min(rangeMin[i - 1], a[i]);
    }
    map<int, int> cnt;
    for (int i = 1; i < N; i++) {
        cnt[a[i] - rangeMin[i - 1]]++;
    }
    cout << (--cnt.end())->second << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	int se[n],sw[n];
	for(int i=0;i<n;i++)
	{
		se[i]=0;
		sw[i]=0;
	}
	if(a[0]=='E') se[0]=1;
	else sw[0]=1;
	for(int i=1;i<n;i++)
		if(a[i]=='E')
		{
			se[i]=se[i-1]+1;
			sw[i]=sw[i-1];
		}
		else
		{
			sw[i]=sw[i-1]+1;
			se[i]=se[i-1];
		}
	int minv=300005;
	for (int i=0;i<n;i++)
	{
		int sum=0;
		if (i==0)  sum=se[n-1]-se[0];
		else if(i==n-1)  sum=sw[n-2];
		else sum=sw[i-1]+(se[n-1]-se[i]);
		minv=min(minv,sum);
	}
	cout<<minv<<endl;
}

Measured memory_bytes: 3076
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
pq = []
for i in range(n):
	for j in range(n):
		if i==j:
			continue
		xi, yi = xy[i]
		xj, yj = xy[j]
		pq.append((xi - xj, yi - yj))
ans = 1e9 if n>1 else 1
for p, q in pq:
	cost = 0
	for x, y in xy:
		if (x + p, y + q) in xy:
			pass
		else:
			cost += 1
	ans = min(ans, cost)
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,k,n,b,d,p,q,ct,x;
    vector<ll>v;
    cin>>t>>n;
    p=0;
    while(n--)
    {
        cin>>x;
       p+=x;
    }
    ct=t-p;
    if(ct>=0)cout<<ct<<endl;
    else cout<<-1<<endl;
}



Measured memory_bytes: 3648
while True:
    n, m = map(int, input().split())
    
    if n == m == 0:
        break
    
    else:
        a = list(map(int, input().split()))
        
        ans = 0
        for i in range(n):
            for j in range(1, n):
                if i != j:
                    kau = a[i] + a[j]
                    if kau <= m and kau > ans:
                        ans = kau
        
        if ans == 0:
            print('NONE')
        else:
            print(ans)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll A, B;
  cin >> A >> B;
  if(A*B%2==1) cout << "Yes" << rt;
  else cout << "No" << rt;
}

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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

int h, w, d;
int a[301][301];
int q;
int l[100001], r[100001];
vector<pair<int, int>> cood(90001);
vector<int> cost(900001, 0);


void solve()
{
    cin >> h >> w >> d;
    REP(i, h) REP(j, w){
        int _a;
        cin >> _a;
        cood[_a] = make_pair(i+1, j+1);
    }
    for(int i = 1; i <= d; i++){
        int j = 1;
        while(i+d*j <= h*w) {
            int num = i+d*j;
            auto now = cood[num];
            auto prev = cood[num - d];
            cost[num] = cost[num - d] + abs(now.first - prev.first) + abs(now.second - prev.second);
            j++;
        }
    }
    cin >> q;
    REP(i, q) cin >> l[i] >> r[i];
    REP(i, q) cout << cost[r[i]] - cost[l[i]] << "\n";
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 6144
N = int(input())
max = [0, 0] # [10,20]
maxIndex = -1

for i in range(N):
  cur = int(input())
  if(max[0] <= cur):
    max[0] = cur
    if(max[1] < max[0]):
      max[1], max[0] = max[0], max[1]
      maxIndex = i

for i in range(N):
  print(max[1] if maxIndex != i else max[0])

Measured memory_bytes: 4540
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [H, W] = nextIntArray()
    let a = []
    while (hasNext()) {
        a.push(next().split(""))
    }
    for (let i = 0; i < a.length; i++) {
        let isDot = true
        for (let el of a[i]) {
            if (el === "#") {
                isDot = false
                break
            }
        }
        if (isDot) {
            a[i] = new Array(a[0].length).fill("x")
        }
    }
    for (let j = 0; j < a[0].length; j++) {
        let isDot = true
        for (let i = 0; i < a.length; i++) {
            if (a[i][j] == "#") {
                isDot = false
                break
            }
        }
        if (isDot) {
            for(let i = 0; i<a.length;i++){
                a[i][j] = "x"
            }
        }
    }
    let ans = []
    for(let i = 0; i<a.length;i++){
        let line = []
        for(let j = 0; j<a[0].length;j++){
            if(a[i][j] !== "x") line.push(a[i][j])
        }
        if(line.length != 0)ans.push(line)
    }
    for(let line of ans){
        console.log(line.join(""))
    }

}
Main()


Measured memory_bytes: 30396
/*
 * author :Sadik Hassan
 * 
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
	string s;
	cin>>s;
	if(SZ(s)&1)
	{
		cout<<"No"<<nl;return 0;
	}
	for(int i=0;i<SZ(s);i+=2)
	{
		if(s[i]!='h'||s[i+1]!='i')
		{
			cout<<"No"<<nl;return 0;
		}
	}
	cout<<"Yes"<<nl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

void trace(int A[], int length, int index) {
  int i;
  for (i = 0; i < length -1; i++) {
    printf("%d ", A[i]);
  }
  printf("%d\n", A[i]);
  printf("%d\n", index);
}

int main() {
  int length, j, tmp;
  int flag = 1, i =0;
  int A[N];
  scanf("%d", &length);
  for(j = 0; j < length; j++) {
    scanf("%d", &A[j]);
  }

  while(flag) {
    flag = 0;
    for(j = length - 1; j > 0; j--) {
      if(A[j] < A[j-1]) {
        tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        flag = 1;
        i++;
      }
    }
  }
  trace(A, length, i);
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
long double a,b,c;
int main() {
	cin>>a>>b>>c;
	a=sqrtl(a);b=sqrtl(b);c=sqrtl(c);
	long double eps=1e-14;
	if(a+b+eps<c) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T>>;
 
#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define int long long 
#define db double
#define eb emplace_back
#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1e-6;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count()); 
int mul(int x, int y)
{
    int res = ((x%MOD)*(y%MOD))%MOD;
    return res;
}
int sub(int x, int y)
{
    int res = ((x%MOD)-(y%MOD)+MOD)%MOD;
    return res;
}
int binpow(int a, int b)
{
    a %= MOD;
    int res = 1;
    while(b)
    {
        if(b & 1) res = (res*a)%MOD;
        a = (a*a)%MOD;
        b >>= 1;
    }
    return res;
}
int comb(int n, int k)
{
    int fact1 = 1,fact2 = 1;
    for(int i = 1; i <= k; i++)
        fact1 = mul(fact1,i);
    for(int i = 0; i < k; i++)
        fact2 = mul(fact2,n-i);
    int x = binpow(fact1,MOD-2);
    int res = mul(fact2,x);
    return res;
}
void test() {
    int n,a,b;
    cin >> n >> a >> b;
    int ans = sub(binpow(2,n),comb(n,a));
    ans = sub(ans,comb(n,b));
    ans -= 1;
    cout << ans << "\n";
}
 
int32_t main() {
    fast_io();
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    cout << fixed << setprecision(15);
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N = in<ll>();
    ll answer = N*(N-1)/2;
    cout << answer << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	int N, CE = 0, CW = 0;
	char S[300010];
	scanf("%d%s", &N, S);
	int i = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'E') {
			CW++;
		}
	}
	int an = CW + CE;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'W') {
			CE++;
		}
		else if (S[i] == 'E') {
			CW--;
		}
		if (CW + CE < an) {
			an = CW + CE;
		}
	}
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 512
n=int(input())
x=list(map(int,input().split()))
f=False
for i in range(n):
  if x[i]%2==0:
    if x[i]%3==0 or x[i]%5==0:
      pass
    else:
      f=True
      break
      
if f==False:
  
  print('APPROVED')
else:
        print('DENIED')



Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}
vector<vector<int>> G;
vector<int> A;

pair<int, int> dfs(int cur = 0){
    pair<int, int> ret = {0, 0};
    vector<pair<int, int>> B;
    for(int v: G[cur]){
        B.pb(dfs(v));
    }
    int sum = 0;
    int sum2 = 0;
    rep(i, B.size()){
        sum += B[i].first;
        sum2 += B[i].second;
    }
    if(sum > A[cur]) {
        output("IMPOSSIBLE");
        exit(0);
    }
    vector<int> dp(A[cur] - sum + 1, 0);
    dp[0] = 1;
    rep(i, B.size()){
        for(int j = (int)dp.size() - 1; j >= 0; j--){
            if (j - (B[i].second - B[i].first) >= 0) dp[j] |= dp[j - (B[i].second - B[i].first)];
        }
    }
    int m = 0;
    rep(i, dp.size()){
        if(dp[i] == 1) m = i;
    }
    int first = A[cur];
    int second = sum2 - m;
    if(first > second) swap(first, second);
//    voutput(dp);
//    cout << cur << ":" << first << "," << second << endl;
    return mp(first, second);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    G.resize(N);
    rep(i, N - 1){
        int p;
        cin >> p;
        G[p - 1].pb(i + 1);
    }
    A.resize(N);
    rep(i, N) cin >> A[i];
    dfs();
    output("POSSIBLE");
    
    return 0;
}

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

typedef long long int ll;


int main()
{
	ios::sync_with_stdio(0);
	ll n,i;
	cin >> n;
	ll a[n];
	for(i=0;i<n;i++)
		cin >> a[i];
	if(n==2)
		cout << abs(a[1]-a[0]) << "\n";
	else
	{
		ll dp[n];
		dp[0]=0;
		dp[1]=abs(a[1]-a[0]);
		for(i=2;i<n;i++)
			dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		cout << dp[n-1] << "\n";
	}
	return 0;
}

Measured memory_bytes: 1792
#include "iostream"
using namespace std;

int main()
{
	char hina[127];
	int n = 0, c = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> hina[i];
		if (hina[i] == 'Y')
			c++;
	}

	c ? cout << "Four" : cout << "Three";
    return 0;
}


Measured memory_bytes: 256
// 2020-07-18 12:24:56
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  vector<ll> a(n), ans(n);
  rep(i, n) cin >> a[i];
  ll b = 2 * a[n-1];
  REPCM(i, n-2, 0) b = 2 * a[i] - b;
  ans[0] = b / 2;
  REP(i, 1, n) ans[i] = 2 * a[i-1] - ans[i-1];
  rep(i, n) {
    if(i) cout << ' ';
    cout << ans[i];
  }
  cout << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4760
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val x = readLine()!!.split(' ').map(String::toInt)
    val xsorted = x.sorted()
    val medianL = xsorted[n / 2 - 1]
    val medianH = xsorted[n / 2]
    for (i in 0..(n - 1)) {
        if(x[i]<=medianL){
            println(medianH)
        }else{
            println(medianL)
        }
    }
}



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

using namespace std;

int main(){
    int A, B;
    scanf("%d%d", &A, &B);
    int tmp = A, sum = 0;
    for(int i = tmp; i <= B; i++){
        A = i;
        if(A % 10 == A / 10000 && ((A / 10) % 10 == (A / 1000) % 10))
            sum++;
    }
    printf("%d\n", sum);
}

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

// data structure
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <vector>

#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[]) {
  int a, b, c;
  std::cin >> a >> b >> c;

  std::swap(a, b);
  std::swap(a, c);

  std::cout << a << " " << b << " " << c << std::endl;
  return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 1000100; 
char s[N];
int n;
int bak[N];
int main(){
	scanf("\n%s", s + 1);
	n = strlen(s + 1);
	int mx = 0, pre = 0, mn, lim, ans;
	for (int i = 1; i <= n; i++){
		if (s[i] == '1') pre++;
			else pre--;
		mx = max(pre, mx);
	}
	for (int i = n; i >= 1; i--){
		if (s[i] == '1') bak[i] = 1 + bak[i + 1];
			else bak[i] = -1 + bak[i + 1];
		bak[i] = max(bak[i], 0);
	}
	
	lim = mx, pre = 0, mn = 0;
	for (int i = 1; i <= n; i++){
		if (s[i] == '1') pre++;
		if (s[i] == '0') pre--;
		if (s[i] == '?'){
			if (pre + 1 + bak[i + 1] <= lim) pre++;
				else pre--;
		}
		mn = min(mn, pre);
	}
	ans = lim - mn;
	
	lim = mx + 1, pre = 0, mn = 0;
	for (int i = 1; i <= n; i++){
		if (s[i] == '1') pre++;
		if (s[i] == '0') pre--;
		if (s[i] == '?'){
			if (pre + 1 + bak[i + 1] <= lim) pre++;
				else pre--;
		}
		mn = min(mn, pre);
	}
	ans = min(ans, lim - mn);
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8608
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

  #define cases int testcases;cin>>testcases; while(testcases--)
      


int32_t main()
{

    
    int n, k;
    cin >> n >> k;
    int h[n+1];


    rep(i,1,n)
    {
      cin >> h[i];
    }


    int dp[n+1];
    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);

    rep(i,3,n)
    {
      dp[i] = 100000000000000000;
    }
    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    rep(i,1,n)
    {
      int l = min(i+k,n);

      rep(j,i+1,l)
      {
        dp[j] = min(dp[j],dp[i] + abs(h[i]-h[j]));
      }
    }

    cout << dp[n];
   return 0;
}  

Measured memory_bytes: 1792
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s == "abc")
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int a[100000];
int ct[2];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	for (int i=0;i<n;i++) {
		cin >> a[i];
		ct[a[i]%2]++;
	}

	if (n==1 || ct[1]%2==0) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
//#define MOD 998244353

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

using namespace std;

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

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


	ll P, Q, R;
	cin >> P >> Q >> R;

	ll m = std::min({ P + Q, Q + R, P + R });

	cout << m << endl;



	return 0;
}



Measured memory_bytes: 888
#include<stdio.h>

int d[100][100];
int s[100][100];
int dd[100][100];
int ss[100][100];
int main(){
	while(1){
	int a,b;
	scanf("%d%d",&a,&b);
	if(b==0)return 0;
	for(int i=0;i<b;i++)
		for(int j=0;j<b;j++){
			d[i][j]=99999999;
			dd[i][j]=99999999;
		}
	
	for(int i=0;i<a;i++){
		int m,n,o,p;
		scanf("%d%d%d%d",&m,&n,&o,&p);
		d[m-1][n-1]=o;
		d[n-1][m-1]=o;
		dd[m-1][n-1]=p;
		dd[n-1][m-1]=p;
	}
	int h=0;
	for(int i=0;i<b;i++){
		for(int j=0;j<b;j++){
			s[i][j]=j;
		}
	}
	while(1<<h<b-1){
		for(int i=0;i<b;i++){
			for(int j=0;j<b;j++){
				for(int k=0;k<b;k++){
					if(d[i][j]>d[k][j]+d[i][k]){
						d[i][j]=d[i][k]+d[k][j];
						s[i][j]=s[i][k];
					}
				}
			}
		}
		h++;
	}
	h=0;
	for(int i=0;i<b;i++){
		for(int j=0;j<b;j++){
			ss[i][j]=j;
		}
	}
	while(1<<h<b-1){
		for(int i=0;i<b;i++){
			for(int j=0;j<b;j++){
				for(int k=0;k<b;k++){
					if(dd[i][j]>dd[k][j]+dd[i][k]){
						dd[i][j]=dd[i][k]+dd[k][j];
						ss[i][j]=ss[i][k];
					}
				}
			}
		}
		h++;
	}
	
	int x;
	scanf("%d",&x);
	for(int i=0;i<x;i++){
		int m,n,o;
		scanf("%d%d%d",&m,&n,&o);
		if(o)printf("%d\n",dd[m-1][n-1]);
		else printf("%d\n",d[m-1][n-1]);
	}
	}
}

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

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define endl "\n"
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);

	int H, W, K; cin >> H >> W >> K;
	vector<set<int>> rows(H), cols(W);

	int x1, y1, x2, y2; cin >> y1 >> x1 >> y2 >> x2;
	x1--, y1--, x2--, y2--;

	vector<vector<char>> M(H, vector<char>(W));

	rep(y, 0, H) rep(x, 0, W) {
	  cin >> M[y][x];
	  rows[y].insert(x), cols[x].insert(y);
	}

	if(M[y1][x1] == '@' or M[y2][x2] == '@') {
		cout << -1 << endl;
		return 0;
	}

	queue<array<int, 3>> Q;
	Q.push({0, x1, y1});

	while(sz(Q)) {
	  auto [d, x, y] = Q.front();
	  Q.pop();

	  if(x == x2 && y == y2) {
		cout << d << endl;
		return 0;
	  }

	  for(auto it = rows[y].lower_bound(x); it != rows[y].end(); ) {
		int nx = *it;
		if(M[y][nx] == '@' or nx - x > K) break;

		it = rows[y].erase(it);
		cols[nx].erase(y);
		Q.push({d+1, nx, y});
	  }

	  for(auto it = rows[y].lower_bound(x); it != rows[y].begin(); ) {
		it--;
		int nx = *it;
		if(M[y][nx] == '@' or x - nx > K) break;

		it = rows[y].erase(it);
		cols[nx].erase(y);
		Q.push({d+1, nx, y});
	  }

	  for(auto it = cols[x].lower_bound(y); it != cols[x].end(); ) {
		int ny = *it;
		if(M[ny][x] == '@' or ny - y > K) break;

		it = cols[x].erase(it);
		rows[ny].erase(x);
		Q.push({d+1, x, ny});
	  }

	  for(auto it = cols[x].lower_bound(y); it != cols[x].begin(); ) {
		it--;
		int ny = *it;
		if(M[ny][x] == '@' or y - ny > K) break;

		it = cols[x].erase(it);
		rows[ny].erase(x);
		Q.push({d+1, x, ny});
	  }
	}

	cout << -1 << endl;
}


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

using namespace std;
using ll = long long;

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

    int K;
    cin>>K;
    int cur = 7;

    for(int i=1;i<=10000000;i++){
        if(cur % K == 0){
            cout<<i;
            return 0;
        }
        cur = (cur * 10 + 7)%K;
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
	int i,j,k,n;
    string s;
    cin >> s;
    int a=0,b=0;
    for(i=0;i<s.size();i++){
    	if(i%2==0){
    		if(s[i]=='L'){
    			a=1;
			}
		} 
		else if(s[i]=='R'){
			b=1;
		}
	}
	if(a+b>0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>

using namespace std;
 
const double eps=1e-10;

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

int main()
{

	int w,h;
	while(cin>>w>>h,w){
		vector< vector<int> > table(h,vector<int>(w));
		int res=0;
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++) cin>>table[y][x];
		}

		queue< pair<int,int> > q;

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){

				if(table[i][j]==0) continue;

				res++;
				q.push(make_pair(i,j));

				while(!q.empty()){
					pair<int,int> p=q.front();
					q.pop();
					int y=p.first,x=p.second;

//					cout<<y<<" "<<x<<endl;

					if(table[y][x]==0) continue;

					table[y][x]=0;
					for(int k=0;k<8;k++){
						int nx=x+dx[k],ny=y+dy[k];
						if(0<=nx && nx<w && 0<=ny && ny<h && table[ny][nx]==1) q.push(make_pair(ny,nx));
					}
				}
			}
		}
		cout<<res<<endl;

	}


	return 0;
}

Measured memory_bytes: 1232
N,M = gets.split(" ").map(&:to_i)
t = gets.split(" ").map(&:to_i)
result = 0
(N-1).times {|i|
  if(t[i+1]-t[i] >= M) then
    result += M
  else
    result += t[i+1]-t[i]
  end
}
result += M
puts(result)


Measured memory_bytes: 15876
class Node:
    def __init__(self, id):
        self.id = id
        self.left = None
        self.right = None
        self.parent = None

    def isRoot(self):
        return self.parent is None

    def preorder(self, arr):
        arr.append(str(self.id))
        if self.left is not None:
            self.left.preorder(arr)
        if self.right is not None:
            self.right.preorder(arr)

    def inorder(self, arr):
        if self.left is not None:
            self.left.inorder(arr)
        arr.append(str(self.id))
        if self.right is not None:
            self.right.inorder(arr)

    def postorder(self, arr):
        if self.left is not None:
            self.left.postorder(arr)
        if self.right is not None:
            self.right.postorder(arr)
        arr.append(str(self.id))

def insert(root, z):
    y = None
    x = root
    while x is not None:
        y = x
        if z.id < x.id:
            x = x.left
        else:
            x = x.right

    z.parent = y

    if z.id < y.id:
        y.left = z
    else:
        y.right = z

def find(root, k):
    x = root
    while x is not None:
        if x.id == k:
            return True
        if x.id > k:
            x = x.left
        else:
            x = x.right
    return False

m = int(input())
root = None

for i in range(m):
    arr = input().split()
    if arr[0] == 'print':
        arr = []
        root.inorder(arr)
        print('', ' '.join(arr))
        arr = []
        root.preorder(arr)
        print('', ' '.join(arr))
        continue

    if arr[0] == 'find':
        k = int(arr[1])
        if find(root, k):
            print('yes')
        else:
            print('no')
        continue

    id = int(arr[1])
    if root is None:
        root = Node(id)
        continue

    insert(root, Node(id))



Measured memory_bytes: 121868
x1, y1, x2, y2 = map(int, input().split())

diff_x = x2 - x1
diff_y = y2 - y1

x3 = x2 - diff_y
y3 = y2 + diff_x
x4 = x3 - diff_x
y4 = y3 - diff_y

print("{} {} {} {}".format(x3, y3, x4, y4))


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int N = sc.nextInt() ,M=sc.nextInt() ,count=0;
       System.out.println( M*(M-1) + ((N-1+M)*(N-M))/ 2 );
    }
    
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  string ans = "Possible";
  for (int i = 0; i < h - 1; i++) {
    for (int j = 0; j < w - 1; j++) {
      if (a[i][j + 1] == '#' && a[i + 1][j + 1] == '#' && a[i + 1][j] == '#') {
        ans = "Impossible";
      }
      if (a[i][j + 1] == '#' && a[i][j] == '#' && a[i + 1][j] == '#') {
        ans = "Impossible";
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

struct SlideMin {
    // data[i]: mininum over [max(0, i + 1 - width), i + 1)
    int n;
    vi data;
    SlideMin(const vi &as, int width, bool minimum = true) : n(as.size()), data(as.size()) {
        using ii = pair<i64, int>;
        deque<ii> deq;
        auto comp = [&](ii &e, i64 v) {
            return minimum ? e.first >= v : e.first <= v;
        };
        for (int i = 0; i < n; i++) {
            if (deq.size() && deq.front().second <= i - width) {
                deq.pop_front();
            }
            while (deq.size()) {
                if (comp(deq.back(), as[i])) deq.pop_back();
                else break;
            }
            deq.push_back(ii(as[i], i));
            data[i] = deq.front().first;
        }
    }
};

int main() {
    int n, x;
    cin >> n >> x;
    vi as(2 * n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as[i] = as[i + n] = a;
    }
    i64 ans = 1e18;
    for (int i = 1; i <= n; i++) {
        SlideMin smin(as, i);
        i64 now = 1ll * x * (i - 1);
        for (int j = n; j < 2 * n; j++) {
            now += smin.data[j];
        }
        ans = min(ans, now);
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();
            if (CheckSimCoffee(line))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            //Console.WriteLine("hello world");
            //while (true)
            //{
            //    var line= Console.ReadLine();
            //    Console.WriteLine(line);
            //}
        }

        private static bool CheckSimCoffee(string line)
        {
            if (line.Length != 6) return false;
            return line[2] == line[3] && line[4] == line[5];
        }
    }
}


Measured memory_bytes: 13140
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

ll a,b;

int main(){
	cin>>a>>b;
	if(a<=0&&b>=0){
		cout<<"Zero"<<endl;
	}else if(b>0){
		cout<<"Positive"<<endl;
	}else{
		if((b-a)%2==1) cout<<"Positive"<<endl;
		else cout<<"Negative"<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<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()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let line: Vec<usize> = read_as_vec();
    let (n, k) = (line[0], line[1]);
    let mut s = read_as_string().chars().collect::<Vec<char>>();
    let a = s[k-1].to_lowercase();
    s[k-1] = a.collect::<Vec<char>>()[0];
    /*
    for i in 0..n{
        if i != k-1{
            print!("{}", s[i]);
    }
     */

    println!("{}", s.into_iter().collect::<String>());
    
}


Measured memory_bytes: 4352
n,k = map(int,input().split())
def Base_10_to_n(X, A):
    if (int(X/A)):
        return Base_10_to_n(int(X/A), A)+str(X%A)
    return str(X%A)
ans = Base_10_to_n(n,k)
print(len(ans))

Measured memory_bytes: 3060
def rotate arr
    rotated_arr = Array.new(arr.size){Array.new(arr[0].size)}
    for i in (0 ... arr.size)
        for j in (0 ... arr[0].size)
            rotated_arr[i][j] = arr[arr.size - 1 - j][i]
        end
    end
    rotated_arr
end

pattern = []
8.times{pattern << gets.chomp.split("")}

p = pattern
for i in 1..3
    puts 90 * i
    p = rotate(p)
    p.each{|line| puts line.join}
end

Measured memory_bytes: 8632
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int inf = 5e18;  
const int mod1 = 998244353;
const int mod = 1e9 + 7;
int n,x,m,period,sum1,sum2,curr;
set<int> s1;
unordered_map<int,int> mp;
vector<int> v;
void calc(int a)
 {
  //cerr<<a<<" "<<n<<END;
  if(curr == 1 && !s1.count(a))
     {
      n--;
      sum1 += a;
      s1.insert(a);
     }
  else if(curr == 1 && s1.count(a))
     {
      period++;
      n--;
      sum2 += a;
     // mp[a]++;
      v.pb(a);
      curr = 2;
     }
  else if(curr == 2 && find(v.begin(), v.end(),a) == v.end())
     {
      period++;
      n--;
      sum2 += a;
     // mp[a]++;
      v.pb(a);
     }
  else if(curr == 2 && find(v.begin(), v.end(),a) != v.end())
     return;
  if(n == 0)
     return;
  a = (a * a)%m;
  calc(a);
 }
void solve()
 {
  cin>>n>>x>>m;
  period = 0;
  sum1 = 0;
  sum2 = 0;
  curr = 1;
  calc(x);
  if(period == 0)
     {
      cout<<sum1 + sum2<<END;
      return;
     }
  int ans = sum1 + sum2;
  int times = n/period;
  ans += sum2 * times;
 // cerr<<bug(times) bug(period)<<END;
  int left = n%period;
  for(auto x : v)
     {
      //cerr<<x<<END;
      if(left == 0)
         break;
      else
         {
          ans += x;
          left--;
         }
     }
  cout<<ans;
 }
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
  /*int t;
  cin>>t;
  while(t--)*/
  solve();
  // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
  return 0;
} 

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

int main()
{
	long long a, b;
	scanf("%lld%lld", &a, &b);
	long long x=a, y=b;

    while (a!= b) {
        if(a>b)
            a-=b;
        else
            b-=a;
    }

	long long nzs = (x*y)/a;

	printf("%lld", nzs);

    return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N;
  cin >> N;
  
  map<int, int> m;
  
  int A[N];
  rep(i, N){
    cin >> A[i];
    m[A[i] ]++;
  }
    
  int Q;
  cin >> Q;
  int B[Q], C[Q];
  rep(i, Q)
    cin >> B[i] >> C[i];
  //

  
  long long ans = 0;
  rep(i, N)
    ans += A[i];
  
  rep(i, Q){
    int tmp = m[B[i] ];
    m[C[i] ] += m[B[i] ];
    m[B[i] ] = 0;

    ans = ans+(C[i]-B[i])*tmp ;
    
    //   for(auto map : m)
    //cout << map.first << " "<<map.second<<endl;
    
    cout << ans << endl;
    
  }
  
  return 0;
}


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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main(void){
    int priceA, priceB, priceAB, x, y, ans, morePizza;
    cin >> priceA >> priceB >> priceAB >> x >> y;
    if(x > y) morePizza = priceA;
    else morePizza = priceB;
    ans = min(max(x, y) * 2 * priceAB, priceA * x + priceB * y);
    ans = min(ans, min(x, y) * 2 * priceAB + (max(x, y) - min(x, y)) * morePizza);

    cout << ans << endl;
    


}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100005;
int a[maxn],odd[maxn],even[maxn];
int seq[maxn];
bool cmp(const int &x,const int &y){
  return a[x]<a[y];
}
int c[maxn];
void add(int x){
  for(;x;x-=x&(-x))c[x]++;
}
int sum(int x){
  int ans=0;for(;x<maxn;x+=x&(-x))ans+=c[x];return ans;
}
int main(){
  int n;scanf("%d",&n);
  for(int i=1;i<=n;++i)scanf("%d",a+i);
  for(int i=1;i<=n;++i)seq[i]=i;
  sort(seq+1,seq+n+1,cmp);
  int old=-1,tot=0;
  for(int i=1;i<=n;++i){
    if(a[seq[i]]!=old){
      ++tot;old=a[seq[i]];
    }
    a[seq[i]]=tot;
  }
  int ans=0;
  for(int i=1;i<=n;++i){
    if((i+a[i])&1){
      ans++;
    }
  }
  printf("%d\n",ans/2);
  return 0;
}


Measured memory_bytes: 896
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<int, pii>
#define puu pair<ULL, ULL>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e5 + 5;
pii a[N];
vector<int> g[N*2];
set<int> s[N];
int n, t[N], c[N], bl[N], tot[N], cnt = 0;
bool vis[N*2];
inline void dfs(int u) {
    vis[u] = true;
    if(u < N) c[cnt]++, bl[u] = cnt;
    for (int v : g[u]) if(!vis[v]) dfs(v);
}
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d %d", &a[i].fi, &a[i].se);
    for (int i = 1; i <= n; ++i) {
        g[a[i].fi].pb(N+a[i].se);
        g[N+a[i].se].pb(a[i].fi);
    }
    for (int i = 1; i < N; ++i) {
        if(!vis[i]) {
            ++cnt;
            dfs(i);
        }
    }
    for (int i = 1; i <= n; ++i) s[bl[a[i].fi]].insert(a[i].se), tot[bl[a[i].fi]]++;
    LL ans = 0;
    for (int i = 1; i <= cnt; ++i) ans += s[i].size()*1LL*c[i]-tot[i];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 17792
//Sameer's Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MOD 1000000007
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i] < a[i - 1]) {
            ans = ans + abs(a[i] - a[i - 1]);
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5216
<?php
//リスト作成
fscanf(STDIN, "%d", $blueCard);
$blueCards = [];
for($i=0; $i<$blueCard; $i++){
    fscanf(STDIN, "%s", $blueCardSentence);
    array_push($blueCards, $blueCardSentence);
}

fscanf(STDIN, "%d", $redCard);
$redCards = [];
for($i=0; $i<$redCard; $i++){
    fscanf(STDIN, "%s", $redCardSentence);
    array_push($redCards, $redCardSentence);
}

//単語とその個数の連想配列作成
$blueList = array_count_values($blueCards);
$redList = array_count_values($redCards);

$resultList = [];

foreach ($blueList as $blueKey => $blueValue) {
    $pushFlag = true;
    foreach ($redList as $redKey => $redValue) {
        if($blueKey === $redKey){
            array_push($resultList, $blueValue-$redValue);
            $pushFlag = false;
            break;
        }
    }
    if($pushFlag == true){
        array_push($resultList, $blueValue);
    }
}

if(max($resultList) >= 0){
    echo max($resultList);
}
else{
    echo 0;
}

Measured memory_bytes: 4728
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  long long ans = 0, l = 1<<s.size();
  for(int i=s.size()-1;i>=0;i--){
    ans += l * (s[i]-'0');
    l = (l*10 + (1<<s.size()))/2;
  }
  cout << ans/2 << endl;
}


Measured memory_bytes: 256