akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

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

//==================================

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

    string S;
    cin >> S;

    deque<char> deq;
    for (int i = 0; i < (int)S.size(); i++) {
        deq.push_back(S[i]);
    }

    int Q;
    cin >> Q;

    bool is_rev = false;
    while (Q--) {
        int q;
        cin >> q;
        if (q == 1) {
            is_rev ^= true;
        }
        else {
            int f;
            char c;
            cin >> f >> c;

            if (f == 1) {
                if (is_rev) {
                    deq.push_back(c);
                }
                else {
                    deq.push_front(c);
                }
            }
            else {
                if (is_rev) {
                    deq.push_front(c);
                }
                else {
                    deq.push_back(c);
                }
            }
        }
    }

    string ans;
    int num = deq.size();
    if (is_rev) {
        for (int i = 0; i < num; i++) {
            ans += deq[num - i - 1];
        }
    }
    else {
        for (int i = 0; i < num; i++) {
            ans += deq[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1368
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        int X=sc.nextInt();
        int[]A=new int[M];
        for(int i=0;i<M;i++){
            A[i]=sc.nextInt();
        }
        int sum=0;
        for(int i=0;i<X;i++){
            out:for(int j=0;j<M;j++){
                if(i==A[j]){
                    sum++;
                    break out;

                }
            }
        }
        int summ=M-sum;
        System.out.println(Math.min(sum,summ));

}
        
        
    }


Measured memory_bytes: 21844
import os
import sys
import numpy as np

def proc(C, L, R, Order, N, Q):
    pl = pr = 0
    ans = 0
    A = np.zeros(N+1, dtype=np.int32)
    Ans = np.zeros(Q, dtype=np.int32)
    for idx_LR in Order:
        l = L[idx_LR]
        r = R[idx_LR]
        while pr < r:
            pr += 1
            c = C[pr]
            if A[c] == 0:
                ans += 1
            A[c] += 1
        while pl > l:
            pl -= 1
            c = C[pl]
            if A[c] == 0:
                ans += 1
            A[c] += 1
        while pr > r:
            c = C[pr]
            A[c] -= 1
            if A[c] == 0:
                ans -= 1
            pr -= 1
        while pl < l:
            c = C[pl]
            A[c] -= 1
            if A[c] == 0:
                ans -= 1
            pl += 1
        Ans[idx_LR] = ans
    return Ans


# >>> numba compile >>>
numba_config = [
    [proc, "i4[:](i4[:],u4[:],u4[:],i8[:],i4,i4)"],
]
if sys.argv[-1] == "ONLINE_JUDGE":
    from numba import njit
    from numba.pycc import CC
    cc = CC("my_module")
    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature)(func)
        cc.export(func.__name__, signature)(func)
    cc.compile()
    exit()
elif os.name == "posix":
    exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
else:
    from numba import njit
    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature, cache=True)(func)
    print("compiled!", file=sys.stderr)
# <<< numba compile <<<


def main():
    input = sys.stdin.buffer.readline
    N, Q = map(int, input().split())
    C = np.empty(N+1, dtype=np.int32)
    C[0] = 0
    C[1:] = np.array(input().split(), dtype=np.int32)
    LR = np.array(sys.stdin.buffer.read().split(), dtype=np.uint32)
    L = LR[::2]
    R = LR[1::2]
    B = L>>9<<20|R
    Idx = (L>>9&1).astype(np.bool)
    B[Idx] = L[Idx]>>9<<20|(1<<20)-R[Idx]
    Order = np.argsort(B)
    Ans = proc(C, L, R, Order, N, Q)
    print("\n".join(map(str, Ans.tolist())))

main()


Measured memory_bytes: 98940
// AOJ 0282: Programming Contest
// 2017.8.19 bal4u@uu
// 2017.10.29 retry

#include <stdio.h>

#define QSIZE 1000000
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int id, key, c; } QUE;
QUE que[QSIZE+5]; int qsize;

void max_heapify(int i)
{
	int l, r, max;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].key > que[i].key || (que[l].key == que[i].key && que[l].id < que[i].id)))
		max = l;
	else max = i;
	if (r < qsize && (que[r].key > que[max].key || (que[r].key == que[max].key && que[r].id < que[max].id)))
		max = r;
	if (max != i) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		max_heapify(max);
	}
}

void deq(void)
{
	if (qsize == 0) return;
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(void)
{
	int i, max;
	i = qsize++;
	while (i > 0 && (que[max = PARENT(i)].key < que[i].key
		|| (que[max].key == que[i].key && que[max].id > que[i].id))) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		i = max;
	}
}

#define MAX 100000
typedef struct { int x, t, c; } T;
T tbl[MAX+5];
char buf[102], *p;

