akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 1<<19;

ii dp[MAXN];
int A[MAXN];
int n;

ii f(int mask){
    if(dp[mask].F != -1) return dp[mask];
    if(!mask) return dp[mask] = {0, -1};
    int mxi = 0, mxi2 = -1;
    for(int s = 0 ; s = (s - mask) & mask ;) {
        if(A[mxi] < A[s]) mxi2 = mxi, mxi = s;
        else if(mxi2 == -1 || A[mxi2] < A[s]) mxi2 = s;
    }
    return dp[mask] = {mxi, mxi2};
}

void mxze(int &a, int b){
    a = max(a,b);
}
void mnze(int &a, int b){
    a = min(a,b);
}

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

    FOR(i,0,MAXN) dp[i] = {-1,-1};
    ri(n);
    FOR(i,0,1<<n) ri(A[i]);

    int ans = 0;
    FOR(i,1,1<<n){
        ii p = f(i);
        mxze(ans, A[p.F] + A[p.S]);
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	string s;
	cin >> s;
	const auto first = s.find_first_of('A');
	const auto last = s.find_last_of('Z');
	cout << last - first + 1 << endl;
  	return 0;
}



Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		char[][] input = new char[h][w];

		for(int i = 0; i < h; i++){
			input[i] = sc.next().toCharArray();
		}

		int[][] dp = new int[h][w];

		if(input[0][0] == '#'){
			dp[0][0] = 1;
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(i != 0 || j != 0){
					dp[i][j] = Integer.MAX_VALUE;
				}

				if(i != 0){
					dp[i][j] = dp[i - 1][j];
					if(input[i][j] == '#' && input[i - 1][j] == '.'){
						dp[i][j]++;
					}
				}

				if(j != 0){
					int tmpDp;
					if(input[i][j] == '#' && input[i][j - 1] == '.'){
						tmpDp = dp[i][j - 1] + 1;
					}
					else {
						tmpDp = dp[i][j - 1];
					}
					dp[i][j] = Math.min(dp[i][j], tmpDp);
				}

//				System.out.print(dp[i][j]+" ");
			}
//			System.out.println();
		}

		System.out.println(dp[h - 1][w - 1]);
	}
}


Measured memory_bytes: 30084
n=int(input())
A=sorted(list(map(int,input().split())))
B=[0]*(A[-1]+1)
for i in A:
  B[i]+=1
  if B[i]>=2:
    continue
  for j in range(2*i,A[-1]+1,i):
    B[j]+=1
ans=0
for i in A:
  if B[i]==1:
    ans=ans+1
print(ans)

Measured memory_bytes: 32300
def main():
    _ = input() # N
    P = [int(x) for x in input().split()]
    count = 1
    min_num = P[0]
    for p in P[1:]:
        if min_num >= p:
            count += 1
        if p < min_num:
            min_num = p
        
    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 25768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, n;
  cin >> h >> w >> n;
  cout << (n+max(h, w)-1)/max(h, w) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define MAXN 10000+5
using namespace std;
vector <int> p[MAXN];
bool jud[MAXN];
int n,m;

void dfs(int i){
	
	int len=p[i].size();
	if (jud[i]) return;
	
	if (len == 0 && !jud[i]) {
		jud[i]=1;
		cout<<i<<endl;
		return;
	}
	
	for (int j = 0;j < len;++j){
		if (!jud[p[i][j]]) {
			dfs(p[i][j]);	
		}
	}
	if (!jud[i]){
		jud[i]=1;
		cout<<i<<endl;
	}
}

int main(){
	int a,b,i,j;
	cin>>n>>m;
	for (i = 0;i < m;++i){
		cin>>a>>b;
		p[b].push_back(a);
	}
	for (i = 0;i < n;++i){
		if (p[i].size() == 0 && !jud[i]){
			jud[i]=1;
			cout<<i<<endl;
		}
		else dfs(i);
	}
	return 0;
} 

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;

int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
	
	ll n;
	cin >> n;
	unordered_map<ll,ll> m;
	ll ans = 0;
	vector<ll> arr(n,0);
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		m[arr[i]]+=1;
		ans+=arr[i];
	}
	//cout << m[15] << endl;

	ll q;
	cin >> q;
	ll b,c;
	while(q--){
		cin >> b >> c;
		ans -= m[c]*c + m[b]*b;
		m[c]+=m[b];
		m[b]=0;
		ans += m[c]*c*1ll;
		cout << ans << "\n";
	}
    

    return 0;
}


