akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

int main(){
	string number;
	int sum;
	
	while(1){
		cin >> number;
		
		if(number == "0"){
			break;
		}
		
		sum = 0;
		for(int i = 0; i < number.size(); i++){
			sum += number[i] - '0';
		}
		
		cout << sum << endl;
		
	}
		
	return 0;
}

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

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

    long long a[n];

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

    long long cost_min = 200*200*100;

    for(long long i = -100; i <= 100; i++){
        long long cost = 0;
        for(long long j = 0; j < n; j++){
            cost += (i-a[j])*(i-a[j]);
        }
        cost_min = min(cost, cost_min);
    }

    cout << cost_min << endl;

    return 0;
}

Measured memory_bytes: 256
//  299143BT
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define mod 998244353
#define pi 3.1415926535
#define fi first
#define se second
#define vll vector<ll>
#define vpll vector<pair <ll,ll> >
#define vvll vector< vll >
#define str string
#define umap unordered_map
#define uset unordered_set
#define rep(i,n) for(ll i=0;i<n;i++)
#define repA(i,s,n) for(ll i=s;i<=n;i++)
#define repD(i,s,n) for(ll i=s;i>=n;i--)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define elif else if
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ALL(v) v.begin(),v.end()
#define sortA(v) sort(ALL(v))
#define sortD(v) sort(ALL(v),greater <ll> ())
#define print(v) for(auto itr:v) cout<<*itr<<" ";
#define sz size()
#define nl cout<<"\n";
using namespace std;
ll factorial(ll n){return (n==1||n==0)?1:n*factorial(n-1);}
ll power(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll powerMod(ll x,ll y,ll m){if(y==0)return 1;ll p=powerMod(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll modInverse(ll a,ll m){return powerMod(a,m-2,m);}
ll gcd(ll a,ll b){if(a==0){return b;}else if(b==0){return a;}else{if(a>b){return gcd(a%b,b);}else{return gcd(b%a,a);}}}

void pre(){

}

void solve(){
    ll n=0;
    cin>>n;
    if(n) cout<<0;
    else cout<<1;
}

int main(){
    fast
    ll t=1;
//    cin>>t;
    pre();
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
char S[10005];
int check(int l, int r) {
	while (l <= r) {
		if (S[l] != S[r]) return 0;
		++l, --r;
	}
	return 1;
}
int main() {
	std::cin >> S + 1;
	int n = strlen(S + 1);
	if (check(1, n) && check(1, (n - 1) / 2) && check((n + 3) / 2, n)) puts("Yes"); 
	else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    REP(i,n)IN(a[i]);
    sort(ALL(a));
    ll ans=0;
    REP(i,n-1){
        if(a[i]<0){
            if(a[i+1]<0){
                a[i]=-a[i];
                a[i+1]=-a[i+1];
            }else{
                if(abs(a[i])>abs(a[i+1])){
                    a[i]=-a[i];
                    a[i+1]=-a[i+1];
                }
            }
            i++;
        }
    }
    REP(i,n)ans+=a[i];
    OUT(ans);
    return 0;
}

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

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

    int ans = 0;
    if (n > 2) {
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++)
                for (int k = j + 1; k < n; k++) {
                    int t[3] = {a[i], a[j], a[k]};
                    sort(t, t + 3);

                    if (((t[0] + t[1] > t[2]) && (t[0] != t[1])) && ((t[0] != t[2]) && (t[2] != t[1])))
                        ans++;
                }
        cout << ans;
    }else
        cout << 0;

}

Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
#include<cassert>
using namespace std;
using lint = long long;
using ld = long double;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define MOD 998244353LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(lint i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m, k;
	cin >> m >> k;
	if((1LL << m) <= k) {
		cout << -1 << endl;
		return 0;
	}
	if(m == 0) {
		cout << 0 << " " << 0 << endl;
		return 0;
	}
	if(m == 1) {
		if(k == 0) {
			cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
		} else {
			cout << -1 << endl;
		}
		return 0;
	}
	vector<int> ans;
	REP(i, (1ll << m)) {
		if(i != k) ans.pb(i);
	}
	ans.pb(k);
	for(int i = (1ll << m) - 1; i >= 0; i--) {
		if(i != k) ans.pb(i);
	}
	ans.pb(k);
	DUMP(ans);
	return 0;
}
/* --------------------------------------- */


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

int main()
{
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(n == 0)
		{
			break;
		}
		int d = 1;
		int m[6] = {1,2,3,5,4,6};
		for(int i = 0; i < n; i++)
		{
			char w[100];
			scanf("%s",w);
			if(strcmp(w,"North") == 0)
			{
				int ww = m[0];
				m[0] = m[1];
				m[1] = m[5];
				m[5] = m[3];
				m[3] = ww;
			}
			if(strcmp(w,"East") == 0)
			{
				int ww = m[0];
				m[0] = m[4];
				m[4] = m[5];
				m[5] = m[2];
				m[2] = ww;
			}
			if(strcmp(w,"West") == 0)
			{
				int ww = m[0];
				m[0] = m[2];
				m[2] = m[5];
				m[5] = m[4];
				m[4] = ww;
			}
			if(strcmp(w,"South") == 0)
			{
				int ww = m[0];
				m[0] = m[3];
				m[3] = m[5];
				m[5] = m[1];
				m[1] = ww;
			}
			if(strcmp(w,"Right") == 0)
			{
				int ww = m[1];
				m[1] = m[2];
				m[2] = m[3];
				m[3] = m[4];
				m[4] = ww;
			}
			if(strcmp(w,"Left") == 0)
			{
				int ww = m[1];
				m[1] = m[4];
				m[4] = m[3];
				m[3] = m[2];
				m[2] = ww;
			}
			d += m[0];
		}
		printf("%d\n",d);
	}
	return 0;
}

Measured memory_bytes: 1032
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (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 INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

template <class T>
void print2dVector(const vector<T> &vv) {
    for (const auto &v : vv) {
        for (const auto &e : v) {
            cout << e << " ";
        }
        cout << endl;
    }
}
int main() {
    int n, cnt = 0;
    cin >> n;
    vector<vector<int>> d(n, vector<int>(2));
    rep(i, n) rep(j, 2) { cin >> d[i][j]; }

    rep(i, n) {
        if (d[i][0] == d[i][1])
            cnt++;
        else
            cnt = 0;
        if (cnt >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3136
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int x;
    cin >> x;
    int i = 0;
    long long cnt = 0;
    while (cnt < x) {
        i++;
        cnt += i;
    }
    cout << i << endl;
    return 0;

}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll Div(ll a, ll b){
    if(a >= 0) return a / b;
    return -((- a - 1)/ b) - 1;
}

int main() {
    ll n;
    cin >> n;
    ll l, t;
    cin >> l >> t;
    ll BeforeX[100050];
    ll AfterX[100050];
    ll w[100050];
    vector<ll> SortedAfterX;
    for(int i = 1; i <= n; i++){
        cin >> BeforeX[i] >> w[i];
        if(w[i] == 2) w[i] = -1;
        AfterX[i] = BeforeX[i] + w[i] * t;
        SortedAfterX.push_back((AfterX[i] + (ll)2000000000 * l) % l);
    }
    sort(SortedAfterX.begin(), SortedAfterX.end());
    int start = 0;
    while((((AfterX[1] + (ll)2000000000 * l) % l) != SortedAfterX[start])) start++;
    ll index = 1;
    for(int i = 2; i <= n; i++){
        if(w[1] == w[i]) continue;
        //ll turn = abs(AfterX[i] - AfterX[1] - BeforeX[i] + BeforeX[1]) / l;
        ll turn = Div(AfterX[i] - AfterX[1], l) - Div(BeforeX[i] - BeforeX[1], l);
        //cout << AfterX[i] << " " << AfterX[1] << " " << BeforeX[i] << " " << BeforeX[1] << endl;
        //cout << Div(AfterX[i] - AfterX[1], l) << " " << Div(BeforeX[i] - BeforeX[1], l) << " ";
        index -= turn;
        //cout << i << " " << index << endl;
    }
    index = (index - 1 + n * (ll)1000000000000) % n + 1;
    ll Ans[100050];
    for(int i = 0; i < n; i++){
        Ans[(index + i - 1) % n + 1] = SortedAfterX[(start + i) % n];
    }
    for(int i = 1; i <= n; i++){
        cout << Ans[i] << endl;
    }
    //cout.precision(10);

    return 0;
}


Measured memory_bytes: 5236
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();

    void Solve()
    {
        int H = cin.Nextint, W = cin.Nextint;
        for (int i = 0; i < H; i++)
        {
            var S = cin.Next;
            Console.WriteLine(S);
            Console.WriteLine(S);
        }
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            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 { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 2776
#include<bits/stdc++.h>
#define slowanddetermined ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;




int32_t main()
{
    

    int k;
    cin>>k;

    deque<int>dq;
    int cnt=0;
    for(int i=1;i<=9;i++){
        dq.push_back(i);
    }
    //cout<<"HERE";
    while(true){
        int fr=dq.front();
        cnt++;
        dq.pop_front();
        if(cnt==k){ cout<<fr; return 0;}
        if(fr%10!=0){
            dq.push_back(fr*10+(fr%10)-1);
        }
        dq.push_back(fr*10+fr%10);
        if(fr%10!=9){
            dq.push_back(fr*10+(fr%10)+1);
        }

    }



    return 0;
}





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

int n,ans,mx;
int a[6005],curdp[2005][2005],dp[2005][2005],f[2005];
int main()
{
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		f[i]=-n*10;
		for(j=i;j<=n;j++)
			dp[i][j]=curdp[i][j]=-n*10;
	}
	for(i=1;i<=n*3;i++)
		scanf("%d",&a[i]);
	dp[min(a[1],a[2])][max(a[1],a[2])]=0;
	f[a[1]]=f[a[2]]=0;
	for(i=5;i<=3*n;i+=3)
	{
		int tt=0;
		if(a[i]==a[i-1]&&a[i-1]==a[i-2])
		{
			ans++;
			tt=1;
		}
		int b[3];
		for(k=0;k<3;k++)
			b[k]=a[i-k];
		sort(b,b+3);
		for(k=0;k<3;k++)
		{
			int t=b[k];
			b[k]=-10;
			sort(b,b+3);
			curdp[b[1]][b[2]]=max(curdp[b[1]][b[2]],max(dp[t][t]+1,mx));
			b[0]=t;
			sort(b,b+3);
		}
		for(k=0;k<3;k++)
		{
			int t=b[k];
			b[k]=-10;
			sort(b,b+3);
			if(b[1]==b[2])
			{
				for(j=1;j<=n;j++)
					curdp[min(t,j)][max(t,j)]=max(curdp[min(t,j)][max(t,j)],dp[min(b[1],j)][max(b[1],j)]+1);
			}
			for(j=1;j<=n;j++)
				curdp[min(t,j)][max(t,j)]=max(curdp[min(t,j)][max(t,j)],f[j]);
			b[0]=t;
			sort(b,b+3);
		}
		for(k=0;k<3;k++)
		{
			int t=b[k];
			b[k]=-10;
			sort(b,b+3);
			dp[b[1]][b[2]]=max(dp[b[1]][b[2]],curdp[b[1]][b[2]]-tt);
			mx=max(mx,dp[b[1]][b[2]]);
			f[b[1]]=max(f[b[1]],dp[b[1]][b[2]]);
			f[b[2]]=max(f[b[2]],dp[b[1]][b[2]]);
			curdp[b[1]][b[2]]=-n*10;
			for(j=1;j<=n;j++)
			{
				dp[min(t,j)][max(t,j)]=max(curdp[min(t,j)][max(t,j)]-tt,dp[min(t,j)][max(t,j)]);
				mx=max(mx,dp[min(t,j)][max(t,j)]);
				f[t]=max(f[t],dp[min(t,j)][max(t,j)]);
				f[j]=max(f[j],dp[min(t,j)][max(t,j)]);
				curdp[min(t,j)][max(t,j)]=-n*10;
			}
			b[0]=t;
			sort(b,b+3);
		}
	}
	printf("%d\n",ans+max(mx,dp[a[n*3]][a[n*3]]+1));
	return 0;
}

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

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    int c[n];
    int a[n][m];
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    
    int ans = 10000000;
    for(int i=0;i<pow(2,n);i++){
        int tmp = 0;
        int sum[m] = {0};
        for(int j=0;j<n;j++){
            if(i>>j&1){
                tmp += c[j];
                for(int l=0;l<m;l++){
                    sum[l] += a[j][l];
                }
            }
        }
        bool ok = true;
        for(int h=0;h<m;h++){
            if(sum[h]<x){
                ok = false;
            }
        }
        if(ok){
            ans = min(tmp, ans);
        }
    }

    if(ans == 10000000){
        ans = -1;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 4064
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll s=0;
    ll i;
    if(k<=a)
    {
        s=k;
    }
    else
    {
        s=a;
    }
    if(k>a+b)
    {
        k=k-a-b;
        s=s-k;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	int n,i,j,ans=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++)
		ans+=a[i]*a[j];
	}
	cout<<ans;
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env runghc
import Text.Printf
import Control.Applicative

sq x = x*x
main = map (read :: String -> Int) . words <$> getLine >>= \[a,b] ->
	if a/=0 then
		printf "%f\n" (minimum (map (\i ->
			abs $ (fromIntegral b)-(sqrt $ fromIntegral $ (sq i)+(sq (a-i)))) [0..(div a 2)]) :: Double)
		>> main
	else
		return ()

Measured memory_bytes: 4336
#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;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
ll n;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n;
		ll res=linf;
		for(ll i=1;i*i<=n;i++) {
			if(n%i==0) res=min(res,i+n/i-2);
		}
		cout<<res;
		return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int a, b, c, f = 0;
  cin >> a >> b >> c;
  
  for ( int x = a; x <= b; x++ ){
    if ( c % x == 0 ) f++;
  }

  cout << f << endl;
    
  return 0;

}


Measured memory_bytes: 3068
import java.util.Scanner;

//public class atcoder0221_A{
public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		String result = "No";
		if(N.matches(".*A.*") && N.matches(".*B.*")) {
			result ="Yes";
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; ++i){
        cin >> H[i];
    }
    vector<int> table(N);
    table[0] = 0;
    int ans = 0;
    for(int i = 0; i < N-1; ++i){
        if(H[i] >= H[i+1]){
            table[i+1] = table[i]+1;
        }else{
            table[i+1] = 0;
        }
    // for(int i = 0; i < N; ++i){
    //     cout << table[i] << " ";
    // }
    // cout << endl;
        ans = max(ans, table[i+1]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = a; i <= n; i++)
#define SIZE_N 200001
#define SIZE_KL 100001
using namespace std;


int N, K, L, p[SIZE_KL], q[SIZE_KL], r[SIZE_KL], s[SIZE_KL];
int pK[SIZE_N], pL[SIZE_N];
pair< pair<int, int>, int > w[SIZE_N];
pair< int, int > cnt[SIZE_N];

void uni(int* p, int a, int b) { p[b] = a; }
int find(int* p, int a) { return p[a] == a ? a : (p[a] = find(p, p[a])); }

bool comp1(pair< pair<int, int>, int > a, pair< pair<int, int>, int > b) {
  return a.first < b.first;
}
bool comp2(pair<int, int> a, pair<int, int> b) {
  return a.first < b.first;
}

int main(void) {
  cin >> N >> K >> L;
  REP(i, 1, K) cin >> p[i] >> q[i];
  REP(i, 1, L) cin >> r[i] >> s[i];

  REP(i, 1, N) pK[i] = pL[i] = i;
  REP(i, 1, K) if(find(pK, p[i]) != find(pK, q[i])) uni(pK, find(pK, p[i]), find(pK, q[i]));
  REP(i, 1, L) if(find(pL, r[i]) != find(pL, s[i])) uni(pL, find(pL, r[i]), find(pL, s[i]));

  REP(i, 1, N) {
    w[i].first.first = find(pK, i);
    w[i].first.second = find(pL, i);
    w[i].second = i;
  }

  sort(w + 1, w + N + 1, comp1);

  for(int i = 1; i <= N;) {
    int c = 1, j, u = w[i].first.first, v = w[i].first.second;
    for(j = i + 1; j <= N && w[j].first.first == u && w[j].first.second == v; j++) c++;
    for(; i < j; i++) {
      cnt[i].first = w[i].second;
      cnt[i].second = c;
    }
  }

  sort(cnt + 1, cnt + N + 1, comp2);

  REP(i, 1, N) cout << cnt[i].second << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,aa=0,bb=0;
	string a,b;
	cin >> n;
	while(n--){
		cin >> a >> b;
		if(a>b)aa+=3;
		else if(a<b)bb+=3;
		else aa++,bb++;
	}
	cout << aa << ' ' << bb << endl;
}


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

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 998244353  
#define M 998244353  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  

long long qpow(long long a, long long n) {
    long long ret = 1;
    a = (a % M + M) % M;
    for (; n; n >>= 1) {
        if (n & 1) ret = (ret * a) % M;
        a = (a * a) % M;
    }
    return ret;
}

int n;
vector<string> vs, l, r;
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        vs.push_back(s);
    }
    priority_queue<pii> va, vb;
    ll nsum = 0;
    for (auto &s : vs) {
        pii a(0,0);
        for (int i = 0; i < s.size(); ++i) {
            a.fi += s[i] == '(' ? 1:-1;
            a.se = min(a.se, a.fi);
        }
        if (a.se >= 0) nsum += a.fi; 
        else if (a.fi >= 0)
            va.push((pii){a.se, a.fi});
        else vb.push((pii){a.fi-a.se, -a.se});
    }
    while (!va.empty()) {
        pii p = va.top(); va.pop();
        if (nsum + p.fi <= 0) {
            cout << "No" << endl; return 0;
        }
        nsum += p.se;
    }

    while (!vb.empty()) {
        pii p = vb.top(); vb.pop();
        if (nsum - p.se < 0) {cout << "No" << endl; return 0;}
        nsum += p.fi - p.se;
    }
    if (nsum == 0)
        cout << "Yes"  << endl;
    else 
        cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 42572
#include<stdio.h>
#include <ctype.h>
int main()
{
    char s1[100],s2[100],s3[100];
    scanf("%s %s %s",s1,s2,s3);
    printf("%c%c%c",toupper(s1[0]),toupper(s2[0]),toupper(s3[0]));
}


Measured memory_bytes: 128
import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm, std.typecons;

void main() {
    alias T = Tuple!(long, "c", long, "b");

    long n, m;
    readf("%d %d\n", &n, &m);
    auto as = readln.strip.split(" ").map!(to!long).array;
    auto xs = new T[](m);

    foreach (i; 0..m) {
        long b, c;
        readf("%d %d\n", &b, &c);
        xs[i] = T(c, b);
    }
    as = sort(as).array;
    xs = sort!"a > b"(xs).array;

    long p = 0;
proc: foreach (x; xs) {
        foreach (_; 0..x.b) {
            if (x.c <= as[p]) {
                break proc;
            }
            as[p] = x.c;
            p++;
        }
    }

    long ans = as.sum();
    writeln(ans);
}


Measured memory_bytes: 9652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n, x;
    cin >> n >> x;
    vi a(n);
    cin >> a;
    sort(ALL(a));
    vector<bool> ok(n, false);
    REP(i, n) {
        if (x < a[i]) break;
        x -= a[i];
        ok[i] = true;
    }

    int ans = 0;
    REP(i, n) ans += ok[i];
    if (ans == n && x != 0) ans--;
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N,A,B; cin>>N>>A>>B;
  int y = B-A-1;
  if(y%2==1){ cout << "Alice\n"; }
  else{ cout <<"Borys\n";}
}

Measured memory_bytes: 256
N=int(input())
max=0
ans=1
num=0
for i in range(N):
    num=i+1
    count=0
    while True:
        if num%2==0:
            count+=1
        else:
            if max<count:
                max=count
                ans=i+1
            break
        num=num/2
print(ans)

Measured memory_bytes: 3060
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

sx,sy,tx,ty = inpl()
ans = ''
ans += 'U' * (ty-sy) + 'R' * (tx-sx)
ans += 'D' * (ty-sy) + 'L' * (tx-sx)
ans += 'L' + 'U' * (ty-sy+1) + 'R' * (tx-sx+1) + 'D' 
ans += 'R' + 'D' * (ty-sy+1) + 'L' * (tx-sx+1) + 'U'
print(ans) 


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

int main(){
  int n,m;
  while(cin>>n>>m,n){
    int veg[n];
    for(int i=0;i<n;i++)cin>>veg[i];
    sort(veg,veg+n,greater<int>());
    int res=0;
    for(int i=0;i<n;i++){
      if((i+1)%m==0)continue;
      res+=veg[i];
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <math.h>
 
using namespace std;
 
int main(){
 
  int N;
  cin >> N;
  
  vector<int64_t> A(N);
  for(int i=0; i<N; i++){
  	cin >> A.at(i);
  }
  
  int64_t sum=1;
  bool answer = true;
 
  for(int i = 0; i<N; i++){
  	if(A.at(i)==0){
    	cout << 0 << endl;
      	answer = false;
    }
  }
    
   if(answer){
   	for(int i=0; i<N; i++){
      int64_t sho = 1000000000000000000/sum; 
      
      if(sho >= A.at(i) ){
      	sum *= A.at(i);
      }
      else{
      	cout << -1 << endl;
        answer = false;
        break;
      }
     }
   }
	
 
  if(answer) cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] str = br.readLine().split(" ");
		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);
		int pos = 0;
		String[] a = new String [h];
		for(int i = 0; i < h; i++){
			a[i] = br.readLine();
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				char c = a[i].charAt(j);
				if(c=='#'){
					if(j-pos<0 || j-pos>1){
						System.out.println("Impossible");
						return;
					}else{
						pos = j;
					}
				}else{
					if(j==pos){
						System.out.println("Impossible");
						return;
					}
				}
			}
		}
		System.out.println("Possible");
	}
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n, a, b, c, x;
    while(cin>>n>>a>>b>>c>>x, n) {
        vi v(n);
        rep(i,n) cin >> v[i];

        int cnt = 0;
        int pos = 0;
        int f = -1;
        while(cnt<=10000) {
            if(v[pos]==x) {
                pos++;
            }

            if(pos==v.size()) {
                f = cnt;
                break;
            }
            cnt++;
            x = (a*x+b)%c;
        }
        P(f);

    }
    return 0;
}

Measured memory_bytes: 2924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 1;
    map<char, int> m;
    string s;
    cin >> s;
    for (char c : s) m[c]++;
    if (m.size() != 2)
    {
        ans = 0;
    }
    else
    {
        for (auto i : m)
            if (i.second != 2) ans = 0;
    }
    if (ans)
        cout << "Yes" << '\n';
    else
        cout << "No\n";


}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t ;
    t = 1;
//   cin >> t;
    while (t--)
        solve();
    return 0;
}




