akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int p = 1000000007;
	long long int dp[102][4][4][4][4];
	int j, k, l, m, q;
	if (n == 3)
	{
		printf("61\n");
		return 0;

	}
	for (j = 0; j < 4; j++)
		for (k = 0; k < 4; k++)
			for (l = 0; l < 4; l++)
				for (m = 0; m < 4; m++)
					dp[4][j][k][l][m] = 1;
	for (j = 0; j < 4; j++)
	{
		dp[4][j][0][2][1] = 0;
		dp[4][j][2][0][1] = 0;
		dp[4][j][0][1][2] = 0;
		dp[4][0][j][2][1] = 0;
		dp[4][0][2][j][1] = 0;
		dp[4][0][2][1][j] = 0;
		dp[4][2][0][1][j] = 0;
		dp[4][0][1][2][j] = 0;
	}
	for (i = 4; i < n; i++)
	{
		for (j = 0; j < 4; j++)
			for (k = 0; k < 4; k++)
				for (l = 0; l < 4; l++)
					for (m = 0; m < 4; m++)
						dp[i + 1][j][k][l][m] = 0;
		for (j = 0; j < 4; j++)
			for (k = 0; k < 4; k++)
				for (l = 0; l < 4; l++)
					for (m = 0; m < 4; m++)
						for (q = 0; q < 4; q++)
							dp[i + 1][j][k][l][m] += dp[i][q][j][k][l];
		for (j = 0; j < 4; j++)
		{
			dp[i + 1][j][0][2][1] = 0;
			dp[i + 1][j][2][0][1] = 0;
			dp[i + 1][j][0][1][2] = 0;
			dp[i + 1][0][j][2][1] = 0;
			dp[i + 1][0][2][j][1] = 0;
		}
		for (j = 0; j < 4; j++)
			for (k = 0; k < 4; k++)
				for (l = 0; l < 4; l++)
					for (m = 0; m < 4; m++)
						dp[i + 1][j][k][l][m] %= p;
	}
	long long int ans = 0;
	for (j = 0; j < 4; j++)
		for (k = 0; k < 4; k++)
			for (l = 0; l < 4; l++)
				for (m = 0; m < 4; m++)
					ans = (ans + dp[n][j][k][l][m]) % p;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
import sys
from collections import Counter
n=int(input())
d=Counter(list(map(int,input().split())))
m=int(input())
t=Counter(list(map(int,input().split())))
k=list(t.keys())
for i in range(len(k)):
    if d[k[i]]<t[k[i]]:
        print('NO')
        sys.exit()
print('YES')



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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;

set<ll>st;
vector<ll>lp;
ll n, x, m, sum, y;

int main(){
	setIO();
	cin >> n >> x >> m;
	y = x;
	st.insert(x);
	for (int i = 0; i <= m; i++){
		x = (x*x)%m;
		if (st.count(x))
			break;
		st.insert(x);
	}
	lp.emp(x); ll z = (x*x)%m, lsum = x;
	while (z != x){
		lsum += z;
		lp.emp(z);
		z = (z*z)%m;
	}
	for (int i = 1; i <= n; i++){
		if (y == x){
			ll loop = (n-i+1)%(int)lp.size(), summ = 0;
			for (int j = 0; j < loop; j++)
				summ += lp[j];
			cout << sum+summ+(n-i+1)/(int)lp.size()*lsum << endl;
			return 0;
		}
		sum += y;
		y = (y*y)%m;
	}
	cout << sum << endl;
}

Measured memory_bytes: 6156
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