int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int N, R, L, d, t;
	int lt, ld, i, ans;

	fgets(p=buf, 100, stdin), N = getint(), p++, R = getint(), p++, L = getint();
	qsize = 0; lt = 0, ld = 1;
	que[0].id = 1, que[0].key = 0, que[0].c = 1, enq();
	tbl[1].x = 0, tbl[1].c = 1;
	while (R--) {
		fgets(p=buf, 100, stdin), d = getint(), p++, t = getint(), p++;
		if (*p == '-') p++, tbl[d].x -= getint(); else tbl[d].x += getint();
		tbl[d].c++;
		que[qsize].id = d, que[qsize].key = tbl[d].x, que[qsize].c = tbl[d].c;
		enq();

		while (1) {
			d = que[0].id;
			if (tbl[d].c == que[0].c) {
				tbl[ld].t += t - lt;
				lt = t, ld = d;
				break;
			}
			deq();
		}
	}
	tbl[ld].t += L - lt;
	for (t = 0, i = 1; i <= N; i++)
		if (tbl[i].t > t) t = tbl[i].t, ans = i;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9348
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 100005;
const int MM = 1000000007;

int N, a, b;

struct UF{
	set<int> R[MX], B[MX];
	int t[MX], cnt[MX];
	int find(int x){ return t[x]? t[x] = find(t[x]) : x; }
	int merge(int a, int b){
		a = find(a), b = find(b);
		if( a == b ) return false;
		if( cnt[a] > cnt[b] ) swap(a, b);

		t[a] = b; cnt[b] += cnt[a];
		
		vector<int> L;
		for(int c : R[a] ) if( B[b].find(c) != B[b].end() ) L.push_back(c);
		for(int c : B[a] ) if( R[b].find(c) != R[b].end() ) L.push_back(c);
		for(int c : R[a]){
			R[c].erase(a);
			R[c].insert(b);
		}
		for(int c : B[a]){
			B[c].erase(a);
			B[c].insert(b);
		}
		for(int c : R[a] ) R[b].insert(c);
		for(int c : B[a] ) B[b].insert(c);
		R[b].erase(b); B[b].erase(b);

		for(int c : L) merge(b, c);
		return 1;
	}
}uf;

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) uf.cnt[i] = 1;
	set<pii> L, M;
	for(int i = 1; i < N; i++){
		scanf("%d%d", &a, &b);
		if( a > b ) swap(a, b);
		L.emplace(a, b);
		uf.B[a].insert(b);
		uf.B[b].insert(a);
	}
	for(int i = 1; i < N; i++){
		scanf("%d%d", &a, &b);
		if( a > b ) swap(a, b);
		if( L.find(pii(a, b)) != L.end() ) M.insert(pii(a, b));
		uf.R[a].insert(b);
		uf.R[b].insert(a);
	}
	
	for(pii c : M) uf.merge(c.first, c.second);
	for(int i = 1; i <= N; i++){
		if( uf.find(i) != uf.find(1) ) return !printf("NO\n");
	}
	printf("YES\n");
}


Measured memory_bytes: 51328
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

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

signed main() {
    INIT;
    cin >> N >> M;
    vector<int> a(N), b(N), c(M), d(M);
    REP(i, N) {
        cin >> a[i] >> b[i];
    }
    REP(i, M) {
        cin >> c[i] >> d[i];
    }
    vi res(N);
    REP(i, N) {
        int mn = INF;
        REP(j, M) {
            int dist = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if (chmin(mn, dist)) {
                res[i] = j;
            }
        }
    }
    REP(i, N)
        cout << res[i] + 1 << " ";
}

Measured memory_bytes: 3620
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a: print("AC")
    else :print("WA")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = ip()                              #入力整数1つ
#x,y = (int(i) for i in input().split())      #入力整数横2つ
x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列


num=0
for d in range(x):
    a,b = (int(i) for i in input().split())
    if a>=y and b>=z:
        num+=1
