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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    string s;
    cin >> s;
    yesno(s[2] == s[3] && s[4] == s[5]);
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
/*
 *  author: chw0501
 *  reference: http://www.secmem.org/blog/2019/05/15/Education-Dp-Contest-Solution/
 *  created: 25.04.2020 03:55:44(UTC)
*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define MOD 1000000007 
#define INF 987654321 

int n;
string s;
//dp[i][j]: 앞의 i개의 숫자를 채워넣을때 1~i 숫자를이용. i번째 숫자는 j. 그런 가짓수
ll dp[3010][3010];
//sum[i][j]: dp[i][1] ~ dp[i][j]까지의 합
ll sum[3010][3010];

int main(){
	cin>>n;
	cin>>s;
	dp[1][1]=1;
	sum[1][1]=1;
	for(int i=2;i<=n;i++){
		if(s[i-2]=='<'){
			for(int j=1;j<=i;j++){
				//dp[i][j]=sum of dp[i-1][1 ~ j-1]
				dp[i][j]=(sum[i-1][j-1]-sum[i-1][0]+MOD)%MOD;
			}
		}else{
			for(int j=1;j<=i;j++){
				//dp[i][j]=sum of dp[i-1][j ~ i-1]
				dp[i][j]=(sum[i-1][i-1]-sum[i-1][j-1]+MOD)%MOD;
			}
		}
		for(int j=1;j<=i;j++){
			sum[i][j]=(sum[i][j-1]+dp[i][j])%MOD;
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans=(ans+dp[n][i])%MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 139904
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	LL K,A,B;
	cin>>K>>A>>B;
	if(K<A){
		cout<<K+1<<endl;
		return 0;
	}
	if(A+1>=B){
		cout<<K+1<<endl;
		return 0;
	}
	LL now=A;
	K-=(A-1);
	if(K%2==1)now++;
	K/=2;
	now+=(B-A)*K;
	cout<<now<<endl;
	return 0;
}

Measured memory_bytes: 256
/*#include<iostream>
using namespace std;
int main() {
int a, sum = 0;
for (int i = 0; i < 4; i++) {
cin >> a;
sum += a;
}
cout << sum / 60 << endl << sum % 60 << endl;
}*/
/*#include<iostream>
using namespace std;
int main() {
int min1 = 2000, min2 = 2000, a;
for (int i = 0; i < 3; i++) {
cin >> a;
if (min1 > a)min1 = a;
}
for (int i = 0; i < 2; i++) {
cin >> a;
if (min2 > a)min2 = a;
}
cout << min1 + min2-50 << endl;
}*/
#include<iostream>
using namespace std;
int main() {
int a[5], b[2] = {1}, sum = 0;
for (int i = 0; i < 5; i++) {
cin >> a[i];
}
while (a[1] > a[3]*b[0]) {
b[0]++;
//cout << "bakatoy" << endl;
}
while (a[2] > a[4]*b[1]) {
b[1]++;
//cout << "bakatoy" << endl;
}
if (b[0] > b[1]) {
cout << a[0]-b[0] << endl;
}
else {
cout << a[0]-b[1] << endl;
}
}
/*#include<iostream>
using namespace std;
int main() {
	int a, sum=0;
	for (int i = 0; i<5; i++) {
		cin >> a;
		if (a < 40)a = 40;
		sum += a;
	}
	cout << sum / 5 << endl;
}*/

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define half (500000004ll)

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

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