int main()
{
	// 入力
	ll r,d,x;
	cin >> r >> d>>x;
	REP(i,10){
		x=r*x-d;
		cout<<x<<endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {

  int S,h,m,s;

  scanf("%d",&S);
  h=S/3600;
  m=S%3600/60;
  s=S%3600%60;
  
  
  printf("%d:%d:%d\n",h ,m, s);

  return 0;

}

  

Measured memory_bytes: 592
#include "bits/stdc++.h"
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
using namespace std;




int main(){
ll n;
cin>>n;
ll tmp;
ll ans=0;
for(ll i=0;i<n;i++){
  cin>>tmp;
  ans+=--tmp;
}
cout<<ans<<endl;
}


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

int main() {
    int n, k; cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int ai; cin >> ai;
        if (ai >= k) ans++;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = (1LL<<40);
using namespace std;
ll exp(ll a , ll b){
	if(b == 0)	return 1;
	int x = b % 2 == 0 ?   ((exp(a , b/2)%mod)*(exp(a , b / 2)%mod))%mod :  (a%mod*exp(a , b - 1) % mod)%mod;
	return x;
}
set< int > a[100005];
vector< int > col(100005);
int has[100005];
int main(int argc,char ** argv){
	dhoom;
	ll n , m;
	cin >> n >> m;
	if(n > m)
		swap(n , m);
	if(n == 1 && m == 1)	
		return cout << 1 ,0;
	else if(n == 1)
		return cout << m - 2 , 0;
	else 
		cout << (m - 2LL)*(n - 2LL) << endl;
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF 1000000000
#define MOD 1000000007
#define M 998244353
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define endl "\n"
#define fori(i, a, b) for(i=a; i<b; i++)
#define ford(i, a, b) for(i=a; i>b; i--)
using namespace std;
const ll N = 500043;
ll fact[N];
ll add(ll x, ll y)
{
	x += y;
	while(x >= MOD) x -= MOD;
	while(x < 0) x += MOD;
	return x;
}
ll mul(ll x, ll y)
{
	return (x * 1ll * y) % MOD;
}
ll mulmod(ll a, ll b)
{
    ll res = 0;
    a = a % MOD;
    while (b>0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
        a = (a * 2) % MOD;
        b /= 2;
    }
    return res % MOD; 
}
ll binpow(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}
ll inv(ll x)
{
	return binpow(x, MOD - 2);
}
ll divide(ll x, ll y)
{
	return mul(x, inv(y));
}
void precalc()
{
	fact[0] = 1;
	ll i;
	fori(i, 1, N)
		fact[i] = mul(i, fact[i - 1]);
}
ll C(ll n, ll k)
{
	if(k > n)
	    return 0;
	return divide(fact[n], mul(fact[n - k], fact[k]));
}

ll solve()
{
    ll a, ans=0;
    cin >> a;
    ans = a + (a*a) + (a*a*a);
    
    
    return ans;
}

int main()
{
    io
    int t;
    t=1;
    // cin >> t;
    while(t--)
        cout << solve() << endl;
        // solve();
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(auto &i:a)cin >> i;
	vector<int> ans(N,0);
	
	for(int i=N-1;i>=0;i--){
		int c=0;
		for(int k=i;k<N;k+=i+1){
			if(ans[k]==1)c++;
		}
		if((c%2)!=a[i])ans[i]=1;
	}
	
	int M=accumulate(ans.begin(),ans.end(),0);
	
	cout << M << endl;
	int c=0;
	for(int i=0;i<N;i++){
		if(ans[i]==1){
			cout << i+1;
			c++;
			if(c==M)cout << endl;
			else cout << " ";
		}
	}
	
	return 0;
}

Measured memory_bytes: 2432
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string s;
    cin>>s;
    for(auto x : s){
        if(x=='x') cnt[0]++;
    }
    if(cnt[0]>=8) cout<<"NO";
    else cout<<"YES";
    return 0;
}
//.........


Measured memory_bytes: 256
N, K = [int(_) for _ in input().split()]
A = [int(_) - 1  for _ in input().split()]

X = [-1 for _ in range(N)]
X[0] = 0

k = 0
p = 0
while k < K:
    p = A[p]
    k += 1
    if X[p] != -1:
        v = (K - k) % (k - X[p]) + X[p]
        print(X.index(v) + 1)
        exit(0)
    X[p] = k
print(p + 1)


Measured memory_bytes: 32244
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N] = r.nn()
    const L = r.nn()
    let i = 0

    for (let ai = 0; ai < N; ai++) {
      const al = L[ai]

      for (let bi = ai + 1; bi < N; bi++) {
        const bl = L[bi]

        for (let ci = bi + 1; ci < N; ci++) {
          const cl = L[ci]

          if (al === bl || bl === cl || cl === al) continue

          if (al + bl > cl && bl + cl > al && al + cl > bl) {
            i++
          }
        }
      }
    }

    return i
  }

  const _io = (i = 0) => {
    const str: string = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map((v) => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map((line) => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 32400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x;
    }
    x=x*x;
    n>>=1;
  }
  return ans;
}

ll sum(ll k) {
  ll res=0;
  while(k) {
    res+=k%10;
    k/=10;
  }
  return res;
}

ll nine(ll k) {
  ll res=0;
  ll tmp=1;
  while(k-->0) {
    res+=tmp*9;
    tmp*=10;
  }
  return res;
}

int main() {
  ll k;
  cin >> k;
  ll tmp=10;
  ll pre=0;
  ll cnt=1;
  while(k--) {
    pre++;
    while(pre/tmp) {
      tmp*=10;
      cnt++;
    }
    double v=-1.0;
    ll x=pre;
    for(ll i=0;i<cnt;i++) {
      ll id=pre/mpow(10,i+1)*mpow(10,i+1)+nine(i);
      for(ll j=0;j<=9;j++) {
        ll tid=id+j*mpow(10,i);
        if(tid<pre) continue;
        double tv=double(tid)/sum(tid);
        if(v<0.0||tv<v) {
          v=tv;
          x=tid;
        }
      }
    }
    cout << x << endl;
    pre=x;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
}

Measured memory_bytes: 256
val zero: Long = 0
fun main(args: Array<String>){
    val (a,b,c,d) = readLine()!!.split(" ").map(String::toLong)
    var s: Long = 0
    var t: Long = 0
    var st: Long = 0
    var e = lcm(c,d)



    val a1 = b / c
    val a2 = (a-1) / c
    val b1 = b / d
    val b2 = (a-1) / d
    val e1 = b / e
    val e2 = (a-1) / e


    val aa = a1 - a2
    val bb = b1 - b2
    val ee = e1 - e2


    val range = b - a + 1

    println(range - aa - bb + ee)




}
fun gcd(a: Long, b: Long): Long= if(a < b) gcd(b, a) else if(b == zero) a else gcd(b, a % b)
fun lcm(a: Long, b: Long): Long= (a * b) / gcd(a, b)


Measured memory_bytes: 37776
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  double a,b;
  cin>>a>>b;
  bool c=0;
  rep(i,a+1){
  if(2*i+4*(a-i)==b)
    c=1;
  }
  YesNo(c);
}


Measured memory_bytes: 3776
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
	string s;
	cin>>s;
	ll sl=stoll(s);
	string ans="0123456789";
	string m;
	ll mi=-1;
	do{
		ll tmp=0;
		for(int i=0;i<s.size();i++)
		{
			tmp*=10;
			tmp+=(ans[i]-'0');
		}
		ll diff=min(llabs(tmp-sl),(ll)pow(10,s.size())-llabs(tmp-sl));
		if(mi<diff)
		{
			//cerr<<diff<<endl;
			mi=diff;
			m=ans;
		}else if(mi==diff && m>ans){
			m=ans;
		}
	}while(next_permutation(ans.begin(),ans.end()));
	//解を出す
	ans="";
	for(int i=0;i<s.size();i++)
		ans+=m[i];
	cout<<ans<<endl;
	return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )

#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    lli n , m , c , cnt = 0 ;
    cin >> n >> m >> c ;
    lli s [n] = {0} ;
    lli a[n][m] ;
    lli b[m] ;
    loopcin(m , b) ;

    D2forrcin(0 , n , 0 , m , a) ;
    loop(n){
        loop2(m){
            s[i] += a[i][j] * b[j] ;
        }
        if (s[i] + c > 0)
            cnt ++ ;
    }
    cout << cnt << endl ;
    /*
    loop (n){
        loopcin(m , a );
        s = 0 ;
        for(lli i = 0 , j = 1 ;  i < m ; i ++ , j ++){
            s += a[i] * b[i] ;
            cout << s << ' ' ;
        }
        if (s - c > 0)
            cnt ++ ;
        //s = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
    }*/
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

int main() {
  int N, D;
  cin >> N >> D;
  
  int ans = 0;
  
  int num = 0;
  while (num < N) {
    ans ++;
    num += 2*D + 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
from bisect import bisect_right
from itertools import accumulate

N, M, K, *AB = map(int, open(0).read().split())
A, B = AB[:N], AB[N:]

A = [0] + list(accumulate(A))
B = [0] + list(accumulate(B))

ans = 0
for i, a in enumerate(A):
    if K - a < 0:
        break
    ans = max(ans, bisect_right(B, K - a) + i - 1)

print(ans)

Measured memory_bytes: 55112
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c)
        cout << 1 << endl;
    else if (a != b && b != c && c != a)
        cout << 3 << endl;
    else
        cout << 2 << endl;
}