print(num)

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    int count = 1;
    int flag = 1;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < i; j++){
            if(h.at(i) < h.at(j)){
                flag = 0;
            }
        }
        if(flag == 1){
            count++;
        }
        flag = 1;
    }
    cout << count;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public void run() throws Exception {
		FastReader file = new FastReader();
		int a = file.nextInt(), b = file.nextInt(), c = file.nextInt();
		int d = a;
		a = b;
		b = d;
		int e = c;
		c = a;
		a = e;
		System.out.println(a + " " + b + " " + c);
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define all(x) (x).begin(), (x).end()
#define sqr(x) (x)*(x)
#define CEIL(a,b) ((a)+(b)-1) /(b)

typedef long long ll;
const int INF = 1001001001;

void sort_second(vector<pair<ll, ll>> &A, int N); //A:array of pair, N:size of array

int main() {
    int n, m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

void sort_second(vector<pair<ll, ll>> &A, int N) {
    rep(i, N) swap(A.at(i).first, A.at(i).second);
    sort(all(A));
    rep(i, N) swap(A.at(i).first, A.at(i).second);
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

int main()
{
    int n, t[100000], x[100000], y[100000];
    pair<int, int> pii;
    int nt = 0;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < n; i++)
    {
        nt += abs(pii.first - x[i]) + abs(pii.second - y[i]);
        //cout << nt << " " << t[i] << " " << (nt - t[i]) % 2 << endl;
        if (nt <= t[i] && (nt - t[i]) % 2 == 0)
        {
            pii.first = x[i];
            pii.second = y[i];
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
n, m = map(int,input().split())
lr = []
for i in range(m):
    lr.append([int(i) for i in input().split()])

if m == 1:
    print(lr[0][1] - lr[0][0] + 1)
    exit()

tmp1 = 0
tmp2 = pow(10, 6)
for i in range(m - 1):
    tmp1 = max(lr[i][0], lr[i + 1][0], tmp1)
    tmp2 = min(lr[i][1], lr[i + 1][1], tmp2)
#print(tmp1, tmp2)
ans = max(tmp2 - tmp1 + 1, 0)
print(ans)


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


#define M 1000000007
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod 998244353
#define sz(v) (int)(v).size()

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

ll add(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a+b)%M;
	return (p+M)%M;
}

ll mul(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a*b)%M;
	return (p+M)%M;
}


int main()
{
	fastio;
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		if((i%3!=0)&&(i%5!=0))
			ans+=i;
	}
	cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 10);

int n;
string t[MAXN];

void read()
{
	cin >> n; 
	for(int i = 0; i < n; i++)
		cin >> t[i];
}

void solve()
{

	int answer = 0;
	for(int a = 0; a < n; a++)
	{
		t[n] = t[0];
		for(int i = 0; i < n; i++)
			t[i] = t[i + 1];

		int err = 0;
		for(int i = 0; i < n; i++)
			for(int j = i + 1; j < n; j++)
				if(t[i][j] != t[j][i])
					err++;

		if(err == 0) answer += n;
	}

	cout << answer << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 512
import sys

sys.setrecursionlimit(1000000)

nCr = {}


def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    nCr[(n, r)] = nCr[(n, r)]
    return nCr[(n, r)]


def acinput():
    return list(map(int, input().split(" ")))


N = int(input())
dct = {}

for i in range(N):
    tmp = input()
    #print("head   ",tmp)
    tmp = "".join(sorted(tmp))
    try:
        dct[tmp] += 1
    except:

        dct[tmp] = 1


res = 0
for sdct in dct:
    if dct[sdct] > 1:
        res += cmb(dct[sdct], 2)

print(res)


#print(dct)

Measured memory_bytes: 98276
N=int(input())
scores=[input() for _ in range(N)]
AC=WA=TLE=RE=0
for score in scores:
  if score == 'AC':
    AC += 1
  elif score == 'WA':
    WA += 1
  elif score == 'TLE':
    TLE += 1
  else:
    RE += 1
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))

Measured memory_bytes: 82708
/**
 *   author:  cryforthemoon46
 *   created: 25.05.2020 16:49:59
**/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)
#define FOREACH(x, a) for(auto&& x : (a))

const double EPS = (double)(1e-7);
const ll INF = (ll)1e18;
const int MOD = (int)1e9 + 7;
const ll dx[4] = { 0,  1,  0, -1};
const ll dy[4] = {-1,  0,  1,  0};

