akhauriyash/Code-Regression huggingface dataset:
def resolve():
    def lcm(X, Y):
        x = X
        y = Y
        if y > x:
            x, y = y, x
        while x % y != 0:
            x, y = y, x % y
        return X * Y // y
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9 + 7
    lsd = a[0]
    for i in range(1, n):
        lsd = lcm(lsd, a[i])
    lsd = lsd % mod

    ans = 0
    for i in range(n):
        ans += (lsd * pow(a[i], mod-2, mod)) % mod

    print(int(ans % mod))

resolve()

Measured memory_bytes: 4084
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

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

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N, W = il()
    VW = [il() for _ in range(N)]
    dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

    for i in range(N):
        for w in range(W+1):
            if w >= VW[i][1]:
                dp[i+1][w] = max(VW[i][0] + dp[i][w-VW[i][1]], dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    print(dp[N][W])


if __name__ == '__main__':
    main()



Measured memory_bytes: 43792
#include<cstdio>
#include<cstdlib> 
#include<algorithm>
#include<map>
using namespace std;
map<int,int>mp;
const int N=100010;
struct node{
	int v,p;
	bool operator<(const node&other)const{
	return v>other.v;}
}vis1[N],vis2[N];
int main()
{
	int n,cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		if(!mp[a])mp[a]=++cnt;
		if(i&1){
			vis1[mp[a]].p=mp[a];
			vis1[mp[a]].v++; 
		}
		else{
			vis2[mp[a]].p=mp[a];
			vis2[mp[a]].v++;
		}
	}
	sort(vis1+1,vis1+1+cnt);
	sort(vis2+1,vis2+1+cnt);
	int l1=1,l2=1;
	if(vis1[l1].p==vis2[l2].p){
		if(vis1[l1+1].v+vis2[l2].v>vis1[l1].v+vis2[l2+1].v)l1++;
		else l2++;
	}
	printf("%d\n",n-vis1[l1].v-vis2[l2].v);
	return 0;
}

Measured memory_bytes: 6528
h, w = map(int, input().split())
s = [input() for _ in range(h)] 

d = {(i, j):c for i, row in enumerate(s) for j, c in enumerate(row)}

surrounds = ((-1, 0), (1, 0), (0, -1), (0, 1))
def black_in_surrounds(i, j):
    return any(d.get((i+a, j+b), '.') == '#' for a, b in surrounds)

if all(black_in_surrounds(i, j) for (i, j), c in d.items() if c == '#'):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    if(b==0){
        return a;
    }
    int x=b;
    return gcd(b,a%b);
}
int gcd3(int a,int b,int c){
    return gcd(a,gcd(b,c));
}
int main(){
    int n;
    cin>>n;
    long long int sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                int x=gcd3(i,j,k);
                sum+=x;
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include <string>

#define ll long long

using namespace std;

int n;
vector<pair<int, int>> v;
int can[3001][3001];


int main() {
    int m, k;
    cin >> m >> k;

    if (m == 0) {
        if (k != 0) printf("-1");
        else printf("0 0");
        return 0;
    }
    if (m == 1) {
        if (k != 0) printf("-1");
        else printf("0 0 1 1");
        return 0;
    }

    if (k >= (1 << m)) {
        printf("-1");
        return 0;
    }

    for (int i = 0; i < (1 << m); i++) {
        if (i != k) printf("%d ", i);
    }
    printf("%d ", k);
    for (int i = (1 << m) - 1; i >= 0; i--) {
        if (i != k) printf("%d ", i);
    }
    printf("%d ", k);
}


Measured memory_bytes: 3768
using System;
using System.Collections.Generic;

namespace AtCoder0106_4
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int h = int.Parse(input[1]);
            List<int> a = new List<int>();
            List<int> b = new List<int>();
            int maxa = 0;

            for (int i = 0; i < n; i++)
            {
                string[] ken = Console.ReadLine().Split(' ');
                a.Add(int.Parse(ken[0]));
                a.Add(int.Parse(ken[1]));
                if (maxa < int.Parse(ken[0]))
                {
                    maxa = int.Parse(ken[0]);
                }
            }

            a.Sort();
            a.Reverse();

            int nokorih = h;
            int num = 0;
            for (int i = 0; i < 2*n; i++){
                if(nokorih <= 0){
                    break;
                }
                if(maxa < a[i]){
                    nokorih -= a[i];
                    num++;
                }
            }

            if(nokorih <= 0){
                // do nothing
            }else if(nokorih%maxa == 0){
                num += nokorih / maxa;
            }else{
                num += nokorih / maxa + 1;
            }

            Console.WriteLine(num);
        }
    }
}


Measured memory_bytes: 17288
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#pragma GCC optimize ("trapv")
using namespace std;