ll rwpw(ll a, ll p){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

ll fc[225816]={1ll},rev[225816]={1ll};

ll comb(int n, int k){
	ll ret=1ll;
	mul_mod(ret,fc[n]);
	mul_mod(ret,rev[k]);
	mul_mod(ret,rev[n-k]);
	return ret;
}

int main(void){
	int b,w,n,i;
	ll bonly=0ll,wonly=0ll,both=1ll,d=1ll,t;
	cin >> b >> w;
	n = b+w;
	for(i=1; i<=n; ++i){
		fc[i] = (fc[i-1]*i)%MOD;
		rev[i] = (rev[i-1]*rwpw(i,MOD-2))%MOD;
		mul_mod(d,half);
		// cout << bonly << " " << wonly << " " << both << endl;
		cout << ((both*half)%MOD+bonly)%MOD << endl;
		if(i>=b){
			t = comb(i-1,b-1);
			mul_mod(t,d);
			add_mod(both,MOD-t);
			add_mod(wonly,t);
		}
		if(i>=w){
			t = comb(i-1,w-1);
			mul_mod(t,d);
			add_mod(both,MOD-t);
			add_mod(bonly,t);
		}
	}
	return 0;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

string itoa(vi v){
    string s = "";
    rep(i, 0, v.size()){
        s += to_string(v[i]);
    }
    return s;
}

int main(){
    int N; cin >> N;
    vi p, q;
    rep(i, 0, N){
        int j; cin >> j;
        p.pb(j);
    }
    rep(i, 0, N){
        int j; cin >> j;
        q.pb(j);
    }
    vi v;
    rep(i, 0, N){
        v.pb(i+1);
    }
    vs S;
    do{
        string s = itoa(v);
        S.pb(s);
    }while(next_permutation(v.begin(), v.end()));
    sort(S.begin(), S.end());
    int a;
    int b;
    rep(i, 0, S.size()){
        if(S[i] == itoa(p)) a = i;
        if(S[i] == itoa(q)) b = i;
    }
    cout << abs(b-a) << endl;


    return 0;
}




Measured memory_bytes: 5348
#include <stdio.h>

int main(void){
    int n;
    int p[21];
    int i,count = 0;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
        scanf("%d", &p[i]);
    }
    
    for(i = 1; i <= n-2; i++){
        if((p[i+1] > p[i] && p[i+1] < p[i+2]) || (p[i+1] < p[i] && p[i+1] > p[i+2])){
            count++;
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
           
            var num = cin.ReadInt;

            int total = (num + num * num + num * num * num);

            WriteLine(total);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.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; }
    }
}

Measured memory_bytes: 27680
#B
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    m = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == m:
                a[j][k] = 0
f = False
for j in range(3):
    if a[j][0] == 0 and a[j][1] == 0 and a[j][2] == 0:
        f = True
    if a[0][j] == 0 and a[1][j] == 0 and a[2][j] == 0:
        f = True
if (a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0) or (a[2][0] == 0 and a[1][1] == 0 and a[0][2] == 0):
    f = True
if f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using ll = long long;
using  INT = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*........................................DEFINE FUNCTIONS.........................................*/


/*....................................DEFINE GLOBAL VARIABLES .....................................*/

using id = string;

/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	ll N, X;
	cin >> N >> X;
	vector<ll> x(N), dis;

	REP(i, N) {cin >> x[i];}
	sort(ALL(x));
	REP(i, N) {dis.push_back(abs(X - x.at(i)));}
	ll ans = dis.at(0);
	REP(i, N) {ans = gcd(ans, dis.at(i));}

	cout << ans << endl;






	return 0;
}












Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=1e5+10 ;

int a[1000][1000];
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	int n; cin>>n;
	for (int m=1; m*(m-1)/2 <=n; ++m)
		if ( m*(m-1)/2 ==n ){
			puts("Yes");
			printf("%d\n", m);
			for (int i=1, cnt=0; i<=m; ++i){
				for (int j=i+1; j<=m; ++j)
					a[i][j] = a[j][i]=++cnt;
				
				printf("%d ", m-1);
				for (int j=1; j<=m; ++j)	if ( a[i][j] ) printf("%d ", a[i][j]);
				puts("");
			}
			return 0;
		}
	puts("No");	
	return 0;
}

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