Measured memory_bytes: 3604
import sys

def solve():
    N, M = map(int, input().split())

    deg = [0] * N

    for i in range(M):
        ai, bi = map(int, input().split())
        ai, bi = ai - 1, bi - 1
        deg[ai] += 1
        deg[bi] += 1

    print(*deg, sep='\n')

if __name__ == '__main__':
    solve()

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

int main (){
    int N;
    cin >> N;
    
    int a[100007] = {};
    int check[100007] ={};
    
    for (int i=1;i<=N;i++){
        cin >> a[i];
    }
    int k = 1,c = 0;
    
    while(1){

        if(check[k]==1){
            c = -1;
            break;
        }
        
        if (a[k]==2){
            c++;
            break;
        }
        
        check[k] = 1;
        k = a[k];
        c++;
    }

    cout << c << endl;
}

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

const int M=2e5+9;
const int MOD=1e9+7;
const long long MOD2=10000004873;
const long long N=1e12+7;

using namespace std;

long long pwr(long long b,int p){
    if(p<=0)return 1;
    long long sq=pwr(b,p>>1);
    sq=(((sq%MOD)*(sq%MOD))%MOD);
    if(p&1)
        sq=(((sq%MOD)*(b%MOD))%MOD);
    return sq;
}

int fr[M],x,n;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n-1;++i){
        scanf("%d",&x);
        ++fr[x];
    }
    for(int i=1;i<=n;++i)
        cout<<fr[i]<<endl;
    return 0;
}


