akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#define MAXN 100006
using namespace std;
int n,v,sum[2][MAXN],ans[2][2],anss;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&v);
		sum[i%2][v]++;
	}
	for(int i=1;i<MAXN;i++)
	{
		for(int j=0;j<=1;j++)
		{
			if(sum[j][i]<=sum[j][ans[j][0]]&&sum[j][i]>sum[j][ans[j][1]]) ans[j][1]=i;
			else 
			{
				if(sum[j][i]>sum[j][ans[j][0]])
				{
					ans[j][1]=ans[j][0];
					ans[j][0]=i;
				}
			}
		}
	}
	if(ans[0][0]==ans[1][0]) anss=max(sum[0][ans[0][1]]+sum[1][ans[1][0]],sum[0][ans[0][0]]+sum[1][ans[1][1]]);
	else anss=sum[0][ans[0][0]]+sum[1][ans[1][0]];
	printf("%d",n-anss);
}

Measured memory_bytes: 896
#include<stdio.h>
main(){
char op;
int a,b;
while(1){
scanf("%d %c %d", &a, &op, &b);
if(op == '+') printf("%d\n",a+b);
if(op == '-') printf("%d\n",a-b);
if(op == '*') printf("%d\n",a*b);
if(op == '/') printf("%d\n",a/b);
if(op == '?') break;
}
return 0;
}

Measured memory_bytes: 600
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=1e5+5;

struct P{
    int n;
    int a[N];
    P(int _n){ n=_n; FOR(i,1,n)a[i]=i; }
    P(){}
    void read(){
        FOR(i,1,n)scanf("%d",&a[i]);
    }
    int & operator[](int x){return a[x];}
    P operator*(P b){
        P res;
        res.n=n;
        FOR(i,1,n)res[i]=a[b[i]];
        return res;
    }
    P operator*=(P b){
        *this = *this * b;
        return *this;
    }
    void print(){
        FOR(i,1,n)printf("%d%c",a[i]," \n"[i==n]);
    }
};

P inv(P& a){
    P res;
    res.n=a.n;
    FOR(i,1,a.n)res[a[i]]=i;
    return res;
}
P pw(P a,int m){
    P res(a.n);
    while(m)m&1?res=res*a:0,a=a*a,m>>=1;
    return res;
}

int n,k;

int main(){
    scanf("%d%d",&n,&k);
    P p(n),q(n);
    p.read();
    q.read();
    P ip=inv(p),iq=inv(q);

    P A=q*ip*iq*p;
    A=pw(A,(k-1)/6);
    if(k%6==4)A*=q;
    else if(k%6==5)A*=q*ip;
    else if(k%6==0)A*=q*ip;

    P B=
        k%6==0?iq*p:
        k%6==1?p:
        k%6==2?q:
        k%6==3?q*ip:
        k%6==4?ip:
        iq;

    P ans=A*B*inv(A);
    ans.print();
    return 0;
}


Measured memory_bytes: 11008
/*2020/03/16 ABC 051*/

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;  


int main() {
    string s;
    cin >> s;
    s.at(5) = ' ';
    s.at(13) = ' ';
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll n=s.size();
	ll a=0,b=0;
	rep(i,n){
		if(s[i]==(i%2?'1':'0'))a++;
	}
	rep(i,n){
		if(s[i]==(i%2?'0':'1'))b++;
	}
	puta(min(a,b));
	return 0;
}

Measured memory_bytes: 512
n,m=map(int,input().split())
L=[]
R=[]
for i in range(m):
	l,r=map(int,input().split())
	L.append(l)
	R.append(r)
res=min(R)-max(L)+1
if res<0:
	print("0")
else:
	print(res)

