akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int check(int x){
	string s = to_string(x);
	for(int i = 0, j = sz(s)-1; i < j; i++, j--){
		if(s[i]!=s[j])return 0;
	}
	return 1;
}
void solve(){
	int l, r, cnt = 0;
	cin>>l>>r;
	for(int i = l; i <= r; i++)cnt+=check(i);
	cout<<cnt;
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 3768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = X;
		for(X=X-(K-1);X<Y;X++) {
			System.out.print(X+" ");
		}
		for(X=Y;X<(Y+K);X++) {
			System.out.print(X+" ");
		}
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=55;
const int M=(1<<18)|5;
int n,k,S,T,top;
int a[N],cnt[M];
pii q[N*M];
ll FF[N][N];
void init(){
	For(i,0,N-1) FF[i][0]=1;
	For(i,1,N-1) For(j,1,i) FF[i][j]=FF[i-1][j]+FF[i-1][j-1];
	For(i,0,N-1) FF[i][0]=0;
	For(i,0,N-1) For(j,1,N-1) FF[i][j]+=FF[i][j-1];
}
int main(){
	init();
	scanf("%d%d%d%d",&n,&k,&S,&T);
	For(i,1,n){
		scanf("%d",&a[i]);
		if ((a[i]&S)!=S||(a[i]|T)!=T) --i,--n;
	}
	if ((S&T)!=S||(S|T)!=T)
		return puts("0"),0;
	For(i,0,(1<<18)-1) cnt[i]=cnt[i/2]+(i&1);
	For(i,1,n) a[i]-=S; T-=S;
	For(i,0,T) if ((i&T)==i)
		For(j,1,n){
			int v1=(a[j]&i);
			int v2=((~a[j])&i);
			q[++top]=(pii){v1,v2};
		}
	sort(q+1,q+top+1);
	int s=1;
	ll ans=0;
	For(i,2,top+1)
		if (i==top+1||q[i].fi!=q[i-1].fi||q[i].se!=q[i-1].se)
			ans+=(cnt[q[i-1].fi]&1?-1:1)*(cnt[q[i-1].se]&1?-1:1)*FF[s][k],s=1;//cerr<<s<<endl;
		else ++s;
	printf("%lld\n",ans);
}

Measured memory_bytes: 107280
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    string S, T;
    cin >> S >> T;
    cout << T << S << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
E = [[] for _ in range(N)]
dp = {}

for _ in range(M):
    a, b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

S = 1
G = (1 << N) - 1


def is_visited(v: int, path: int):
    return path & (1 << v)


def visit(v: int, path: int):
    return path ^ (1 << v)


def count(u: int, path: int):
    if path == G:
        return 1

    if (u, path) in dp:
        return dp[(u, path)]

    return sum(
        count(v, visit(v, path))
        for v in E[u]
        if not is_visited(v, path)
    )


print(count(0, S))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef pair<int, long double> pil;
const int maxn = 5e5 + 10;
int n, L;
long double sv;
deque<pil> Q;
int main()
{
	cin >> n >> L;
	for(int i = 1; i <= n; ++i)
	{
		long double t;
		double tin;
		int v;
		cin >> tin >> v;
		t = tin * v;
		int ret = v;
		if(i > 1)
		{
			while(ret > 0)
			{
				if(Q.front().first <= ret)
				{
					ret -= Q.front().first;
					sv -= Q.front().second;
					Q.pop_front();
				}
				else
				{
					sv -= Q.front().second * ret / Q.front().first;
					Q.front().second -= Q.front().second * ret / Q.front().first;
					Q.front().first -= ret;
					ret -= ret;
				}
			}
		}
		sv += t;
		double ans = sv / L;
		printf("%.7lf\n", ans);
		while(!Q.empty() && Q.back().second * v >  Q.back().first * t)
		{
			t += Q.back().second;
			v += Q.back().first;
			Q.pop_back();
		}
		Q.push_back(mp(v, t)); 
	}
	return 0;
}
/*
5 10
1 10
9999 5
10000 5
5 1
4 1
*/

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

typedef long long lint;
const int maxn = 2005, mod = 1e9 + 7;

int n, k, m, fac[maxn * maxn], ifac[maxn * maxn], f[maxn][maxn];

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline void inc(int &a, int b) {a += b; if (a >= mod) a -= mod;}
inline int C(int n, int m)
{
	return (lint)fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int main()
{
	n = gi(); k = gi();
	if (k == 1) return puts("1"), 0;

	m = n * k;
	fac[0] = ifac[0] = ifac[1] = 1;
	for (int i = 1; i <= m; ++i) fac[i] = (lint)fac[i - 1] * i % mod;
	for (int i = 2; i <= m; ++i) ifac[i] = (lint)(mod - mod / i) * ifac[mod % i] % mod;
	for (int i = 1; i <= m; ++i) ifac[i] = (lint)ifac[i - 1] * ifac[i] % mod;

	f[1][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= i; ++j) {
			if (i > j) inc(f[i][j], f[i - 1][j]);
			if (j) inc(f[i][j], (lint)f[i][j - 1] * C(m - i - (j - 1) * (k - 1) - 1, k - 2) % mod);
		}

	printf("%lld\n", (lint)f[n][n] * fac[n] % mod);
	
	return 0;
}


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

int main(){
    string s;   cin >> s;
    int mini = 1e+5;
    for(int i=0; i<s.size()-2; i++){
        int tmp = (s[i]-'0')*100 + (s[i+1]-'0')*10 +(s[i+2]-'0');
        mini = min(abs(tmp-753), mini);
    }
    cout << mini << endl;
}
    

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

using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int> k(10000, 0);
	vector<int> p(10000, 0);
	for (int i = 0; i < n; i++) {
		cin >> k[i] >> p[i];
		if (k[i] % p[i] == 0) {
			cout << p[i] << endl;
		}
		else {
			cout << k[i] % p[i] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iN = int.Parse(sS);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "No";
            // 各桁の和のロジック
            int iNum = iN;              // 元の値
            int iSum = 0;               // 各桁の和
            while (iNum > 0)
            {
                iSum += iNum % 10;
                iNum /= 10;
            }
            if (iN % iSum == 0) { sOut = "Yes"; }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long ll;
const int maxn=1e5+10;
int n;
struct node{
	int x,y;
	char c;
}cor[maxn];
double cal(double tim){
	double ml=1e10,mr=-1e10,mu=-1e10,md=1e10;
	for(int i=1;i<=n;i++){
		pair<double,double>tmp;
		tmp=make_pair(cor[i].x,cor[i].y);
		switch(cor[i].c){
			case 'U':tmp.second+=tim;break;
			case 'D':tmp.second-=tim;break;
			case 'L':tmp.first-=tim;break;
			case 'R':tmp.first+=tim;break;
		}
		ml=min(ml,tmp.first);
		mr=max(mr,tmp.first);
		md=min(md,tmp.second);
		mu=max(mu,tmp.second);
	}
	return (mu-md)*(mr-ml);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d %c",&cor[i].x,&cor[i].y,&cor[i].c);
	}
	double l=0,r=1e12,ans=1e18;
	for(int i=1;i<=300;i++){
		double m1=l+(r-l)/3,m2=l+(r-l)*2/3;
		double tmp1=cal(m1),tmp2=cal(m2);
		if(tmp1>tmp2)l=m1;
		else r=m2;
		ans=min(ans,tmp1);
		ans=min(ans,tmp2); 
	}
	printf("%.10f\n",ans);
}



Measured memory_bytes: 1408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(),b = sc.nextInt();
    int ans[] = new int[3];
    ans[0] = a+b;
    ans[1] = a-b;
    ans[2] = a*b;
    int max = -1001;
    for(int i = 0;i<3;i++){
      if(ans[i] > max){
        max = ans[i];
      }
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c,sum=0;
  string s;
  cin>>a;
  cout<<setprecision(12)<<(a+1)/2/(double)a<<'\n';
  return 0;
}


Measured memory_bytes: 256
// Problem : J - Sushi
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_j
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int n,dp[105][maxn],k;
void solve()
{
	cin >> n >> k;
	vector<int> v(n);
	for(auto &x:v)
		cin >> x;
	for(int i=0;i<maxn;i++)
		dp[0][i]=1;
	for(int i=0;i<=n;i++)
		dp[i][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			dp[i][j] = dp[i-1][j];
			if(v[i-1] < j)
				dp[i][j] -= dp[i-1][j-v[i-1]-1];
			dp[i][j] = (mod+dp[i][j])%mod;
			// if(i == 1 and j == 2)
			// {
				// cout << dp[i][j] <<" "<< dp[i-1][j] <<" "<< dp[i-1][0] <<"\n";
			// }
			//cout << dp[i][j] <<" ";
		}
		//cout <<"\n";
		if(i == n)
		{
			cout << dp[n][k];
			return; 
		}
		for(int j=1;j<=k;j++)
			dp[i][j] = (dp[i][j]+dp[i][j-1])%mod;
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


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

string s;

bool trei(int from, int to)
{
	int last = 0;
	for (int i = from; i <= to; i++) {
		if (s[i] == '#')
			last = 0;
		else {
			last++;
			if (last >= 3)
				return 1;
		}
	}
	return 0;
}

bool can(int a, int b)
{
	int last = 1;
	for (int i = a; i <= b; i++) {
		if (s[i] == '.')
			last = 0;
		else if (last)
			return 0;
		else
			last = 1;
	}
	return (last == 0);
}

int main()
{
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d >> s;
	s = "@" + s;

	bool ok = 1;
	ok &= (can(a, c) && can(b, d));
	
	if (c > d)
		ok &= trei(b - 1, d + 1);

	cout << (ok ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 772
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int k,i,j,n;
    cin>>s>>k;
    n=s.size();
    set<string>subs;    
    for(i=0;i<n;++i){
        for(j=1;j<=k;++j){
            subs.insert(s.substr(i,j));
        }
    }
    set<string>::iterator t=subs.begin();
    for(i=1;i<k;i++)++t;
    cout<<*t<<endl;
}

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

int main(){
    int N,ans=0,mi=1000;
    cin>>N;
    vector<int> s(N);
    for(int i=0; i<N; i++){
        cin>>s[i];
        ans += s[i];
    }

    sort(s.begin(),s.end());

    if(ans % 10 != 0){
        cout<<ans<<endl;
        return 0;
    }

    else{
        for(int i=0; i<N; i++){
            if(s[i] % 10 != 0){
                cout<<ans-s[i]<<endl;
                return 0;
            }
        }
    }

    cout<<0<<endl;

    return 0;
}

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

#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
#include <tuple>
#include <string>

using namespace std;

#define MAX(A, B)	((A) > (B) ? (A) : (B))
#define MIN(A, B)	((A) < (B) ? (A) : (B))


int main(int argc, char const *argv[]) {
	string s;
	cin >> s;

	char c = s[0];
	int r = 0;

	for (int i = 1; i < s.length(); ++i) {
		if (c != s[i]) {
			c = s[i];
			r += 1;
		}
	}

	cout << r << endl;

	return 0;
}

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

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

	int ans = 0;
	for (int i = 1; i < n; i++) {
		int cnt = 0;
		for (char c = 'a'; c <= 'z'; c++) {
			bool left = false, right = false;
			for (int j = 0; j < i; j++) {
				if (s[j] == c) {
					left = true;
				}
			}
			for (int j = i; j < n; j++) {
				if (s[j] == c) {
					right = true;
				}
			}
			if (left && right) cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(){
    long n, f = 0, b, i, c;
    scanf("%ld", &n);
    
    for(i = 0;i < n;i++){
        scanf("%ld", &b);
        if(b < f){
            c += (f - b);
            b = f;
        }
        f = b;
    }
    printf("%ld", c);

    return 0;
}

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

ll d, g;
ll mi = 100000000000000;
vector<ll> p, c;

void calc(vector<ll> v){
    ll count = 0;
    ll score = 0;
    ll not_use_max = 0;
    rep(i, v.size()){
        if(v[i] == 1){
            score += (i + 1) * 100 * p[i] + c[i];
            count += p[i];
        }else{
            not_use_max = max(not_use_max, i);
        }
    }

    if(score < g){
        if(ceil((g - score) / double((not_use_max + 1) * 100)) < p[not_use_max]){
            count += ceil((g - score) / double((not_use_max + 1) * 100));
        }else{
            return;
        }
    }

    mi = min(mi, count);
}

void dfs(ll dp, vector<ll> v){
    if(dp == d){
        calc(v);
        return;
    }

    v[dp] = 0;
    dfs(dp + 1, v);

    v[dp] = 1;
    dfs(dp + 1, v);

    return;
}

int main(void){
    cin >> d >> g;

    vector<ll> v;
    rep(i, d){
        ll tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        p.push_back(tmp1);
        c.push_back(tmp2);
        v.push_back(0);
    }

    dfs(0, v);
    cout << mi << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[2][55];
ll dp[55];

void solve()
{
    int n;
    scanf("%d%s%s", &n, str[0], str[1]);
    dp[0] = 1;
    int i;
    for (i = 0; i < n; i++) {
        if (str[0][i] == str[1][i]) {
            if (i == 0) {
                dp[i + 1] = (dp[i+1] + dp[i] * 3) %MOD;
            }
            else if (str[0][i - 1] == str[1][i - 1]) {
                dp[i + 1] = (dp[i+1] + dp[i] * 2) %MOD;
            }
            else {
                dp[i + 1] = (dp[i+1] + dp[i]) %MOD;
            }
        }
        else {
            if (i == 0) {
                dp[i + 2] = (dp[i+2] + dp[i] * 6) %MOD;
            }
            else if (str[0][i - 1] == str[1][i - 1]) {
                dp[i + 2] = (dp[i+2] + dp[i] * 2) %MOD;
            }
            else {
                dp[i + 2] = (dp[i+2] + dp[i] * 3) %MOD;
            }
        }
    }
    printf("%lld\n", dp[n]);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[222222];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
string s;
signed main(){
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])puts("Bad");
	else puts("Good");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
    #define dbg(x) cerr<<#x" = "<<x<<endl
    #define rep(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
    #define per(i,a,b) for(register int i=(a),i##_st=(b);i>=i##_st;--i)
    #define rpg(i,x) for(register int i=fir[x];i;i=e[i].nxt)
    #define ull unsigned long long
    #define fi first
    #define se second
    #define pb push_back
    #define bin(i) (1<<i)
    #define cls(x,y) memset(x,y,sizeof x)
    typedef pair<int,int> pa;
    typedef long long LL;
    const int INF = 0x7fffffff;
    const int oo = 0x3f3f3f3f;
    inline char nc()
    {
        static char buf[100000],*p1=buf,*p2=buf;
        if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
        return *p1++;
    }
    //#define  getchar() nc()
    template <typename T>
    inline void rd(T &x)
    {
        x = 0; int f = 1; char CH = getchar();
        while(CH<'0'||CH>'9') {if(CH=='-')f=0;CH=getchar();}
        while(CH>='0'&&CH<='9') {x=(x<<3)+(x<<1)+(CH-48);CH=getchar();}
        return;
    }
    const int N = 200020;
    int a[N],n,k,cnt,book[N],vcnt,ans,fuck[N]; 
    int main()
    {
    	rd(n),rd(k);
    	rep(i,1,n) {
    		rd(a[i]); 
    		if(!book[a[i]]) cnt++;
    		book[a[i]]++;
    	}
    	int t=cnt-k;
    	if(t<=0) return printf("%d\n",ans),0;
    	rep(i,1,N) if(book[i]) fuck[++vcnt]=book[i];
    	sort(fuck+1,fuck+vcnt);
    	rep(i,1,t) ans+=fuck[i];
    	printf("%d\n",ans);
    	return 0;
    }

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <cmath>
#include <random>
#include <climits>
using namespace std;
using lint=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  cout<<((max(a,b)<=8)? "Yay!": ":(")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, x, i;
	cin >> x >> n;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	
	map <int, int> mp;
	for(int z : arr)
	mp[z] = 1;
	
	int lf = inf, rt = inf;
	foe(i, x, 105) {
		if(!mp[i]) {
			rt = i;
			break;
		}
	}
	for(i = x; i >= -1; i--) {
		if(!mp[i]) {
			lf = i;
			break;
		}
	}
	if(rt - x == x - lf) cout << lf << '\n';
	else if(rt - x < x - lf) cout << rt << '\n';
	else cout << lf << '\n';
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <assert.h>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;

void print_text(const string& text){
  int offset = 0;
  int text_i = 0;
  while(offset < text.size()){
    for(text_i = offset; text_i < text.size(); text_i++){
      if(text_i - offset >= 72) break;
      printf("%c",text[text_i]);
    }
    printf("\n");
    offset += 72;
  }
}

void print_co_occurrence(const string& text,const string& query){

  int head = 0;
  int tail = 0;

  int include_keys = 0;
  int freq[256] = {};

  bool is_key[256];
  memset(is_key,false,sizeof(is_key));

  for(int query_i = 0; query_i < query.size(); query_i++){
    is_key[query[query_i]] = true;
  }

  int min_tail = INF;
  int min_len = INF;
  int ans_freq = 0;
  string ans = "";

  while(tail < text.size()){
    for(;head < text.size();head++){
      if(is_key[text[head]] && !freq[text[head]]++){
        include_keys++;
        if(include_keys == query.size()){
          head++;
          break;
        }
      }
    }

    for(;tail <= head;tail++){
      if(is_key[text[tail]] && !--freq[text[tail]]){

        if(include_keys == query.size()) {
          if((head -1) - tail + 1 < min_len){
            min_len = (head -1) - tail + 1;
            ans = text.substr(tail,(head -1) - tail + 1);
            ans_freq = 1;
          }
          else if((head -1) - tail + 1 == min_len){
            ans_freq++;
          }
        }
        include_keys--;
        tail++;
        break;
      }
    }
  }

  if(ans_freq == 0){
    printf("%d\n",ans_freq);
    printf("\n");
  }
  else{
    printf("%d\n",ans_freq);
    printf("\n");
    print_text(ans);
    printf("\n");
  }
}

int main(){
  string str;
  int phase = 0;
  string text = "";
  string query = "";
  while(getline(cin,str)){
    if(str.size() == 0){
      phase++;
      continue;
    }
    if(phase % 2 == 0){
      text += str;
    }
    else{
      query = str;

      print_co_occurrence(text,query);
      
      query = "";
      text = "";
    }
  }
}

Measured memory_bytes: 1844
#include <cstdio>
#include <vector>
#include <map>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <queue>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair < int , int >

int n,m;
pii p[100005];
priority_queue < int , vector < int > , greater < int > > taken;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> m;
	for ( int i = 0; i < n; i++ ) {
		cin >> p[i].fi >> p[i].se;
		p[i].fi = m - p[i].fi;
	}
	sort(p,p+n);

	int ans = 0;
	int Time = 0;
	for ( int i = 0; i < n; i++ ){
		if ( Time <= p[i].fi ) {
			taken.push(p[i].se);
			ans += p[i].se;
			Time++;
		} else {
			if ( !taken.empty() && taken.top() < p[i].se ){
				ans += p[i].se;
				ans -= taken.top();
				taken.pop();
				taken.push(p[i].se);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int n, m, k = -1, ans;
pair<int, int>a[123456];
signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++)cin >> a[i].second >> a[i].first;
	sort(a, a + m);
	for (int i = 0; i < m; i++) {
		if (k < a[i].second) {
			k = a[i].first - 1;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import sys

n,x,m = (int(i) for i in input().split())
l = [x]
ans = x
memo_array = [-1]*(m+1)

for i in range(1,n):
    ans = ans**2%m
    idx = memo_array[ans]
    if idx != -1:
        loop_num, mod = divmod((n-idx),(i-idx))
        print(sum(l[:idx]) + sum(l[idx:])*(loop_num)+sum(l[idx:idx+mod]))
        sys.exit()
    l.append(ans)
    memo_array[ans]=i
print(sum(l))

Measured memory_bytes: 13448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e2+5;
const int INF = 0x3f3f3f3f;

int main( )
{
    std::ios::sync_with_stdio(0);cin.tie(0); 
	
	ll n,m;
	cin >> n >> m;
	printf("%lld\n",n*(n-1)/2+m*(m-1)/2);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
    int N, u, v;
    cin >> N >> u >> v;
    vector<vector<int> > E(N+1);
    for(int n=1; n<N; n++) {
        int a, b;
        cin >> a >> b;
        
        E[a].push_back(b);
        E[b].push_back(a);
    }
    
    vector<int> leaf;
    for(int n=1; n<=N; n++) {
        if(E[n].size()==1) {
            leaf.push_back(n);
        }
    }
    
    vector<int> du(N+1, -1), dv(N+1, -1);
    du[u]=0; dv[v]=0;
    queue<int> queu;
    queue<int> quev;
    queu.push(u);
    quev.push(v);
    while(!queu.empty()) {
        int cur=queu.front(); queu.pop();
        
        for(int i=0; i<E[cur].size(); i++) {
            if(du[E[cur][i]]!=-1) continue;
            du[E[cur][i]] = du[cur]+1;
            queu.push(E[cur][i]);
        }
    }

    // for(int n=1; n<=N; n++) {
    //     cout << n << ": " << du[n] << endl;
    // }

    while(!quev.empty()) {
        int cur=quev.front(); quev.pop();
        
        for(int i=0; i<E[cur].size(); i++) {
            if(dv[E[cur][i]]!=-1) continue;
            dv[E[cur][i]] = dv[cur]+1;
            quev.push(E[cur][i]);
        }
    }

    // for(int n=1; n<=N; n++) {
    //     cout << n << ": " << dv[n] << endl;
    // }

    int ans=0;
    for(int i=0; i<leaf.size(); i++) {
        if(du[leaf[i]]<dv[leaf[i]]) {
            ans = max(ans, dv[leaf[i]]);
        }
    }
    cout << ans-1 << endl;
    
    return 0;
    
}

Measured memory_bytes: 6908
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

int date[100000];
bool bit[31];
int did[31];

int main()
{
	memset(bit,false,sizeof(bit));
	while(true)
	{
		int a,b;
		scanf("%d,%d",&a,&b);
		if(a==0&&b==0)break;
		bit[b]=true;
		date[a]=b;
	}
	int k=1;
	for(int i=30;i>-1;i--)
	{
		if(bit[i]==true)
		{
			did[i]=k;
			k++;
		}
	}
	int j;
	while(scanf("%d",&j)!=EOF)
	{
		printf("%d\n",did[date[j]]);
	}
	return 0;

}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main(void) {
  ll N, K;
  cin >> N >> K;
  vector<ll> T(N), D(N);
  REP(i, 0, N) cin >> T[i] >> D[i], T[i]--;

  vector<ll> ord(N);
  REP(i, 0, N) ord[i] = i;

  sort(ord.begin(), ord.end(), [&](ll i, ll j) { return D[i] > D[j]; });

  vector<ll> cnt(N);
  priority_queue<pll, vector<pll>, greater<pll>> q;
  ll x = 0, p = 0;

  REP(k, 0, K) {
    ll i = ord[k];
    q.push(make_pair(D[i], T[i]));
    x += D[i];
    if (cnt[T[i]]++ == 0) p++;
  }

  priority_queue<pll> z;
  REP(k, K, N) {
    ll i = ord[k];
    z.push(make_pair(D[i], T[i]));
  }

  ll ans = x + p * p;
  while (++p <= N) {
    bool ok1 = false, ok2 = false;
    ll d1, t1, d2, t2;

    while (!q.empty()) {
      d1 = q.top().first;
      t1 = q.top().second;
      q.pop();

      if (cnt[t1] == 1) continue;
      ok1 = true;

      while (!z.empty()) {
        d2 = z.top().first;
        t2 = z.top().second;
        z.pop();

        if (cnt[t2] > 0) continue;
        ok2 = true;

        goto lbl;
      }
    }

lbl:

    if (!(ok1 && ok2)) break;

    x -= d1;
    cnt[t1]--;

    x += d2;
    cnt[t2]++;

    ans = max(ans, x + p * p);
  }

  cout << ans << endl;
}

Measured memory_bytes: 6004
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
pair<P,P> cat(P cake,ll s){
  P p0,p1;
  ll dis = 2*(cake.first+cake.second);
  s %= dis;
  if(cake.first>=s){
    p0.second = p1.second = cake.second;
    p0.first = s;
    p1.first = cake.first - s;
  }else if(cake.first+cake.second>=s){
    s -= cake.first;
    p0.first = p1.first = cake.first;
    p0.second = s;
    p1.second = cake.second - s;
  }else if(2*cake.first+cake.second>=s){
    s-=cake.first+cake.second;
    p0.second = p1.second = cake.second;
    p0.first = s;
    p1.first = cake.first - s;
  }else{
    s -= 2*cake.first+cake.second;
    p0.first = p1.first = cake.first;
    p0.second = s;
    p1.second = cake.second - s;
  }
  if(p0.first*p0.second > p1.first*p1.second) swap(p0,p1);
  return {p0,p1};
}
void solve(){
  ll n,w,d;
  cin >> n >>w >> d;
  if(n==0&&w==0) return;
  vector<ll> p(n),s(n);
  vector<P> cake;
  cake.push_back(P(w,d));
  for(int i=0;i<n;i++){
    cin >> p[i] >> s[i];
    p[i]--;
    auto np = cat(cake[p[i]],s[i]);
    cake.erase(cake.begin() + p[i]);
    cake.push_back(np.first);
    cake.push_back(np.second);
  }
  vector<ll> ans;
  for(auto c:cake){
    ans.push_back(c.first*c.second);
  }
  sort(ans.begin(),ans.end());
  ll m = ans.size();
  for(int i=0;i<m;i++){
    cout << ans[i];
    if(i!=m-1) cout<<" ";
  }
  cout << endl;
  solve();
}
signed main(){
  init_io();
  solve();
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
	#include <set>
	#define ll long long 
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=1;i<n;i++)
	using namespace std;
	ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}

	int power(ll int x,  ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
	void fastio()
	{					
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	// vector<ll int> adj[100001];
	// ll int vis[100001]={0};
	// ll int indegree[100001]={0};
	// ll int dist[100001]={0};
	// void dfs(ll int n)
	// {
	// 	vis[n]=1;
	// 	for(auto node: adj[n])
	// 	{
	// 		dist[node]=max(dist[node],dist[n]+1);
	// 		indegree[node]--;
	// 		if (indegree[node]==0)
	// 			dfs(node);
	// 	}
	// }
	// ll int dp[100001]={0};
	void solve()
	{
		ll int n,i;
		cin>>n;
		vector<pair<ll int, ll int>  > v;
		rep(i,n)
		{
			ll int x ,y;
			cin>>x>>y;
			v.pb(mp(x,y));

		}
		ll int ans=0;
		rep(i,n)
		{
			ll int  c=0;
			if (v[i].first==v[i].second)
			{
				while(v[i].first==v[i].second && i<n)
				{
					i++;
					c++;
				}
			}
			ans=max(ans,c);
		}
		if (ans>=3)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
		// cout<<ans<<endl;

		
    }
	int main()
	{
		fastio();
		ll int t;
		t=1;
		// cin>>t;
		
		while(t--)
		{
			solve();
		}
			
	}
			

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  map<int, int> mp;
  bool all_zero = true;
  REP(i,n) {
    int tmp;
    cin >> tmp;
    if(tmp) all_zero = false;
    ++mp[tmp];
  }
  if(all_zero) {
    cout << "Yes" << endl;
    return 0;
  }
  int input_count = mp.size();
  if(input_count > 3 || input_count < 2) {
    cout << "No" << endl;
    return 0;
  }
  if(n%3) {
    cout << "No" << endl;
    return 0;
  }
  int third_n = n / 3;
  if(input_count==2) {
    REPOBJ(itr, mp) {
      if(itr->first == 0) {
        if(itr->second != third_n)  {
          cout << "No" << endl;
          return 0;
        }
      } else {
        if(itr->second != third_n*2) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  } else {
    int should_be_zero = 0;
    REPOBJ(itr, mp) {
      should_be_zero ^= itr->first;
      if(itr->second != third_n) {
        cout << "No" << endl;
        return 0;
      }
    }
    if(should_be_zero) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes";
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 5120
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n+2];
		for (i = 1; i <= n; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		a[0]=a[n+1]=0;
		int sum=0;
		int[] b = new int[n+1];
		int[] c = new int[n];
		for (i = 0; i < n; i++) {
			b[i] = abs(a[i+1]-a[i]);
			sum+=b[i];
			c[i] = abs(a[i+2]-a[i]);
		}
		b[i] = abs(a[i+1]-a[i]);
		sum+=b[i];
		PrintWriter pw = new PrintWriter(out);
		for(i = 0; i < n; i++) {
			pw.println(sum-b[i]-b[i+1]+c[i]);
		}
		pw.flush();
	}
}


Measured memory_bytes: 52100
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"reflect"
)

var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Card struct {
	mark   string
	number int
}

func nextCard() Card {
	sc.Scan()
	text := sc.Text()
	mark := text[0:1]
	number, e := strconv.Atoi(text[1:])
	if e != nil {
		panic(e)
	}
	return Card{mark, number}
}

func main() {
	sc.Split(bufio.ScanWords)
	var n int = nextInt()
	var A []Card

	for i := 0; i < n; i++ {
		A = append(A, nextCard())
	}

	bubble_A := make([]Card, n)

	copy(bubble_A, A)

	var flag = true
	for flag {
		flag = false
		for i := n - 1; i >= 1; i-- {

			if bubble_A[i].number < bubble_A[i-1].number {
				bubble_A[i], bubble_A[i-1] = bubble_A[i-1], bubble_A[i]
				flag = true
			}
		}
	}
	for i := 0; i < n; i++ {
		var minj = i
		for j := i; j < n; j++ {
			if A[j].number < A[minj].number {
				minj = j
			}
		}
		if A[i].number != A[minj].number {
			A[i], A[minj] = A[minj], A[i]
		}
	}
	fprintCardArray(bubble_A)
	fmt.Fprintln(wtr,"Stable")
	fprintCardArray(A)
	if reflect.DeepEqual(A,bubble_A){
		fmt.Fprintln(wtr,"Stable")
	}else {
		fmt.Fprintln(wtr,"Not stable")
	}
	_ = wtr.Flush()
}
func fprintCardArray(arr []Card) {
	for i := 0; i < len(arr); i++ {
		if i == 0 {
			fmt.Fprintf(wtr, "%s%d", arr[i].mark, arr[i].number)
		} else {
			fmt.Fprintf(wtr, " %s%d", arr[i].mark, arr[i].number)
		}
	}
	fmt.Fprintln(wtr)
}


Measured memory_bytes: 1168
#include <algorithm>
#include <iostream>
#include <queue>

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

  vector<P> arb(n);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    arb[i] = make_pair(a, b);
  }

  sort(arb.begin(), arb.end());

  int ans = 0;
  priority_queue<P> pq;
  int k = 0;
  for (int i = 1; i <= m; ++i) {
    while (arb[k].first <= i) {
      pq.push(make_pair(arb[k].second, arb[k].first));
      ++k;
    }

    if (pq.empty()) continue;

    ans += pq.top().first;
    pq.pop();
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2296
#include <iostream>
#include <cmath>
using namespace std;
int sum(int x){
    return x*(x+1)/2;
}
int main(){
    long long n; cin >> n;
    int ans = 0;
    int y = sqrt(n);
    for(int i = 2; i <= y+1; i++){
        int cnt = 0;
        while(n%i == 0){
            cnt++;
            n /= i;
        }
        for(int j = 0;;j++){
            if(cnt < sum(j)){
                ans += j-1;
                break;
            }
        }
    }
    if(n != 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a+b+c >= 22) {
			System.out.println("bust");
		}else {
			System.out.println("win");

		}
	}

}


Measured memory_bytes: 20948
/*
          ,     \    /      ,
         / \    )\__/(     / \
        /   \  (_\  /_)   /   \
   ____/_____\__\@  @/___/_____\____
  |             |\../|              |
  |              \VV/               |
  |        ------hoi-------         |
  |_________________________________|
   |    /\ /      \\       \ /\    |
   |  /   V        ))       V   \  |
   |/     `       //        '     \|
   `              V                '
*/

#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define f first
#define se second
#define Speedforce boost();
#define fop(s1, s2) freopen(s1, "r", stdin);freopen(s2, "w", stdout);

using namespace std;

void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 1e6;
const ll inf = 1e9 + 7;
const ld PI = acos(-1);

ll bin_pow(ll x, ll y){
    ll res = 1, base = x;
    while(y){
        if(y & 1){
            res *= base;
            res %= inf;
        }
        base *= base;
        base %= inf;
        y /= 2;
    }
    return res;
}

int n;
ll dp[2005][2005];
pair <ll, ll> a[2005];
bool was[2005][2005];

ll rec(int l, int r){
    if(l > r){
        return 0;
    }
    if(was[l][r]){
        return dp[l][r];
    }
    was[l][r] = 1;
    ll v = a[r - l + 1].f, pos = a[r - l + 1].se;
    return dp[l][r] = max(rec(l + 1, r) + v * abs(pos - l), rec(l, r - 1) + v * abs(pos - r));
}

int main(){
    Speedforce
    //fop("F.in", "F.out")
    //mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    for(int i = 1;i <= n;i ++){
        cin >> a[i].f;
        a[i].se = i;
    }
    sort(a + 1, a + 1 + n);
    cout << rec(1, n);
}


Measured memory_bytes: 30324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    vector<P> a(n);
    for(int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i;
    sort(a.begin(), a.end());
    int can1 = a[n/2-1].first, can2 = a[n/2].first;
    vector<int> ans(n);
    for(int i = 0; i < n; i++) {
        if(a[i].first <= can1) {
            ans[a[i].second] = can2;
        }else{
            ans[a[i].second] = can1;
        }
    }
    for(int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4480
x = int(input())

if x == 1:
  print(1)
else:
  i = 2
  maxp = 2
  while i*i <= x:
    j = 1
    while pow(i, j) <= x:
      j += 1
    maxp = max(maxp, pow(i, j-1))
    i += 1
  print(maxp)

Measured memory_bytes: 3060
N=int(input().strip())
flis=[0]*1001
inf=(10**9)+7
def fact(n):
    global flis
    for i in range(2,n+1):
        while n%i==0:
            n=n//i
            flis[i]+=1


def solve(n):
    ans=1
    for i in range(1,n+1):
        fact(i)
    for i in range(1,n+1):
        ans*=(flis[i]+1)
    return ans

print(solve(N)%inf)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int takahashi = int.Parse(input[0]);
            int aoki = int.Parse(input[1]);
            int kaisu = int.Parse(input[2]);

            for(int i = 1; i <= kaisu; i++)
            {
                if(i % 2 != 0)
                {
                    if(takahashi % 2 != 0)
                    {
                        takahashi -= 1;
                    }
                    aoki += takahashi / 2;
                    takahashi /= 2;
                }
                else
                {
                    if (aoki % 2 != 0)
                    {
                        aoki -= 1;
                    }
                    takahashi += aoki / 2;
                    aoki /= 2;
                }
            }
            Console.WriteLine(takahashi + " " + aoki);


            /*
            int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int b = int.Parse(input[0]);
            int c = int.Parse(input[1]);
            // 文字列の入力
            string s = Console.ReadLine();
            //出力
            Console.WriteLine((a + b + c) + " " + s);
            */
        }
    }
}


Measured memory_bytes: 11092
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int n;
    scanf("%d", &n);
    char s[n+2];
    scanf("%s", &s[1]);

    int sum_e_=0, sum_w_=0;
    int sum_e[n+2], sum_w[n+2];
    sum_e[0] = 0, sum_w[0] = 0;
    for ( int i=1; i<=n; i++ ) {
        if ( s[i] == 'E' )
            sum_e_++;
        else
            sum_w_++;
        sum_e[i] = sum_e_;
        sum_w[i] = sum_w_;
    }
    sum_e[n+1] = sum_e_, sum_w[n+1] = sum_w_;

    int min = INT_MAX;
    for ( int i=1; i<=n; i++ ) {
        if ( min > sum_w[i-1] + (sum_e_ - sum_e[i]) )
            min = sum_w[i-1] + (sum_e_ - sum_e[i]);
    }

    printf("%d\n", min);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 2816
import sys
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
n=int(input())
d=[]
for e in sys.stdin:
	e=int(e)
	if e in a:
		a[a.index(e)]=0
	if e in b:
		b[b.index(e)]=0
	if e in c:
		c[c.index(e)]=0
if sum(a)==0 or sum(b)==0 or sum(c)==0:
	print("Yes")
	exit()
for i in range(3):
	if a[i]==0 and b[i]==0 and c[i]==0:
		print("Yes")
		exit()
if (a[0]==0 and b[1]==0 and c[2]==0) or (a[2]==0 and b[1]==0 and c[0]==0):
	print("Yes")
	exit()
print("No")


Measured memory_bytes: 9244
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    String[] S = new String[n];
    for(int i=0;i<n;i++){
      S[i] = next();
    }

    Arrays.sort(S);

    int ans = 1;

    for(int i=0;i<n-1;i++){
      if(!S[i].equals(S[i+1])){
        ans++;
      }
    }

    System.out.println(ans);

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 69384