Measured memory_bytes: 7768
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int  Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int main() {
	char n[4];
	scanf("%s", &n);
	char tar = n[0];
		if (n[1] <= tar && n[2] <= tar) {
			printf("%c%c%c\n", tar, tar, tar);
		}
		else {

			printf("%c%c%c\n", tar+1, tar+1, tar+1);
		}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <cstdlib>
using namespace std;
int main()
{
    long long n,i;
    static long long ara[100002],t[100002];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>ara[i];
    t[0]=0;
    for(i=1;i<n;i++)
    {
        if(i==1)
            t[i]=abs(ara[i]-ara[i-1]);
        else
            t[i]=min(t[i-1]+abs(ara[i]-ara[i-1]),t[i-2]+abs(ara[i]-ara[i-2]));
    }
    cout<<t[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 5136
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long n,i,a[131072],mp,np,res;
    char s1[64],s2[64];
    scanf("%lld%s%s",&n,s1,s2);
    if(s1[0]==s2[0]){
        res=3;mp=1;i=1;
    }
    else{
        res=6;mp=2;i=2;
    }
    while(i<n){
        if(s1[i]==s2[i]){np=1;i++;}else{np=2;i+=2;}
        if(mp==1&&np==1){
            res*=2;
        }
        if(mp==1&&np==2){
            res*=2;
        }
        if(mp==2&&np==1){
            res*=1;
        }
        if(mp==2&&np==2){
            res*=3;
        }
        res%=mod;
        mp=np;
    }
    printf("%lld\n",res%mod);
    return 0;
}

Measured memory_bytes: 128
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r=l+1
 if l<H and A[i]<A[l]:g=l
 else:g=i
 if r<H and A[g]<A[r]:g=r
 if g!=i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 64796
#include<stdio.h>
int main(void){
	int x,y;
	for(;;){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0){
			break;
		}
		if(x>=y){
			printf("%d %d\n",y,x);
		}else if(x<y){
			printf("%d %d\n",x,y);
		}
	}
	return 0;
}

Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  vector<int> v;
  rep(i, n) v.eb(i);
  double ans = 0;
  do {
    rep3(i, 1, n) ans += sqrt((x[v[i]] - x[v[i - 1]]) * (x[v[i]] - x[v[i - 1]]) + (y[v[i]] - y[v[i - 1]]) * (y[v[i]] - y[v[i - 1]]));
  } while (next_permutation(all(v)));
  rep3(i, 2, n + 1) ans /= 1.0 * i;
  cout << ans << endl;
}


Measured memory_bytes: 3780
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var a = input[0];
            var b = input[1];
            var c = input[2];
            var d = input[3];
            var x = c - a;
            var y = d - b;

            var x3 = c - y;
            var y3 = d + x;
            var x4 = a - y;
            var y4 = b + x;
            Console.WriteLine(string.Join(" ",new int[]{x3,y3,x4,y4}));
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const int maxn=1e6+10;
#define p 1000000007
int main(){
	fast;
	ll n,t,cnt=0; cin>>n;
	vector<ll> a(n);
	for(auto &it:a)cin>>it;
	sort(a.begin(), a.end());
	for(auto i=0;i<n;++i){
		for(auto j=0;j<i;++j){
			for(auto k=0;k<j;++k){
				if(a[j]+a[k]>a[i] && a[i]!=a[j] && a[j]!=a[k]){
					++cnt;
				}
			}
		}
	}
	cout<<cnt<<'\n';
	return 0;
}
//prime func
//subset production
//factorization
//modpow
//modinv ( a^(p-2)=a^(-1) (mod p) )
//sieve
//ncr
//euler totien func (co prime divisiors upto n)
//matrix exponentation
//dsu
//Trees
//Graphs(dfs,bfs,shortes path etc.)
//DP-Recursion

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    string c; cin >> c;
    vector<int> r,w;
    for(int i=0;i<N;i++){
        if(c[i]=='R') r.push_back(i);
        else w.push_back(i);
    }
    if(w.size()==0 || r.size()==0){
        cout << 0 << endl;
        return 0;
    }
    int out=w.size();
    int cnt=0;
    int ch=0;
    int cm=r.size()-1;
    int m=r[cm];
    int h=w[ch];
    while(h<m){
        ch++;
        cm--;
        h = w[ch];
        m = r[cm];
        cnt++;
    }
    cout << min(out,cnt) << endl;
    return 0;
}