Measured memory_bytes: 10996
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    vi p(n);
    rep(i,0,n){
        cin>>p[i];
    }
    sort(all(p));
    int sum=0;
    rep(i,0,k){
        sum+=p[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3664
n,m=gets.split.map(&:to_i)
l=Array.new(n).map{[]}
m.times do |i|
  p,y=gets.split.map(&:to_i)
  l[p-1] << [y,i]
end
a=[]
n.times do |i|
  j=1
  l[i].sort.each do |y,k|
    a[k]=format("%06d%06d",i+1,j)
    j+=1
  end
end
puts a


Measured memory_bytes: 29084
S = input().split()
numbers =[]

for i in S:
    if i in ['+','-','*']:
        b = int(numbers.pop())
        a = int(numbers.pop())

        if i == '+':
            numbers.append(a+b)
        elif i == '-':
            numbers.append(a-b)
        else:
            numbers.append(a*b)
    else:
        numbers.append(i)
print(numbers[0])



Measured memory_bytes: 5600
#include <stdio.h>

int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key) i++;
  return i!=n;
}

int main(){
  int i,n,A[10000+1],q,key,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}



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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2==0) cout<<a-b;
    else cout<<b-a;
    cout<<endl;
}

Measured memory_bytes: 3544
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define edge pair<int,int>
#define x first
#define y second

const int N=2e5+5;
int use[N],du[N],n,m,v[N];
vector<edge> g[N];
edge eg[N];

void dfs(int x){
	v[x]=1;
	for(edge e:g[x]) if(!v[e.x]){
		dfs(e.x);
		use[e.y>>1]=1;
	}
}

bool dfs(int x,int fa,int to){
	for(edge e:g[x]) if(e.x!=fa&&use[e.y>>1]) du[x]^=dfs(e.x,x,e.y>>1);
	if(du[x]&1) if(eg[to].x!=x) swap(eg[to].x,eg[to].y);
  	if(~du[x]&1) if(eg[to].y!=x) swap(eg[to].x,eg[to].y);
	return ~du[x]&1;
}

signed main(){
	read(n,m);
	if(m&1) return write(-1),0;
	for(int i=1,x,y;i<=m;i++){
		read(x,y);
		eg[i]={x,y};
		g[x].emplace_back(y,i<<1);
		g[y].emplace_back(x,i<<1|1);
	}
	dfs(1);
	for(int i=1;i<=m;i++) if(!use[i]) du[eg[i].x]^=1;//,printf("#%d\n",i);
	dfs(1,0,0);
	for(int i=1;i<=m;i++) printf("%d %d\n",eg[i].x,eg[i].y);
}

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


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  cin >> a;
  cout << max(-1LL, n - accumulate(all(a), 0LL)) << endl;
}


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

using namespace std;

const int N = 2e5+5; 

void solve() {
    int res = N*100;
    int n; cin >> n;
    vector<int> X(n), Y(n);
    string d(n,'?');
    for (int i = 0; i < n; i++) {
        cin >> X[i] >> Y[i] >> d[i];
    }
    auto rotate = [&](){
        for (int i = 0; i < n; i++) {
            if (d[i] == 'R') d[i] = 'U';
            else if (d[i] == 'U') d[i] = 'L';
            else if (d[i] == 'L') d[i] = 'D';
            else d[i] = 'R';

            swap(X[i], Y[i]);
            X[i] = N - X[i];
        }
    };
    // -> <-
    auto ck0 = [&](){
        vector<vector<int>> evs(N+1);
        for (int i = 0; i < n; i++) {
            if (d[i]=='L' || d[i]=='R') {
                evs[Y[i]].push_back(i);
            }
        }
        for (auto& a: evs) {
            sort(a.begin(), a.end(), [&](auto& u, auto& v){
                return X[u] < X[v];
            });
            int n = a.size();
            for (int i = 1; i < n; i++) {
                if (d[a[i-1]] == 'R' && d[a[i]] == 'L') {
                    res = min(res, (X[a[i]] - X[a[i-1]]) * 5);
                }
            }
        }
    };
    // ->
    //   ^
    auto ck1 = [&](){
        vector<vector<int>> evs(N*2);
        for (int i = 0; i < n; i++) {
            if (d[i] == 'R' || d[i] == 'U') {
                evs[X[i]+Y[i]].push_back(i);
            }
        }
        for (auto& a: evs) {
            sort(a.begin(), a.end(), [&](auto& u, auto& v){
                return X[u] < X[v];
            });
            int n = a.size();
            for (int i = 1; i < n; i++) {
                if (d[a[i-1]] == 'R' && d[a[i]] == 'U') {
                    res = min(res, (X[a[i]] - X[a[i-1]]) * 10);
                }
            }
        }
    };
    for (int _ = 0; _ < 4; _++) {
        ck0();ck1();rotate();
    }
    if (res == N*100) cout << "SAFE";
    else cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),m=read();
	vi cnt(n,0);
	REP(i,m){
		int a=read()-1,b=read()-1;
		if(a==0)cnt[b]++;
		else if(b==0)cnt[a]++;
		else cnt[a]++,cnt[b]++;
	}
	REP(i,n)if(cnt[i]&1)return printf("NO\n"),0;
	printf("YES\n");
}


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