Measured memory_bytes: 3644
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

struct Sieve {
  vector<int> f, primes; // primesは素数集合，fは合成数に素因数を一つ示したもの
  Sieve(int N):f(N+1,0) {
    f[0] = f[1] = -1;
    for (int i = 2; i <= N; ++i) {
      if (!(f[i]==0)){
        continue;
      }
      primes.push_back(i);
      f[i] = i;
      if(i>sqrt(N)){
        continue;
      }
      for (int j = i*i; j <= N; j += i) {
        if (f[j]==0){
          f[j] = i;
        }
      }
    }
  }

  bool isPrime(int x) { //xが素数かどうかを判断するメンバ関数
    return f[x] == x;
  }

  vector<int> factorList(int x) { //xの素因数を小さい順ソートされた配列
    vector<int> res;
    if(x==0 || x==1){
      return { };
    }
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<pair<int,int>> factor(int x) { //xのfactorListをランレングス圧縮したもの
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<pair<int,int>> res(1, make_pair(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      }
      else {
        res.push_back(make_pair(p, 1));
      }
    }
    return res;
  }

  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0){
        x /= p, ++y;
      }
      if (y != 0){
        res.push_back(make_pair(p,y));
      }
    }
    if (x != 1){
      res.push_back(make_pair(x,1));
    }
    return res;
  }
};

int main(){
  int N;
  cin >> N;
  Sieve S(N+5);
  ll ans=0;
  for(int i=1;i<N;i++){
    int M=N-i;
    vector<pair<int,int>> F=S.factor(M);
    ll count=1;
    for(auto x:F){
      count*=(x.second+1);
    }
    ans+=count;
  }
  cout << ans << endl;
}

Measured memory_bytes: 7692
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn = 1e5 + 10;
int a[maxn];
int gcd(int a, int b) {
    while (b) {
        int t = a;
        a = b;
        b = t % b;
    }
    return a;
}

int main() {
    int n;
    scanf("%d%d", &n, &a[0]);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a, a + n + 1);
    for (int i = 0; i < n; i++) {
        a[i] = a[i+1] - a[i];
    }
    int g = a[0];
    for (int i = 1; i < n; i++) {
        g = gcd(g, a[i]);
    }
    printf("%d\n", g);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int a,b,x; cin>>a>>b>>x;
	ote(a+b>=x && a<=x?"YES":"NO");
}


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