ll N, X; 
ll a[100];
ld c = 0;
ll ans = 0;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    REP(i, N) {
        cin >> X;
        a[i] = X;
        c += X;
    }
    c = (ll)round(c / N);
    REP(i, N) {
        ans += pow(a[i] - c, 2);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(){
	int x,y,group[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
	cin>>x>>y;
	if(group[x]==group[y]) puts("Yes");
	else puts("No");

	return 0;
}



Measured memory_bytes: 256
import std.algorithm;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


immutable long MOD = 1000000007;


auto solve(long N, long M, long K) {
    const a =
        (
            iota(M)
                .map!(d => (M - d) * d % MOD)
                .reduce!((a, b) => (a + b) % MOD) * N % MOD * N % MOD
            +
            iota(N)
                .map!(d => (N - d) * d % MOD)
                .reduce!((a, b) => (a + b) % MOD) * M % MOD * M % MOD
        ) % MOD;
    const b =
        ModCalc(MOD).C(N * M - 2, K - 2);

    return a * b % MOD;
}


struct ModCalc {
private:
    long mod;
    long[] fac;
    long[] inv;
    long[] finv;

public:
    this(long mod) {
        this.mod = mod;
        fac = [1, 1];
        inv = [0, 1];
        finv = [1, 1];
    }

    long factorial(long n) {
        assert(n >= 0);

        auto n_ = n.to!size_t;
        extendTable(n_ + 1);
        return fac[n_];
    }

    long P(long n, long k) {
        assert(0 <= k && k <= n);

        auto n_ = n.to!size_t;
        auto k_ = k.to!size_t;
        extendTable(n_ + 1);
        return fac[n_] * finv[n_ - k_] % mod;
    }

    long C(long n, long k) {
        assert(0 <= k && k <= n);

        auto n_ = n.to!size_t;
        auto k_ = k.to!size_t;
        extendTable(n_ + 1);
        return fac[n_] * finv[k_] % mod * finv[n_ - k_] % mod;
    }

    long H(long n, long k) {
        return C(n + k - 1, k);
    }

private:
    void extendTable(size_t size) {
        auto oldsize = fac.length;
        if (size <= oldsize)
            return;

        fac.length = size;
        inv.length = size;
        finv.length = size;

        foreach (i; oldsize .. size) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[(mod % i).to!size_t] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long M;
    M = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N, M, K);
    else
        solve(N, M, K).writeln;
}


Measured memory_bytes: 7292
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for(int i=0; i < n; i++){
			num[i] = sc.nextInt();
		}
		
		int temp;
		int count = 0;
		for(int i=0; i <  num.length; i++){
			for(int j=num.length-1; j > i; j--){
				if(num[j] < num[j-1]){
					temp = num[j];
					num[j] = num[j-1];
					num[j-1] = temp;
					count++;
				}
			}
		}
		System.out.print(num[0]);
		for(int i=1; i < num.length; i++){
			System.out.print(" " + num[i]);
		}
		System.out.println();
		System.out.println(count);
	}
}

Measured memory_bytes: 19092
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> b(n-1),a(n);
    rep(i,n-1)cin>>b[i];
    a[0]=b[0],a[n-1]=b[n-2];
    for(int i=1;i<n-1;i++){
        a[i] = min(b[i-1],b[i]);
    }
    ll sum=accumulate(all(a),0);
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int num = 0;
		for(int i = 0 ; i <= 9 ; i++) {
			String[] s2 = s.split(Integer.toString(i), 2);
			if(s2.length == 1)
				continue;
			for(int j = 0 ; j <= 9 ; j++) {
				String s3[] = s2[1].split(Integer.toString(j), 2);
				if(s3.length == 1)
					continue;
				for(int k = 0 ; k <= 9 ; k++) {
					if(s3[1].contains(Integer.toString(k)))
						num++;

				}

			}

		}
		System.out.println(num);



	}

}


Measured memory_bytes: 28244
import sys
input = sys.stdin.readline
x = list(input())[: -1]
s = 0
t = 0
res = len(x)
for i in range(len(x)):
  if x[i] == "S":
    s += 1
  else:
    t += 1
    if s > 0:
      res -= 2
      s -= 1
print(res)

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , k ;
  cin >> n >> k ;
  vector<int> v(n+1);
  
  rep(i,n){
    int c ;
    cin >> c ;
    v.at(c) ++ ;
  }
  
  sort(all(v));
  reverse(all(v));
  
  int ans = n;
  rep(i,k) ans -= v.at(i) ;
  
  cout <<ans ;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    long long int k=0,l=0;
    char s[200000];
    scanf("%s",s);
    for(int i=0;s[i]!='\0';i++){
        if (s[i]=='B') {
            k++;
        }else{
            l=l+k;
        };
    };
    printf("%lld",l);
    return 0;
}

Measured memory_bytes: 384
N = int(input())
S = list(input())
e_ = [0 for i in range(N)]
w_ = [0 for i in range(N)]

e_c = S.count('E')
w_c = 0
for i in range(N):
    if S[i] == 'E':
        e_c -= 1
    e_[i] = e_c

    w_[i] = w_c
    if S[i] == 'W':
        w_c += 1


# print(e_)
# print(w_)
ans = 10**9
for i in range(N):
    ans = min(ans, w_[i]+e_[i])
print(ans)