Measured memory_bytes: 4644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,memo[1111][1111];
  string x,y;
  memset(memo,0,sizeof(memo));
  cin>>n;
  for(int count=0;count<n;count++){
    cin>>x>>y;
    int h=x.size(),w=y.size();
    for(int i=0;i<=w;i++){
      for(int j=0;j<=h;j++){
	if(i==0||j==0) continue;
	if(x[j-1]==y[i-1]){
	  memo[i][j]=max(memo[i-1][j-1]+1,memo[i][j-1]);
	}else if(x[j-1]!=y[i-1]){
	  memo[i][j]=max(memo[i-1][j],memo[i][j-1]);
	}
      }
    }
    cout<<memo[w][h]<<endl;
  }
  return(0);
}



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

int ans[1005][1005];
int main(){

  int R, C, h, w;
  cin >> R >> C >> h >> w;
  int d = 1000, sum = 0;
  for(int i=1; i<=R; i++){
    for(int j=1; j<=C; j++){
      if(i%h == 0 && j%w== 0){
        ans[i][j] = -((h*w-1)*d) - 1;
      }
      else ans[i][j] = d;
      sum += ans[i][j];
    }
  }

  if(sum < 0) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  for(int i=1; i<=R; i++){
    for(int j=1; j<=C; j++) cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 5572
(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    const lines = input.split(/\n/);
    const [h, w] = lines[0].split(/\s/).map(v => +v);
    const [ch, cw] = lines[1].split(/\s/).map(v => v - 1);
    const [dh, dw] = lines[2].split(/\s/).map(v => v - 1);
    const counts = lines.slice(3, h + 3).map(line => line.split('').slice(0, w).map(c => c == '#' ? -1 : Infinity));

    let que = {0: [], 1: []};
    counts[ch][cw] = 0;
    que[0].push([ch, cw, 0]);

    const addQue = (queNumber, x, y, count) => {
        if(x < 0)return;
        if(x >= h)return;
        if(y < 0)return;
        if(y >= w)return;
        if(counts[x][y] <= count)return;
        que[queNumber].push([x, y, count]);
        counts[x][y] = count;
    }
    
    while(que[0].length || que[1].length){
        if(!que[0].length){
            que[0] = que[1];
            que[1] = [];
        }
        const [x, y, count] = que[0].pop();
        if(x == dh && y == dw)break;
        
        addQue(0, x - 1, y, count);
        addQue(0, x + 1, y, count);
        addQue(0, x, y - 1, count);
        addQue(0, x, y + 1, count);
        for(let i = -2; i <= 2; i++){
            for(let j = -2; j <= 2; j++){
                addQue(1, x + i, y + j, count + 1);
            }
        }
    }

    if(counts[dh][dw] == Infinity){
        console.log(-1);
    }else{
        console.log(counts[dh][dw]);
    }

})();


Measured memory_bytes: 74768
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b <= a) cout << "delicious" << endl;
	else if (b - a <= x) cout << "safe" << endl;
	else cout << "dangerous" << endl;
    return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 1007 , mo = 1000000007;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

lint jc[_],rjc[_];