using namespace std;

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

    vector<long long> dp(n);
    dp[0] = 1000;
    for (int i = 1; i < n; i++) {
        dp[i] = dp[i - 1];
        for (int j = 0; j < i; j++) {
            dp[i] = max(dp[i], (dp[j] / a[j]) * a[i] + (dp[j] % a[j]));
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
}

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

using namespace std;

#define ll long long

int main(){
  int n, k;
  cin >> n >> k;
  
  vector<ll> v(n);
  for(int i = 0; i < n; i++) cin >> v[i];
  
  int max_value = 0;
  for(int l = 0; l <= min(n, k); l++){
    for(int r = 0; r <= min(n, k) - l; r++){
      vector<ll> get;
      for(int i = 0; i < l; i++) get.push_back(v[i]);
      for(int i = 0; i < r; i++) get.push_back(v[n - i - 1]);
      
      sort(get.begin(), get.end());
      int rem = k - l - r;
      int sum = 0;
      for(int i = 0; i < l + r; i++){
        if(get[i] < 0 && rem > 0){
          rem--;
          continue;
        }
        sum += get[i];
      }
      
      max_value = max(sum, max_value);
    }
  }
  
  cout << max_value << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Wed Mar 18 19:04:24 JST 2020
 **/

signed main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    cout << (s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n,m,x,ans=-1;
    cin>>n>>m>>x;
    vector<vector<int>> c(n,vector<int>(m));
    rep(i,n) rep(j,m+1) cin>>c[i][j];
    rep(i,1<<n)
    {
        vector<int> allc(m+1);
        rep(j,n)
        {
            if(i>>j&1)
            {
                rep(k,m+1)
                {
                    allc[k]+=c[j][k];
                }
            }
        }
        int datam=0;
        rep(u,m)      //allc'kakuninn
        {
            if(allc[u+1]>=x) datam++;
        }
        if(datam==m&&ans==-1) ans=allc[0];
        else if (datam==m) ans=min(ans,allc[0]);
    }
    cout<<ans;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));
    bool c = 0 < a && a < 13;
    bool d = 0 < b && b < 13;
    if (c && d) cout << "AMBIGUOUS" << endl;
    else if (c)cout << "MMYY" << endl;
    else if (d)cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(){
    int a[5];
    int k;
    for(int i = 0; i < 5; i++){
        scanf("%d", &a[i]);
    }
    scanf("%d", &k);

    bool f = true;
    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            if(abs(a[i] - a[j]) > k){
                f = false;
                break;
            }
        }
        if(f == false){
            break;
        }
    }

    if(f){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 1000010;

int main(){
        int n, K, S;
        scanf("%d%d%d", &n, &K, &S);
        vector<int> ans;
        rep(i, K) ans.push_back(S);
        int dummy = (int)(S==mod-7 ? 1 : mod-7);
        rep(i, n-K) ans.push_back(dummy);
        for(int x: ans) printf("%d ", x);
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b>=c-1)printf("%lld",b+c);
  else printf("%lld",a+b+b+1);
}

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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
/* -------------------------------------------------------------------------- */