Measured memory_bytes: 19832
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for (int i = 0; i <= m; ++i) c[i][0] = 0;
  for (int j = 1; j <= n; j++) c[0][j] = 0;

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X[i] == Y[j]) {
        c[i][j] = c[i-1][j-1] + 1;
      }
      else {
        c[i][j] = max(c[i-1][j], c[i][j-1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}



Measured memory_bytes: 7120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int ans = 0;
    for(int i=0; i<N; i+=2){
        ans += a[i];
    }
    for(int i=1; i<N; i+=2){
        ans -= a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	cin >> n;
	char s[n][101];
	for(int i = 0; i < n; i++) cin >> s[i];
	int flg = 1;
	for(int i = 1; i < n; i++){
		for(int j = 0; j < i; j++){
			if(strcmp(s[i], s[j]) == 0) flg = 0;
		}
		if(flg){
			int len = strlen(s[i - 1]);
			if(s[i - 1][len - 1] != s[i][0]) flg = 0;
		}
	}
	if(flg) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 998244353
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
const ll MAX = 200005;
ll fac[MAX], finv[MAX], inv[MAX];
void cmbinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i=2;i<MAX;i++) {
		fac[i] = fac[i-1]*i%MOD;
		inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i] = finv[i-1]*inv[i]%MOD;
	}
}
ll cmb(ll n, ll k) {
	if(n<k) return 0;
	if(n<0 || k<0) return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int main()
{
     cmbinit();
  ll n,m,k;
  ll val,ans=0;
  cin>>n>>m>>k;
  for(int i=n-k-1;i<=n-1;i++)
  {
       val=(fast_expo(m-1,i)*cmb(n-1,i))%MOD;
       val=(val*m)%MOD;
       ans=(ans+val)%MOD;
  }
  cout<<ans<<'\n';
}


Measured memory_bytes: 8344
program ee
    implicit none
    integer :: n
    character(10) :: s
    integer :: k
    integer :: i
    character :: m
    read(*,*)n
    read(*,*)s
    read(*,*)k
    m = s(k:k)
    do i = 1,n
        !TODO_statement
        if ( m /= s(i:i) ) then
            s(i:i) = '*'
        end if
    end do
    write(*,*)s
end program ee

Measured memory_bytes: 512
#include<stdio.h>
main()
{
	int n,a,b,i,p,q,sum=0,add=0;
	
	scanf("%d%d%d",&n,&a,&b);
	
	for(i=1;i<=n;i++)
	{  
	 q=i;
	 sum=0;
	while(q>0)
	{
		p=q%10;
		sum+=p;
		q=q/10;
	}
	if(sum>=a&&sum<=b)
	{
		add+=i;
	}
	}
	
	printf("%d",add);
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int s = 1;
  int sum = 1;
  
  for (int i = 0; i < n; i++) {
    if (s <= k) {
      sum *= 2;
      s *= 2;
    }
    
    else
      sum += k;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line1 = Console.ReadLine().Split();
            int W = int.Parse(line1[0]);
            int H = int.Parse(line1[1]);
            int N = int.Parse(line1[2]);
            int minX = 0;
            int minY = 0;
            for (int i = 0; i < N; i++)
            {
                var d = Console.ReadLine().Split().Select(int.Parse).ToArray();
                switch (d[2])
                {
                    case 1:
                        minX = Math.Max(minX, d[0]);
                        break;
                    case 2:
                        W = Math.Min(W, d[0]);
                        break;
                    case 3:
                        minY = Math.Max(minY, d[1]);
                        break;
                    case 4:
                        H = Math.Min(H, d[1]);
                        break;
                }
            }
            int ans = (W - minX) * (H - minY);
            if (W - minX < 0 || H - minY < 0)
                ans = 0;
            Console.WriteLine(ans);
        }
    }
}

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

long long int gcm(long long int a, long long int b)
{
	long long int i;

	long long int ansg = 0;

	for(i=a; i>0; i--){
		if(a%i == 0){
			if(b%i == 0){
				ansg = i;
				break;
			}
		}
	}
	return ansg;
}


long long int lcm(long long int a, long long int b)
{
  long long int r, tmp, x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }


	return x/b;
}