int main() {
  ll n,wall;
  cin>>n>>wall;
  vector<P> v(n);
  vector<ll>w1;
  vector<ll>w2;
  vector<ll>w3;
  vector<ll>w4;
  vector<ll>W1(101,0);
  vector<ll>W2(101,0);
  vector<ll>W3(101,0);
  vector<ll>W4(101,0);
  ll s1,s2,s3,s4;

  rep(i,n){
    cin>>v[i].first;
    cin>>v[i].second;
  }
  ll w=v[0].first;
  rep(i,n){
    if (v[i].first==w)w1.push_back(v[i].second);
    if (v[i].first==w+1)w2.push_back(v[i].second);
    if (v[i].first==w+2)w3.push_back(v[i].second);
    if (v[i].first==w+3)w4.push_back(v[i].second);
  }
  sort(w1.rbegin(),w1.rend());
  sort(w2.rbegin(),w2.rend());
  sort(w3.rbegin(),w3.rend());
  sort(w4.rbegin(),w4.rend());

  s1=w1.size();  s2=w2.size();
  s3=w3.size();  s4=w4.size();
  //cout<<s1<<' '<<s2<<' '<<s3<<' '<<s4<<endl;
  /*
  W1[0]=w1[0];  W2[0]=w2[0];
  W3[0]=w3[0];  W4[0]=w4[0];
*/
  rep(i,s1){
    W1[i+1]=W1[i]+w1[i];
  //  cout<<W1[i+1]<<endl;
  }
  rep(i,s2){
    W2[i+1]=W2[i]+w2[i];

  }
  rep(i,s3){
    W3[i+1]=W3[i]+w3[i];

  }
  rep(i,s4){
    W4[i+1]=W4[i]+w4[i];
  }
  ll ans=0;
rep(i,s1+1)rep(j,s2+1)rep(k,s3+1)rep(l,s4+1){
  ll wtot=(i+j+k+l)*w+j+2*k+3*l;
  //cout<<wtot<<endl;
  //cout<<i<<'i'<<j<<'j'<<k<<'k'<<l<<'l'<<endl;
  if (wtot>wall)continue;
  ll temp=W1[i]+W2[j]+W3[k]+W4[l];
//cout<<temp<<endl;
  ans=max(ans,temp);
}
cout<<ans;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=9000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll bit[800010];
ll u;
void bitinit(ll n){
    ll y=1;
    rep(i,0,69){
        
        if(y>=n){
            u=y;
            break;
        }
        y*=2;
    }
    fill(bit,bit+u+10,0);
}
void add(ll n,ll x){
    ll i=n;
    bit[i]+=x;
    bit[i]%=mod;
    while(i<u){
        i+=i&(-i);
        bit[i]+=x;
        bit[i]%=mod;
    }
}
ll sum(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
ll rev(ll n){
    ll ret=0;
    vector<ll> v;
    while(n>0){
        v.push_back(n%10);
        n/=10;
    }
    reverse(v.begin(),v.end());
    ll now=1;
    rep(i,0,v.size()){
        ret+=v[i]*now;
        now*=10;
    }
    return ret;
}
ll dfs(ll d,ll now,ll ue,ll si,ll sum){
    if(now<=0){
        if(d==0)return sum;
        else return 0;
        
    }
    ll ret=0;
    rep(i,-9,10){
        ll yy=d-now*i;
        ll ne=max((ll)0,ue/10-si*10);
        if(abs(yy)>ne*10)continue;
        ll rr=10-abs(i);
        if(si==1&&i>=0)rr=9-i;
        ret+=dfs(d-now*i,ue/10-si*10,ue/10,si*10,sum*rr);
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll d;cin>>d;
    ll ans=0;
    ll now=0;
    rep(i,2,20){
        now*=10;
        now+=9;
        ll ue=now+1;
        ll si=1;
        ll noww=d;
        ll ttt=1;
        if(i%2)ttt=10;
        ans+=dfs(noww,now,ue,si,1)*ttt;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+9;

int a[N],t[N];

int main(){
	int n,ans=1,c=1;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		t[a[i]]=i;
	}
	for(int i=1;i<n;i++){
		if(t[i]<t[i+1])c++;
		else c=1;
		ans=max(ans,c);
	}
	cout<<n-ans;
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = "";
            while (true)
            {
                s = Console.ReadLine();

                if (s == "0") break;

                var answer = 0L;
                foreach (var c in s)
                {
                    answer += int.Parse(c.ToString());
                }

                Console.WriteLine(answer);
            }
        }
    }
}



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

#define N (long long)(pow(10,9)+7)

long long solve(long long n){
	if(n==1) return 1;
	
	return (solve(n-1)*n)%N;
}

int main(void){
	long long n;cin >> n;
	cout << solve(n) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i * i <= n; i++){
    ll cnt = 0;
    while(n%i==0){
      cnt++;
      n /= i;
    }
    for (int j = 1;;j++){
      if(cnt>=j){
        cnt -= j;
        ans++;
      }
      else
        break;
      }
    }
    if (n != 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int dp[3001][3001];
int main()
{
    char a[3000],b[3000];
    cin>>a>>b;
    memset(dp,-1,sizeof(dp));
    dp[0][0]=a[0]==b[0]?1:0;
    int m=strlen(a);
    int n=strlen(b);
    for(int i=1;i<m;i++)
    {
        dp[i][0]=max(dp[i-1][0],a[i]==b[0]?1:0);
    }
    for(int i=1;i<n;i++)
    {
        dp[0][i]=max(dp[0][i-1],a[0]==b[i]?1:0);
    }
    for(int i=1;i<m;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(a[i]==b[j])
                dp[i][j]=1+dp[i-1][j-1];
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    stack<char> ans;
    int i=m-1,j=n-1;
    while(i>0&&j>0)
    {
        if(a[i]==b[j])
            {
                ans.push(a[i]);
                i--;
                j--;
            }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else
            {
                j--;
            }
        }  
    }
    if(i==0)
    {
        if(dp[i][j]==1)
            cout<<a[i];
    }
    else if(j==0)
    {
        if(dp[i][j]==1)
            cout<<b[j];
    }
    while(!ans.empty())
    {
        cout<<ans.top();
        ans.pop();
    }
    return 0;   
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,K,h[200001];
  cin >> N;
  REP(i,N)cin >> h[i];
  sort(h,h+N);
  int res=0;
  REP(i,N-1){
    res += h[i]; 
  }
  cout << (res+h[N-1]/2) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <tuple>
#include <unordered_map>
#include <vector>

#include <boost/range/adaptors.hpp>


int main() {
    long X;
    std::cin >> X;

    std::vector<long> a_can;
    std::vector<long> b_can;

    a_can.push_back(0);
    b_can.push_back(0);
    for (long i = 1; i*i*i*i <= X ; ++i) {
      a_can.push_back(i*i*i*i*i);
      b_can.push_back(a_can.back());
    }

    for (int i = 0; i < a_can.size(); ++i) {
      for (int j = 0; j < b_can.size(); ++j) {
        if (a_can[i] - b_can[j] == X) {
          std::cout << i << " " << j << std::endl;
          return 0;
        } else if (a_can[i] + b_can[j] == X) {
          std::cout << i << " " << -j << std::endl;
          return 0;
        }
      }
    }
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
  long long int n,i,s=1000000,l=-1000000,ans=0;
  scanf("%lld",&n);
  long int a[n];
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    if(a[i]<s)s=a[i];
    if(a[i]>l)l=a[i];
    ans+=a[i];
  }
  printf("%lld %lld %lld\n",s,l,ans);
  return 0;
}

Measured memory_bytes: 676
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 12 14:43:03 2018
ABC947D
@author: maezawa
"""

n, t = list(map(int, input().split()))
a = list(map(int, input().split()))

cnt_buy = 0
cnt_sell = 0
buy = 10**9
sell = 2
profit = 0

for i in range(n):
    if a[i] - buy > profit:
        profit = a[i] - buy
        sell = a[i]
    elif a[i] < buy:
        buy = a[i]

buy = 10**9
sell = 2
buys = []
sells = []
i_buy = []

for i in range(n):
    if a[i] - buy == profit:
        buys.extend(i_buy)
        sells.append(i)
    elif a[i] < buy:
        buy = a[i]
        i_buy = [i]
    elif a[i] == buy:
        i_buy.append(i)
    
n_sell = len(set(sells)) 
n_buy = len(set(buys))   
        

print(min(n_sell, n_buy))

        

Measured memory_bytes: 14480
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      if i < j and j < k:
        if l[i] == l[j]:
          continue
        if l[i] == l[k]:
          continue
        if l[k] == l[j]:
          continue
        if l[i]+l[j]+l[k] <= max(l[i],l[j],l[k])*2:
          continue
        ans += 1
print(ans)


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

int main() {
  char s[5];
  scanf("%s",s);
  int A=s[0]-'0';
  int B=s[1]-'0';
  int C=s[2]-'0';
  int D=s[3]-'0';
  if (A-B-C-D==7) {
    printf("%d-%d-%d-%d=7\n",A,B,C,D);
  } else if (A-B-C+D==7) {
    printf("%d-%d-%d+%d=7\n",A,B,C,D);
  } else if (A-B+C-D==7) {
    printf("%d-%d+%d-%d=7\n",A,B,C,D);
  } else if (A-B+C+D==7) {
    printf("%d-%d+%d+%d=7\n",A,B,C,D);
  } else if (A+B-C-D==7) {
    printf("%d+%d-%d-%d=7\n",A,B,C,D);
  } else if (A+B-C+D==7) {
    printf("%d+%d-%d+%d=7\n",A,B,C,D);
  } else if (A+B+C-D==7) {
    printf("%d+%d+%d-%d=7\n",A,B,C,D);
  } else if (A+B+C+D==7) {
    printf("%d+%d+%d+%d=7\n",A,B,C,D);
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int A, B, T; cin >> A >> B >> T;
	cout << ((int)(T + 0.5 ) / A)*B;
}



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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  int n = s.size();
  string s1 = "", s2 = "";
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      s1 += '0', s2 += '1';
    } else {
      s1 += '1', s2 += '0';
    }
  }
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] != s1[i]) ans1++;
    if (s[i] != s2[i]) ans2++;
  }
  cout << min(ans1, ans2) << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

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

  char a, b;
  cin >> a >> b;

  if (a == b) cout << "H" << "\n";
  else cout << "D" << "\n";
}


Measured memory_bytes: 3656
fun main(args: Array<String>) {
    readLine()
    val a = mutableListOf(0).apply {
        addAll(readLine()
                ?.split(" ")
                ?.map { it.toInt() }!!)
        add(0)
    }
    val _a = a

    val list = _a.mapIndexed { i, v ->
        if (i == 0) 0 else (a[i - 1] abs v)
    }

    val sum = list.sum() + (a[a.lastIndex] abs 0)

    (1 until a.size - 1).forEach {
        println(sum - list[it] - list[it + 1] + (a[it - 1] abs a[it + 1]))
    }
}

infix fun Int.abs(x: Int) = if ((this - x) < 0) (this - x) * (-1) else (this - x)


Measured memory_bytes: 58176
N,K=map(int,input().split())
L=[int(input()) for _ in range(N)]
LS = sorted(L)
import sys
ANS = sys.maxsize
#print(LS)
for i in range(N-K+1):
  #print("i={}, i+K-1={}, ANS={}, LS[i+K-1]={},LS[i]={}".format(i, i + K -1, ANS, LS[i+K-1],LS[i]))
  ANS = min(ANS, LS[i+K-1] - LS[i])
print(ANS)

Measured memory_bytes: 8196
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;

using ll = long long;


int main(void){
    
    int N;
    cin >> N;
    vector<size_t> s(N);

    string str(10, 0);
    for (auto& x : s){
        cin >> str;
        sort(str.begin(), str.end());
        x = hash<string>()(str);
    }
  	sort(s.begin(), s.end());

    long start = 0;
    long ans = 0;
    for(int i : boost::irange(1,N)) {
        if(s[i] == s[i-1])
            continue;

        long len = i - start;
        if (len > 1){
            ans += len * (len-1) / 2;
        }

        start = i;
    }
    if (start != N-1) {
        long len = N - start;
        ans += len * (len-1) / 2;
    }

    cout << ans << endl;

} 

Measured memory_bytes: 1024
import sys

# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a,b = map(str, input().split())

    s=""
    s = [i+j for i, j in zip(a,b)]
    print("".join(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int count=0;
while((line=br.readLine())!=null){
StringBuffer sb=new StringBuffer(line);
if(sb.reverse().toString().equals(line)){
count++;
}
}
System.out.println(count);
}
}

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

int main() {
    string s, t;
    cin >> s;
    int i = 0, n = s.size();
    while(i < n) {
        if(s[i] != 'B') {
            t += s[i];
            i++;
        }
        else {
            if(i + 1 < n && s[i + 1] == 'C') {
                t += 'X';
                i += 2;
            }
            else {
                t += 'B';
                i++;
            }
        }
    }
    //cout << t << '\n';
    int aseg = 0;
    long long ans = 0;
    for(int i = 0; i < n; i++) {
        if(t[i] == 'B' || t[i] == 'C')
            aseg = 0;
        if(t[i] == 'A')
            aseg++;
        if(t[i] == 'X')
            ans += aseg;
    }
    cout << ans << endl;
}

Measured memory_bytes: 900
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int A,B,C;
/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B >> C;
    cout << ((C>=A&&C<=B) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
int main(){
  ll n;
  cin >> n;
  vll b(n+1);
  for (ll i = 1; i <= n; i++) {
    cin >> b[i];
    if (b[i] > i) {
      cout << -1 << endl;
      return 0;
    }
  }
  
  vll ans(n);
  ll index = n - 1;
  while (index >= 0) {
    for (ll i = index+1; i >= 1; i--) {
      if (b[i] == i) {
        ans[index] = i;
        b.erase(b.begin()+i);
        index--;
        break;
      }
    }
  }
  
  for (ll i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 256
import math
#x a bを設定する
x,a,b = map(int,input().split())
#x からaまでの距離とxからbまでの距離を計算する

a_distant = a - x
b_distant = b - x
if a_distant < 0:
    a_distant = a_distant*(-1)
if b_distant < 0:
    b_distant = b_distant*(-1)
#aまでとbまでを比較して短い方を出力する
if a_distant > b_distant:
    print("B")
else:
    print("A")

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


void solve(long long a, long long b){
    cout << (a<=b ? a : a-1) << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int n;
	cin >> n;
	vector<double> v(n);
	rep(i,n) {
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	rep(i,n-1) {
		v[i+1] = (v[i] + v[i+1])/2;
	}
	cout << v[n-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int n,cnt=0;
  cin >> n;
  fp(i,1,n)
    {
        int x;
        cin >> x;
        if(x%2==1 && i%2==1)
            cnt++;
    }
    cout << cnt << '\n';
  return;
} 

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long 
#define pb push_back
int main(){	
	fast;
		ll n,r; cin>>n>>r;
		if(n>=10) cout<<r;
		else {
			ll p=100 * (10-n);
			cout<<r+p;
			}
			}
	
	
	
	
		
		
	
	
		
	
	 	
	 	

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c=0,i,j,k;
	while(1){
		
	scanf("%d %d",&a,&b);
	if(a==0&&b==0)
	break;
	for(i=1;i<=a;i++)
	for(j=i+1;j<=a;j++)
	for(k=j+1;k<=a;k++){
	if(i+j+k==b)
			c++;
}
			printf("%d\n",c);
		c=0;
	}
	return 0;
}
	

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

int main()
{
  int N, M;
  cin >> N >> M;
  int N2, M2;
  N2 = N * (N - 1) / 2;
  M2 = M * (M - 1) / 2;
  cout << M2 + N2 << endl;
}


Measured memory_bytes: 256
i;
p(a,b){for(i=0;i++<b;)putchar(a);}

int main(void){

    int x,y,u,v;
    scanf("%d%d%d%d",&u,&v,&x,&y);
    
    x-=u;
    y-=v;
    
    p(85,y);
    for(int i=0;i<x;i++){
        printf("R");
    }
    for(int i=0;i<y;i++){
        printf("D");
    }
    for(int i=0;i<x;i++){
        printf("L");
    }
    
    printf("L");
    for(int i=0;i<y+1;i++){
        printf("U");
    }
    for(int i=0;i<x+1;i++){
        printf("R");
    }
    printf("DR");
    for(int i=0;i<y+1;i++){
        printf("D");
    }
    for(int i=0;i<x+1;i++){
        printf("L");
    }
    printf("U");
    printf("\n");
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define ld long double
#define ff float
#define pb push_back
#define ist insert
#define vec vector <int>
#define vecc vector <char>
#define vecs vector <string>
#define vecl vector <ll int>
#define vecp vector <pair<int,int>>
#define vecpl vector <pair<ll int,ll int>>
#define ub upper_bound
#define lb lower_bound
#define bg begin()
#define en end()
#define el endl
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define wl while
#define sz size()
#define ss set <int>
#define ssl set <ll int>
#define mapi map<int,int>
#define mapl map<ll int,ll int>
#define mapc map<char,ll int>
#define maps map<string,ll int>
#define mapss map<string,string>
#define scni(x) scanf("%d",&x)
#define scns(x) scanf("%s",x)
#define scnc(x) scanf("%c",&x)
#define pti(x) printf("%d",x)
#define pts(x) printf("%s",x)
#define ptc(x) printf("%c",x)
#define test int t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
const int mod=1e9+7;
const int mex=1e6+1;
ll power(ll a,ll b)
{
    ll ans=1,temp=a;
    while(b!=0)
    {
        if(b&1)
        ans=ans*temp;
        ans=ans%mod;
        temp=temp*temp;
        temp=temp%mod;
        b/=2;
    }
    return ans;
}
int spf[mex];
void seive()
{
    int p[mex];
    for(int i=0;i<mex;i++) p[i]=1;
    p[0]=0;
    p[1]=0;
    for(int i=2;i*i<mex;i++)
    {
        if(p[i])
        for(int j=i*i;j<mex;j+=i)
        p[j]=0;
    }
    
}
ll int x1,x2,d1;
void exeu(ll int a1,ll int b1)
{
    if(b1==0)
    {
        x1=1;
        x2=0;
        d1=a1;
    }
    else
    {
        exeu(b1,a1%b1);
        ll int temp=x1;
        x1=x2;
        x2=temp-(a1/b1)*x2;
    }
}
ll int modinv(ll int A,ll int M)
{
    exeu(A,M);
    return (x1%M+M)%M;
}
void Lcs(string X,string Y,int m,int n) 
{ 
   int L[m+1][n+1];
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   }
   int index = L[m][n];
   char lcs[index+1]; 
   lcs[index] = '\0';
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   {
      if (X[i-1] == Y[j-1]) 
      { 
        lcs[index-1]=X[i-1]; 
        i--; 
        j--; 
        index--;
      }
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   }
   cout<<lcs<<el;
}
int main()
{
    fast
    string s,t;
    cin>>s>>t;
    Lcs(s,t,s.sz,t.sz);
    
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int a[4];
	rep(i, 4) {
		cin >> a[i];
	}
	if (a[3] == 1)
		cout << 1 << endl;
	else
		cout << 0 << endl;
}

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

int main() {
    int h, n, i, mov, sum=0;
    cin >> h >> n;

    for(i=0; i<n; i++) {
        cin >> mov;

        sum = sum + mov;
    }

    if(sum>=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}
const int INF = 100000000;

int gcd(ll a, ll b){
    if(a == 0){
        return b;
    }
    return gcd(b % a, a);
}

int main(){
    ll a, b;
    cin >> a >> b;

    ll x = b / gcd(a, b) * a;
    cout << x << endl;
}

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

int main() {
    int N;
    cin >> N;
    int x=N*0.92;
    bool z=true;
    for(int i=x;i<=N;i++){
        int X=i*1.08;
        if(X==N){
            cout << i << endl;
            z=false;
            break;
        }
    }
    if(z){
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back



int memo[64][64];

int main(void){
  while(1){
    int n,p;
    int pl[64] = {0};
    int ans = -1;
    int bowl;
    cin >> n >> p;
    bowl = n;
    if(n+p==0)break;
    if(memo[n][p] == 0){
      bowl = p;
      rep(i,1000000){
        if(bowl){
          bowl--;
          pl[(i%n)]++;
          if(pl[i%n] == p){ans = i%n;break;}
        }else{
          bowl = pl[i%n];
          pl[i%n] = 0;
        }
      }
      cout << ans << endl;
      memo[n][p] = ans;
    }else{
      cout << memo[n][p] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3008
n,k = map(int, input().split())
A = list(map(int, input().split()))
A = {i+1:A[i] for i in range(len(A))}

if k <= n:
    current = 1
    for i in range(k):
        current = A[current]
    print(current)
else:
    current = 1
    count = 0
    pos = []
    visited = {i+1:-1 for i in range(len(A))}
    for i in range(k):
        #print(pos, visited[current])
        if visited[current] >= 0:
            circle = pos[visited[current]:]
            ans = k - visited[current]
            ans = ans % len(circle)
            #print(visited[current], ans, circle, circle[ans])
            print(circle[ans])
#             circle_len = count - visited[current]
#             #final_pos = visited[current] + 
#             print(pos[k%circle_len])
            break
        
        pos.append(current)
        visited[current] = count
        count += 1
        current = A[current]

Measured memory_bytes: 63392
#include <iostream>
#include <string>

using namespace std;

int ret, h, w;
string field[128];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

void count(int y, int x, char c)
{
	field[y][x] = '.';

	for (int i = 0; i < 4; i++){
		int ny = y + dy[i], nx = x + dx[i];
		if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
		if (field[ny][nx] == c){
			count(ny, nx, c);
		}
	}

	return;
}

int main(void)
{
	while (cin >> h >> w, h || w){
		for (int i = 0; i < h; i++){
			cin >> field[i];
		}

		ret = 0;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				char c = field[i][j];
				if (c == '#' || c == '*' || c == '@'){
					count(i, j, c);
					ret++;
				}
			}
		}
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
//input
string S,T;

 
//processing
int ans;

//dpTable
//int dp[100050];

int main(){
    cin >> S >> T;
    for (int i = 0; i < S.size(); i++){
        if (S.at(i) != T.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3848
#include<stdio.h>

int main ()
{
	char str[5];
	int flag=0;

	scanf("%s",str);

	for (int i=0;i<3;i++)
	{
		if (str[i]==str[i+1])
			flag++;
	}

	if (flag==0)
		printf("Good\n");

	else 
		printf("Bad\n");

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int n=s.size();
  auto NO=[](){cout<<-1<<endl;exit(0);};
  if(s.back()=='1') NO();
  if(s.front()!='1') NO();

  s.insert(s.begin(),'0');
  for(Int i=1;i<n;i++)
    if(s[i]!=s[n-i]) NO();
  
  vector<vector<Int> > G(n);
  auto add_edge=
    [&](Int x,Int y){
      G[x].emplace_back(y);
      G[y].emplace_back(x);
    };
  Int idx=0;

  vector<Int> v(n+1,0);
  for(Int i=1;i<=n;i++) v[i]=v[i-1]+(s[i]=='1');
  if(v[n]==n-1){
    for(Int j=0;j+1<n;j++){
      add_edge(idx,idx+1);
      idx++;
    }
  }else{
    Int cur=0;
    for(Int i=n-1;i>=1;i--){
      if(s[i]=='1'){
	//cout<<i<<":"<<idx+1<<endl;
	add_edge(cur,idx+1);
	idx++;
	cur=idx;
	continue;
      }
      while(s[i]=='0') i--;
      while(n-(idx+1)>i) add_edge(cur,++idx);      
      i++;
    }
  }

  vector<Int> dp(n+1,0);
  function<Int(Int, Int)> dfs=
    [&](Int v,Int p){
      Int sub=1;
      for(Int u:G[v])
	if(u!=p) sub+=dfs(u,v); 
      if(~p) dp[sub]=dp[n-sub]=1;
      return sub;
    };
  dfs(0,-1);
  //for(Int i=1;i<=n;i++) cout<<dp[i]<<" "<<s[i]<<endl;
  for(Int i=1;i<=n;i++) assert(dp[i]==s[i]-'0');
  
  using P = pair<Int, Int>;
  vector<P> ans;
  for(Int v=0;v<n;v++)
    for(Int u:G[v]) if(u<v) ans.emplace_back(u,v);
  sort(ans.begin(),ans.end());
  for(auto p:ans) cout<<p.first+1<<" "<<p.second+1<<endl;
  return 0;
}


Measured memory_bytes: 18028
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    int N;
    cin >> N;
    string S;
    cin >> S;
    int curr = 0;
    for (char c : S) curr += c == 'E';
    int ans = curr;
    for (int i = 0; i < N; i++) {
        curr += (S[i] == 'E')?-1:1;
        ans = min(curr, ans);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
priority_queue<ll> pq;
int main(){
        int n,m;
        while(~getII(n,m)){
                F(i,0,n){
                        ll x;
                        scanf("%lld",&x);
                        pq.push(x);
                }
                while(m--){
                        ll now=pq.top();
                        pq.pop();
                        now/=2;
                        pq.push(now);
                }
                ll ans=0;
                while(pq.size()){
                        ans+=pq.top();
                        pq.pop();
                }
                printf("%lld\n",ans);
        }
}

Measured memory_bytes: 1400