int main(int argc, char *argv[])
{
    int x, y;
    cin >> x >> y;
    cout << (x+y)%24 << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] != s[s.size()-1-i]) ++ans;
        s[s.size()-1-i] = s[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  cout<<fixed<<setprecision(10);
  int N;
  cin >> N;
  vector<double> V(N);
  for (int i=0;i<N;i++) cin >> V.at(i);
  sort(V.begin(), V.end()); 
  double v=V.at(0);
  for (int i=1;i<N;i++) v = v/2.0 + V.at(i)/2.0;
  cout << v <<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

int main() {
 // std::ios::sync_with_stdio(false);
 // std::cin.tie(0);
  
  int n, x;
  string cmd;
  cin >> n;
  list<int> lst;
  REP(i, n) {
    cin >> cmd;
    if (cmd == "insert") {
      cin >> x;
      lst.push_front(x);
    } else if (cmd == "delete") {
      cin >> x;
      auto it = find(ALL(lst), x);
      if (it != lst.end()) lst.erase(it);
    } else if (cmd == "deleteFirst") {
      lst.pop_front();
    } else if (cmd == "deleteLast") {
      lst.pop_back();
    }
  }
  for (auto it = lst.begin(); it != lst.end(); ++it) {
    if (it != lst.begin()) cout << " ";
    cout << *it;
  }
  cout << endl;
}



Measured memory_bytes: 34436
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

//const long long MOD = 1000000007;
const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int r, d, x; cin >> r >> d >> x;
	rep(i, 10) {
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}

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

int main() {
	long long n;
	cin>>n;
	long long ans = n-1;
	for(long long i = 2; i*i <= n; i++)
		if(n%i == 0)
			ans = min(ans, (i-1) + (n/i-1));
	cout<<ans;
	return 0;
}

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll N, K;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> K;
  ll ans = 1 + ((N-K) + (K-2)) / (K-1);
  cout << ans << endl;

  return 0;
}



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

int main(){
    long x, y;
    cin >> x >> y;
    while (x != 0 && y != 0){
        if (x >= y){
            long tmp = 0;
            tmp = y;
            y = x % y;
            x = tmp;
        }
        else {
            long tmp = 0;
            tmp = x;
            x = y;
            y = tmp;
        }
    }
    if (x == 0) cout << y << endl;
    else cout << x << endl;
    return 0;
}

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

int n, d, x[11][11];

int main()
{
  cin >> n >> d;
  for (int i = 0; i < n; ++ i)
  {
    for (int j = 0; j < d; ++ j)
    {
      cin >> x[i][j];
    }
  }
  int count = 0;
  for (int i = 0; i < n - 1; ++ i)
  {
    for (int j = i + 1; j < n; ++ j)
    {
      int sum = 0;
      for (int k = 0; k < d; ++ k)
      {
        sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      if (int(sqrt(sum)) * int(sqrt(sum)) == sum) count++;
    }
  }
  cout << count << endl;    
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] nums = new int[N];
		for(int i = 0; i < N; i++) {
			nums[i] = sc.nextInt();
		}

		long[] cnt = new long[N];

		//各番号ごとの組み合わせを計算する
		for(int i = 0; i < N; i++) {
			cnt[nums[i]-1] ++;
		}

		long result = 0;
		//各項目の組み合わせを計算する。
		for(int i = 0; i < N; i++) {
			long count = 0;
			long num = cnt[i];
			for(long j = 1; j < num; j++) {
				count = count + num - j;
			}
			result = result + count;
		}

		for(int i = 0; i < N; i++) {
			System.out.println(result - (cnt[nums[i]-1] - 1));
		}
	}
}

Measured memory_bytes: 96628
#include<stdio.h>
   
typedef struct{
   
  int parent;
     
  int left;
 
  int right;
 
}Node;
 
Node N[30];
 
void output1(int x);
void output2(int x);
void output3(int x);
 
int main(){
   
  int i, n, a;
 
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){ 
    
    N[i].parent = -1;
 
  }
  
  for(i = 0; i < n; i++){
     
    scanf("%d", &a);
 
    scanf("%d %d", &N[a].left, &N[a].right);
 
    if(N[a].left != -1) 
      N[N[a].left].parent = a;
 
    if(N[a].right != -1) 
      N[N[a].right].parent = a;
 
  }
  
  int root;
 
  for(i = 0; i < n; i++){
    if(N[i].parent == -1){
 
      root = i;
 
      break;
 
    }
  }
 
  printf("Preorder\n");
 
  output1(root);
    
  printf("\nInorder\n");
 
  output2(root);
 
  printf("\nPostorder\n");
 
  output3(root);
 
  printf("\n");
 
  return 0;
}
 