int main() {
  long long int  A, B, C, D, k, c_cnt = 0, d_cnt = 0, cd_cnt = 0;
  string S;
  vector<long long int> l_v, r_v, s_v;
  vector<vector<long long int>> hit_v;
  cin >> A >> B >> C >> D;
  k = B-A;

  c_cnt = (B/C) - (A/C);
  if (A%C == 0) c_cnt ++;
  d_cnt = (B/D) - (A/D);
  if (A%D == 0) d_cnt ++;
  long long int a = lcm(C, D);
  //cout << a << endl;
  cd_cnt = (B/a) - (A/a);
  if (A%a == 0) cd_cnt ++;
  cout << (B-A+1) -c_cnt -d_cnt +cd_cnt << endl;
  //cout << c_cnt << " " << d_cnt << " " << cd_cnt << " " << endl;

  // k - C - D + CD
  // k = 0;
  // long long int tmp = A / C;
  // k = (tmp-1)*C;
  // while (1) {
  //   k += C;
  //   if (k > B) break;
  //   if (A <= k) c_cnt++;
  // }
  // k = 0;
  // long long int tmp = A / D;
  // k = (tmp-1)*D;
  // while (1) {
  //   k += D;
  //   if (k > B) break;
  //   if (A <= k) d_cnt++;
  // }
  // k = 0;
  // long long int a = lcm(C, D);
  // long long int tmp = A / a;
  // k = (tmp-1)*a;
  // //cout << a << endl;
  // while (1) {
  //   k += a;
  //   if (k > B) break;
  //   if (A <= k) cd_cnt++;
  // }
  //cout << c_cnt << " " << d_cnt << " " << cd_cnt << " " << endl;
  // for (int i = 0; i < Q; i++) {
  //   long long int l, r;
  //   cin >> l >> r;
  //   l_v.push_back(l);
  //   r_v.push_back(r);
  // }

  // for (int i = 0; i < S.size()-1; i++) {
  //   if (S[i] == 'A' && S[i+1] == 'C') {
  //     cnt++;
  //     hit_v.push_back({i, i+1});
  //   }
  // }
  // for (int i = 0; i < Q; i++) {
  //   cnt = 0;
  //   for (int j = 0; j < hit_v.size(); j++) {
  //     if (l_v[i]-1 <= hit_v[j][0] && hit_v[j][1] <= r_v[i]-1) {
  //       cnt ++;
  //     }
  //     else if (hit_v[j][1] > r_v[i]-1) {
  //       break;
  //     }
  //   }
  //   cout << cnt << endl;
  // } 
  
  // char S[1000000] = {0};
  // vector<int> s_v, s_01v, s_10v;
  // cin >> S;
  // //cout << strlen(S) << endl;
  // for (int i = 0; i < strlen(S); i++) {
  //   s_v.push_back(S[i] - '0');
  //   switch(i%2) {
  //   case 0:
  //     s_01v.push_back(0);
  //     s_10v.push_back(1);
  //     break;
  //   case 1:
  //     s_01v.push_back(1);
  //     s_10v.push_back(0);
  //     break;
  //   }
  // }
  // long long int cnt_01 = 0, cnt_10 = 0;

  // for (int i = 0; i < strlen(S); i++) {
  //   if (s_01v[i] != s_v[i]) cnt_01++;
  //   if (s_10v[i] != s_v[i]) cnt_10++;
  // }
  // if (cnt_01 > cnt_10) {
  //   cout << cnt_10 << endl;
  // }
  // else {
  //   cout << cnt_01 << endl;
  // }
  // for (int i = 0; i < strlen(S); i++) {
  //   printf("%d ", s_v[i]);
  // }
  return 0;
}


Measured memory_bytes: 256
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;

    namespace ConsoleApp2
    {
        class Program
        {
        static string S;
        static long N;

            static void Main(string[] args)
            {
            N = long.Parse(Console.ReadLine());

            
            Console.WriteLine(N*2*PI);
           

            
            }

        static long zalgo(int k)
        {
            var len = N - k;
            var Z = new long[len];
            Z[0] = len;
            int i = k+1;
            int j = k;

            while (i < len)
            {
                while (i + j < len && S[j] == S[i + j]) j++;
                Z[i] = j;

                if(j == 0)
                {
                    i++;
                    continue;
                }

                int l = 1;
                while(l < j && l + Z[l] < j)
                {
                    Z[i + l] = Z[l];
                    l++;
                }
                i += l;
                j -= l;
            }

            long ans = 0;
            for (int w = 1; w < len; w++)
            {
                ans = Max(ans, Z[w]);
            }
            return ans;
        }
        }
}


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