#define LL long long
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1; char c=getchar();
	for (;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}

const int MAXN = 100010;

int q[MAXN],dp[MAXN],Lnk[MAXN];
int N,M;
char s[MAXN];
int main(){
	N=read(); M=read();
	scanf("%s",s);
	if (s[N]=='1'){
		puts("-1"); return 0;
	} memset(dp,0x3f,sizeof(dp));
	int l,r; dp[N]=0; q[l=r=1]=N;
	for (int i=N-1;i>=0;--i){
		if (s[i]=='1') continue;
		int lst=min(i+M,N);
		while (l<=r&&q[l]>lst) ++l;
		dp[i]=dp[q[l]]+1; Lnk[i]=q[l];
		while (l<=r&&dp[i]<=dp[q[r]]) --r; q[++r]=i;
	} if (dp[0]>N){
		puts("-1");
	} else{
		int cur=0;
		while (cur!=N){
			printf("%d ",Lnk[cur]-cur);
			cur=Lnk[cur];
		} printf("\n");
	}
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int a, b; cin >> a >> b;
	if (a < 0) {
		if (b >= 0)cout << "Zero" << "\n";
		else {
			if ((abs(a - b) + 1) % 2 == 0)cout << "Positive" << "\n";
			else cout << "Negative" << "\n";
		}
	}
	else if (a > 0) {
		if (b <= 0)cout << "Zero" << "\n";
		else cout << "Positive" << "\n";
	}
	else cout << "Zero" << "\n";

	return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
c1 = Counter(v[::2]).most_common()
c2 = Counter(v[1::2]).most_common()
if c1[0][0] == c2[0][0]:
    if len(c1) > 1 and len(c2) > 1:
        print(n-max(c1[1][1]+c2[0][1], c1[0][1]+c2[1][1]))
    elif len(c1) > 1:
        print(n-c1[1][1]-c2[0][1])
    elif len(c2) > 1:
        print(n-c1[0][1]-c2[1][1])
    else:
        print(n//2)
else:
    print(n-c1[0][1]-c2[0][1])

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



namespace CSharpSample01
{

    
      
    class Program
    {
        
        static void Main(string[] args)
        {
            //入力1(S)
            int N = int.Parse(Console.ReadLine());
            int[] H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int cnt = 0;
            int ans = 0;

            for(int i = 0; i < N - 1; i++)
            {
                if (H[i] >= H[i + 1])
                {
                    cnt++;
                }
                else
                {
                    ans = Math.Max(ans, cnt);
                    cnt = 0;
                }
            }

            ans = Math.Max(ans, cnt);

            Console.WriteLine(ans);
        }
    }

}

Measured memory_bytes: 24156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int count=0;
  rep(i,k){
    rep(j,a){
      if(k==0){
        break;
      }
      count++;
      k--;
    }
    rep(j,b){
      if(k==0){
        break;
      }
      k--;
    }
    rep(j,c){
      if(k==0){
        break;
      }
      count--;
      k--;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int n;
int t1,x1,y1;
int t2,x2,y2;

int f(int x){
	if (x<0)return -x;
	else return x;
}

int main()
{
//	freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	cin>>n;
	int i,j;
	for (i=1;i<=n;i++){
		cin>>t2>>x2>>y2;
		int dt=t2-t1;
		int dx=f(x2-x1);
		int dy=f(y2-y1);
		if ((dt<(dx+dy)) || ((dt%2)^((dx+dy)%2))){
			cout<<"No"<<endl;
			return 0;
		}
		t1=t2;x1=x2;y1=y2;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b; cin >> a >> b;
    ll ans=1e12;
    for(ll k=1;k<=a;k++){
        ll c=(b*k+a-1)/a*a;
        if(c/a<c/b+c%b){
            ans=min(ans,c);
            break;
        }
    }
    if(ans==1e12){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}



Measured memory_bytes: 3212
#include<stdio.h>

main(void){
  
  int a[100],N,i,j,tempo,c=0;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(a[j]<a[j-1]){
	tempo=a[j];
	a[j]=a[j-1];
	a[j-1]=tempo;
	c=c+1;
      }
    }
  }

  for(i=0;i<N;i++){
    if(i==N-1)printf("%d\n",a[i]);
    else printf("%d ",a[i]);
  }
  printf("%d\n",c);
return 0;
}

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



const int N = 405, MOD = 1e9 + 7;
const long long INF = 9e18;



int n, a[N];
long long b[N];
long long dp[N][N];

inline long long get(int l, int r){
    return b[r] - b[l - 1];
}
long long rec(int l, int r){
    if(dp[l][r] != -1){
        return dp[l][r];
    }
    if(l > r){
        assert(false);
    }
    if(l == r){
        return dp[l][r] = 0;
    }
    if(l + 1 == r){
        return dp[l][r] = a[l] + a[r];
    }
    dp[l][r] = INF;
    for(int i = l; i + 1 <= r; i++){
        dp[l][r] = min(dp[l][r], rec(l, i) + rec(i + 1, r) + get(l, i) + get(i + 1, r));
    }
    //cout << l << " " << r << " " << dp[l][r] << "\n";
    return dp[l][r];
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        b[i] = b[i - 1] + a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << rec(1, n);
    return 0;
    cout << "\n";
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j++){
            cout << i << " " << j << " " << dp[i][j] << "\n";
        }
    }
}


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

ll dp[2005][2005];

int main(){
	int n;
  	cin >> n;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  	
  	vector<P> p;
  	rep(i, n) p.emplace_back(a[i], i);
  	sort(p.rbegin(), p.rend());
  	
  	rep(i, n){
    	int pi = p[i].second;
      	rep(l, i+1){
        	int r = i-l;
          	dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l]+ll(pi-l)*a[pi]);
            dp[i+1][l] = max(dp[i+1][l], dp[i][l]+ll((n-r-1)-pi)*a[pi]);
        }
    }
  
  	ll ans = 0;
  	rep(i, n+1) ans = max(ans, dp[n][i]);
  	cout << ans << endl;
}