inline void fuck(int n=_-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

inline lint C(int n,int m)
{
	if(n<m || n<0 || m<0)return 0;
	return jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

int n,m,len[_],got[_]={0};
lint f[_][_]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	fuck();

	n=ty(),m=ty();
	for(int i=1;i<=n;i++)len[i]=ty(),got[len[i]]++;

	f[0][0]=1;
	for(int i=m;i>=1;i--)
	{
		for(int j=m;j>=1;j--)
			for(int k=i;k<=m;k++)
				for(int a=1;a<=j && a*i<=k;a++)
					f[j][k]=(f[j][k]+f[j-a][k-a*i]*rjc[a]%mo)%mo;
		if(got[i])
			for(int j=0;j<=m;j++)
				for(int k=0;k<=m;k++)
					f[j][k]=f[j][k]*powa(k-j*(i-1),got[i])%mo;
	}

	lint ans=0;
	for(int j=1;j<=m;j++)
	{
		for(int k=1;k<=m;k++)
		{
			if(!f[j][k])continue;
			lint sum=0;
			for(int a=0;a<j;a++)
				sum=(sum+((a&1)?mo-1ll:1ll)*C(j-1,a)%mo*C(m-k+j-a,m-k)%mo)%mo;
			sum=sum*f[j][k]%mo*jc[j]%mo;
			ans=(ans+(((m-k)&1)?mo-1ll:1ll)*sum%mo)%mo;
		}
	}

	cout<<ans<<lf;
	
	return 0;
}


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

#define min(a, b) a < b ? a : b
#define max(a, b) a > b ? a : b

#define MAXS 200000

int main(void)
{
	int i, count = 0, ans, flag = 0;
	char s[MAXS + 1];

	scanf("%s", s);

	for (i = 0; i < strlen(s); i++) {
		if (s[i] == 'A') {
			flag = 1;
		}
		if (flag) {
			count++;
		}
		if (s[i] == 'Z') {
			ans = count;
		}
	}

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

	return (0);
}

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

#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0)
#define ll long long

map<string,int>memo;
#define psi pair<string, int>



///comp ascending order
bool comp1(const psi& l, const psi& r)
{
    if(l.second != r.second){
        return l.second < r.second;
    }
    return l.first < r.first;
}
///descending order
bool comp(const psi& l, const psi& r)
{
    if(l.second != r.second){
        return l.second > r.second;
    }
    return l.first < r.first;
}
int main() {
    IO;
    int n;
    cin>> n;

    for(int i= 0;i<n;i++) {
            string s;
            cin>>s;
            memo[s] += 1;
    }


    vector<pair<string, int> > v;

    copy(memo.begin(), memo.end(), back_inserter< vector<pair< string, int> > >(v));

    sort(v.begin(), v.end(), comp);
    int maxv= v[0].second;
    //cout<<v[0].first<<"\n";

    for (size_t i = 0; i < v.size(); ++i) {
        if(v[i].second < maxv) break;
        cout << v[i].first << "\n";
    }


    return 0;
}

/****
7
beat
vet
beet
bed
vet
bet
beet
*/


Measured memory_bytes: 28016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    vector<pair<pair<string, int>, int>> book;
    rep(i,n){
        string s; cin >> s;
        int p; cin >> p;
        book.push_back(make_pair(make_pair(s,-p),i));
    }
    sort(ALL(book));
    rep(i,n) cout << book[i].second + 1 << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(min({a,b,c})==5 && max({a,b,c})==7 && a+b+c==17)
        puts("YES");
    else
        puts("NO");
}

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

public class Main {
    static int[][] memo;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int ans = 0;
        memo = new int[k + 1][k + 1];
        for(int[] m : memo) Arrays.fill(m, -1);
        for(int a = 1; a <= k; a++) {
            for(int b = 1; b <= k; b++) {
                for(int c = 1; c <= k; c++) {
                    int d = gcd(a, b);
                    ans += gcd(d, c);
                }
            }
        }
        System.out.println(ans);
    }

    static int gcd(int a, int b) {
        if(memo[a][b] != -1) return memo[a][b];
        int l = Math.max(a, b);
        int m = Math.min(a, b);
        while(m > 0) {
            int t = l % m;
            l = m;
            m = t;
        }
        return memo[a][b] = l;
    }
}


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

