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

#define _ << " _ " <<
#define TRACE(x) cout << #x << " = " << x << endl

typedef long long ll;

const int MaxN = 1e5;

int n, k;
vector<int> id, p, q, P, Q, PQ, pq, Pq, pQ;
vector<int> PQpq[31], PqpQ[31], pQPq[31];

vector<int> mult(vector<int>& a, vector<int>& b) {
    vector<int> c(n);
    for (int i = 0; i < n; i++) c[i] = a[b[i]];
    return c;
}

void powers(vector<int> a[]) {
    for (int i = 1; i < 31; i++) a[i] = mult(a[i-1], a[i-1]);
}

vector<int> get_pow(vector<int> a[], int e) {
    vector<int> b = id;
    for (int i = 0; i < 31; i++)
        if (e & (1 << i)) b = mult(b, a[i]);
    return b;
}

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

    cin >> n >> k;
    p.resize(n);
    q.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < n; i++) {
        cin >> q[i];
        q[i]--;
    }

    if (k == 1) {
        for (int i = 0; i < n; i++) cout << p[i] + 1 << " ";
        return 0;
    }

    id.resize(n);
    P.resize(n);
    Q.resize(n);
    for (int i = 0; i < n; i++) {
        id[i] = i;
        P[p[i]] = i;
        Q[q[i]] = i;
    }

    PQ = mult(P, Q);
    pq = mult(p, q);
    PQpq[0] = mult(PQ, pq);
    powers(PQpq);
    pQ = mult(p, Q);
    Pq = mult(P, q);
    PqpQ[0] = mult(Pq, pQ);
    powers(PqpQ);
    pQPq[0] = mult(pQ, Pq);
    powers(pQPq);

    k = ((k - 2) / 3) * 4 + (k - 2) % 3 + 1;

    vector<int> sol = q;

    int a = k / 4; if (k % 4 == 3) a++;
    vector<int> x = get_pow(PQpq, a / 2); sol = mult(sol, x);
    if (a % 2) sol = mult(sol, PQ);

    int b = k / 4;
    if (k % 8 < 4) {
        if (k % 8 == 2) sol = mult(sol, P);
        vector<int> y = get_pow(PqpQ, b / 2); sol = mult(sol, y);
        if (b % 2) sol = mult(sol, Pq);
    } else {
        if (k % 8 == 6) sol = mult(sol, p);
        vector<int> y = get_pow(pQPq, b / 2); sol = mult(sol, y);
        if (b % 2) sol = mult(sol, pQ);
    }

    for (int i = 0; i < n; i++) cout << sol[i] + 1 << " ";

    return 0;
}



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

int main() 
{
    int n;
    cin >> n;
    vector<int> a(n);
    
    for(int i=0;i<n;i++) cin >> a[i];
    
    int ans = 0;
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] && a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i]) ++ans;
            }
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3556
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        public static readonly string Yes = "Yes";
        public static readonly string YES = "YES";
        public static readonly string No = "No";
        public static readonly string NO = "NO";
        public static readonly string OK = "OK";
        public static readonly string NG = "NG";

        void Omame()
        {
            cin = new Scanner();
            long N = cin.nextLong();
            long K = cin.nextLong();

            Console.WriteLine(K * (long)Math.Pow(K - 1, N - 1));
        }

    }
}


