akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[225816],b[225816],c[225816],d[225816];
int db[225816];
bool match[225816];

int main(void){
	int n,i,j;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	a[n] = a[0];
	for(i=0; i<n; ++i){
		cin >> b[i];
	}
	b[n] = b[0];
	for(i=0; i<n; ++i){
		c[i] = a[i]^a[i+1];
		d[i] = b[i]^b[i+1];
	}
	db[0] = -1; db[1] = 0;
	i = 2; j = 0;
	d[n] = (1ll<<32);
	while(i<=n){
		if(d[i-1] == d[j]){
			++j;
			db[i] = j;
			++i;
		}else if(j > 0){
			j = db[j];
		}else{
			db[i] = 0;
			++i;
		}
	}
	i = 0; j = 0;
	while(i<=n){
		if(c[(i+j)%n]==d[j]){
			++j;
			if(j==n){
				match[i] = true;
				i += j;
				i -= db[j];
				j = db[j];
			}
		}else{
			i += j;
			i -= db[j];
			if(j>0){
				j = db[j];
			}
		}
	}
	for(i=0; i<n; ++i){
		if(match[i] && (b[0]^a[i])==(b[1]^a[i+1])){
			cout << i << " " << (b[0]^a[i]) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 11136
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define pb  push_back
#define mp make_pair
#define ll long long
#define pr pair<int, int> 
#define vpr vector<pr> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define all(n) n.begin(),n.end()
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define Test printf("Case %d: ",tc++);
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
const int mod = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

ll pw (ll a, ll b){
	ll res = 1;
	while(b){
		if(b&1) res =( res * a ) % mod;
		a = (a*a)%mod;
		b>>=1;
	}

	return res;
}

ll cnt[N];

int solve() 
{
	//happy coding

	int n,k;
	cin>>n>>k;
	cnt[k] = 1;
	ll ans = k;

	for(int i=k-1;i>=1;i--){
		int rp = k/i;
		cnt[i] = pw(rp,n);
		for(int j=i+i;j<=k;j+=i){
			cnt[i] = cnt[i] + mod - cnt[j];
			if(cnt[i]>=mod){
				cnt[i] -= mod;
			}
		}

		ans += 1LL*cnt[i]* i;
		ans%=mod;
	}

	cout<<ans<<endl;


	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 4372
import math

n = int(input())
m = int(math.sqrt(n))



if n % m == 0:
    print(int(math.log10(m) + 1))

else:
    for i in range(1, m)[::-1]:
        if n % (i) == 0:
            print(int(math.log10(n / i) + 1))
            break


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, a[3] = {0, 0, 0}, b[3];
    scanf("%d", &n);
    bool yes = true;
    for(int i = 0, dis; i < n; ++i)
    {
        scanf("%d%d%d", &b[0], &b[1], &b[2]);
        dis = abs(b[1] - a[1]) + abs(b[2] - a[2]);
        yes &= (dis <= b[0] - a[0]) && (dis % 2 == (b[0] - a[0]) % 2);
        a[0] = b[0];
        a[1] = b[1];
        a[2] = b[2];
    }
    printf(yes ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back

int solve(const string& s) {
    vector<int> dp(1 << 26, TYPEMAX(int) / 2);

    dp[0] = 0;
    int cur = 0;
    for (int i = 0; i != SZ(s); ++i) {
        cur ^= (1 << (s[i] - 'a'));
        
        for (int let = 0; let != 26; ++let) {
            int go = cur ^ (1 << let);
            dp[cur] = min(dp[cur], dp[go] + 1);
        }
    }

    if (cur == 0)
        return 1;
    else
        return dp[cur];
}

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    string s = input<string>();
    cout << solve(s) << "\n";
    
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    ll N, K;
    cin >> N >> K;

    if(K % 2 == 1){
        cout << (N/K)*(N/K)*(N/K) << endl;
    }else{
        ll n, m;
        n = N / K;
        m = N / (K / 2) - n;
        cout << n*n*n + m*m*m << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

s, t = input(), input()
c = 0
for x, y in zip(s, t):
    if x == y:
        c += 1
print(c)


Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

	string s2 = "";
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != 'x') {
			s2 += s[i];
		}
	}

	string s3 = s2;
	reverse(s3.begin(), s3.end());

	string s4 = s;
	reverse(s4.begin(), s4.end());

	if (s2 == s3) {
		long long int a, a4;
		a = a4 = 0;
		long long int ans = 0;
		while (true) {
			if (a == s.size() && a4 == s4.size()) {
				break;
			}
			else if (a == s.size()) {
				ans++;
				a4++;
			}
			else if (a4 == s4.size()) {
				ans++;
				a++;
			} else if (s[a] == s4[a4]) {
				a++;
				a4++;
			}
			else if (s[a] == 'x') {
				a++;
				ans++;
			}
			else {
				a4++;
				ans++;
			}
		}
		cout << ans/2 << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
	int L, R, d;

	cin >> L >> R >> d;

	int counter = 0;

	for(int i = L; i <= R; i++)
	{
		if(i % d == 0)
		{
			counter++;
		}
	}

	cout << counter << endl;

    return 0;
}



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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 3010;
ll c[N][N];
ll s[N][N];
ll ways[N];
ll mod;

ll get_st(ll a, int st, ll m = mod) {
    //debug(mt(a, st, m));
    ll res = 1;
    while(st) {
        if (st & 1) {
            (res *= a) %= m;
        }
        (a *= a) %= m;
        st >>= 1;
    }
    return res;
}

ll tw[N * N];

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
    ll n;
    cin >> n >> mod;
    forn(i, N) {
        c[i][0] = 1;
        s[i][0] = 1;
    }
    forn(i, 1, N) {
        forn(j, 1, N) {
            (c[i][j] = c[i - 1][j] + c[i - 1][j - 1]) %= mod;
            (s[i][j] = s[i - 1][j - 1] + (j + 1) * s[i - 1][j]) %= mod;
        }
    }   
    
    debug('1');
    ll phi = 1;
    ll m = mod;
    for (int i = 2; i * i <= m; ++i) {
        if (m % i == 0) {
            phi *= i - 1;
            m /= i;
            while (m % i == 0) {
                phi *= i;
                m /= i;
            }    
        }        
    }
    if (m > 1) {
        phi *= m - 1;
    }

    debug('2');
    tw[0] = 1ll;
    forn(i, 1, N * N) {
        (tw[i] = tw[i - 1] * 2) %= mod;
    }

    forn(i, n + 1) {
        ways[i] = 0ll;
        ll st0 = get_st(2, get_st(2, n - i, phi));
        forn(j, i + 1) {
            (ways[i] += s[i][j] * tw[(n - i) * (j) % phi] % mod * st0) %= mod;
        }
    }

    debug('3');
    ll ans = 0;
    forn(i, n + 1) {
        ll sgn = ((i & 1)?(mod - 1):(1));
        (ans += sgn * c[n][i] % mod * ways[i]) %= mod;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 212608
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=b-1;i>=a;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

string S;

ll A[105];

int main(){
  ll  N,K;
  cin >> N;
  cin >> K;
  rep(i,K){
    ll D,X;
    cin >> D;
    rep(i,D){
      cin >> X;
      A[X]=1;
    }
  }
  ll ans=N;
  rep(i,N+1){
    if(A[i]==1){
      ans--;
    }
  }
  cout <<  ans << endl;
}

Measured memory_bytes: 3640
from collections import deque

N = int(input())
done = deque()
#探索スタート地点を「探索候補スタック」に積む
arr =  deque([N])
ans = 0
stop = 0
  
#while スタックが空っぽになるまで
while arr:
  a = arr.popleft()
  
  if a == -1:
    ans += 1
  
  done.append(a)
  Next = deque()
  if a-1 >= 0:
    Next.append(a-1)

  if a-46656 >= 0:
    Next.append(a-46656)
  elif a-7776 >= 0:
    Next.append(a-7776)
  elif a-1296 >= 0:
    Next.append(a-1296)
  elif a-216 >= 0:
    Next.append(a-216)
  elif a-36 >= 0:
    Next.append(a-36)
  elif a-6 >= 0:
    Next.append(a-6)

  if a-59049 >= 0:
    Next.append(a-59049)
  elif a-6561 >= 0:
    Next.append(a-6561)
  elif a-729 >= 0:
    Next.append(a-729)
  elif a-81 >= 0:
    Next.append(a-81)
  elif a-9 >= 0:
    Next.append(a-9)
    
  if -1 not in arr:
    arr.append(-1)
    

  while Next:
    i = Next.pop()
    if i in done:
      continue
    elif i in arr:
      continue
    else:
      arr.append(i)
      if i == 0:
        stop = 1
        break
  if stop == 1:
    break

print(ans+1)

Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;


int main() {
	int a[3];
	int b[2];
	for (int i = 0; i < 3; i++) cin >> a[i];
	for (int i = 0; i < 2; i++) cin >> b[i];

	sort(a, a + 3);
	sort(b, b + 2);

	cout << a[0] + b[0] - 50 << endl;
	
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ans=0;
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int k=0;k<=c;k++)
                if(i*500+j*100+k*50==x)
                    ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 25
#define NIL -1
struct tree {
        int parent;
        int left;
        int right;
};

void depth(int, int, struct tree*, int*);
int height(int, struct tree*, int*);
void disp(int, struct tree*, int*, int*);
main()
{
        struct tree t[MAX];
        int i, j, n, id, l, r, prec, root, d[MAX], h[MAX];
        scanf("%d", &n);
        for (i = 0; i < n; i++) {
                t[i].parent = NIL;
        }
    for(i = 0; i < n; i++) {
        scanf("%d %d %d", &id, &l, &r);
        t[id].left = l;
                t[id].right = r;
                if (l != -1) {
                        t[l].parent = id;
                }
                if (r != -1) {
                        t[r].parent = id;
                }
    }
    for (i = 0; i < n; i++) {
        if(t[i].parent == NIL) {
                        root = i;
                        break;
                }
        }
        depth(root, 0, t, d);
        height(root, t, h);
        for (i = 0; i < n ; i++) {
                disp(i, t, d, h);
        }
}
void depth(int u, int p, struct tree *t, int *d)
{
        d[u] = p;
        if (t[u].right != NIL) {
                depth(t[u].right, p + 1, t, d);
        }
        if (t[u].left != NIL) {
        depth(t[u].left, p + 1, t, d);
    }
}
int height(int u, struct tree *t, int *h)
{
        int h1 = 0, h2 = 0;
        if (t[u].right != NIL) {
        h1 = height(t[u].right, t, h) + 1;
    }
    if (t[u].left != NIL) {
        h2 = height(t[u].left, t, h) + 1;
    }
        return h[u] = (h1 > h2 ? h1 : h2);
}
void disp(int u, struct tree *t, int *d, int *h)
{
        int deg = 0;
        printf("node %d: parent = %d, ", u, t[u].parent);
        if (t[u].parent == NIL) {
                printf("sibling = -1, ");
        } else if (t[t[u].parent].left == u) {
                printf("sibling = %d, ", t[t[u].parent].right);
        } else {
                printf("sibling = %d, ", t[t[u].parent].left);
        }
        if (t[u].left != NIL) {
                deg++;
        }
        if (t[u].right != NIL) {
        deg++;
    }
        printf("degree = %d, depth = %d, height = %d, ", deg, d[u], h[u]);
        if (t[u].parent == NIL) {
                printf("root\n");
        } else if (t[u].left != NIL || t[u].right != NIL) {
                printf("internal node\n");
        } else {
                printf("leaf\n");
        }
}

Measured memory_bytes: 1856
import numpy as np
n, k = map(int, input().split())
R, S, P = map(int, input().split())
t = input()

hand = {
    "s": R,
    "p": S,
    "r": P,
}

hands = sorted(
    hand.items(), key=lambda x: x[1],
    reverse=True
)
r = np.zeros(n)
ans = 0
for j in range(3):
    a = hands[j][0]
    b = hands[j][1]
    for i in range(n):
        if t[i] == a:
            if t[i-k] == a and i+1 > k and r[i-k] == 1:
                continue
            else:
                ans += b
                r[i] = 1
        else:
            continue
print(ans)


Measured memory_bytes: 14948
#include<stdio.h>
int main(){
  int i,x;

		i=1;
	
	while(1){
		scanf("%d",&x);
	
		
		if(x == 0){
			break;
		}
		
		
			printf("Case %d: %d\n",i,x);
		i++;
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int x = values[a];
			values[a] = values[b];
			values[b] = x;
		}
		// values??????????????????
		for (int i = 0; i < values.length; i++)
			System.out.println(values[i]);
	}
}

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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int check = 1;
	// keisan
	for(int i=0;i<n;i++){
		if(a[i]%2 == 0){
			if(a[i]%3 != 0 && a[i]%5 != 0){
				check = 0;
			}
		}
	}
	// syutsuryoku
	if(check){
		cout << "APPROVED";
	}else{
		cout << "DENIED";
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#define SQ(x) ((x)*(x))
using namespace std;
int main(void){
  double x1,x2,y1,y2;
  scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
  printf("%.8f\n",sqrt(SQ(x1-x2)+SQ(y1-y2)));
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    cin >> s;
    OP(s[0] + to_string(s.size() - 2) + s[s.size() - 1]);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int r;
  cin >> r;
  cout << r*r << endl;
}


Measured memory_bytes: 256
while True :
    n = int(input())
    if n == 0 :
        break
    
    ice = list([0] * 10)
    for i in range(n) :
        ice[int(input())] += 1
    

    for i in range(10) :
        if ice[i] > 0 :
            for j in range(ice[i]) :
                print("*", sep="", end="")
            print()
        else :
            print("-")


Measured memory_bytes: 7588
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n) sum += a[i];
    sum /= 2;
    ll ex_last_sum = 0;
    for(int i = 0; i < n-1; i += 2) {
        ex_last_sum += a[i];
    }
    vector<ll> ans(n);
    ans[n-1] = sum-ex_last_sum;
    for(int i = n-2; i >= 0; i--) {
        ans[i] = a[i]-ans[i+1];
    }
    rep(i,n-1) cout << ans[i]*2 << " ";
    cout << ans[n-1]*2 << endl;
}

Measured memory_bytes: 2944
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
	ll a,b,c,x,y;
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
	ll ans = 2 * c * max(x,y);
	ans = min(ans,a*x+b*y);
	if(x<y){
		ans = min(ans,2*c*x+b*(y-x));
	}else{
		ans = min(ans,2*c*y+a*(x-y));
	}
	printf("%lld\n",ans);
}


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

using namespace std;

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    for(int h=0; h<H; h++) {
        for(int w=0; w<W; w++) {
            if((w<A && h<B) || (w>=A && h>=B)) {
                cout << 1;
            } else {
                cout << 0;
            }
        }
        cout << endl;
    }


    return 0;
    
}

Measured memory_bytes: 1280
/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
int n,m,s;
double a[105],sum;
int main(){
    read(n),read(m);
	fr(i,1,n)cin>>a[i],sum+=a[i];
	rf(i,n,1)if(a[i]>=sum/(4*m))++s;
	if(s>=m)puts("Yes");
	else puts("No"); 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<stdio.h>
#include<ctype.h>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int x = a - b * 2;
	if (x < 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << x << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int S;
    int h, m, s;
    int tmp;
    cin >> S;
    tmp = S;
    s = tmp % 60;
    tmp /= 60;
    m = tmp % 60;
    h = tmp / 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); ++i)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 1000005
#define MS(m,v) memset(m,v,sizeof(m))
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
typedef long long  ll;
typedef pair<int, int> P;

bool p[1000005];

int main()
{

	REP(i, 1000000) p[i] = true;
	p[0] = p[1] = false;
	for (int i = 2; i*i <= 1000000; i++)
	{
		if (p[i] == true)
		{
			for (int j = 2; j*i <= 1000000; j++)
			{
				p[i*j] = false;
			}
		}
	}
	int n;
	int ncpy;
	cin >> n;
	ncpy = n;
	cout << n << ": ";
	REP(i, 1000000){
		if (p[i]==true)
		{
			while (n%i==0)
			{
				cout << i ;
				n /= i;
				if (n>=i)cout << " ";
			}
		}
	}
	if (n==ncpy)
	{
		cout << n << endl;
	}
	else
	{
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <climits>
#include <cstring>
#include <string>
#include <bitset>
#include <cmath>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    if (k % 2 == 0) {
        cout << (k / 2) * (k / 2) << endl;
    } else {
        cout << (k / 2) * (k / 2 + 1) << endl;
    }
    return 0;
}

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

struct process{
  std::string name;
  int time;
};

int main(){
  int n, q;
  std::cin >> n;
  std::cin >> q;

  std::queue<process> que;
  for(int i = 0; i < n; i++){
    std::string name;
    int time;
    std::cin >> name;
    std::cin >> time;

    process p = {name, time};
    que.push(p);
  }

  int time = 0;
  while(!que.empty()){
    process p = que.front();
    if(p.time <= q){
      time += p.time;
      std::cout << p.name << " " << time << std::endl;
    }else{
      p.time -= q;
      time += q;
      que.push(p);
    }
    que.pop();
  }
  
  return 0;
}



Measured memory_bytes: 6216
solve :: String -> String
solve a
 | a == "SSR" = "1"
 | a == "SRS" = "1"
 | a == "RSS" = "1"
 | a == "RSR" = "1"  
 | a == "SRR" = "2"
 | a == "RRS" = "2"
 | a == "RRR" = "3"
 | otherwise = "0"

main = putStr =<< solve <$> getLine

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c,d,e,f=1;
  cin>>a>>b>>c>>d>>e;
  if(c<0||d<0){
    f=0;
  }
  if(a>=c+e&&b>=d+e&&f==1){
    cout<<"Yes"<<"\n";
  }
  else{
    cout<<"No"<<"\n";
  }
  return(0);
}



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

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

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