signed main(){
	int N; cin>>N;
	vector<pair<int,int>> AB(N),BA(N);
	for(int i=0;i<N;i++){
		cin>>AB[i].first>>AB[i].second;
		BA[i]=AB[i];
		swap(BA[i].first,BA[i].second);
	}
	sort(AB.begin(),AB.end());
	sort(BA.begin(),BA.end());
	int ans;
	if(N%2==1){
		reverse(BA.begin(),BA.end());
		ans=BA[(N-1)/2].first-AB[(N-1)/2].first+1;
	}else{
		reverse(BA.begin(),BA.end());
		double left=double(BA[N/2].first+BA[(N-2)/2].first)/2.00;
		double right=double(AB[N/2].first+AB[N/2-1].first)/2.00;
		ans=(left-right)*2+1;
	}
	cout<<ans<<endl;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll p;

bool sorter(const P& a,const P& b){
  return a.fi*(100-p)+a.se*p>b.fi*(100-p)+b.se*p;
}

ll n;
ll w[101010],b[101010];
vector<P> ps;

int main(){
	cin>>n>>p;
  rep(i,n)cin>>w[i]>>b[i];
  rep(i,n){
    ps.push_back(P(w[i],b[i]));
  }
  ll bsum=0,wsum=0;
  rep(i,n)bsum+=b[i];
  sort(all(ps),sorter);
  ll res=0;
  rep(i,n){
    bsum-=ps[i].se;
    wsum+=ps[i].fi;
    res++;
    if(wsum*(100-p)-bsum*p>=0)break;
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3956
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
int a[200000];

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

	
	cin >> n;
	rep(i, n)cin >> a[i];

	unordered_map<int, int> f;

	rep(i, n)f[a[i]]++;

	long long sum = 0;
	for (auto p : f) {
		sum += (long long)p.second * (p.second - 1) / 2;
	}


	rep(i, n) {
		long long ans = sum;
		int v = f[a[i]];

		ans -= (long long)v * (v - 1) / 2;
		ans += (long long)(v - 1) * (v - 2) / 2;
		cout << ans << endl;

	}




	return 0;
}

Measured memory_bytes: 8392
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

void print_cv(vector<char> cv) {
	for (auto c : cv) {
		cout << c << ' ';
	} 
	cout << endl;
}

int main() {
	string s,t;
	cin >> s;
	cin >> t;
	vector<char> sind,tind;
	for (long si=0;si<s.size();++si) {
		if (sind.end() == find(sind.begin(),sind.end(),s[si])) {
			sind.push_back(s[si]);
			tind.push_back(t[si]);
			
			vector<size_t> same_t_dic_idx;
			vector<char>::iterator iter = tind.begin();
			while ((iter = find(iter,tind.end(),t[si])) != tind.end()) {
				size_t t_idx = distance(tind.begin(),iter);
				same_t_dic_idx.push_back(t_idx);
				iter++;
			}
			for (auto t_idx : same_t_dic_idx) {
				if (sind[t_idx] != s[si]) {
					cout << "No" << endl;
					return 0;
				}
			}
		} else {
			auto s_iter = find(sind.begin(),sind.end(),s[si]);
			size_t s_idx = distance(sind.begin(),s_iter);
			char t_dic = t[s_idx];
			vector<size_t> same_t_dic_idx;
			vector<char>::iterator iter = tind.begin();
			while ((iter = find(iter,tind.end(),t_dic)) != tind.end()) {
				size_t t_idx = distance(tind.begin(),iter);
				same_t_dic_idx.push_back(t_idx);
				iter++;
			}
			if (tind[s_idx] != t[si]) {
				cout << "No" << endl;
				return 0;
			}
			//for (auto t_idx : same_t_dic_idx) {
			//	if (sind[t_idx] != s[si]) {
			//		cout << "No" << endl;
			//		return 0;
			//	}
			//}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776
n = gets.to_i
a = gets.split.map(&:to_i)

def counting_sort(a, k)
  c = Array.new(k+1){0}
  b = Array.new(a.length)

  a.each do |item|
    c[item]+=1
  end

  b = c.each_with_index.inject([]) do |memo, (item, i)|
    item.times {memo << i}
    memo
  end

  return b
end

puts counting_sort(a, 10000).join(" ")


Measured memory_bytes: 164988
import math
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

N = int(input())
T = [int(input()) for _ in range(N)]
if N == 1:
    print(T[0])
    exit()

ans = lcm(T[0] , T[1])
for i in range(2 , N):
    ans = lcm(T[i] , ans)
print(ans)


Measured memory_bytes: 9192
def xsum(A):
    total=0
    for i in range(len(A)):
        total^=A[i]
    return total

n=int(input())
A=list(map(int,input().split()))
B=[0]*n
total=xsum(A)
for i in range(n):
    B[i]=total^A[i]
B_str=[str(i) for i in B]
print(' '.join(B_str))

Measured memory_bytes: 43932
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=1e9+7;
const int N=55;
struct mat{
    int d[N][N];
    mat(){memset(d,0,sizeof(d));}
}a;
mat mul(mat&,mat&,int);
mat pow(mat,long long,int);
int main(){
    int n;
    long long k;
    scanf("%d%lld",&n,&k);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) scanf("%d",&a.d[i][j]);
    }
    a=pow(a,k,n);
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) ans=(ans+a.d[i][j])%mod;
    }
    printf("%d",ans);
}
mat pow(mat a,long long p,int n){
    mat re;
    for(int i=0;i<n;i++) re.d[i][i]=1;
    for(;p;p>>=1){
        if(p&1) re=mul(re,a,n);
        a=mul(a,a,n);
    }
    return re;
}
mat mul(mat&a,mat&b,int n){
    mat c;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                c.d[i][j]=(c.d[i][j]+1LL*a.d[i][k]*b.d[k][j]%mod)%mod;
            }
        }
    }
    return c;
}