void output1(int x){
 
  if(x == -1)
    return;
 
  printf(" %d", x);
   
  output1(N[x].left);
 
  output1(N[x].right);
 
}
  
void output2(int x){
 
  if(x == -1)
    return;
 
  output2(N[x].left);
 
  printf(" %d", x);
 
  output2(N[x].right);
 
}
  
void output3(int x){
 
  if(x == -1)
    return;
 
  output3(N[x].left);
 
  output3(N[x].right);
 
  printf(" %d", x);
 
}

Measured memory_bytes: 616
#include<iostream>
#include<stack>
#include<stdlib.h>


using namespace std;

int main(void) {
  stack<int> S;

  int pre;
  int next;
  string s;
  while(cin >> s) {
    if(s[0] == '+') {
        pre = S.top();
        S.pop();
        next = S.top();
        S.pop();
        S.push(next + pre);
    }
    else if(s[0] ==  '-') {
        pre = S.top();
        S.pop();
        next = S.top();
        S.pop();
        S.push(next - pre);
    }
    else if(s[0] == '*') {
        pre = S.top();
        S.pop();
        next = S.top();
        S.pop();
        S.push(next * pre);
    }
    else if(s[0] == '/') {
        pre = S.top();
        S.pop();
        next = S.top();
        S.pop();
        S.push(next / pre);
    }
    else {
        S.push(atoi(s.c_str()));
    }
  }
  cout << S.top() << endl;
  S.pop();
  return 0;
}

Measured memory_bytes: 1196
str = list(input())
q = int(input())

for _ in range(q):
    l = input().split()
    cmd = l[0]
    a = int(l[1])
    b = int(l[2])
    if cmd == 'print':
        print(''.join(str[a:b+1]))
    elif cmd == 'reverse':
        str[a:b+1] = reversed(str[a:b+1])
    else:
        str[a:b+1] = l[3]



Measured memory_bytes: 5624
import sys
from fractions import gcd
from functools import reduce

N, K = map(int, input().split())
A = [int(_) for _ in input().split()]

if max(A) < K:
    print('IMPOSSIBLE')
    sys.exit()
if K in A:
    print('POSSIBLE')
    sys.exit()

def gcd_list(numbers):
    return reduce(gcd, numbers)

num = gcd_list(A)
if num == 1:
    print('POSSIBLE')
else:
    if K % num == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