Measured memory_bytes: 26284
#include <vector>
#include <iostream>
using namespace std;
const int mod = 100000;
int N, M, S;
int main() {
	while (cin >> N >> M >> S, N) {
		N *= N;
		M -= N;
		S -= N * (N + 1) / 2;
		vector<vector<int> > dp(M + 1, vector<int>(S + 1, 0));
		dp[0][0] = 1;
		for (int i = 1; i <= N; i++) {
			vector<vector<int> > dp2(M + 1, vector<int>(S + 1, 0));
			for (int j = 0; j <= M; j++) {
				for (int k = j; k <= S; k++) {
					dp2[j][k] = dp[j][k - j];
					if (j >= 1) {
						dp2[j][k] += dp2[j - 1][k - 1];
						if (dp2[j][k] >= mod) dp2[j][k] -= mod;
					}
				}
			}
			dp = dp2;
		}
		int ret = 0;
		for (int i = 0; i <= M; i++) {
			ret += dp[i][S];
			if (ret >= mod) ret -= mod;
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 30060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class C
{
	public static void Main()	
	{
		long mod = 1000000007;
		int N = GetInt();

		long[] numFactor = new long[N+1];
		for(int i = 2; i <= N; i++)
		{
			int tmp = i;
			for(int j = 2; j <= N; j++)
			{
				while(tmp % j == 0)
				{
					tmp /= j;
					numFactor[j]++;	
				}
				if(tmp == 1)
					break;
			}
		}

		long ans = 1;
		for(int i = 1; i <= N; i++)
			ans = (ans * (numFactor[i] + 1)) % mod;
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11204
import java.util.*;
public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] M = new int [N + 1];
        for (int i = 1; i <= N; ++i) {
            M[i] = sc.nextInt();
        }
        M[0] = 0;
        sc.close();

        Arrays.sort(M);
        int fl = X;
        for (int i = 1; i <= N; ++i) {
            fl -= M[i];
        }

        int ans = N;
        while (fl >= 0) {
            fl -= M[1];
            ans++;
        }

        System.out.println(ans - 1);
	}
}


Measured memory_bytes: 23636
s = gets.chomp

s_size = s.size

if s_size.odd?
  ary1 = s.slice(0, s_size / 2).split('')
  # m = s.slice(s / 2)
  ary2 = s.slice(s_size / 2 + 1, s_size).split('')
else
  ary1 = s.slice(0, s_size / 2).split('')
  # m = nil
  ary2 = s.slice(s_size / 2, s_size).split('')
end

ary2 = ary2.reverse

puts ary1.each_with_index.count { |s1, i| s1 != ary2[i] }



Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int> a(n);
	bool flag=false;
	rep(i,n){
		a[i]=s[i]-'0';
		a[i]--;
		if(a[i]==1) flag=true;
	}
	if(flag){
		int cnt=0;
		rep(i,n){
			a[i]%=2;
			if(a[i] && ((n-1-i)|i)==n-1){
				cnt++;
			}
		}
		cout<<(cnt%2)<<endl;
	}else{
		int cnt=0;
		rep(i,n){
			if(a[i] && ((n-1-i)|i)==n-1){
				cnt++;
			}
		}
		if(cnt%2) cout<<2<<endl;
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 5276
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
    int n; cin >> n ;
    string s; cin >> s;
    if(n%2==0){
    	string ans ="", ans2="";
    	for(int i=0 ; i < n/2 ; i++){
    		ans+=s[i];
		}
		for(int i= n/2 ; i < n ; i++){
			ans2+=s[i];
		}
		//cout << ans << " " << ans2 << endl;
		if(ans==ans2)
		cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else cout << "No" << endl;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

int Solve(int h,int w){
	int ans=inf;
	FOR(i,1,h){
		int x=i*w;
		{
			int y=(h-i)*(w/2);
			int z=(h-i)*((w+1)/2);
			chmin(ans,max({x,y,z})-min({x,y,z}));
		}
		{
			int y=w*((h-i)/2);
			int z=w*(((h-i)+1)/2);
			chmin(ans,max({x,y,z})-min({x,y,z}));
		}
	}
	return ans;
}

signed main(){
	int h=read(),w=read();
	cout<<min(Solve(h,w),Solve(w,h))<<endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/arc031/tasks/arc031_2 
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <deque>
#include <stdio.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	ll n;
	ll ans=0;
	cin >> n;
	for (int i = 1;i < n;i++) {
		int quot;
		int rem;
		quot = n / i;
		rem = n % i;
		if (rem == 0) {
			ans += quot - 1;
		}
		else {
			ans += quot;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {	
		Scanner sc = new Scanner(System.in);
		int[] time = new int[5];
		for(int i=0;i<time.length;i++) {
			time[i] = Integer.parseInt(sc.next());
		}
		
		int[] los = new int[5];
		int totaltime = 0;
		for(int i=0;i<los.length;i++) {
			if(time[i]<10) {
				los[i] = 10-time[i];
			}else if(time[i]<100) {
				int t = (time[i]/10);
				los[i] = 10-(time[i]-t*10);
				if(los[i]==10) los[i]=0;
			}else {
				int t = (time[i]/10);
				los[i] = 10-(time[i]-t*10);
				if(los[i]==10) los[i]=0;
			}
		}
		
		for(int i=0 ;i<los.length;i++) {
			totaltime += time[i]+los[i];
		}
		int max=los[0],index=0;
		for(int i=1;i<los.length;i++) {
			if(los[i]>max) {
				max=los[i];
				index=i;
			}
		}
		
		System.out.println(totaltime-los[index]);
		
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;
 
public class Main {    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int red = Integer.parseInt(sc.next());
        int green = Integer.parseInt(sc.next());
        int blue = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        String flag = "No";
        while(true){
            if(green > red && blue > green){
                flag = "Yes";
                break;
            }
            if(k==0){
                break;
            }
            if(red >= green){
                green = green * 2;
                k--;
//                System.out.println("k:" + k + "blue:" + blue + "green:" + green + "red:" + red);
            }else{
                if(green >= blue){
                    blue = blue * 2;
                    k--;
//                System.out.println("k:" + k + "blue:" + blue + "green:" + green + "red:" + red);
                }
            }
        }
        System.out.println(flag);
    }
}



Measured memory_bytes: 35488
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    ret = 10**9
    for a in range(1,N):
        b = N-a
        ret = min(ret,sum(map(int,list(str(a))))+sum(map(int,list(str(b)))))

    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N, K = map(int, input().split())
As = [int(i) for i in input().split()]

d = {}
for a in As:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1


diff = len(d) - K
ans = 0
if diff > 0:
    new_d = sorted(d.items(), key=lambda x: x[1])
    # 辞書がリスト[(タプル),(タプル),(タプル)]の形になる
    for x, y in new_d[:diff]:
        ans += y
    print(ans)
else:
    print('0')


Measured memory_bytes: 39044
n = int(input())
line = input()
liststr = line.split()
list = []
 
for i in liststr:
    i = int(i)
    list.append(i)
 
 
cc = 0
for r in list:
    while r%2 == 0:
        r = r / 2
        cc = cc + 1
 
 
print(cc)

Measured memory_bytes: 4212
#include<bits/stdc++.h>                          
using namespace std;
int a,b,num1,num2,num3;
int main(){
    cin>>a>>b;
    num1=a-b;
    num2=a+b;
    num3=a*b;
    cout<<max(num3,max(num1,num2));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args)
    {
        int n = new Scanner(System.in).nextInt();
        for(int i=1;i<=n;i++)
        {
            int x = i;
            if(x%3==0)
            {
                System.out.print(" "+i);
                continue;
            }
            do
            {
                if (x % 10 == 3)
                {
                    System.out.print(" " + i);
                    break;
                }
                x /= 10;
            }while(x!=0);
        }
        System.out.println();
    }
}

Measured memory_bytes: 28668
#include <iostream>
#include <queue>
#include <map>
#include <string>
#define f first
#define s second
using namespace std;
int main(){

  string x; int y;
  int n,q,i,cnt=0;
  queue<pair <string,int> > a;

  cin>>n>>q;
  for(i=0;i<n;i++){
    cin>>x>>y;
    a.push(make_pair(x,y));
  }
  while(!a.empty()){
    cnt+=q;
    a.front().s-=q;
    if(a.front().s>0){
      a.push(a.front());      
      a.pop();
    } else {
      cnt+=a.front().s;
      cout<<a.front().f<<" "<<cnt<<endl;
      a.pop();
    }
  }
  return 0;
}



Measured memory_bytes: 6396
#include <iostream>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main(){
  int N, B, C, Q, tmp;
  cin >> N;
  unordered_map<int, list<int>> hash;
  ll sum = 0;
  for (int i=0; i<N; i++){
    cin >> tmp;
    hash[tmp].push_back(tmp);
    sum += (ll)tmp;
  }
  cin >> Q;
  for (int i=0; i<Q; i++){
    cin >> B >> C;
    if (hash[B].size() > 0){
      sum += (ll)(C - B) * (ll)hash[B].size();
      hash[C].merge(hash[B]);
      hash.erase(B);
    }
    cout << sum << "\n";
  }
  

  return 0;
}

Measured memory_bytes: 10632
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W = MI()
    cnt = [0]*26
    for _ in range(H):
        for s in ST():
            cnt[ord(s)-ord("a")] += 1
    
    cnt_cnt = defaultdict(int)
    for c in cnt:
        cnt_cnt[c%4] += 1


    #2個セットのは,2ペア集めると4の倍数個ある文字を採用することが出来るのでそれを考慮する

    if H%2==0 and W%2==0: #even even
        if cnt_cnt[0]==26:
            print("Yes")
        else:
            print("No")
    elif H&1 and W&1: #odd odd
        flag1 = (cnt_cnt[1]+cnt_cnt[3]==1)
        cnt_cnt[2]+=cnt_cnt[3] ## 3のやつは真ん中に一つと2個ペアに2つ使う
        flag2 = (cnt_cnt[2]%2==((H//2)+(W//2))%2 and cnt_cnt[2]<=(H//2)+(W//2))
        if flag2 and flag1:
            print("Yes")
        else:
            print("No")
    else: #others
        if cnt_cnt[1] or cnt_cnt[3]:
            print("No")
            return
        if H&1:
            if cnt_cnt[2]%2==(W//2)%2 and cnt_cnt[2]<=(W//2):
                print("Yes")
            else:
                print("No")
        else:
            if (cnt_cnt[2])%2==(H//2)%2 and (cnt_cnt[2])<=(H//2):
                print("Yes")
            else:

                print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  if(mp.count("AC")) cout << "AC x " <<mp["AC"]<< endl;
  else cout << "AC x " <<0<< endl;
  if(mp.count("WA")) cout << "WA x " <<mp["WA"]<< endl;
  else cout << "WA x " <<0<< endl;
  if(mp.count("TLE")) cout << "TLE x " <<mp["TLE"]<< endl;
  else cout << "TLE x " <<0<< endl;
  if(mp.count("RE")) cout << "RE x " <<mp["RE"]<< endl;
  else cout << "RE x " <<0<< endl;
}



Measured memory_bytes: 3624
<?php
    //入力
    fscanf(STDIN, "%d", $n);
    fscanf(STDIN, "%d %d", $t, $a);
    $array_h = explode(" ", trim(fgets(STDIN)));
    //気温の計算
    for ($i=0; $i < $n; $i++) { 
        $array_h[$i] = $t - (int)$array_h[$i]*0.006;
    }
    //指定値との比較
    for ($i=0; $i < $n; $i++) { 
        $array_h[$i] = abs($a - $array_h[$i]);
    }
    
    $temp = 999;
    $ans;
    foreach ($array_h as $key => $value) {
        if ($temp > $value) {
            $temp = $value;
            $ans = $key + 1;
        }
    }

    echo $ans."\n";

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    double sum = v[0];
    rep(i, n-1) {
        sum = (sum + (double)v[i+1]) / 2;
    }
    printf("%12f", sum);
}

Measured memory_bytes: 256
A, B = map(int, input().split())
POKER = [2,3,4,5,6,7,8,9,10,11,12,13,1]
a=POKER.index(A)
b=POKER.index(B)
if a > b:
    print('Alice')
elif a < b:
    print('Bob')
else:
    print('Draw')


Measured memory_bytes: 3060
//??：4s   空?：256MB
//?意:在一?无?深的二叉?上挂牌子,?定n个操作,表示在深度?di
//的子?点?挂牌子,如果符合到根的路径上只有1个牌子,那?就挂上去
//如果可以挂一定要挂,根?点深度?0
//算法:直接模?挂牌操作,??当前挂牌的情况,??当前允?挂牌上界 
//和最深的位置,如果某个的位置出?了??牌子,通?移?可以将他?
//移?至同一?子?,然后将其向上?点,更新最深点
//?于最浅的点,可以将牌子按照深度,从左挂到右?,可以??如果
//当前最浅深度的一个子?点挂牌,那就将挂牌上界往下移?
//因?只有?外一个子?点可以挂牌子了,如果?外一个子?点的一个
//儿子又有牌子,那就??将上界下移? 
//?个子?点都被挂牌,相当于自己被挂牌子 
//如果根?点被挂上牌子,就直接No,如果在最浅位置上方,那也不能挂
//当然如果上界和最深?不相等,上界?个深度明?是不能挂牌的 
//?于?目的数据,是不可能?下整个??数?的,所以?于明?可行的
//操作直接跳?就可以了(在根没有挂牌子的情况下)但是需要更新一下
//最深的深度 
#include<cstdio>
#include<algorithm>
using namespace std;
int d[1000005];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n;
	scanf("%d",&n);
	int top=0,down=0;
	while(n--){
		int x;
		scanf("%d",&x);
		if(d[0]||x<top){printf("No\n");continue;}		
		if(x==top&&top!=down){printf("No\n");continue;}
		if(x>=1000000){printf("Yes\n");down=max(down,x);continue;}
		d[x]++;down=max(down,x);
		while(d[x]>=2){
			d[x-1]++;
			d[x]=0;
			if(x==down)down--;
			x--;
		}
		for(int i=top+1;d[i]==1;i++)
			top=i;
		printf("Yes\n");
	}
	return 0;
} 

Measured memory_bytes: 4616
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int v[] = new int[N];
    for(int i=0; i<N; i++){
      v[i] = sc.nextInt();
    }
    Arrays.sort(v);
    double ans = v[0];
    for(int i=1; i<N; i++){
      ans = (ans + v[i]) / 2;
    }
    out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> l(n);
    rep (i, n) cin >> l[i];
    sort(all(l));
    ll ans = 0;
    rep (i, n) {
        rep (j, i + 1, n) {
            rep (k, j + 1, n) {
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                if (l[i] + l[j] > l[k]) ans++;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) loop(i, 0, n)
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << endl
int INF = numeric_limits<int>::max();

typedef long long LL;
typedef pair<int, int> P;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  LL X, Y;
  cin >> X >> Y;
  LL a = X;
  int cnt = 0;
  while (Y >= a) {
    cnt++;
    a = a * 2;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
from collections import defaultdict
dic = defaultdict(int)
ans = 0
flag = 0
l = []
for _ in range(n):
   s,t = map(str,input().split())
   l.append((s,t))


x = input()


for s,t in l:
   if flag:
      ans += int(t)
   if s == x:
      flag = 1
   
print(ans)

Measured memory_bytes: 3444
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		myout(N * N * N);
	}
	//Method addition frame start



	//Method addition frame end
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans = max(max(a * c, a * d), max(b * c, b * d));
    cout << ans << '\n';
    return 0;
}

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

int main() {
  int n=0;
  cin>>n;
  int q=n%10;
  
  if(q==2||q==4||q==5||q==7||q==9){
    cout<<"hon";
  }else if(q==0||q==1||q==6||q==8){
    cout<<"pon";
  }else{
    cout<<"bon";
  }
}

Measured memory_bytes: 3636
<?php

[$N, $K] = fscanf(STDIN, "%d%d");
$A = array_map('intval', explode(" ", fgets(STDIN)));

for ($i = $K; $i < $N; $i++) {
    if ($A[$i] > $A[$i - $K]) {
        echo 'Yes';
    } else {
        echo 'No';
    }
    if ($i < $N - 1) {
        echo "\n";
    }
}

?>

Measured memory_bytes: 38308