const ll MAX = 100100;

int main(int argc, char **argv)
{
	ll N; cin >> N;

	ll dp[MAX];
	for (ll i = 0; i < MAX; ++i) dp[i] = INF;

	dp[0] = 0;
	for (ll i = 0; i < N; ++i)
	{
		chmin(dp[i+1], dp[i] + 1);

		for (ll j = 1; i+pow(6ll,j) <= N; ++j)
			chmin(dp[i+static_cast<ll>(pow(6ll,j))], dp[i]+1);
		
		for (ll j = 1; i+pow(9ll,j)<= N; ++j)
			chmin(dp[i+static_cast<ll>(pow(9ll,j))], dp[i]+1);
	}

	std::cout << dp[N] << std::endl;
}


Measured memory_bytes: 1152
N = int(input())
l = [input() for _ in range(N)]
ans = 0
dic = {}
for n in range(N):
    new = sorted(l[n])
    if not str(new) in dic:
        count = 1
        dic[str(new)] = count
    else:
        ans += dic[str(new)]
        dic[str(new)] += 1
print(ans)

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

void fastio(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	return;
}
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
	if (n == 0)return 1;
	if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
	return (x * modexp((x * x) % md, n / 2, md)) % md;
}
vector<pair<pii,pii>>a(50);
int q,n,m,ans=0;
vi pm(10,0);
void check(int z1){
	if(z1==n){
		int temp=0;
		f(i,0,q){
			int x=a[i].second.first-1,y=a[i].second.second-1,c=a[i].first.second,d=a[i].first.first;
			if(pm[x]-pm[y]==c){
				temp+=d;
			}
		}
		ans=max(ans,temp);
		return;
	}
	if(z1==0){
		f(i,1,m+1){
			pm[z1]=i;
			check(z1+1);
		}
	}
	else{
		f(i,pm[z1-1],m+1){
			pm[z1]=i;
			check(z1+1);
		}
	}
}
int main() {
	fastio();
	//clock_t tm = clock();
	cin>>n>>m>>q;
	f(i,0,q){
		cin>>a[i].second.second>>a[i].second.first>>a[i].first.second>>a[i].first.first;
	}
	check(0);
	cout<<ans<<endl;
	//cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
    int W, H, x, y, r;
    
    cin >> W >> H >> x >> y >> r;
    
    if(r+x > W || r+y > H || x-r < 0 || y-r < 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    
}

Measured memory_bytes: 1156
#include<stdio.h>
int main()
{
	int x,kioku=0,kioku2;
	char a,mozi[21]={NULL};
	scanf("%s",mozi);
	for(x=0; x<21; x++)
	{
		if(mozi[x]==NULL)
			continue;
		kioku++;
	}
	kioku--;
	kioku2=kioku/2;
	for(x=0; x<=kioku2; x++)
	{
		a=mozi[x];
		mozi[x]=mozi[kioku-x];
		mozi[kioku-x]=a;
	}
	printf("%s\n",mozi);
	return 0;
}

Measured memory_bytes: 524
#include <cstdio>
#include <iostream>

using namespace std;

void FZT(int n, int *a) {
  for(int i=0; i<n; i++)
    for(int j=0; j<(1<<n); j++)
      if(!(j & (1<<i))) a[j] |= a[j | (1 << i)];
}

void FZT2(int n, int *a) {
  for(int i=0; i<n; i++)
    for(int j=0; j<(1<<n); j++)
      if((j & (1<<i))) a[j] |= a[j ^ (1 << i)];
}



int a[1<<20], b[1<<20];;

int main() {
  int N;

  scanf("%d", &N);

  for(int i=0; i<(1<<N); i++) {
    scanf("%d", a+i);
    b[i] = a[i];
  }

  FZT2(N, a);
  //FZT(N, a);

  for(int i=0; i<(1<<N); i++) {
    if(b[i] != a[i]) {
      puts("-1");
      return 0;
    }
  }

  int ans = 0;

  for(int i=0; i<(1<<N); i++) {
    if(!a[i]) continue;

    bool ok = true;

    for(int j=0; j< N; j++) {
      if (i & (1 << j)) {
        ok &= !a[i ^ (1<<j)];
      }
    }

    ans += ok;

  }


  cout << ans << endl;
}



Measured memory_bytes: 11428
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

/*
    Author: Koushik Sahu
    Created: 29 August 2020 Sat 17:33:09
*/

string s, t;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>s>>t;
    int n=s.length(), m=t.length();
    int ans = m;
    for(int i=0; i+m-1<=n-1; i++){
        int tmp = 0;
        for(int j=i; j<=i+m-1; j++){
            if(s[j]!=t[j-i]) tmp++;
        }
        ans = min(ans, tmp);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3616
p=lambda x,y,z:print(x,y,z);L=int(input());S=bin(L);N=len(S)-2;p(N,N+N+S.count("1")-3,"")
for i in range(1,N):
 p(i,-~i,0);p(i,-~i,1<<~-i)
 if int(S[-i]):L^=1<<~-i;p(i,N,L)

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

int main() {
    string N;
    cin >> N;
	for(int i=0;i<3;i++){
		if(N[i]=='7'){
			cout << "Yes" << endl;
			return 0;
		}
	}
    cout<< "No" <<endl;

    return 0;
}


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

int main() {
	int r, g, b, sum;
	cin >> r >> g >> b;
	r = 100 * r;
	g = 10 * g;
	sum = r + g + b;

	if (sum % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const ll inf = 1LL<<60;

int main()
{
  string s; cin >> s;
  reverse(s.begin(), s.end());
  s.push_back('0');
  int l = s.size();

  vector<vector<ll>> dp(l+1, vector<ll>(2, inf));
  dp[0][0] = 0;
  for (int i=0; i<l; i++) {
    for (int j=0; j<2; j++) {
      int n = s[i]-'0';
      n += j;
      for (int a=0; a<10; a++) {
        int b = a-n;
        if (b < 0) {
          b += 10;
          dp[i+1][1] = min(dp[i+1][1], dp[i][j]+a+b);
        } else {
          dp[i+1][0] = min(dp[i+1][0], dp[i][j]+a+b);
        }
      }
    }
  }
  cout << dp[l][0] << endl;

  return 0;
}


Measured memory_bytes: 56068
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
    int dp[100001];
    int go[100001];
    int visit[100001];
    vector<int> edge[100001];
    priority_queue<pair<int,int>> q;
    pair<int,int> tmp;
    int lx,x;
    int n,m;
    int a,b;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        dp[i]=1000000;
        visit[i]=0;
        go[i]=-1;
    }
    for(int i=0;i<m;i++)
    {
        scanf("%d %d",&a,&b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    go[1]=0;
    dp[1]=0;
    q.push(make_pair(0,1));
    while(!q.empty())
    {
        tmp=q.top();
        q.pop();
        x=tmp.second;
        lx=-tmp.first;
        if(visit[x]==0)
        {
            visit[x]=1;
            for(int i=0;i<edge[x].size();i++)
            {
                if(dp[edge[x][i]]>dp[x]+1)
                {
                    dp[edge[x][i]]=dp[x]+1;
                    go[edge[x][i]]=x;
                    q.push(make_pair(-dp[edge[x][i]],edge[x][i]));
                }
            }
        }
    }
    int chk=1;
    for(int i=1;i<=n;i++)
    {
        if(visit[i]==0)
        {
            chk=0;
            break;
        }
    }
    if(chk==0) printf("No\n");
    else
    {
        printf("Yes\n");
        for(int i=2;i<=n;i++)
        {
            printf("%d\n",go[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 11036
n=int(input())
da=list(map(str,input().split()))
me=[i for i in range(n)]
def mark(kop):
    return int(kop[1])

da1=da[:]
for i in range(n):
    for j in range(n-1,i,-1):
        x=mark(da1[j])
        y=mark(da1[j-1])
        if x<y:
            da1[j],da1[j-1]=da1[j-1],da1[j]

da2=da[:]
for i in range(n):
    mian=i
    for j in range(i,n):
        x=mark(da2[j])
        y=mark(da2[mian])
        if x<y:
            mian=j
    da2[i],da2[mian]=da2[mian],da2[i]
    me[i],me[mian]=me[mian],me[i]
ans=True
for i  in range(1,n):
    if mark(da2[i])==mark(da2[i-1]) and me[i]<me[i-1]:
        ans=False
        break

for i in range(n):
    if i==n-1:
        print(da1[i])
    else:
        print(da1[i],end=' ')
print('Stable')
for i in range(n):
    if i ==n-1:
        print(da2[i])
    else:
        print(da2[i],end=' ')
if ans:
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 5616
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		
		long[] a = new long[n];
		
		for(int i=0;i<n;i++) {
			a[i] = in.nextLong() - 1 - i;
		}
		
		Arrays.sort(a);
		
		int half = n/2;
		long b = a[half];
		
		long sum1 = 0;
		long sum2 = 0;
		
		for(int i=0;i<half;i++) {
			sum1 = sum1 + a[i];
		}
		for(int i=half;i<n;i++) {
			sum2 = sum2 + a[i];
		}
		
		long sumB = (half - n + half )* b;
		
		System.out.println(sum2 - sum1 + sumB);

	}

}

Measured memory_bytes: 65516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;

    vector<vector<ll>> xyz(N, vector<ll>(3));
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> xyz[i][j];

    ll ans = LLONG_MIN;
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for (int i = 0; i < 8; ++i) {
        for (int j = 0; j < N; ++j) {
            ll tmp = 0;
            for (int k = 0; k < 3; ++k)
                tmp += xyz[j][k] * (i & (1 << k) ? -1 : 1);
            que.push(tmp);
            if (que.size() > M)
                que.pop();
        }
        ll sum = 0;
        while (!que.empty()) {
            sum += que.top();
            que.pop();
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stdio.h>
using namespace std;

struct Dijkstra{

  typedef int Type;

  int V;
  vector<vector<pair<int,Type> > > G;
  vector<int> cost;
  
  Dijkstra(int n):
    V(n),G(n,vector<pair<int,Type> >()){}
  
  void add_edge(int u, int v, Type c){
    G[u].push_back({v,c});
  }
  
  Type solve(int s, int g = -1){
    cost.assign(V,-1);
    priority_queue<pair<Type,int> > pq;
    Type max_cost = 0;
    
    pq.push({0,s});

    while(pq.size()){
      Type now_cost = pq.top().first;
      int now = pq.top().second;
      pq.pop();

      if(cost[now] >= 0) continue;
      
      cost[now] = -now_cost;
      max_cost = max(max_cost, -now_cost);
      
      if(now == g) return -now_cost;
      
      for(int i=0;i<(int)G[now].size();i++){
        pq.push({now_cost-G[now][i].second, G[now][i].first});
      }
    }
        
    return -1;
  }
  
};


int main(void){
    // Your code here!
    int N,M,L,K,A,H;
    while(1){
        scanf("%d %d %d %d %d %d",&N,&M,&L,&K,&A,&H);
        if(N==0)return 0;
        long long int d[N][N];
        int po[L+2];
        for(int i=0;i<L;i++)scanf("%d",&po[i]);
        po[L]=A;
        po[L+1]=H;
        for(int i=0;i<N;i++)for(int j=0;j<N;j++)d[i][j]=(i==j?0:1145141919);
        for(int i=0;i<K;i++){
            int x,y;
            long long int z;
            scanf("%d %d %lld",&x,&y,&z);
            d[x][y]=z;
            d[y][x]=z;
        }
        for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++)if(d[i][j]>d[i][k]+d[k][j])d[i][j]=d[i][k]+d[k][j];
        Dijkstra pomu(N);
        for(int i=0;i<L+2;i++)for(int j=0;j<L+2;j++){
            if(d[po[i]][po[j]]<=M){
                pomu.add_edge(po[i],po[j],d[po[i]][po[j]]);
                pomu.add_edge(po[j],po[i],d[po[j]][po[i]]);
            }
        }
        
        if(pomu.solve(A,H)!=-1)printf("%d\n",M>pomu.solve(A,H)?pomu.solve(A,H):pomu.solve(A,H)*2-M);
        else printf("Help!\n");
        
    }
}


Measured memory_bytes: 3500
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char s[200005],t[200005];
int h,w,n,sr,sc;
int ss[200005][4],st[200005][4];
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	scanf("%d%d",&sr,&sc);
	scanf("%s%s",s+1,t+1);
	for(int i=1;i<=n;i++)
	{
		ss[i][0]=ss[i-1][0];
		ss[i][1]=ss[i-1][1];
		ss[i][2]=ss[i-1][2];
		ss[i][3]=ss[i-1][3];
		st[i][0]=st[i-1][0];
		st[i][1]=st[i-1][1];
		st[i][2]=st[i-1][2];
		st[i][3]=st[i-1][3];
		if(s[i]=='L')ss[i][0]++;
		if(s[i]=='R')ss[i][1]++;
		if(s[i]=='U')ss[i][2]++;
		if(s[i]=='D')ss[i][3]++;
		if(t[i]=='L'&&sc-st[i][0]+ss[i][1]>1)st[i][0]++;
		if(t[i]=='R'&&sc+st[i][1]-ss[i][0]<w)st[i][1]++;
		if(t[i]=='U'&&sr-st[i][2]+ss[i][3]>1)st[i][2]++;
		if(t[i]=='D'&&sr+st[i][3]-ss[i][2]<h)st[i][3]++;
		if(ss[i][0]>=st[i-1][1]+sc)
		{
			printf("NO\n");
			return 0;
		}
		if(ss[i][1]>=st[i-1][0]+w-sc+1)
		{
			printf("NO\n");
			return 0;
		}
		if(ss[i][2]>=st[i-1][3]+sr)
		{
			printf("NO\n");
			return 0;
		}
		if(ss[i][3]>=st[i-1][2]+h-sr+1)
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 6784
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        Main instance = new Main();
        instance.solve();
    }

    private void solve() {
        try {
            int n = sc.nextInt();
            int y = sc.nextInt();

            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    int k = n - i - j;
                    if (k < 0) {
                        continue;
                    }
                    if (i * 10000 + j * 5000 + 1000 * k == y) {
                        System.out.println(i + " " + j + " " + k);
                        return;
                    }
                }
            }
            System.out.println("-1 -1 -1");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		Integer[] l = new Integer[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}

		int count = 0;
		int bound = 1;
		for (int i = 0; i < n; i++) {
			count = count + l[i];
			if (count <= x) {
				bound++;
			} else {
				break;
			}
		}
		System.out.println(bound);

	}

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k) cout<<k;
    else if((a+b)>=k){
        cout<<a;
    }
    else if((a+b+c)>=k){
        cout<<a-(k-a-b);
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
using namespace std;
typedef long long int ll;


int main() {

	vector<string> str;
	int kazu;
	int n;
	cin >> n;
	char shiri;

	for (int i = 0; i < n; i++) {
		char c[11];
		cin >> c;
		str.push_back(c);
	}

	for (int i = 0; i < n; i++) {
		if (i != 0 && shiri != str[i][0]) { cout<< "No" << endl; return 0; }
		for (int k = i-1; k >= 0; k--) {
			if (str[k] == str[i]) { cout <<"No" << endl; return 0; }
		}
		for (int j = 0; str[i][j] != '\0'; j++) { kazu = j; }
		shiri = str[i][kazu];
	}

	cout << "Yes" << endl;


	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%MOD;
    a=a*a%MOD;
    n/=2;
  }
  return ans;
}

ll kai(ll n){
  ll fac[n+1];
    fac[0]=fac[1]=1;
    for (int i=2;i<=n;i++){
    fac[i]=fac[i-1]*i%MOD;
  }
  return fac[n];
}

int main(){
  cout << fixed << setprecision(10);
  int N; cin >> N;
  vector<double> x(N);
  vector<double> y(N);
  rep(i,N){
    cin >> x[i] >> y[i];
  }
  vector<int> v(N);
  rep(i,N) v[i]=i;
  double sum=0;
  do{
    rep(i,N-1){
      sum+=sqrt(rui((x[v[i+1]]-x[v[i]]),2)+rui((y[v[i+1]]-y[v[i]]),2));
    }
  }while(next_permutation(all(v)));
  double ans=sum/kai(N);
  cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int n; cin>>n;
    vector<int>b(n);
    rep(i,n)cin>>b[i];
    vector<int>ans(n);
    int mx=0;
    bool jud=false;
    int cnt=0;
    rep(i,n){
        rep(j,b.size()){
               if(b[j]==j+1){
            mx=max(j,mx);
            jud=true;
        }
        }
        if(jud){
            b.erase(b.begin()+mx);
            ans[cnt]=mx+1;
            cnt++;
            mx=0;
            jud=false;
        }
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    reverse(ans.begin(),ans.end());
    rep(i,n){
        cout<<ans[i]<<endl;
    }
}








Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
 int N,p[100],i,j;

  scanf("%d",&N);
  j=0;
 for(i=0;i<N;i++){
  scanf("%d",&p[i]);
 if(p[i]!=i+1)
  j++;
 }

 if(j<=2)
 printf("YES\n");
 else
 printf("NO\n");

 return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  char c;in(c);
  string s="abcdefghijklmnopqrstuvwxyz";
  out(s[c-'a'+1]);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

int main(int argc, char const *argv[]) {
  int h, w;

  cin >> h >> w;

  while (!(h == 0 && w == 0)) {
    for (int i = 0; i < h; i++) {
      if (i == 0 || i == h - 1) {
        for (int j = 0; j < w; j++) {
          cout << "#";
        }
      } else {
        for (int j = 0; j < w; j++) {
          if (j == 0 || j == w - 1) {
            cout << "#";
          } else {
            cout << ".";
          }
        }
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }

  return 0;
}


Measured memory_bytes: 3012
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

 ll int A,B;

 cin >> A >> B;
  ll int a,b;
  a = A ;
  b = B;
 ll int r;


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

 r = a%b;
if(r == 0){
	break;
}
else{
 a = b;
 b = r;
}
}
cout << (A/b)*B;










	return 0;

}



Measured memory_bytes: 256