#define pii pair<int, int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define DEBUG 1
#define cerr if (DEBUG) cerr
#define test cerr << "hi\n";

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<long long>(l, r)(rng)
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define INF 0x3f3f3f3f3f3f3f3f
#define MAXN 500005
//#define MOD 998244353LL
#define MOD 1000000007LL

int n;
int a[MAXN];
int sorted[MAXN];

long long T1[MAXN], T2[MAXN];
long long* f[2];

#define SHIFT 100105

void add(long long T[], int x, long long v) {
    for (; x < MAXN; x += x&-x)
        T[x] += v;
}

long long sum(long long T[], int x) {
    long long ans = 0;
    for (; x; x -= x&-x)
        ans += T[x];
    return ans;
}

int work1(int x) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int len = 1; len+i<=n; len++) {
            vector<int> v;
            for (int j = i; j < i+len; j++)
                v.pb(a[j]);
            sort(v.begin(), v.end());
//            for (int x : v)
//                cerr << x << ' ';
//            cerr << " med " << v[len/2] << '\n';
            if (v[len/2] <= x) ans++;
        }
    }
//    cerr << "work " << x << ' ' << ans << '\n';
    return ans;
}

long long work(int x) {
    long long ans = 0;
    vector<pii> slots;
//    cerr << "---------\n";
//    cerr << "work " << x << '\n';

    for (int i = 0, ps = 0; i < n; i++) {
        add(f[(i%2)^1], ps+SHIFT, 1);
        slots.pb(mp((i%2)^1, ps+SHIFT));

        if (a[i] <= x)
            ps++;
        else
            ps--;


        int s1 = sum(f[(i%2)^1], ps-1 + SHIFT);
        int s2 = sum(f[(i%2)], ps-2 + SHIFT);

//        cerr << "ps " << ps << ' ' << s1 << ' ' << s2 << '\n';

        ans += s1 + s2;
    }

    for (auto op : slots)
        add(f[op.fi], op.se, -1);

    // cur - pref >= 1
    // pref <=
    // pref = cur-1

//    cerr << " ret " << ans << '\n';

    return ans;
}

void solve() {
    f[0] = T1;
    f[1] = T2;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    sort(sorted, sorted+n);

    int hi = n, lo = -1;
    while (hi-lo>1) {
        int mi = (hi+lo)/2;
        if (work(sorted[mi]) >= ((long long)n*(n+1)/2)/2+1) hi = mi;
        else lo = mi;
    }
//    cout << hi << '\n';
    cout << sorted[hi] << '\n';
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    auto start_time = clock();
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
//    cin >> t;
    for (int no = 1; no <= t; no++) {
//        cout << "Case #" << no << ": ";
        solve();
    }

#ifdef LOCAL
    cerr << "TIME ELAPSED: " << double(clock() - start_time) / CLOCKS_PER_SEC << '\n';
#endif
}

Measured memory_bytes: 7428
#include <bits/stdc++.h>
#define reps(i,j,k) for(int i=j;i<k;++i)
#define rep(i,j) reps(i,0,j)
#define fr first
#define sc second
#define fs fr
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef long long ll;

int f(int a, int l){
	vi v(l);
	int idx = 0;
	while(a>0){
		v[idx++] = a%10;
		a/=10;
	}
	sort(v.begin(), v.end());
	int bg = 0, sm = 0;
	rep(i,l){
		bg = bg * 10 + v[l-1-i];
		sm = sm * 10 + v[i];
	}
	return bg - sm;
}

int main(){
	int a, l;
	while(cin >> a >> l, l){
		map<int, int> memo;
		memo[a] = 1;
		int ans = 1;
		for(;;){
			a = f(a, l);
			if(memo[a]){
				cout << memo[a]-1 << " " <<  a << " " << ans - memo[a] + 1 << endl;
				break;
			}
			memo[a] = ++ans;
		}
	}
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int h,w,d; cin>>h>>w>>d;
    vector<P> p(h*w);
    rep(i,h){
        rep(j,w){
            int a; cin>>a;
            a--;
            p[a]={i,j};
        }
    }
    vector<int> cost(h*w,0);
    rep(i,d){
        for(int j=i; j<h*w-d; j+=d){
            cost[j+d]=cost[j]+abs(p[j+d].first-p[j].first)+abs(p[j+d].second-p[j].second);
        }
    }
    int qqq; cin>>qqq;
    rep(qqqq,qqq){
        int r,l; cin>>l>>r;
        l--; r--;
        ll ans=0;
        ans=cost[r]-cost[l];
        cout<<ans<<endl;
    }
    return 0;
}

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