Measured memory_bytes: 4540
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        sc.close();
        boolean judge=true;
        for(int i=0;i<str.length()-1;i++){
            if(str.charAt(i)==str.charAt(i+1)){
                judge=false;
                break;
            }
        }
        if(judge){
            System.out.println("Good");
        }else{
            System.out.println("Bad");
        }
    }
}

Measured memory_bytes: 23380
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    n = len(s)
    ans = 0
    i = 0
    pre = ""
    while i < n:
        if s[i] != pre:
            pre = s[i]
            i += 1
        else:
            if i == n-1:
                ans -= 1
            pre = s[i:i+2]
            i += 2
        ans += 1
    print(ans)
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()
    a = LI()
    b = LI()
    q = []
    for i in range(n):
        if b[i] > a[i]:
            heappush(q,(-b[i],i))
    ans = 0
    while q:
        bi,i = heappop(q)
        r = (i+1)%n
        l = i-1
        s = b[l]+b[r]
        if a[i] < s:
            m = b[i]//s
            if m:
                ans += m
                b[i] %= s
                if b[i] != a[i]:
                    heappush(q,(-b[i],i))
        else:
            k = -bi-a[i]
            m = k//s
            b[i] -= m*s
            ans += m
            if b[i] != a[i]:
                break
    if a == b:
        print(ans)
    else:
        print(-1)
    return