Measured memory_bytes: 256
R,C,K = map(int,input().split())

grid=[[0]*C for _ in range(R)]
for i in range(K):
    x,y,v = map(int,input().split())
    grid[x-1][y-1] = v


dp0 = [[0]*(C+1) for _ in range(R+1)]
dp1 = [[0]*(C+1) for _ in range(R+1)]
dp2 = [[0]*(C+1) for _ in range(R+1)]
dp3 = [[0]*(C+1) for _ in range(R+1)]

for i in range(R):
    for j in range(C):
        dp1[i][j] = max(dp1[i][j-1],dp1[i-1][j]+grid[i][j],
                    dp2[i-1][j]+grid[i][j],dp3[i-1][j]+grid[i][j])
        dp2[i][j] = max(dp2[i][j-1],dp1[i][j-1]+grid[i][j])
        dp3[i][j] = max(dp3[i][j-1],dp2[i][j-1]+grid[i][j])
ans=max(dp1[R-1][C-1],dp2[R-1][C-1],dp3[R-1][C-1])
print(ans)

Measured memory_bytes: 429252
#include <iostream>
using namespace std;
int main()
{
  int N,a[9],s,M;
  cin>>N;
  s=0;
  M=N;
  for(int i=0;i<9;i++)
  {
    a[i]=M%10;
    M=(M-M%10)/10;
    s+=a[i];
  }
  if(N%s==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
other=[0,0,0,0,0,0,0,0]
red=0
n=int(input())
arr=list(map(int,input().split()))
for a in arr:
    if a<400:
        other[0]=1
    elif a<800:
        other[1]=1
    elif a<1200:
        other[2]=1
    elif a<1600:
        other[3]=1
    elif a<2000:
        other[4]=1
    elif a<2400:
        other[5]=1
    elif a<2800:
        other[6]=1
    elif a<3200:
        other[7]=1
    else:
        red+=1
if sum(other)==0:
    print(1,red)
else:
    print(sum(other),sum(other)+red)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }
        int Q = sc.nextInt();
        int[] B = new int[Q];
        int[] C = new int[Q];
        for (int i=0; i<Q; i++) {
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }

        long[] ans = solve(N, A, Q, B, C);
        for (int i=1; i<Q+1; i++) {
            System.out.println(ans[i]);
        }
    }

    private static long[] solve(int N, int[] A, int Q, int[] B, int[] C) {
        long[] ans = new long[Q+1];

        int[] count = new int[100000 + 1];
        for (int i=0; i<N; i++) {
            count[A[i]]++;
            ans[0] += A[i];
        }

        for (int i=0; i<Q; i++) {
            ans[i+1] = ans[i];
            ans[i+1] += (C[i] - B[i]) * count[B[i]];
            count[C[i]] += count[B[i]];
            count[B[i]] = 0;
        }

        return ans;
    }
}

Measured memory_bytes: 60680
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,-1,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fst first
#define sec second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
ll min(ll a,ll b)
{
	if(a<b){return a;}
	return b;
}
int main()
{
	fastio;
//	fopen();
	string s,t;
	cin>>s>>t;
	cout<<t<<s;
	

}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	static public void  main(String[] args){
		Scanner scan = new Scanner(System.in);

		int H = scan.nextInt();
		int W = scan.nextInt();
		int h = scan.nextInt();
		int w = scan.nextInt();

		System.out.println(H * W - h * W -  H * w  + h * w);

	}
}