ll calc_m(string s){
    stack<ll> num;
    stack<char> ope;
    for(auto c : s){
        if(c >= '0' && c <= '9'){
            num.push(c-'0');
            if(!ope.empty() && ope.top() == '*'){
                ll n1, n2;
                n2 = num.top(), num.pop();
                n1 = num.top(), num.pop();
                num.push(n1*n2);
            }
        }
        else ope.push(c);
    }
    ll res = 0;
    while(!num.empty()){
        res += num.top();
        num.pop();
    }
    return res;
}

ll calc_l(string s){
    ll res = s[0] - '0';
    for(int i=1;i<int(s.size());i+=2){
        if(s[i]=='+'){
            res += s[i+1]-'0';
        }
        else{
            res *= s[i+1]-'0';
        }
    }
    return res;
}

int main() {
    string s;
    ll x, m, l;
    cin >> s >> x;
    m = calc_m(s);
    l = calc_l(s);
    if(x==m && x!=l){
        cout << 'M' << endl;
    }
    else if(x!=m && x==l){
        cout << 'L' << endl;
    }
    else if(x==m && x==l){
        cout << 'U' << endl;
    }
    else{
        cout << 'I' << endl;
    }
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    ll h, n;
    cin >> h >> n;
    int hp=h;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        hp -= a;
    }
    if(hp <= 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<cctype>
#include<string.h>


int main(void){

	char s[1200];
	int i;

	gets(s);

	for(i=0;i<strlen(s);i++){
		if(s[i] <= 'z' && s[i] >= 'a')
			printf("%c",toupper(s[i]));
		else
			printf("%c",tolower(s[i]));
	}
	puts("");

	return 0;

}

Measured memory_bytes: 928
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n;
    cin >> n;
    vector<int> idx(n + 1);
    rep(i, n) {
        int a;
        cin >> a;
        idx[a] = i + 1;
    }
    
    ll ans = 0;
    set<int> st = {0, n + 1};
    repr(a, 1, n + 1) {
        auto it = st.upper_bound(idx[a]);
        int r = *it;
        int l = *(--it);
        ans += ll(a) * (idx[a] - l) * (r - idx[a]);
        st.insert(idx[a]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 10368
import collections as col

n = int(input())
a = [0] + list(map(int,input().split()))

def binp(arr, val):
    left,right = 0,len(arr)-1
    while left <= right:
        mid = (left+right)//2
        if val==arr[mid]: return 1
        elif val>=arr[mid]: left = mid+1
        else: right = mid-1
    return 0

ap = [a[i] + i for i in range(1,n+1)]
an = [i - a[i] for i in range(1,n+1)]
counter = col.Counter(an)

ans = 0
for ele in ap:
    ans += counter[ele]

print(ans)


Measured memory_bytes: 50524
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define MAX 1001

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    int arr[MAX];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", arr + i);
    }

    int q, comment, b, e;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &comment);
        if (comment == 1)
        {
            scanf("%d %d", &b, &e);
            int maxNum = arr[b];
            for (int loop= b + 1; loop < e; loop++)
            {
                maxNum = max(maxNum, arr[loop]);
            }
            printf("%d\n", maxNum);
        }
        else
        {
            scanf("%d %d", &b, &e);
            int minNum = arr[b];
            for (int loop = b + 1; loop < e; loop++)
            {
                minNum = minNum < arr[loop] ? minNum : arr[loop];
            }
            printf("%d\n", minNum);
        }
    }


    return 0;
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod 1e9+7
#define P(a,b) pair<a,b>
#define CIN(V,s,n) for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}

using namespace std;
bool sortBylen(string &a,string &b)
{
    if(a.size()>b.size())
        return true;
    else if(a.size()==b.size())
    {
        if(a>b)
        {
            return true;
        }
        else
            false;
    }
    else
        return false;
}
int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,i,j,k,l,m;
    cin >> n >> k;
    vector<ll> dp(n+1,1e9),h(n+1);
    CIN(h,1,n+1);
    dp[0]=0;
    dp[1]=0;
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(i-j>0)
            {
                dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }

    cout << dp[n] << endl;


}

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<'\n'
using namespace std;