int main() {
  string s;
  cin >> s;
  int sum = 0;
  rep(i, (int)s.size()) sum += s[i] - '0';
  if (sum % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ull a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    ull prod=1;
    sort(a,a+n);
    if(a[0]==0)
    {
        cout<<0;
    }
    else
    {
        bool flag=0;
        for(int i=0;i<n;i++)
        {
            if(prod<=1000000000000000000/a[i])
            {
                prod*=a[i];
            }
            else
            {
                flag=1;
                break;
            }
        }
        if(flag)
        {
            cout<<-1;
        }
        else cout<<prod;
    }
    return 0;
}

Measured memory_bytes: 4412
N,K=gets.split.map(&:to_i)
a=[0]+gets.split.map(&:to_i)
b={}
x=1
i=0
while i<K
  b[x]=i
  x=a[x]
  if b[x]
    d=i-b[x]+1
    i+=((K-i)/d-1)*d+1
    break
  else
    i+=1
  end
end
while i<K
  x=a[x]
  i+=1
end
p x

Measured memory_bytes: 38360
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll x;
  	ci(x);
  ll ans=1;
  FOR(i,1,x){
    FOR(j,2,x){
      ll a=pow(i,j);
      if(a<=x){
      ans=max(ans,a);
      }
    }
  }
  co(ans)
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n,m;
	cin >> n;
	set<string> se;
	map<string,int> s={};
	rep(i,0,n){
		string st;
		cin >> st;
		s[st]++;
		se.insert(st);
	}

	cin >> m;
	map<string,int> t={};
	rep(i,0,m){
		string tt;
		cin >> tt;
		t[tt]++;
		se.insert(tt);
	}
	
	int ans = 0xFFFFFFFF;
	for(auto itr = se.begin() ; itr != se.end() ; itr++ ){
		string str = *itr;
		int num = 0;

		num = s[str] - t[str];
		//cout << str << " " << s[str] << " " << t[str] << endl;
		ans = max(num,ans);

	}
	
	if(ans > 0)
		P(ans);
	else
		P(0);
	ret 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int D=1e9+7;
const int MAXN=5005;
int n,c[MAXN];
vector<int> ver[MAXN];
void upt(int &x,int y) {
	x=x+y<D?x+y:x+y-D;
}
int siz[MAXN],f[MAXN][MAXN],Tf[MAXN];
void dfs(int u,int fa) {
	siz[u]=1;
	f[u][1]=1;
	for(int v:ver[u]) if(v!=fa) {
		dfs(v,u);
		for(int i=1;i<=siz[u];i++)
			for(int j=0;j<=siz[v];j++)
				upt(Tf[i+j],1ll*f[u][i]*f[v][j]%D);
		siz[u]+=siz[v];
		for(int i=1;i<=siz[u];i++)
			f[u][i]=Tf[i],Tf[i]=0;
	}
	for(int i=2;i<=siz[u];i+=2)
		upt(f[u][0],(D-1ll*f[u][i]*c[i]%D)%D);
}

int main() {
	scanf("%d",&n);
	c[0]=1;
	for(int i=2;i<=n;i+=2)
		c[i]=1ll*c[i-2]*(i-1)%D;
	for(int i=1;i<n;i++) {
		int x,y; scanf("%d%d",&x,&y);
		ver[x].push_back(y);
		ver[y].push_back(x);
	}
	dfs(1,0);
	printf("%d\n",(D-f[1][0])%D);
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	long power=1;
	for(int i=1; i<=n; ++i){
		power = power *i %(long)(pow(10,9)+7);
	}
	cout << power << endl;
	return 0;
}

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

int main() {
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int count=0;
    for(int i=0;i<n;++i){
            if(s[i]==t[i]){
                count++;
            }
    }
    if(count==n){
        cout<<"Yes"<<endl;
    }
    else
    cout<<"No"<<endl;
    
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
string a,b,c;
int main()
{
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long ll;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

void File() {
#ifdef zjp_shadow
	freopen ("B.in", "r", stdin);
	freopen ("B.out", "w", stdout);
#endif
}

ll n, S;

inline bool Check(int val) {
	ll tmp = n, res = 0;
	for (; tmp; tmp /= val)
		res += tmp % val;
	return res == S;
}

int main () {

	File();

	cin >> n >> S;

	int gap = sqrt(n + .5);
	For (i, 2, gap)
		if (Check(i)) return printf("%d\n", i), 0;
	
	for (ll i = gap + 1, Nexti; i <= n; i = Nexti + 1) {
		Nexti = n / (n / i);
		ll res = (S - n);
		if (res % (n / i)) continue ;
		res = res / (n / i);
		ll b = - res + 1;
		if (i <= b && b <= Nexti)
			return printf ("%lld\n", b), 0;
	}

	if (n == S)
		return printf("%lld\n", n + 1), 0;

	puts("-1");

	return 0;

}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t a, b, c, d, e, f, g;
    cin >> a >> b >> c >> d >> e >> f >> g;

    auto t = a / 2 * 2 + d / 2 * 2 + e / 2 * 2;
    auto r = a % 2 + d % 2 + e % 2;
    if (r == 2 && a > 0 && d > 0 && e > 0) {
        t += 1;
    } else if (r == 3) {
        t += 3;
    }

    cout << b + t << endl;
}

Measured memory_bytes: 384
#include <string>
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string train,former,latter;
        cin >> train;
        typedef set<string> set_t;
        set_t C;
        for(int divp=1;divp<train.size();divp++){
            former=train.substr(0,divp);
            latter=train.substr(divp);
            C.insert(former+latter);
            C.insert(latter+former);
            reverse(former.begin(),former.end());
            C.insert(former+latter);
            C.insert(latter+former);
            reverse(latter.begin(),latter.end());
            C.insert(former+latter);
            C.insert(latter+former);
            reverse(former.begin(),former.end());
            C.insert(former+latter);
            C.insert(latter+former);
        }
        cout << C.size() << endl;
    }
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int a[2][230];
//int t[100005] , x[100005] , y[100005];
int gcd(int a , int b , int c)
{
		int x = __gcd(a ,b);
		return __gcd(x , c);
}
vector<int > r , g , b;
int dp[3][5000];
int main(){
	dhoom;
	int n;
	cin >> n;
	int a = 0 , b = 0 , c = 0 , d = 0;
	for(int i  = 0 ; i < n ;i++){
		char x;
		cin >> x;
		if(x == 'P')
			a = 1;
		if(x == 'W')
			b = 1;
		if(x == 'Y')
			c = 1;
		if(x == 'G')
			d = 1;
	}
	if(a && b && c && d)
		cout << "Four" << endl;
	else 
		cout << "Three" << endl;
	return 0;
}


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

const ll INF = 1e18;
const int MX = 2005;

int main() {
  double L;
  cin >> L;
  L = L/3;
  double ans = pow(L,3);
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int n;
int a[100005];

bool judge()
{
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i) return false;
	}
	return true;
}