Measured memory_bytes: 13268
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    string a,b,c;
    
    cin>>a>>b>>c;
    string d=a+b+c;
    int num = stoi(d);
    if(num%4==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

x,y = Ss()

x = int(x,16)
y = int(y,16)

if x > y:
    print(">")
elif x < y:
    print("<")
else:
    print("=")



Measured memory_bytes: 3436
s = input()
if len(s) / 2 == 0:
    print("No")
    exit()

def check(i):
    if len(i) % 2 != 0:
        i2 = i[len(i) // 2 + 1:len(i)]
    else:
        i2 = i[len(i) // 2:len(i)]
    if i[0:len(i) // 2] == i2[::-1] or len(i) == 1:
        return(True)
    return(False)

s2 = s[0:(len(s) - 1) // 2]
s3 = s[(len(s) - 1) // 2 + 1:len(s)]

if check(s) == True and check(s2) == True and check(s3) == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

const int mm = 55600;

void sieve(ll m, vector<bool> &is_prime) {
    is_prime[0] = false; is_prime[1] = false;
    for (int i=2;i<m;++i) {
        if (!is_prime[i]) continue;
        for (int j=i*2;j<m;j+=i) is_prime[j] = false;
    }
}

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

    vector<bool> is_prime(mm, true);
    sieve(mm, is_prime);

    int cnt = 0;

    for (int i = 0; i <= 55555; ++i) {
        if (cnt == n) break;
        if (is_prime[i]) {
            if (i % 5 == 1) {
                cout << i << " ";
                cnt++;
            }
        }
    }

    cout << endl;
}

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

using namespace std;

int main() {
  long long r, d, x;
  scanf("%lld %lld %lld", &r, &d, &x);
  for (int i = 0; i < 10; i++) {
    long long tmp = r * x - d;
    printf("%lld\n", tmp);
    x = tmp;
  }
  return 0;
}


Measured memory_bytes: 256
/*
      author : Nishikawa
      created: 04.08.2020 20:24:39
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int N;
    cin >> N;
    string c;
    cin >> c;
    int R_cnt=0,W_cnt=0;
    int R_cnt_inv=0;
    for(int i=0; i<N; i++){
        if(c[i]=='R') R_cnt++;
        else W_cnt++;
    }
    for(int i=0; i<R_cnt; i++){
        if(c[i]=='W') R_cnt_inv++;
    }
    cout << R_cnt_inv << endl;
    
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

bool dp1[10000][20000];
bool dp2[10000][20000];

inline int id(int i){ return i+8000; }

int main(){
    string s;
    cin >> s;
    int N = s.size();
    int x,y;cin >> x >> y;

    vi v[2];

    int idx = 0;
    int vidx = 0;
    while(idx < N){

        int a = idx;
        while(idx < N and s[idx] == 'F') idx++;
        int cnt = idx - a;
        idx++;
        v[vidx].push_back(cnt);
        vidx ^= 1;
    }

    int n = v[0].size();
    int m = v[1].size();

    dp1[0][id(0)] = true;
    for(int i=0;i<n;i++){
        for(int j=-8000;j<=8000;j++){
            if(dp1[i][id(j)]){
                int nx1 = j + v[0][i];
                int nx2 = j - v[0][i];
                if(-8000<=nx1 and nx1<=8000){
                    dp1[i+1][id(nx1)] = true;
                }
                if(-8000<=nx2 and nx2<=8000 and i>0){
                    dp1[i+1][id(nx2)] = true;
                }
            }
        }
    }


    dp2[0][id(0)] = true;
    for(int i=0;i<m;i++){
        for(int j=-8000;j<=8000;j++){
            if(dp2[i][id(j)]){
                int nx1 = j + v[1][i];
                int nx2 = j - v[1][i];
                if(-8000<=nx1 and nx1<=8000){
                    dp2[i+1][id(nx1)] = true;
                }
                if(-8000<=nx2 and nx2<=8000){
                    dp2[i+1][id(nx2)] = true;
                }
            }
        }
    }

    if(dp1[n][id(x)] and dp2[m][id(y)]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 156416
#include<stdio.h>

int main() {
  int flag, i, N, tmp, count, A[100];
  flag = 1;
  count = 0;
  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
  while (flag) {
    flag = 0;
    for ( i = N - 1; i > 0; i-- ) {
      if ( A[i-1] > A[i] ) {
        tmp = A[i];
        A[i] = A[i-1];
        A[i-1] = tmp;
        flag = 1;
        count++;
      }
    }
  }
  for (i = 0; i < N; i++ ) {
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2736
using System;
	class Program
    {
        static void Main(string[] args)
        {
			string input = Console.ReadLine();
			long n = long.Parse(input);
			long r = (long)Math.Floor(Math.Sqrt(n));
			while (r > 0)
			{
				if (n % r == 0) break;
				r = n / (n / r + 1);
			}
			long result = r + n / r - 2;
			Console.WriteLine(result);
        }
    }


Measured memory_bytes: 13140
require 'pp'
s = gets.chomp.chars
Q = gets.to_i
mu = 1
q = []
Q.times do
  n, f, c = gets.split
  n = n.to_i
  if n == 1
    mu *= -1
  else # n == 2
    f = f.to_i
    if mu == 1
      if f == 1
        s.unshift c
      else # f == 2
        s << c
      end
    else
      if f == 1
        s << c
      else # f == 2
        s.unshift c
      end
    end

  end
end
if mu == 1
  puts s.join
else
  puts s.reverse.join
end



Measured memory_bytes: 30716
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<long> T(N), A(N);
  for (int i = 0; i < N; i++)
    cin >> T[i] >> A[i];
  long tk = 1;
  long ao = 1;
  for (int i = 0; i < N; i++)
  {
    long t = max((tk + T[i] - 1) / T[i], (ao + A[i] - 1) / A[i]);
    tk = T[i] * t;
    ao = A[i] * t;
  }
  cout << tk + ao << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1E+15;


int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a);
    vector<ll> t(b);
    rep(i, a) cin >> s[i];
    rep(i, b) cin >> t[i];
    rep(i, q) {
        ll x;
        cin >> x;
        ll s1, s2, t1, t2;
        auto its = lower_bound(whole(s), x);
        if (its==s.end()) s2 = INF;
        else s2 = *its;
        if (its==s.begin()) s1 = -INF;
        else {
            its--;
            s1 = *its;
        }
        auto itt = lower_bound(whole(t), x);
        if (itt==t.end()) t2 = INF;
        else t2 = *itt;
        if (itt==t.begin()) t1 = -INF;
        else {
            itt--;
            t1 = *itt;
        }
        ll res = INF;
        chmin(res, max(s2, t2)-x);
        chmin(res, x-min(s1, t1));
        chmin(res, (x-s1)*2+(t2-x));
        chmin(res, (x-t1)*2+(s2-x));
        chmin(res, (s2-x)*2+(x-t1));
        chmin(res, (t2-x)*2+(x-s1));
        cout << res << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,ans[3]={1,1,1};
    cin >> A >> B;
    ans[A-1]=0;
    ans[B-1]=0;
    for(int i=0; i<3; i++){
        if(ans[i]) cout << i+1;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  ll n,k;
  ll ans=0;
  cin >> n >> k;
  if(k==0){
    ans=n*n;
    cout<<ans<<endl;
    return 0;
  }
  for(ll b=k+1;b<=n;b++){
    ans+=(n/b)*max(0ll,b-k)+max(0ll,n%b-k+1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>

int main(void){
	
	int n,i,j,c,k,t;
	k=0;
	
	scanf("%d",&n);
	
	int A[n];
	c=0;
	
	for(i=0; i<n; i++)
	{
		scanf("%d",&A[i]);
	}
	
	for(t=0; t<n; t++)
	{
		if(A[t]==2)
		{
			c++;
		}
	}
	
	
		for(t=0; t<n; t++)
	{
			if(A[t]%2 != 0){
				
				for(j=3;j<=sqrt(A[t]);j+=2)
				{
					if(A[t]%j==0)
					{
						k=1;
						
					}
				}
				if(k==0) c++;
			}
		k=0;
				
		
		
			
		
	}

	printf("%d\n",c);

	return 0;
}
	


Measured memory_bytes: 2716
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
bool v[N];
int n,m,x,y,c[N],A,s,q[N],t,X,C;
vector<int>a[N];
int main()
{
	cin>>n>>m;
	while(m--&&cin>>x>>y)
		a[x].push_back(y),a[y].push_back(x),c[x]++,c[y]++;
	for(int i=1;i<=n;i++)
		if(c[i]&1)
		{
			cout<<"No";
			return 0;
		}
	for(int i=1;i<=n;i++)
		if(c[i]>=6)
		{
			cout<<"Yes";
			return 0; 
		}
		else if(c[i]==4)
			A=i,s++;
	if(s>=3)
	{
		cout<<"Yes";
		return 0;
	}
	if(s<=1)
	{
		cout<<"No";
		return 0;
	}
	q[++t]=a[A][0],v[A]=v[a[A][0]]=true;
	while(t)
	{
		X=q[t--];
		for(int i=0;i<a[X].size();i++)
			if(!v[a[X][i]])
				C++,q[++t]=a[X][i],v[a[X][i]]=true;
	}
	if(C==n-2)
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <set>
#include <ctime>
#include <cstdlib>


using namespace std;

set<string> used;

string gen(char start, char end)
{
	string str;
	while(true)
	{
		str = "";
		str += start;
		for(int i = 0; i < 5; ++i)
		{
			str += rand() % 26 + 'a';
		}
		if(!used.count(str))
		{
			break;
		}
	}
	str += end;
	return(str);
}

string ask(const string out)
{
	printf("?%s\n", out.c_str());
	fflush(stdout);
	string ret;
	cin >> ret;
	return(ret);
}

void output(string str) 
{
	fprintf(stderr,"%s\n", str.c_str());    
}

void solve()
{
	srand((unsigned int)time(NULL));
	char prev = 'a';
	for (int i = 0; i < 51; ++i) 
	{
		string send, receive;
		send = gen(prev, 'a');
		used.insert(send);
		receive = ask(send);
		if (receive[0] != *send.rbegin()) 
		{ 
			break; 
		}
		if (used.count(receive)) 
		{ 
			break;
		}
		used.insert(receive);
		prev = *receive.rbegin();
	}
	puts("!OUT");
	fflush(stdout);
}

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

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <stdexcept>

using namespace std;
char alf[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

int main() {
	int last = -1;
	string s;
	bool flg = true, allflg = true;
	cin >> s;

	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}


	if (s.size() == 26) {
		for (int i = 25; i > 1; i--) {

			if (s[i] > s[i - 1]) {

				for (int j = 0; j < 26; j++) {
					if (alf[j] == s[i - 1]) {
						last = j;
					}
				}
				s= s.substr(0, i - 1);
				allflg = false;
				break;
			}

		}
		if (allflg) {
			for (int i = 0; i < 26; i++) {
				if (alf[i] == s[0]) {
					cout << alf[i + 1] << endl;
					return 0;
				}
			}
		}
	}

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < s.size(); j++) {

			if (alf[i] == s[j] ) {
			flg = false;
			break;
			}
		}
		if (flg&&i>last) {
			cout << s << alf[i] << endl;
			return 0;
		}
		flg = true;
	}
}



Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
Ps = sorted(P)

cnt = 0
flag = True
for i in range(N):
    if P[i] != Ps[i]: cnt += 1
    if cnt > 2:
        flag = False
        break
if flag: print('YES')
else: print('NO')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

#define MAX_N   100000

long long result[10];

struct Node {
    int val, x, y;
    long long key;
    struct Node *lch, *rch;
};
typedef struct Node node;

node *modify (node *p, int new_x, int new_y, long long new_key){
    if(p == NULL){
        node *q = (node*)malloc(sizeof(node));
        q->val = 1;
        q->x = new_x; q->y = new_y;
        q->key = new_key;
        q->lch = q->rch = NULL;
        return q;
    }
    else if (p->key == new_key){
        p->val++;
        return p;
    }
    else {
        if (new_key < p->key) p->lch = modify(p->lch, new_x, new_y, new_key);
        else p->rch = modify(p->rch, new_x, new_y, new_key);
        return p;
    }
}

void answer(node *p){
    if (p != NULL){
        answer(p->lch);
        result[p->val]++;
        result[0]--;
        answer(p->rch);
    }
}

void release(node *p){
    if (p != NULL){
        release(p->lch);
        free(p);
        release(p->rch);
    }
}

int main(){
    int n, i, j, H, W, N, a[MAX_N], b[MAX_N];
    long long key;
    node *root = NULL;
    
    scanf("%d %d %d", &H, &W, &N);
    for (n=0; n<N; n++) scanf("%*c%d %d", &a[n], &b[n]);
    
    result[0] = (long long)(H-2)*(W-2);
    for (n=0; n<N; n++){
        for (i=-1; i<=1; i++){
            if (a[n]-1+i<1 || H-2<a[n]-1+i) continue;
            for (j=-1; j<=1; j++){
                if (b[n]-1+j<1 || W-2<b[n]-1+j) continue;
                key = (long long)(a[n]-1+i)*(W-1)+b[n]-1+j;
                root = modify(root, a[n]-1+i, b[n]-1+j, key);
            }
        }
    }
    answer(root);
    for (i=0; i<10; i++){
        printf("%lld\n", result[i]);
    }
    release(root);
    return 0;
}

Measured memory_bytes: 43136
#include<iostream>
#include<algorithm>
#include <vector>
#include<math.h>
#include <map>
#include <functional>
#include <queue>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
using namespace std;
int n;
vector<int> g[100005];
int cnt[100005];
int val[100005];
int main(){
	cin >>n;
	for(int i=0;i<n-1;i++){
		int a,b; cin >>a>>b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
		cnt[a]++;
		cnt[b]++;
	}
	vector<int> c(n);
	cinf(n,c);
	sort(c.begin(),c.end());
	queue<int> q;
	for(int i=0;i<n;i++){
		if(cnt[i]==1)q.push(i);
	}
	ll ans=0;
	int cur=0;
	while(q.size()){
		int v=q.front();
		q.pop();
		val[v]=c[cur];
		ans+=cnt[v]*c[cur++];
		for(int i=0;i<g[v].size();i++){
			int nv=g[v][i];
			cnt[nv]--;
			if(cnt[nv]==1){
				q.push(nv);
			}
		}
	}
	cout << ans << endl;
	for(int i=0;i<n;i++){
		cout << val[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 3452
#include<bits/stdc++.h>
#include<iostream>
#include<string.h>
#include<climits>

using namespace std;

#define lld long long int
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);	cout.tie(0);

/* 											CODE:-									*/
														


void IMPLEMENT_CODE(){
	
	lld n;
	cin>>n;
	lld h[n];
	for(lld i=0; i<n; i++)	cin>>h[i];

	lld dp[n];
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(lld i=2; i<n; i++){
		dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2]+abs(h[i] - h[i-2]));
		//cout<<dp[i]<<" ";
	}
	cout<<dp[n-1]<<endl;
}



int main(){
	
	FASTIO;

	IMPLEMENT_CODE();

	return 0;

}


Measured memory_bytes: 5100
n, m = map(int, raw_input().split())
A = [input() for i in range(n)]
B = [input() for i in range(m)]
vote = [0] * n
for b in B:
    for i, a in enumerate(A):
        if a <= b:
            vote[i] += 1
            break
print vote.index(max(vote)) + 1

Measured memory_bytes: 4332
ans = 0
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
for i in range(N):
  A = list(map(int,input().split()))
  v=0
  for j in range(M):
    v += A[j]*B[j]
  if v+C > 0:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, c, a[N];
int main()
{
	int i;
	cin >> n;
	for (i = 1; i <= n; i++) scanf("%d", &a[i]);
	if (a[n] == n) swap(a[n], a[n - 1]), c++;
	for (i = 1; i < n; i++) {
		if (a[i] == i) swap(a[i], a[i + 1]), c++;
	}
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	int ans = a;
	if (a > b)
	{
		ans--;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector<int> vec(n);
    in(vec);
    sort(all(vec));
    int left=0,right=vec.size()-1;
    deque<ll> dq;
    dq.push_back(vec[0]);
    left++;
    for(int i=1;i<n;i++){
        if(i%4==1){
            dq.push_back(vec[right]);
            right--;
        }else if(i%4==2){
            dq.push_front(vec[right]);
            right--;
        }else if(i%4==3){
            dq.push_back(vec[left]);
            left++;
        }else if(i%4==0){
            dq.push_front(vec[left]);
            left++;
        }
    }
    ll ans=0,sum=0;
    for(int i=1;i<n;i++){
        sum+=abs(dq[i]-dq[i-1]);
    }
    ans=sum;
    for(int i=0;i<n;i++){
        sum+=abs(dq[0]-dq[n-1])-abs(dq[1]-dq[0]);
        dq.push_back(dq.front());
        dq.pop_front();
        ans=max(ans,sum);
    }
    out(ans);
}

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

using namespace std;

int main()
{
	int h, n;
	cin >> h >> n;
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		sum += t;
	}
	
	if (sum >= h)
	{
		cout << "Yes";
	} else {
		cout << "No";
	}
	
	return 0;
}


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

int main(){
int A,B,C,D,E;
  cin>>A>>B>>C>>D>>E;
  if(A==0){
    cout<<1<<endl;
  }
  else if(B==0){
    cout<<2<<endl;
  }
  else if(C==0){
    cout<<3<<endl;
  }
  else if(D==0){
    cout<<4<<endl;
  }
  else{
    cout<<5<<endl;
  }
}

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

int main(){

  int w, h, n, x, y, a, cnt=0;
  bool s[100][100]={};

  cin>>w>>h>>n;
  for(int i=0;i<n;i++){
    cin>>x>>y>>a;
    if( a==1) for(int i=0;i<x;i++) for(int j=0;j<h;j++) s[j][i]=1;
    else if(a==2) for(int i=x;i<w;i++) for(int j=0;j<h;j++) s[j][i]=1;
    else if(a==3) for(int i=0;i<y;i++) for(int j=0;j<w;j++) s[i][j]=1;
    else for(int i=y;i<w;i++) for(int j=0;j<w;j++) s[i][j]=1;
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]==false) cnt++;
    }
  }

  cout<<cnt<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 200000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000000;
// clang-format on

int N, K;
int H[MAX_N + 1];

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  REP(i, N) cin >> H[i];
  priority_queue<ll> h;
  REP(i, N) h.push(H[i]);

  ll ans = 0;
  while (!h.empty()) {
    ll now = h.top();
    h.pop();
    if (K > 0) {
      K--;
      continue;
    }
    ans += now;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3188
n, t = map(int, input().split())
a = list(map(int, input().split()))

ans = []
min_a = a[0]
for i in range(1, n):
    min_a = min(min_a, a[i-1])
    ans.append(a[i] - min_a)
r = max(ans)
print(ans.count(r))


Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
    C(){}
};
VP crosspointCC(C a, C b){
    VP ps;
    if(a.r < b.r) swap(a,b);
    P ab = b.p-a.p;
    double dist = abs(ab);
    if(EQ(dist, a.r+b.r) || EQ(dist, a.r-b.r)){
        ps.push_back( a.p +ab*(a.r/dist) );
        return ps;
    }
    if(dist > a.r +b.r || dist < abs(a.r-b.r)){
        return ps;
    }
    double l = ((a.r*a.r -b.r*b.r)/dist +dist) /2;
    double n = sqrt(a.r*a.r -l*l);
    P mid = a.p + ab*l/dist;
    P ort = ab *(n/dist) *P(0,1);
    ps.push_back(mid+ort);
    ps.push_back(mid-ort);
    return ps;
}

const int nrep = 50;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		vector<double> x(n), y(n), l(n);
		double lmin=INF;
		for(int i=0; i<n; i++){
			cin >> x[i] >> y[i] >> l[i];
			lmin = min(lmin, l[i]);
		}
		
		double lb=0, ub=lmin;
		for(int i=0; i<nrep; i++){
			double mid = (lb+ub)/2;
			vector<C> c(n);
			for(int j=0; j<n; j++){
				c[j] = C(P(x[j],y[j]), sqrt(l[j]*l[j] -mid*mid));
			}
			bool success = false;
			for(int s=0; s<n && !success; s++){
				for(int t=s+1; t<n && !success; t++){
					VP cp = crosspointCC(c[s], c[t]);
					for(int j=0; j<(int)cp.size(); j++){
						bool flag = true;
						for(int k=0; k<n; k++){
							if(abs(cp[j]-c[k].p) > c[k].r +EPS){
								flag = false;
								break;
							}
						}
						if(flag){
							success = true;
							break;
						}
					}
				}
			}
			for(int j=0; j<n; j++){
				bool flag = true;
				for(int k=0; k<n; k++){
					if(abs(c[j].p-c[k].p) > c[k].r +EPS){
						flag = false;
						break;
					}
				}
				if(flag){
					success = true;
					break;
				}
			}
			if(success){
				lb = mid;
			}else{
				ub = mid;
			}
		}
		
		cout << fixed;
		cout << setprecision(10);
		cout << (lb+ub)/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 3308
use strict;
use warnings;
use Data::Dumper;

my ( $K, $S ) = split " ", <>;

my $count = 0;

for my $x (0..$K) {
    for my $y (0..$K) {
        my $z = $S - $x - $y;
        $count++ if ( ($z >= 0) && ($z <= $K) );
    }
}
print $count;




Measured memory_bytes: 1920
# http://even-eko.hatenablog.com/entry/2013/09/05/215236
# https://qiita.com/python_walker/items/d1e2be789f6e7a0851e5

import bisect

N = int(input())
Data = []
for _ in range(N):
    Data.append(int(input()))

LIS = []
LIS.append( Data[0] )

for i in range(1,N):
    n = Data[i]
    if n > LIS[-1]:
        LIS.append(n)
    else:
        p = bisect.bisect_left(LIS,n)
        LIS[p] = n

print(len(LIS))


Measured memory_bytes: 10344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int max=0;
		max =Math.max(max, a);
		max=Math.max(max, b);
		max=Math.max(max, c);
		System.out.println((a+b+c-max));
	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(n) for(ll i=0; i<n; i++)

int main()
{
  ll n,k;
  cin >> n >> k;
  string s,t;
  cin >> s;
  char c = s[0];
  rep(n){
    if(c!=s[i]){
      t.push_back(c);
      c = s[i];
    }
  }
  t.push_back(c);
  if(t.size()==1){
    cout << n-1 << endl;
    return 0;
  }
  ll rot = 0;
  ll sad = t.size();
  if(sad > 2*k){
    sad -= 2*k;
  } else {
    sad = 1;
  }
  cout << n-sad << endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <utility>
#include <vector>
#include <queue>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename head, typename... tail>
bool scan(head &h, tail&&... t){return scan(h) && scan(t...);}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

struct node {int x, y, d;};
typedef vector<bool> vb;

int main() {
	for (int w, h; w = in(), h = in(), w || h;) {
		vector<vb> m(h * 2 + 1, vb(w + 2));
		for (size_t i = 1; i < m.size() - 1; i++)
			for (int j = 1, e = i % 2 ? (gcu(), w - 1) : w; j < e + 1; j++)
				m[i][j] = !in();
		vector<vb> v(h + 1, vb(w + 1));
		int r = 0;
		queue<node> q;
		for (q.push({1, 1, 1}); !q.empty(); q.pop()) {
			node n = q.front();
			if (n.x == w && n.y == h)
				r = n.d;
			if (v[n.y][n.x])
				continue;
			v[n.y][n.x] = true;
			static int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1},
					   tx[] = {0, 0, -1, 0}, ty[] = {-1, 0, -1, -2};
			for (int i = 0; i < 4; i++)
				if (m[n.y * 2 + ty[i]][n.x + tx[i]] && !v[n.y + dy[i]][n.x + dx[i]])
					q.push({n.x + dx[i], n.y + dy[i], n.d + 1});
		}
		out(r, '\n');
	}
}


Measured memory_bytes: 2492
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int area = x * y;
		int length = 2 * (x + y);
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 26132
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define fcout cout << fixed << setprecision(15)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int N;
  cin >> N;
  vector<ll> T(N);
  rep(i, 0, N) cin >> T[i];

  ll ans = T[0];
  rep(i, 1, N) ans = lcm(ans, T[i]);

  cout << ans << endl;
}