Measured memory_bytes: 22740
N = int(input())
a = list(map(int, input().split()))

ans = 1
for i in range(N):
  ans = ans * a[i]
  if (ans > 10 ** 18):
    break
  
if (ans > 10**18):
  if a.count(0) > 0:
    print(0)
  else:
    print(-1)
else:
  print(ans)


Measured memory_bytes: 21480
N = int(input())

if 100000 <= N:
  print(9+(999-100)+1+(99999-10000)+1)
elif 10000<=N<=99999:
  print(9+(999-100)+1+(N-10000)+1)
elif 1000<=N<=9999:
  print(9+(999-100)+1)
elif 100<=N<=999:
  print(9+(N-100)+1)
elif 10<=N<=99:
  print(9)
else:
  print(N)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] array = new int[n];
		String[] strArray = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			array[i] = Integer.parseInt(strArray[i]);
		}
		insertionSort(array, n);
	}

	public static void insertionSort(int[] A, int N) {
		for (int i = 0; i < N; i++) {
			int temp = A[i];
			int j = i - 1;
			while (j >= 0 && temp < A[j]) {
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = temp;
			toArray(A);
		}
	}

	public static void toArray(int[] target) {
		for (int i = 0; i < target.length; i++) {
			System.out.print(target[i]);
			if (i < target.length - 1) System.out.print(" ");
		}
		System.out.println("");
	}
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.setf(ios::fixed);
	cout.precision(4);
	
	int ans1 = 0, ans2 = 0, min;

	string s, a, b;

	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		a = (i % 2) ? "1" : "0";
		b = (i % 2) ? "0" : "1";
		
		if (s[i] != a[0]) ans1++;
		if (s[i] != b[0]) ans2++;
	}

	min = (ans1 >= ans2) ? ans2 : ans1;

	cout << min << '\n';

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	ll a,b;
	cin>>n>>a>>b;
	if(n%(a+b)==0)
	{
		cout<<a*(n/(a+b))<<endl;
	}
	else
	{
		ll ans=n-(n/(a+b)*(a+b));
		cout<<a*(n/(a+b))+min(ans,a)<<endl;
	}
	return 0;
}

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