#D
def D():

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 62832
#include <stdio.h>

int main(void) {
  int n, k;
  scanf("%d %d", &n, &k);
  int i, a[n];
  for (i = 0; i < n ; i++) {
    scanf("%d", &a[i]);
  }
  if (n == k) {
    printf("1\n");
    return 0;
  }
  if (( (n - 1) % (k - 1) ) == 0) {
    printf("%d\n", (n - 1) / (k - 1));
  } else {
    printf("%d\n", (n - 1) / (k - 1) + 1);
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    repi(i,n/2,0){
        if(s[i] != s[n - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    
    repi(i,n/4,0){
        if(s[i] != s[n/2 - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    
    repi(i,n/4 + n/2 + 1,n/2 + 1){
        if(s[i] != s[n - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

void trace(int A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) printf(" ");
		printf("%d", A[i]); 	
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int v, j;

	for (int i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;

		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		
		// Output
		trace(A, N);
	}
}

int main() {
	int N;
	int A[100];

	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	trace (A, N);

	insertionSort(A, N);

	return 0;
}

Measured memory_bytes: 3216
def hoge(x,y,w,h,stage):
    temp = [-1,0,1]
    count = 0
    for i in temp:
        if x + i < 0 or x+i >= h:
            continue
        for j in temp:
            if y + j < 0 or y+j >= w:
                continue
#            print (x+i,y+j)
            if stage[x+i][y+j] == "#":
                count += 1
    return count


h,w = map(int,input().split())

stage = []
for i in range(0,h):
    stage.append(input())

for i in range(0,h):
    for j in range(0,w):
        if stage[i][j] == "#":
            print("#",end = "")
        else:
            print(hoge(i,j,w,h,stage),end = "")
    print()



Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int a[];
		long sum;
		long max;

		n = sc.nextInt();
		while (n != 0) {
			a = new int[n];
			sum = 0L;
			max = 0L;
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			for (int i = 0; i < n; i++) {
				sum = a[i];
				max = (i == 0) ? sum : max;
				max = (max < sum) ? sum : max;
				for (int j = i + 1; j < n; j++) {
					sum += a[j];
					max = (max < sum) ? sum : max;
				}
			}

			System.out.println(max);
			n = sc.nextInt();
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
int n;
cin>n;
vi a(n);
cin>a;
int ma1=0,ma2=0;
REP(i,n){
if(ma1<a[i]){
ma2=ma1;ma1=a[i];
}else if(ma2<a[i]){
ma2=a[i];
}
}
REP(i,n){
if(a[i]==ma1)cout<ma2<endl;
else cout<ma1<endl;
}
    return 0;
}


Measured memory_bytes: 2432
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    int t;
    int ans=-1;
    for(int i=1; i<=n;i++){
        int hoge=-1;
        int sub=i;
        while(hoge++,((sub%2)==0)&&sub!=0)sub/=2;
        if(ans<hoge){ans=hoge; t=i;}
    }
    cout<<t<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a[21],x;
    int n,sum = 0;
    scanf("%d",&n);
    for(int i = 0;i < n;i++)
    	scanf("%d",&a[i]);
    for(int i = 0;i < n;i++){
    	scanf("%d",&x);
    	a[i] = a[i] - x;
    	if(a[i] > 0) sum += a[i];
	}
	printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
    char ch;
    int c = -4;

    FOR(i,0,4){
        cin >> ch;
        if(ch ==  '+')c += 2;
    }
    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256