int main()
{
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	long long step=0;
	while(!judge())
	{
		for(int i=1;i<=n;i++)
		{
			if(a[i]==i)
			{
				int t=a[i];
				a[i]=a[i+1];
				a[i+1]=t;
				step++;
			} 
		}
		if(a[n]==n)
		{
			int t=a[n];
			a[n]=a[n-1];
			a[n-1]=t;
			step++;
		} 
	}
	cout<<step<<endl; 
	return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
        //#include <ttmath.h>
        #define endl '\n'
        #define modulo 998244353
        #define int long long
        #pragma GCC optimize("-Ofast")
        #define float double
        #define PI 3.141592653589793238462643
        #define sinDegrees(x) sin((x) * PI / 180.0)
        #define tanDegrees(x) tan((x) * PI / 180.0)
        #define atanDegrees(x) atan(x)* 180.0 / PI
        using namespace std;
        int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x*temp%m)*temp%m)%m;
        }
        int inv(int x)
        {
        return (power(x,modulo-2,modulo))%modulo;
        }
        //#include "testlib.h"
        /*int main(int argc, char* argv[])
        {
        iostream::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        registerGen(argc, argv, 1);
        int n,k;
        n=rnd.next(1,50);
        k=rnd.next(1,n);
        cout<<n<<' '<<k;
        }*/
        ///Solution created by:Ahmadsm2005
        bool comp(int a,int b)
        {
            return a>b;
        }
        int32_t main()
        {
            //freopen("output.txt","w", stdout);
            //freopen("input0.txt","r", stdin);
            iostream::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
            int n;
            cin>>n;
            cout<<arr[n-1];
            return 0;
        }


Measured memory_bytes: 256
/*
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    WELCOME
***************************************************************************
                  .-"      "-.
                 /            \
                |              |
                |,  .-.  .-.  ,|
                | )(__/  \__)( |
                |/     /\     \|
      (@_       (_     ^^     _)
 _     ) \_______\__|IIIIII|__/__________________________
(_)@8@8{}<________|-\IIIIII/-|___________________________>
       )_/        \          /
      (@           `--------`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    MADRIS  IIT PATNA
**********************************************************************
*/




#include<bits/stdc++.h>
using namespace std;
#define vect vector<int>
#define lli long long int
#define mp make_pair
#define mod 1000000007
#define pb push_back




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

     lli n;
     cin>>n;
     lli arr[n];
     for(int i=0;i<n;i++){
        cin>>arr[i];
     }

     lli ans=0;
     int i=0;

     lli dp[n];
     dp[0]=0;
     dp[1]=abs(arr[0]-arr[1]);
     for(int i=2;i<n;i++){
        dp[i]=min(dp[i-2]+abs(arr[i-2]-arr[i]),dp[i-1]+abs(arr[i-1]-arr[i]));
     }

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

    return 0;
    }



/*
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  BANANA
****************************************************
                      ."`".
              .-./ _=_ \.-.
             {  (,(oYo),) }}
             {{ |   "   |} }
             { { \(---)/  }}
             {{  }'-=-'{ } }
             { { }._:_.{  }}
             {{  } -:- { } }
             {_{ }`===`{  _}
            ((((\)     (/))))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                SIGNING OFF
********************************************************

*/

Measured memory_bytes: 5156