int main(void)
{
	int ans;
	int n;
	int m;
	char graph[500][500];
	char f[500];
	char ff[500];
	
	while (1){
		memset(graph, 0, sizeof(graph));
		memset(f, 0, sizeof(f));
		memset(ff, 0, sizeof(ff));
		
		scanf("%d%d", &n, &m);
		
		if (n == 0 && m == 0){
			break;
		}
		
		for (int i = 0; i < m; i++){
			int s, e;
			
			scanf("%d%d", &s, &e);
			graph[s - 1][e - 1] = graph[e - 1][s - 1] = 1;
		}
		
		for (int i = 0; i < n; i++){
			if (graph[0][i] == 1){
				f[i] = 1;
			}
		}
		
		for (int i = 0; i < n; i++){
			if (f[i] == 1){
				for (int j = 0; j < n; j++){
					if (graph[i][j] == 1){
						ff[j] = 1;
					}
				}
			}
		}
		
		ans = 0;
		for (int i = 1; i < n; i++){
			if (f[i] | ff[i] == 1){
				ans++;
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 数入力 */
  ull       answer;
  ull       a;
  ld        b; 
  answer = 0;
  scan = scanf("%llu", &a);
  scan = scanf("%Lf", &b);

  /* プログラムを書く */
  ull        bint;

  bint = (ull)round(100 * b); 
   
  answer = a * bint;
  answer = answer / 100;


  /* 数回答 */
  printf("%llu", answer);

  return (0);
}


Measured memory_bytes: 2164
n = int(input())
h = list(map(int, input().split()))

ma = h[n-1]
for i in reversed(range(n-1)):
    if h[i] == ma or h[i] == ma + 1:
        continue
    elif h[i] > ma + 1:
        print('No')
        exit()
    else:
        ma = h[i]

print("Yes")

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;

int n, a, b;
int ans;

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

pii extgcd(int a, int b) {
  if (!b) return pii(1, 0);
  pii t = extgcd(b, a%b);
  return pii(t.ss, t.ff - t.ss * (a / b));
}

signed main() {
  cin >> n;
  n *= 2;
  ans = n - 1;
  for (int i = 2; i*i <= n; i++) {
    if (n % i == 0 && gcd(i, n/i) == 1) {
      pii t = extgcd(i, n/i);
      if (t.ff < 0) t.ff = -t.ff;
      if (t.ss < 0) t.ss = -t.ss;
      //cout << i << " * " << t.ff << "  " << n/i << " * " << t.ss << "\n";
      //cout << min(t.ff * i, t.ss * (n/i)) << "\n";
      ans = min(ans, min(t.ff * i, t.ss * (n/i)));
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3636
#include <stdio.h>
#define N 8

int check(int *x, int *y, int OK){

  int i;

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

    if( x[i] == x[OK] )
      return 0;
    if( y[i] == y[OK] )
      return 0;
    if( x[i] + y[i] == x[OK] + y[OK] )
      return 0;
    if( x[i] - y[i] == x[OK] - y[OK] )
      return 0;

  }

  return 1;

}

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

  int num;
  int i,j;
  int OK;
  int x[N],y[N];
  int field[N][N];

  for( i = 0 ; i < N ; i++ ){
    x[i] = 0;
    y[i] = 0;
  }

  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      field[j][i] = 0;
    }
  }

  scanf("%d",&num);
  OK = num;

  for( i = 0 ; i < num ; i++ )
    scanf("%d %d",&x[i],&y[i]);


  while( OK < N ){

    if( y[OK] == N-1 ){
      x[OK]++;
      y[OK] = 0;
    }else{
      y[OK]++;
    }

    if( x[OK] > N-1 ){
      x[OK] = 0;
      y[OK] = 0;
      OK--;
    }else if( check(x,y,OK) ){
      OK++;
    }

  }

  for( i = 0 ; i < N ; i++ ){
    field[y[i]][x[i]] = 1;
  }

  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if( field[j][i] == 1 ){
        printf("Q");
      }else{
        printf(".");
      }
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;
using System.Text.RegularExpressions;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var S = cin.ReadLine;
            var half = (S.Length - 1) / 2;
            Console.WriteLine(Palindrome(S, 0, S.Length) && Palindrome(S, 0, half) && Palindrome(S, half + 1, half) ? "Yes" : "No");
        }
        public bool Palindrome(string S, int first,int length) {
            var Part = S.Substring(first, length);
            return Part.Zip(Part.Reverse(), (s, t) => s == t).All(b => b);
        }
    }

    static class ExtendClass {
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


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

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  int x = 0, y = 1;
  vector<vector<int>> v(h, vector<int>(w));
  for (int i = 0; i < h; ++i) {
    if (i == b)
      swap(x, y);
    for (int j = 0; j < w; ++j) {
      if (j < a)
        v[i][j] = x;
      else
        v[i][j] = y;
    }
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << v[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 5120
// Card Game for Two

#include <iostream>
#include <algorithm>

using namespace std;

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

	sort(a, a+N);
	reverse(a, a+N);

	int Alice = 0, Bob = 0;

	for(int i = 0; i < N; ++i){
		if (i % 2)
			Bob += a[i];
		else
			Alice += a[i];
	}

	cout << Alice - Bob << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		Queue<Long> qe = new ArrayDeque<Long>();
		if(n < 10) ou.println(n);
		else{
			for(int i = 1 ; i <= 9 ; i++) qe.add((long)i);
			for(int i = 0 ; i < n - 1 ; i++){
				long a = qe.poll();
				if(a % 10 != 0) qe.add(10 * a - 1 + (a % 10));
				qe.add(10 * a + a % 10);
				if(a % 10 != 9) qe.add(10 * a + 1 + (a % 10));
			}
			ou.println(qe.poll());
		}
		ou.flush();
	}
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 200010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;

ll x,y,n;
int main()
{

	
	string t;
	cin >> t;
	if(t == "ABC")
	{
		cout<<"ARC"<<endl;
	}
	else
	{
		cout<<"ABC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3624