Measured memory_bytes: 16244
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScan in = new MyScan(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, MyScan in, PrintWriter out) {
            int[] l = in.na(3);
            Arrays.sort(l);
            int k = 0;
            while (3 * l[0] != Arrays.stream(l).sum()) {
                if (l[0] + 2 <= l[1]) {
                    l[0] += 2;
                } else {
                    l[0]++;
                    l[1]++;
                }
                k++;
                Arrays.sort(l);

            }
            out.println(k);

        }

    }

    static class MyScan {
        private final InputStream in;
        private byte[] inbuf = new byte[1024];
        public int lenbuf = 0;
        public int ptrbuf = 0;

        public MyScan(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int[] na(int n) {
            int[] k = new int[n];
            for (int i = 0; i < n; i++) {
                k[i] = nextInt();
            }
            return k;
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 26580
from collections import Counter
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    cnt = Counter(A)


    ans = sum(A)
    for i in range(Q):
        B, C = map(int, input().split())
        ans += cnt[B] * (C - B)
        cnt[C] += cnt[B]
        cnt[B] = 0
        print(ans)

main()

Measured memory_bytes: 24028
n = int(input())
lst = [0]*(n+1)
for i in range(n):
    lst[int(input())] = i
s = 0
t = 1
for i in range(1,n):
    if lst[i] < lst[i+1]:
        t += 1
    else:
        s = max(t,s)
        t = 1
s = max(t,s)
print(n-s)

Measured memory_bytes: 16876
n = int(input())
a = list(map(int, input().split()))
dict = {}
q = int(input())
ans = sum(a)
for i in range(n):
    dict[a[i]] = dict.get(a[i], 0) + 1
for _ in range(q):
    b,c = map(int, input().split())
    count = dict.get(b, 0)
    ans += count*(c-b)
    print(ans)
    dict[b] = 0
    dict[c] = dict.get(c, 0) + count

Measured memory_bytes: 88776
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;

int main(){
long long N,K;
cin>>N>>K;

multimap<int,int>A;
int a,b;
for(int i=0;i<N;i++){
cin>>a>>b;
A.insert(make_pair(a,b));
}

auto iter=A.begin();

while(K>0){
    K-=iter->second;
    iter++;
}
iter--;

cout<<iter->first<<endl;
 return 0;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
  long long n;cin>>n;
  long long a[n];
  long long sum = 0;
  for(long long i = 0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  long long avg = sum/n;
  long long ans = 100000000000;
  for(long long i = avg-1; i <= avg+1;i++){
    long long t=0;
    for(long long j = 0;j < n;j++){
      t += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans,t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[][] bingo = new int[3][3];
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				bingo[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			int tmp = sc.nextInt();
			for(int j =0; j < 3; j++){
				for(int k = 0; k < 3; k ++){
					if(bingo[j][k] == tmp){
						bingo[j][k] = 0;
					}
				}
			}
		}
		for(int i = 0; i < 3; i++){
			if(bingo[i][0] == 0 && bingo[i][1] == 0 && bingo[i][2] == 0){
				System.out.println("Yes");
				break;
			}
			if(bingo[0][i] == 0 && bingo[1][i] == 0 && bingo[2][i] == 0){
				System.out.println("Yes");
				break;
			}
			if(bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0){
				System.out.println("Yes");
				break;
			}
			if(bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0){
				System.out.println("Yes");
				break;
			}
			if(i == 2){
				System.out.println("No");
			}
		}
 	}
}  


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

public class hello
{
    public static void Main()
    {
        var dict = new Dictionary<string, int>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (dict.ContainsKey(line[0])) dict[line[0]] += int.Parse(line[1]);
            else dict[line[0]] = int.Parse(line[1]);
        }
        var a = dict.OrderBy(x => x.Key.Length).ThenBy(y => y.Key);
        foreach (var x in a)
            Console.WriteLine("{0} {1}", x.Key, x.Value);
    }
}

Measured memory_bytes: 10704
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){
  int i, c = 0;
  char s[3], t[3];
  for(i = 0; i < 3; i++){
    cin >> s[i];
  }
  for(i = 0; i < 3; i++){
    cin >> t[i];
    if(t[i] == s[i]){
      c++;
    }
  }
  cout << c << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

void end(int n = -1)
{
	cout << n << "\n";
	exit(0);
}
int n;
int a[3009];
int dp[3009][3009][2];
bool vis[3009][3009][2];

int fun(int i, int j, int ch)
{
	if (i > j)
		return 0;
	if (vis[i][j][ch])
		return dp[i][j][ch];
	int ans = 0;
	if (ch)
	{
		ans = max(a[i] + fun(i + 1, j, !ch), a[j] + fun(i, j - 1, !ch));
	}
	else
	{
		ans = min(-a[i] + fun(i + 1, j, !ch), -a[j] + fun(i, j - 1, !ch));
	}
	vis[i][j][ch] = 1;
	return dp[i][j][ch] = ans;
}

int32_t main()
{
	AB_BHI_NI_DEGI
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cout << -fun(0, n - 1, 0) << "\n";

	return 0;
}

Measured memory_bytes: 158336
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int h, m, s;

		String str = br.readLine();
		s = Integer.parseInt(str);

		h = s/3600;
		m = s/60;
		m = m%60;
		s = s%60;

		System.out.println(h + ":" + m + ":" + s);

	}
}

Measured memory_bytes: 17048