Measured memory_bytes: 384
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int main() {
    double pi = 3.14159265;
    double N;cin >> N;
    cout << N*2*pi << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 3764
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    int N;
    cin >> N;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            int n = i * 4 + j *7;
            if(n == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sum(int i){
  int a=0;
  while(i>=1){
    a+=i%10;
    i/=10;
  }
  return a;
}
int main() {
  int n,a,b;
  long long ans=0;
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++){
    if(a<=sum(i) && sum(i)<=b) ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
class card{
public:
	char s;
	int c;
};
bool operator==(const card a, const card b){
	if (a.c == b.c){
		if (a.s == b.s){
			return true;
		}
	}
	return false;
}
void swap(card& a, card& b){
	card v;
	v = a;
	a = b;
	b = v;
}
void print(card a[], int n){
	int i;
	for (i = 0; i < n; i++){
		if (i)cout << " ";
		cout << a[i].s << a[i].c;
	}
	cout << endl;
}
int check(card a[], card b[], int n){
	int i, j, k, l;
	for (i = 0; i < n - 1; i++){
		for (j = i + 1; j < n; j++){
			if (a[i].c == a[j].c){
				for (k = 0; k < n - 1; k++){
					for (l = k + 1; l < n; l++){
						if (a[i] == b[l] && a[j] == b[k]){
							return 0;
						}
					}
				}
			}
		}
	}
	return 1;
}
void bprint(int a){
	if (a)cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}
void bubble(card a[], int n){
	int i, j, flag = 0;
	for (i = 0; i < n; i++){
		flag = 0;
		for (j = n - 1; j > i; j--){
			if (a[j].c < a[j - 1].c){
				swap(a[j], a[j - 1]);
				flag = 1;
			}
		}
		if (!flag)break;
	}
}
void select(card a[], int n){
	int i, j, min;
	for (i = 0; i < n; i++){
		min = i;
		for (j = i + 1; j < n; j++){
			if (a[j].c < a[min].c){
				min = j;
			}
		}
		swap(a[i], a[min]);
	}
}
int main(){
	int n, i;
	card a[36], b[36], c[36];
	cin >> n;
	for (i = 0; i < n; i++){
		cin >> a[i].s >> a[i].c;
		b[i].s = a[i].s;
		b[i].c = a[i].c;
		c[i].s = a[i].s;
		c[i].c = a[i].c;
	}
	bubble(b, n);
	print(b, n);
	bprint(check(a, b, n));
	select(c, n);
	print(c, n);
	bprint(check(a, c, n));
	return 0;
}



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

int main() {

  int n;
  double a[1000];
  double b[1000];
  double sum[5]={0,0,0,0,0};
  double ans[5]={0,0,0,0,0};

  cin >> n;

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

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

  for (int i = 0; i < n; i++) {
      sum[1] += abs(a[i] - b[i]);
  }

  for (int i = 0; i < n; i++){
      sum[2] += pow(a[i] - b[i], 2);
  }

  for (int i = 0; i < n; i++) {
      sum[3] += pow(abs(a[i] - b[i]), 3);
  }
   
  for (int i = 0; i < n; i++) {
      sum[4] = max(sum[4], abs(a[i] - b[i]));
  }

  for (int i = 1; i <= 3; i++){
      ans[i] = pow(sum[i], 1.0 * 1 / i);
  }

  ans[4] = sum[4];
  
  for (int i = 1;i <= 4; i++){
      cout << fixed << setprecision(30) << ans[i] << endl;
  }

  return 0;

}


Measured memory_bytes: 3472
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  ll ans=INF;
  for(int i=1;i<=100;i++){
    ll cu=0;
    for(int j=0;j<n;j++){
      cu+=abs(a[j]-i)*abs(a[j]-i);
    }
    ans=min(ans,cu);
  }
  COUT(ans);
}


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


int main() {
  int n;
  cin >> n;
  ll sum_a = 0;
  ll sum_b = 0;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> diff;
  vector<int> mx;
  rep(i, n){
    cin >> a[i];
    sum_a += a[i];
  }
  rep(i, n){
    cin >> b[i];
    sum_b += b[i];
  }
  if(sum_a < sum_b){
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  ll minus_sum = 0;
  rep(i, n){
    if(b[i] > a[i]){
      ans++;
      minus_sum += abs(a[i] - b[i]);
    }else if(a[i] > b[i]){
      mx.push_back(a[i] - b[i]);
    }else{
      continue;
    }
  }
  sort(mx.begin(), mx.end(), greater<int>());
  vector<ll> mx_sum(mx.size() + 1, 0);
  rep(i, mx.size()){
    mx_sum[i + 1] += mx_sum[i] + mx[i];
  }
  auto ite = lower_bound(mx_sum.begin(), mx_sum.end(), minus_sum);
  ans += (int)distance(mx_sum.begin(), ite);
  cout << ans << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> keta(M, vector<int>(2));
  vector<int> kazu(N);
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> keta.at(i).at(j);
    }
  }
  bool b = true;
  if (N > 1) {
    for (int i = 0; i < M; i++) {
      if (keta.at(i).at(0) == 1 && keta.at(i).at(1) == 0) {
        b =false;   
      }
    }
  }
  for (int i = 0; i < M; i++) {
    for (int j = i; j < M; j++) {
      if ((keta.at(i).at(0) == keta.at(j).at(0)) &&
          (keta.at(i).at(1) != keta.at(j).at(1))) {
        b = false;
      }
    }
  }
  
  for (int i = 0; i < M; i++) {
    kazu.at(keta.at(i).at(0) - 1) = keta.at(i).at(1);
  }
  if (kazu.at(0) == 0 && kazu.size() != 1) {
    kazu.at(0) = 1;
  }
  if (b) {
    for (int i = 0; i < N; i++) {
      cout << kazu.at(i);
    }
    cout << endl;
  }
  else {
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 256
N = int(raw_input())
H = map(int, raw_input().split())

ans = 0

prev = 0
count = 0
for i in range(N):
    current = H[i]
    if current <= prev:
        count = count + 1
        ans = max(ans, count)
    else:
        count = 0
    prev = current

print ans







Measured memory_bytes: 11316
void main() {
	auto ip = readAs!(int[]), W = ip[0], H = ip[1], x = ip[2], y = ip[3], r = ip[4];
	if(W < x+r || H < y+r || x-r < 0 || y-r < 0) {
		writeln("No");
	} else writeln("Yes");
}

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

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

constexpr int MAX = 1e6;

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

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

	vector<int> a(n);
	map<int, int> count;
	for (int& ai : a) {
		cin >> ai;
		++count[ai];
	}

	vector<bool> p(MAX + 1, true);
	bool pairwise = true;
	for (int i = 2; i <= MAX; ++i) {
		if (!p[i]) {
			continue;
		}

		int k = count[i];
		for (int j = i * 2; j <= MAX; j += i) {
			p[j] = false;
			k += count[j];
		}

		if (k > 1) {
			pairwise = false;
			break;
		}
	}

	if (pairwise) {
		cout << "pairwise coprime" << endl;
		return 0;
	}

	int g = gcd(a[0], a[1]);
	for (int i = 2; i < n; ++i) {
		g = gcd(g, a[i]);
	}

	if (g == 1) {
		cout << "setwise coprime" << endl;
		return 0;
	}

	cout << "not coprime";
	
	return 0;
}


Measured memory_bytes: 54064
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Coins
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 3;
const int MAX_S = 20000 / 50;

const int cs[N] = { 500 / 50, 100 / 50, 50 / 50 };

/* typedef */

/* global variables */

int es[N];
int dp[N + 1][MAX_S + 1];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < N; i++) scanf("%d", &es[i]);
  int s;
  scanf("%d", &s);
  s /= 50;

  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    const int &ci = cs[i], &ei = es[i];
    memcpy(dp[i + 1], dp[i], sizeof(dp[i]));

    for (int e = 1, ce = ci; e <= ei && ce <= s; e++, ce += ci)
      for (int j = 0; j + ce <= s; j++) dp[i + 1][j + ce] += dp[i][j];
  }

  printf("%d\n", dp[N][s]);
  return 0;
}


Measured memory_bytes: 256