int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int n; cin >> n;
	rep(i, 101) rep(j, 101) if(4 * i + 7 * j == n){
		print("Yes");
		return 0;
	}
	print("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n;
    cin>>n;
    
    ll total = 0ll;
    vector<ll> s(n+1,0ll);
    for(ll i =0; i<=n; i++){
        ll e;
        cin>>e;
        s[i]=e;
        total += e;
    }
    
    if(s[0]>1){
        cout<<-1<<endl;
        return 0;
    }
    
    if(s[0]==1 && total>1){
        cout<<-1<<endl;
        return 0;
    }
    
    if(s[0]==1 && total==1){
        cout<<1<<endl;
        return 0;
    }
    
    ll ans = 1ll;
    
    ll sum = 1;
    
    
    for(int i=1; i<=n; i++){
        ll m = min(2*sum, total);
        ans+=m;
        sum = m-s[i];
        if(sum<0){
            cout<<-1<<endl;
            return 0;
        }
        total -= s[i];
        
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 4000
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;


//trueで埋め尽くせ！
int f(vector<bool>wh)
{
	int res = 0;
	for (;;)
	{
		bool flag = true;
		for (bool b : wh)flag &= b;
		if (flag)return res;
		vector<bool>nxt;
		for (int i = 1; i < wh.size(); ++i)
		{
			nxt.push_back(wh[i - 1] | wh[i]);
		}
		wh = nxt;
		++res;
	}
}

int main(void)
{
	int ans = 1234567;
	string s;
	cin >> s;
	for (char c = 'a'; c <= 'z'; ++c)
	{
		vector<bool>wh;
		for (char ss : s)wh.push_back(ss == c);
		ans = min(ans, f(wh));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<deque>
#include<string>
#include<stack>
using namespace std;

map<int, int>m;
signed main() {
	int a; cin >> a;
	for (int i = 0; i < a; i++) {
		int b; cin >> b;
		m[b]++;
	}
	int b; cin >> b;
	for (int c = 0; c < b; c++) {
		int d; cin >> d;
		if (m[d]) {
			m[d]--;
		}
		else {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}


Measured memory_bytes: 9984
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string A,B;
    cin>>A>>B;
    
    if(A.length()>B.length()){
        cout<<"GREATER"<<endl;
    }else if(A.length()<B.length()){
        cout<<"LESS"<<endl;
    }else{
        if(A>B){
            cout<<"GREATER"<<endl;
        }else if(A<B){
            cout<<"LESS"<<endl;
        }else{
            cout<<"EQUAL"<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    ll n, m, d;
    cin >> n >> m >> d;

    double ans = (n-d) * (m-1) / (double)(n*n);
    if (d != 0) ans *= 2;

    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(x) for x in input().split()]


    ans = float("inf")
    for j in range(-101, 101):
        tmp = 0
        for i in A:
            tmp += (i - j) ** 2

        ans = min(ans, tmp)

    print(ans)


    
    

if __name__ == '__main__':
    main()


#2
#-1 -4
#5

Measured memory_bytes: 3060
// ------- PBDS ------ //
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// ------- PBDS ------ //

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define testcase ll tt; cin>>tt; while(tt--)
#define pb push_back
#define nn cout<<"\n"
#define MOD 1000000007
#define pi 3.1415926535
#define endl "\n"
#define vll vector<ll>
#define MULTI int T; cin >> T; while(T--)
#define all(a)      (a).begin(),(a).end()
#define here cout<<"I'm here\n";
void vout(vector<ll> ans){
    for(auto ele:ans) cout<<ele<<" "; cout<<endl;
}
vector<ll> adj[200001];
bool vis[200001];

// ------- PBDS ------ //
typedef tree<
// change this for any data-type
string,
null_type,
// change this for any data-type
less<string>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

/*
    to get the position of an element in set , do
    s.order_of_key(ele);
    this returns the number of elements strictly lesser than ele in set s
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    s.order_of_key(6) : Count of elements strictly smaller than 6 is 2.
    s.order_of_key(25) : Count of elements strictly smaller than 25 is 4.

    to get the element at position k
    s.find_by_order(k);
    returns an iterator to the ele counting from 0
    Let us assume we have a set s : {1, 5, 6, 17, 88}, then :
    *(s.find_by_order(2)) : 3rd element in the set i.e. 6
    *(s.find_by_order(4)) : 5th element in the set i.e. 88
*/

// ------- PBDS ------ //

clock_t time_p=clock();
void purvansh11()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

//BINARY EXPONENTIATION  -- O(log2(b))
ll power(ll a, ll b) {
    /*
        for 3^11 :
        as 11 -> 1011, we mean 3^8 * 3^2 * 3^1
        so multiply for all ones in binary rep of b
    */

    ll ans = 1;
    ll num = a;
    while (b > 0) {
        if (b & 1) ans = ((ans % MOD) * (num % MOD)) % MOD;
        num = ((num % MOD) * (num % MOD)) % MOD;
        b /= 2;
    }
    return ans;
}
ll dp[1001][1001];
ll n,m;
char arr[1001][1001];
ll solve(ll i,ll j){
    if(i>=n or j>=m) return 0;
    if(arr[i][j] == '#') return 0;
    if(i==n-1 and j==m-1) return 1;

    if(dp[i][j]!=-1) return dp[i][j];

    ll a = 0;
    ll b = 0;
    if(j+1<m){
        a = solve(i,j+1);
    }
    if(i+1<n){
        b = solve(i+1,j);
    }

    return dp[i][j] = (a%MOD+b%MOD)%MOD;
}

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

    SPEED;
    cout.precision(8);
    cout << fixed;
    cin>>n>>m;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            cin>>arr[i][j];
        }
    }   
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0);
    purvansh11();
    return 0;
}

Measured memory_bytes: 17372
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::BinaryHeap;
use std::io::*;
use std::str::FromStr;
use superslice::*;

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

//abc160-E
#[fastout]
fn main() {
    input![
        X: usize,
        Y: usize,
        a: usize,
        b: usize,
        c: usize,
        p_input: [i64; a],
        q_input: [i64; b],
        r_input: [i64; c],
    ];

    let mut p = BinaryHeap::from(p_input);
    let mut q = BinaryHeap::from(q_input);
    let mut r = BinaryHeap::from(r_input);

    // let read_closure = |v: &mut BinaryHeap<i128>, count| {
    //     for _ in 0..count {
    //         v.push(read());
    //     }
    // };

    // read_closure(&mut p, a);
    // read_closure(&mut q, b);
    // read_closure(&mut r, c);

    let (mut x, mut y, mut z) = (0, 0, 0);

    let mut ans = 0;
    while x + y + z < X + Y {
        let a_max = if x == X { -1 } else { *p.peek().unwrap() };
        let b_max = if y == Y { -1 } else { *q.peek().unwrap() };
        let c_max = *r.peek().unwrap_or(&-1);

        if a_max >= b_max && a_max >= c_max {
            ans += a_max;
            x += 1;
            p.pop();
        } else if b_max >= c_max && b_max >= a_max {
            ans += b_max;
            y += 1;
            q.pop();
        } else if c_max >= a_max && c_max >= b_max {
            ans += c_max;
            z += 1;
            r.pop();
        }
    }

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

fn go(mid: usize, d: usize, use_num: usize, num753_cand: &mut Vec<usize>, n: usize) {}


Measured memory_bytes: 7404
#include <stdio.h>
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};

void getDepth(int, int);
int getHeight(int);
int getSibling(int);
int getDegree(int);
void printType(int);

struct Node t[25];
int Depth[25];
int Height[25];
int height1=0, height2=0;

int main(){

  int n, id, vec, left, right, root;
  int i, j, k;

  scanf("%d", &n); //n=節点の数
  
  for(i=0; i<n; i++) t[i].parent =t[i].left =t[i].right =NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d %d", &vec, &left, &right);
    
    t[vec].left=left; t[vec].right=right;
    
    if(left!=NIL) t[left].parent=vec;
    if(right!=NIL) t[right].parent=vec;
  }

  for(i=0; i<n; i++){
    if(t[i].parent==NIL) root=i;
  }

  getDepth(root, 0);

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

    printf("node %d: ", i);
    printf("parent = %d, ", t[i].parent);
    printf("sibling = %d, ",getSibling(i));
    printf("degree = %d, ", getDegree(i) );
    printf("depth = %d, ", Depth[i]);
    printf("height = %d, ", getHeight(i) );
    printType(i);

  }
  return 0;
}

void getDepth(int x, int d){

  if(x==NIL) return; //一番底に来たとき

  Depth[x]=d;
  getDepth( t[x].left, d+1);
  getDepth( t[x].right, d+1);
}

int getHeight(int x){

  int height1=0, height2=0; //右と左にそれぞれ子がいないか確かめる
  int height;

  if(t[x].right ==NIL && t[x].left==NIL) Height[x]=0;
  else{
  if(t[x].left != NIL){
    
    height1=getHeight( t[x].left)+1;
  }
  if( t[x].right != NIL){

    height2=getHeight( t[x].right)+1;
  }
  }
  if(height1 < height2) height=height2;
  else height=height1;

  return height;
}

int getSibling(int x){

  if( t[x].parent == NIL) return NIL;

  else if(  t[ t[x].parent ].left ==  x && t[ t[x].parent ].right != NIL){
    //xが親の左の子で、右の子がNILでないとき、右の子を返す
    return t[ t[x].parent ].right;
  }
  else if( t[ t[x].parent ].right == x && t[ t[x].parent ].left != NIL){
    return t[ t[x].parent ].left;
  }
  return NIL;
}

int getDegree(int x){

  if(t[x].right ==NIL && t[x].left==NIL) return 0;
  else if(t[x].right !=NIL && t[x].left !=NIL) return 2;
  else return 1; 
}
void printType(int x){

  if(t[x].parent == NIL) printf("root\n");
  else if(t[x].left == NIL && t[x].right == NIL) printf("leaf\n");
  else printf("internal node\n");

}



Measured memory_bytes: 2144
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [n, m, x] <- getInts
  as <- getInts
  print $ solve n m x as

solve :: Int -> Int -> Int -> [Int] -> Int
solve n m x as = min (length xs) (length ys)
  where (xs, ys) = span (< x) as

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


Measured memory_bytes: 508
#include "bits/stdc++.h"
using namespace std;
int main() {
	string S;
	cin >> S;
	string T;
	int num = 0;
	for (int i = 0; i < S.size(); i++) {
		if (i == 0 || i == S.size() - 1) T.push_back(S.at(i));
		else if (i == S.size() - 2) {
			num++;
			string str = to_string(num);
			for (int j = 0; j < str.size(); j++) {
				T.push_back(str.at(j));
			}
		}
		else num++;
	}
	cout << T << endl;
}

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

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    long x[1000], y[1000], z[1000];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>z[i];
    }

    long long ans = 0;
    for(int signx=0;signx<=1;signx++){
        for(int signy=0;signy<=1;signy++){
            for(int signz=0;signz<=1;signz++){
                long long sum[1000]={};
                long long total=0;
                for(int i=0;i<n;i++){
                    sum[i]=(int)(pow(-1,signx))*x[i]+(int)(pow(-1,signy))*y[i]+(int)(pow(-1,signz))*z[i];
                }
                for(int i=0;i<n;i++){
                    for(int j=i+1;j<n;j++){
                        if(sum[i]<sum[j]){
                            long long tmp = sum[i];
                            sum[i] = sum[j];
                            sum[j] = tmp;
                        }
                    }
                }
                for(int i=0;i<m;i++){
                    total+=sum[i];
                }
                if(ans<total) ans=total;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

const int MAXN = 100000 + 10;

int X[MAXN], Y[MAXN], t[MAXN];

int dist(int x1, int y1, int x2, int y2) {
	return abs(x2 - x1) + abs(y2 - y1);
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> t[i] >> X[i] >> Y[i];

	bool flag = true;
	int count = 0;
	while (true) {
		if (count == n) break;
		int sx, sy, ex, ey, st, et;
		if (count == 0) {
			sx = 0, sy = 0, st = 0;
		}
		else
			sx = X[count - 1], sy = Y[count - 1], st = t[count - 1];
		ex = X[count], ey = Y[count], et = t[count];
		if (dist(sx, sy, ex, ey) > et - st || (et - st - dist(sx, sy, ex, ey)) % 2 != 0) {
			flag = false;
			break;
		}
		count++;
	}

	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1408
X = int(input())
if X == 2:
  print(X)
while X > 2:
  if X % 2 == 0:
    # 偶数
    X += 1
  else:
    n = 3
    while n * n <= X:
      if X % n == 0:
        # 割り切れる
        X += 1
        break
      n += 1
    else:
      print(X)
      break

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

//与えられた数列を逆順にして出力するプログラム
int main(){
    int n, i, j, a;
    cin >> n;
    int * array = new int[n];

    i = 0;
    while(i < n){
        cin >> a;
        array[i] = a;
        i++;
    }

    j = n-1;
    while(j > 0){
        cout << array[j] <<" ";
        j--;
    }
    cout << array[0] << endl;
    delete[] array;

    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int countmax(int conum,int cone,int ne)
{
  int y=(ne/cone);
  return (y<conum)?y:conum;
}
int countmin(int cone,int ne,int sonota)
{
  int y=(ne-sonota);
  int z=(y/cone);
  if(z<0)
    {
      return 0;
    }
  else
    {
      return z;
    }
}
int main(void)
{
  int a,b,c,x;
  int ans=0;
  scanf("%d%d%d%d",&a,&b,&c,&x);
  int ma=a*500;
  int mb=b*100;
  int mc=c*50;
  int amax=countmax(a,500,x);
  int amin=countmin(500,x,(mb+mc));
  int i,j;
  for(i=amin;i<=amax;i++)
    {
      int nokori=(x-i*500);
      int bmax=countmax(b,100,nokori);
      int bmin=countmin(100,nokori,mc);
      for(j=bmin;j<=bmax;j++)
	{
	  int noko=(nokori-j*100);
	  if(noko<=mc)
	    {
	      ans++;
	    }
	}
    }
  printf("%d\n",ans);
  return 0;
}


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

void copy(char *from,char *to,int n){
	int i;
	for(i=0;i<6;i++){
		if(i<n){
			to[i] = from[i];
		}else{
			to[i] ='\0';
		}
	}
}

int check(char *a,char *b){
	int i;
	for(i=0;i<5;i++){
		if(a[i]<b[i]){
			return -1;
		}else if(a[i] >b[i]){
			return 1;
		}
	}
	return 0;
}

int int_sort( const void *a,const void *b){
	return strcmp((char *) a, (char *)b);
}

int main(void){
	char s[5001];
	int K;
	int i,j;
	scanf("%s",s);
	scanf("%d",&K);
	
	char kouho[25000][6];
	int index=0;
	//長さ5以下のsubstringをkouho[]に詰めていく。
	for(i=0;s[i]!='\0';i++){//まず先頭のs[i]を決める。
		for(j=1;s[i+j-1]!='\0';j++){//s[i],s[i]s[i+1],s[i]s[i+1]s[i+2]...とs[i]を基準として5文字までsubstringを作っている。
			if(j>5){//長さ5以上のsubstringは必要ないので処理を終える。
				break;
			}else{
			copy(&s[i],kouho[index],j);
			index++;
			}
		}
	}
	
	qsort(kouho,index,sizeof(kouho[0]),int_sort);//kouhoをソートしている
	int ex[25000];
	for(i=0;i<25000;i++){
		ex[i]=1;
	}
	for(i=0;i<index;i++){
		if(check(kouho[i],kouho[i+1])==0){
			ex[i+1]=-1;
		}
	}
	int count=0,flag=0;
	i=0;
	while(flag < K){
		if(ex[i] > 0){
			count = i;
			flag++;
		}
		i++;
	}
	
	printf("%s",kouho[count]);
	
	return 0;
}

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

ll a[100005], dp[100005];

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

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

int main()
{
  int n;
  cin >> n;
  vector<pair<int, int>> lr(n);
  for(auto& i : lr){
    cin >> i.first >> i.second;
  }
  
  vector<bool> c(100001, true);
  c[0] = false;
  c[1] = false;
  for(int i = 2; i < 100001; ++i){
    if(!c[i]){
      continue;
    }
    for(int j = i + i; j < 100001; j += i){
      c[j] = false;
    }
  }
  vector<int> v(100001, 0);
  for(int i = 3; i < 100001; ++i){
    v[i] = v[i-1];
    if(i % 2 == 0){
      continue;
    }
    if(!c[i]){
      continue;
    }
    if(!c[(i + 1) / 2]){
      continue;
    }
    ++v[i];
  }
  
  for(auto& i : lr){
    cout << v[i.second] - v[i.first - 1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1792
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[0]*h
for i in range(h):
  st=str(input())
  st=list(st)
  s[i]=st
  
from collections import deque
temp=[[999999]*w for i in range(h)]
temp[ch-1][cw-1]=0
queue0 = deque([[ch-1, cw-1, 0]])
queue1 = deque()
while queue0:  
  x,y,c=queue0.popleft()
  queue1.append((x,y,c))
  for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
    xtemp,ytemp=x+i,y+j
    if xtemp<0 or h<=xtemp or ytemp<0 or w<=ytemp or s[xtemp][ytemp]!=".":
      continue
    if temp[xtemp][ytemp]<=c:
      continue
    temp[xtemp][ytemp]=c
    queue0.append([xtemp,ytemp,temp[xtemp][ytemp]])
    
  if len(queue0)==0:      
    while queue1:
      x,y,c=queue1.popleft()
      for i,j in [[2,2],[2,1],[2,0],[2,-1],[2,-2],[1,2],[1,1],[1,-1],[1,-2],[0,2],[0,-2],[-1,2],[-1,1],[-1,-1],[-1,-2],[-2,2],[-2,1],[-2,0],[-2,-1],[-2,-2]]:
        xtemp,ytemp=x+i,y+j
        if xtemp<0 or h<=xtemp or ytemp<0 or w<=ytemp or s[xtemp][ytemp]!=".":
          continue
        if temp[xtemp][ytemp]<=c+1:
          continue
        temp[xtemp][ytemp]=c+1
        queue0.append([xtemp,ytemp,temp[xtemp][ytemp]])
        
if temp[dh-1][dw-1]==999999:
  print(-1)
else:
  print(temp[dh-1][dw-1])

Measured memory_bytes: 171680
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)
    elif op == '?':
        break

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

using namespace std;

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

const ll INF=1e9+7;
ll n,ans,k,t;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	t=n;
	while(t){
		k++;
		t/=10;
	}
	/*if(k<=8){
		for(ll i=sqrt(n);i<=n;i++){
			if(n%i==0){
				while(i){
					ans++;
					i/=10;
				}
				cout<<ans;
				return 0;
			}
		}
	}*/
	for(ll i=sqrt(n);i<=10e7;i++){
		if(n%i==0){
			while(i){
				ans++;
				i/=10;
			}
			cout<<ans;
			return 0;
		}
	}
	for(int i=999;i>=100;i--){
		if(n%i==0){
			t=n/i;
			k=0;
			while(t){
				k++;
				t/=10;
			}
			cout<<k;
			return 0;
		}
	}
	for(int i=99;i>=10;i--){
		if(n%i==0){
			t=n/i;
			k=0;
			while(t){
				k++;
				t/=10;
			}
			cout<<k;
			return 0;
		}
	}
	for(int i=9;i>=1;i--){
		if(n%i==0){
			t=n/i;
			k=0;
			while(t){
				k++;
				t/=10;
			}
			cout<<k;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	var tree Tree

	tree.root = nil

	for i := 0; i < n; i++ {
		order := getNextString(scanner)
		switch order {
		case "print":
			tree.i = 0
			tree.keys = make([]int, tree.n)
			tree.printInOrders(tree.root)
			fmt.Fprintln(writer, fmt.Sprintf(" %s", joinint(tree.keys, " ")))
			tree.i = 0
			tree.keys = make([]int, tree.n)
			tree.printPreOrders(tree.root)
			fmt.Fprintln(writer, fmt.Sprintf(" %s", joinint(tree.keys, " ")))
		case "insert":
			key := getNextInt(scanner)
			tree.insert(key)
		case "find":
			key := getNextInt(scanner)
			if tree.find(key) {
				fmt.Fprintln(writer, "yes")
				continue
			}
			fmt.Fprintln(writer, "no")
		}
	}

	writer.Flush()
}

// Tree tree
type Tree struct {
	root *Node
	keys []int
	i    int
	n    int
}

func (t *Tree) insert(key int) {
	t.n++
	node := Node{
		key:    key,
		parent: nil,
		left:   nil,
		right:  nil,
	}
	if t.root == nil {
		t.root = &node
		return
	}

	n := t.root
	var p *Node
	p = nil

	for n != nil {
		p = n
		if n.key < key {
			n = n.right
			continue
		}
		n = n.left
	}
	node.parent = p
	if p.key < key {
		p.right = &node
		return
	}
	p.left = &node
}

func (t *Tree) find(key int) bool {
	if t.root == nil {
		return false
	}

	n := t.root

	for n != nil {
		if n.key == key {
			return true
		}
		if n.key < key {
			n = n.right
			continue
		}
		n = n.left
	}

	return false
}

func (t *Tree) printPreOrders(n *Node) {
	if n == nil {
		return
	}
	t.keys[t.i] = n.key
	t.i++
	t.printPreOrders(n.left)
	t.printPreOrders(n.right)
}

func (t *Tree) printInOrders(n *Node) {
	if n == nil {
		return
	}
	t.printInOrders(n.left)
	t.keys[t.i] = n.key
	t.i++
	t.printInOrders(n.right)
}

// Node node
type Node struct {
	key    int
	parent *Node
	left   *Node
	right  *Node
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}



Measured memory_bytes: 55732
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int h=sc.nextInt();
		int w=sc.nextInt();
		String c[][]=new String[h][w];
		String ans[][]=new String[2*h][w];
		String s[]=new String[h];
		for(int i=0;i<h;i++) {
			s[i]=sc.next();
		}
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				c[i][j]=String.valueOf((s[i].charAt(j)));
			}
		}
		
		for(int i=0;i<2*h;i++) {
			for(int j=0;j<w;j++) {
				ans[i][j]=c[(int)((i+2)/2)-1][j];
			}
		}
		String ans_s[]=new String[2*h];
		
		for(int i=0;i<2*h;i++) {
			ans_s[i]=String.valueOf(ans[i][0]);
			if(w!=1) {
				for(int j=1;j<w;j++) {
					ans_s[i]+=String.valueOf(ans[i][j]);
				}
			}
		}
		for(int i=0;i<2*h;i++) {
			System.out.println(ans_s[i]);
		}
		
		
	}
	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			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: 32468
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pr;
typedef vector<int> vec;
typedef long long int lli;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define TEST int T; cin >> T; while(T--)


int main() {
    int n, k;
    cin >> n >> k;

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

    int l = 1, r = *max_element(a, a+n), ans = -1;

    while(l <= r) {
        int m = (l+r)/2;

        int cuts = 0;

        for(int i=0; i<n; i++) {
            cuts += (a[i]+m-1)/m -1;
        }

        if(cuts <= k) {
            ans = m;
            // cout << m << ' ' << cuts << endl;
            r = m - 1;
        }
        else {
            l = m + 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4360
def f(n, c):
    if n == 1:
        print c
        return
    else:
        if n % 2 == 0:
            n = n / 2
        else:
            n = 3*n + 1
        c += 1
        return f(n, c)

while True:
    n = int(raw_input())
    if n == 0: break
    c = 0
    f(n, c)

Measured memory_bytes: 4264
s = {}
l = ["A","B","C"]
p = "A"
for x in l:
  s[x] = list(input().upper())
while True:
  if s[p] == []:
    print(p)
    break
  else:
    q = s[p][0]
    s[p] = s[p][1:]
    p = q

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    // input
    string S;
    cin >> S;
    for (int i = 0; i < S.length(); ++i) {
        cout << 'x';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n; cin >>n;

    int x = 800*n;
    int y = (n/15)*200;

    cout << x - y << endl;

    return 0;
}




Measured memory_bytes: 256