akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

void modinvs(long long N, vector<long long>& inv, vector<long long>& sinv, long long mod = 1e9 + 7) {
	inv.resize(N + 1);
	sinv.resize(N + 1);
	inv[1] = 1;
	sinv[0] = 1;
	sinv[1] = 1;
	for (int n = 2; n <= N; n++) {
		inv[n] = mod - (inv[mod % n] * (mod / n)) % mod;
		sinv[n] = (sinv[n - 1] * inv[n]) % mod;
	}
}

LL N, K;
VLL inv, sinv;
VLL st;
VLL A;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N >> K;
	modinvs(N + 1, inv, sinv);
	st.resize(N + 1, 1);
	for (LL n = 2; n <= N; n++) {
		st[n] = st[n - 1] * n;
		st[n] %= MOD;
	}
	A.resize(N);
	for (LL n = 0; n < N; n++)cin >> A[n];
	sort(A.begin(), A.end(), [](LL a, LL b) {
		return a < b;
	});
	LL ans = 0;
	for (LL n = 0; n <= N - K; n++) {
		LL temp = 1;
		temp = (temp * st[N - n - 1] * sinv[K - 1]) % MOD;
		temp = (temp * sinv[N - n - K]) % MOD;
		temp = (temp * A[n]) % MOD;
		ans -= temp;
	}
	for (LL n = K - 1; n < N; n++) {
		LL temp = 1;
		temp = (temp * st[n] * sinv[n - K + 1]) % MOD;
		temp = (temp * sinv[K - 1]) % MOD;
		temp = (temp * A[n]) % MOD;
		ans += temp;
	}
	cout << ans % MOD << "\n";
	return 0;
}

Measured memory_bytes: 3456
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
long b = sc.nextLong();
long x = sc.nextLong();
long ax;
if(a != 0){
ax = ((a -1) / x )+ 1;
}else{
ax = 0;
}
long bx = b / x + 1;
long ans = bx - ax;

/*if(ans == 0&&a % x == 0){
ans = 1;
}*/

System.out.println(ans);


}
}

Measured memory_bytes: 23760
#include<iostream>
using namespace std;
int main()
{
    char ch;
    scanf(" %c",&ch);
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u'){
        printf("vowel\n");
    }
    else
    {
        printf("consonant\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	double sum=0;
	cin>>n>>m;
	int a[101];
	for (int i=0;i<n;i++){
		cin>>a[i];
		sum+=(double)a[i];
	}
	sum/=4*m;
	int cnt=0;
	for (int i=0;i<n;i++)
		if (a[i]>=sum)
			cnt++;
	cout<<(cnt>=m ? "Yes" : "No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1e9+7
#define EPS 1e-8
#define INF 1e9+10
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  cout << (N-1)/2 << endl;
}



Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include <numeric>

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(p) cerr<<#p<<'='<<(p.first)<<" "<<p.second<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
const ll MOD = 1e9 + 7;
const int N = 1000000000000001;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char button[4]={'L','R','U','D'};

// Ahhiya thi lakhvanu chalu thasse....


signed main() {
    FAST
    int q = 1;
    //cin>>q;
    while (q--) {
        int n;
        cin>>n;
        map<string,int> mp;
        for(int i=0;i<n;i++){
            string s;
            cin>>s;
            mp[s]++;
        }
        cout<<"AC x "<<mp["AC"]<<endl;
        cout<<"WA x "<<mp["WA"]<<endl;
        cout<<"TLE x "<<mp["TLE"]<<endl;
        cout<<"RE x "<<mp["RE"]<<endl;
    }
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  rep(ka,k+1)rep(kb,k+1)rep(kc,k+1){
    if(ka+kb+kc>k)continue;
    ll na=a*(1LL<<ka);
    ll nb=b*(1LL<<kb);
    ll nc=c*(1LL<<kc);
    if(na<nb&&nb<nc){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <cstdlib>

#define MOD 1000000007
#define ll long long

using namespace std;

ll N;
vector<ll>a;

int main(){
  ll inp;
  ll sumall;
  ll sumhalf;
  ll di;
  ll result;
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> N;
  sumall = 0;
  for(ll i =0;i<N;i++){
    cin >> inp;
    a.push_back(inp);
    sumall += inp;
  }
  result = abs(sumall-2*a[0]);
  sumhalf = a[0];
  for(ll i =1;i<N-1;i++){
    sumhalf += a[i];
    di = abs(sumall-(2*sumhalf));
    if(result > di) result = di;
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 2420
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define reg register
typedef long long ll;
template<typename T>inline T read(){
	reg T x=0;reg short f=1;reg char c=getchar();
	for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());
	for(;isdigit(c);x=x*10+(c^48),c=getchar());
	return x*f;
}
const int MN=20005;
int p[MN],a[MN];
int main(){
	reg int n=read<int>();
	for(reg int i=1;i<=n;i++)a[p[i]=read<int>()]+=i;
	for(reg int i=1;i<=n;i++)printf("%d ",a[i]+i*MN);puts("");
	for(reg int i=1;i<=n;i++)printf("%d ",(n-i+1)*MN);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}   
     
int main()
{
      
    fast;
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  d=abs(d);

  ll n=x/d;
  if(k>n)
  {
    ll m=x-(n*d);
    if((n-k)%2==0)
        cout<<m<<endl;
    else cout<<abs(m-d)<<endl;
  }
  else cout<<abs(x-(d*k))<<endl;
    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

void find_divisor(ll N, vector<ll>& divisor) {
  for(int i=1; i<=sqrt(N); i++) {
    if(N % i == 0)
      divisor.push_back(i);
  }
  int n = divisor.size();
  for(int i=n-1; i>=0; i--) {
    if(N != (ll)pow(divisor[i], 2))
      divisor.push_back(N / divisor[i]);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll m; cin >> n >> m;
  vector<ll> div;
  find_divisor(m, div);
  ll ans = 1;
  for(ll d: div) {
    if(d*n <= m) ans = d;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int Left = A + B ; 
  int Right= C + D ;
  if (Left == Right){
  	cout << "Balanced" << endl;
  } else if (Left > Right){
  	cout << "Left" << endl;
  } else if (Right > Left){
  	cout << "Right" << endl;
  }
  
  }

Measured memory_bytes: 256
N=int(input())
a=[]
z=0
for i in range(1,N+1):
    if i%3==0:
        z=0
    elif i%5==0:
        z=0
    elif i%3==0 and i%5==0:
        z=0
    else:
        a.append(i)
print(sum(a))

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

#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() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> red;
    vector<int> blue;
    vector<int> green;
    
    int idx_r = 0;
    int idx_b = 0;
    int idx_g = 0;
    rep(i, n){
        if(s[i] == 'R'){
            red.push_back(i+1);
            // cout << "R" << i << endl;
            ++idx_r;
        }else if(s[i] == 'B'){
            blue.push_back(i+1);
            // cout << "B" << i << endl;
            ++idx_b;
        }else{
            green.push_back(i+1);
            // cout << "G" << i << endl;
            ++idx_g;
        }
    }
    
    ll res = 0;
    rep(i, idx_r){
        int rr = red[i];
        rep(j, idx_b){
            int bb = blue[j];
            int big = max(rr, bb);
            int small = min(rr, bb);
            int dif = big - small;
            
            int mid = 0;
            if((big + small) % 2 == 0){
                mid = (find(green.begin(), green.end(), small + dif/2) != green.end());
            }
            int left = (find(green.begin(), green.end(), small - dif) != green.end());
            int right = (find(green.begin(), green.end(), big + dif) != green.end());
            
            // cout << mid << "," <<  left << "," << right << endl;
            res += idx_g - mid - left - right;
        }
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

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

  for (int i = 0; i < k; ++i) {
    if (i % 2 == 0) {
      if (a % 2 == 1) a--;
      b += a / 2;
      a /= 2;
    } else {
      if (b % 2 == 1) b--;
      a += b / 2;
      b /= 2;
    }
  }
  cout << a << " " << b << endl;
}


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


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

    int q; cin >> q;
    vector<int> l(q),r(q);
    for(int i = 0;i < q;i ++){
        cin >> l.at(i) >> r.at(i);
    }  
    for(int i = 0;i < q;i ++){
        if(l.at(i) < 3) l.at(i) = 3;
    }

    vector<int> sosu(100001),sosunomi(1,2);
/*    for(int i = 3;i < 100001;i += 2){
        for(int j = 0;j < sosunomi.size();j ++){
            if(i % sosunomi.at(j) == 0){
                break;
            }
            if(sosunomi.at(j) > i/2){
                sosu.at(i) = 1;
                sosunomi.push_back(i);
                break;
            }
        }
    }  
*/

    for(int i = 2;i < 50000;i ++){
        if(sosu.at(i) == 1) continue;
        for(int j = i * 2;j < 100001;j += i) sosu.at(j) = 1;
    }

    vector<int> a(100001);
    for(int i = 0;i < 100001;i ++){
        if(sosu.at(i) == 0 && sosu.at((i+1) / 2) == 0){
            a.at(i) = 1;
        }
    }
    a.at(2) = 1;

    vector<int> sum(100001);
    for(int i = 1;i < 100001;i ++){
        sum.at(i) = sum.at(i-1) + a.at(i);
    }

    for(int i = 0;i < q;i ++){
        cout << sum.at(r.at(i)) - sum.at(l.at(i) - 1) << endl;
    }
}

Measured memory_bytes: 4608
B='{:041b}'.format
n,k,*a=map(int,open(0).read().split())
if not k:
  print(sum(a))
  exit()
l=[0]*41
for i in a:
  for j,t in enumerate(B(i)):
    if int(t):l[j]+=1
dp=[[0,-1]for i in range(41)]
for i,f in enumerate(map(int,B(k))):
  if not i:continue
  v0,v1=(n-l[i])*pow(2,40-i),l[i]*pow(2,40-i)
  if f:
    dp[i][0]=dp[i-1][0]+v0
    if dp[i-1][1]>=0:
      dp[i][1]=max(dp[i-1][0]+v1,dp[i-1][1]+max(v0,v1))
    else:
      dp[i][1]=dp[i-1][0]+v1
  else:
    dp[i][0]=dp[i-1][0]+v1
    if dp[i-1][1]>=0:
      dp[i][1]=dp[i-1][1]+max(v0,v1)
print(max(dp[-1]))

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

int main(void){
        int n;
        int a;
        int cnt = 0;
        std::cin >> n;
        for(int i = 0; i < n; i++){
                std::cin >> a;
                if(a%2 == 0) cnt++;
        }
        std::cout << std::pow(3, n) - std::pow(2, cnt)<< std::endl;

        return 0;
}

Measured memory_bytes: 256
cat<<EOF>Source.cpp
#include <iostream>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	#pragma omp parallel for num_threads(2)
	rep(i,k){
		int cnt[max(n,k)];
		rep(j,max(n,k))cnt[j]=0;
		rep(j,n){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		rep(j,k){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	rep(i,k)Max=max(Max,ans[i]);
	cout<<Max<<endl;
}
EOF
g++ -O3 -mtune=native -march=native Source.cpp -o Source -fopenmp -std=c++11
./Source

Measured memory_bytes: 32408
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int dp[100010] = {0};

int main(){
	int n,m,a,b=-1;
	cin >> n >> m;
	rep(i,m) {
		cin >> a;
		if(a-b == 1){
			cout << 0 << endl;
			return 0;
		}
		dp[a] = -1;
		b=a;
	}
	dp[0] = 1;
	if(dp[1] != -1)dp[1] = 1;
	else dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		if(dp[i] == -1) {
			dp[i] = 0;
			continue;
		}
		dp[i] = (dp[i-1] + dp[i-2]) % mod;
	}
	cout << dp[n] << endl;
	return 0;

}


Measured memory_bytes: 640
def prepare(n, MOD):

    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f
    
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    
    return fn, invs

def solve(x,y):
    MOD=10**9+7
    if (x+y)%3!=0:
        return 0
    L=(x+y)//3
    if x<L or y<L:
        return 0
    i=min(x,y)-L
    if i==0 or i==L:
        return 1
    fn,invs=prepare(L,MOD)
    ret=(fn*invs[i])%MOD
    ret=(ret*invs[L-i])%MOD
    return ret

x,y=map(int,input().split())
print(solve(x,y))

Measured memory_bytes: 35212
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
using System.Threading;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var t=sc.S;
		if(t[t.Length-1]=='s'){t+="es";}
		else{t+="s";}
		Console.WriteLine("{0}",t);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 25980
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
typedef long long int ll;

ll dp[110][2][110];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int kk; cin >> kk;
	dp[0][0][0]=1;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<=kk;k++){
				if(dp[i][j][k]==0)continue;
				if(j==0){
					for(int l=0;l<=s[i]-'0';l++){
						if(l==0){
							if(s[i]-'0'!=0)dp[i+1][1][k]+=dp[i][j][k];
							else dp[i+1][0][k]+=dp[i][j][k];
						}
						else if(l<s[i]-'0'){
							dp[i+1][1][k+1]+=dp[i][j][k];
						}
						else{
							if(s[i]-'0'==0)dp[i+1][0][k]+=dp[i][j][k];
							else dp[i+1][0][k+1]+=dp[i][j][k];
						}
					}
				}
				else{
					for(int l=0;l<=9;l++){
						if(l)dp[i+1][1][k+1]+=dp[i][j][k];
						else dp[i+1][1][k]+=dp[i][j][k];
					}
				}
			}
		}
	}
	cout << dp[s.size()][1][kk]+dp[s.size()][0][kk] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ip pair<int, int>
#define it pair<int, pair<int, int>>
#define F first
#define S second
#define fori(p, n) for(int i = p; i < n; i++)
#define forj(q, m) for(int j = q; j < m; j++)
#define fork(r, l) for(int k = r; k < l; k++)
#define revi(h) for(int i = h; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define PI 3.14159265358
#define debug(x) cout<<"DEBUGGING --- "<<x<<endl;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file freopen("output.txt", "w", stdout);

signed main(){
    fastio;
    // input_from_file; 
    // output_to_file;
    int n; cin >> n;
    string s; cin >> s;
    stack<char>st;
    fori(0, n){
        if(st.empty()) st.push(s[i]);
        else if(st.top() != s[i]) st.push(s[i]); 
    }
    cout << st.size() << endl;
 }


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
struct triple{ll   x=0;ll   y=0;ll   z=0;void mt(ll   a,ll   b, ll   c){x=a;y=b;z=c;} void holify(){x=69;y=420;z=911;}};
#define pb push_back
#define x first 
#define y second
#define vec vector
#define pf(vec,val) vec.insert(vec.begin(),val)
#define mp make_pair
#define pii pair<ll  ,ll  >
#define maxll  69696991169
#define minll  -69696942069
#define sz(vec) (ll )vec.size()
#define speedup ios_base::sync_with_stdio(0); cin.tie(NUll ); cout.tie(NUll );
#define loop(mep) for(auto it = mep.begin();it!=mep.end();++it)
//#define usaco_crap(str)ifstream cin((string)str + (string)".in"); ofstream cout ((string)str+(string)".out");
#define range(n) =0;i<(n);i++
#define prll  (vec) for(auto it=vec.begin();it!=vec.end();++it)cerr<<*it<<" ";cerr<<endl;
// mt make triple // triple.mt(a,b,c) //
int  main(){
	int n; cin>>n;
	int flag = 0;
	for(int i = 1; i < 10 ; i++){
		for(int j = 1 ; j< 10 ; j++){
			if(i*j==n)flag=1;
		}
	}
	if(flag)cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll ct;
void dfs(vector<vector<ll>>&adj,ll x,vector<ll>&vis)
{
    ct++;
    vis[x]=1;
    for(auto a:adj[x])
    {
        if(vis[a]==0)
            dfs(adj,a,vis);
    }
}
int main()
{
    ll N,M;
    cin>>N>>M;
    vector<ll>vis(N,0);
    vector<vector<ll>>adj(N);
    for(ll i=1;i<=M;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    ll ans=0;
    for(ll i=0;i<N;i++)
    {
        if(vis[i]==0)
        {
            ct=0;
            dfs(adj,i,vis);
            ans=max(ans,ct);
        }
    }
    cout<<ans;
    return 0;
}

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

#define endl "\n"
#define long long long

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    long int n;
    cin>>n;

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

    long int val = 0;
    for(long int i = 0; i < n; i++)
        val ^= v[i];
    
    if(!val)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 1024
import Control.Monad (replicateM, forM_)
import Data.List (sort, group)

solve :: [[Int]] -> [Int] -> [[Int]] -> [[Int]]
solve acc [] xss = acc
solve acc (n:ns) [] = solve ([]:acc) ns []
solve acc (n:ns) (xs:xss) =
  if n == head xs
    then solve (xs:acc) ns xss
    else solve ([]:acc) ns (xs:xss)


main = do
  [n, m] <- fmap read <$> words <$> getLine :: IO [Int]
  xss <- fmap (fmap read) <$> fmap words <$> replicateM m getLine :: IO [[Int]]
  forM_ (fmap (show . length) . reverse . solve [] [1..n] . group . sort . concat $ xss) putStrLn


Measured memory_bytes: 1020
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
	int x,y;
	int cnt = 0;
	cin >> x >> y;

	if(x == y)
	{
		cnt = 0;
	}else if(x*(-1)==y){
		cnt = 1;
	}else{
		if(abs(x)<abs(y) && x < 0)
		{
			cnt++;
			x *= -1;
			while(x != abs(y))
			{
				x++;
				cnt++;
			}
			if(y<0)
			{
				cnt++;
			}
		}else if(abs(x)<abs(y) && x >= 0){
			while(x != abs(y))
			{
				x++;
				cnt++;
			}
			if(y<0)
			{
				cnt++;
			}
		}else if(abs(x)>abs(y) && x<0){
			while(abs(x) != abs(y))
			{
				cnt++;
				x++;
			}
			if(y > 0)
			{
				cnt++;
			}
		}else if(abs(x)>abs(y) && x>=0){
			cnt++;
			x*=-1;
			while(abs(x) != abs(y))
			{
				x++;
				cnt++;
			}
			if(y > 0)
			{
				cnt++;
			}
		}
	}

	cout << cnt << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

void YesNo(bool x) {
    cout << (x ? "Yes" : "No") << endl;
}

int main() {
    string s;
    cin >> s;
    int ret = 0;
    for (auto c:s)ret += c - '0';
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
import bisect
N = int(input())
a = list(map(int, input().split()))

b = a[:N]
c = a[-N:]
L = [0]*(N+1)
R = [0]*(N+1)

L[0] = sum(b)


heapq.heapify(b)

R[-1] = sum(c)
c = list(map(lambda x: -x, c))
heapq.heapify(c)

for i in range(N):
    k = a[i+N]
    x = heapq.heappop(b)
    if x < k:
        L[i+1] = L[i] + k - x
        heapq.heappush(b, k)
    else:
        L[i+1] = L[i]
        heapq.heappush(b, x)

for i in range(N-1, -1, -1):
    k = a[i+N]
    x = heapq.heappop(c)
    if -x > k:
        heapq.heappush(c, -k)
        R[i] = R[i+1] + x + k
    else:
        R[i] = R[i+1]
        heapq.heappush(c, x)
ans = -10**14
for i in range(N+1):
    ans = max(ans, L[i]-R[i])
#print(L, R)
print(ans)


Measured memory_bytes: 37212
b=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
for i in range(max(0,b[0]-100,b[1]-100,b[2]-100),min(100,b[0],b[1],b[2])+1):
  t1=set()
  t2=set()
  for j in range(3):
    t1.add(a2[j]-(b[j]-i))
    t2.add(a3[j]-(b[j]-i))
  if len(t1)==1 and len(t2)==1 and list(t1)[0]>=0 and list(t2)[0]>=0:
    print('Yes')
    break
else:
  print('No')

Measured memory_bytes: 3064
#include<stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include<cmath>
using namespace std;

const static int MAX = 3000000;
int x, y, z, k;
long A[MAX], B[MAX], C[MAX], D[MAX], E[MAX];

int main() {
    scanf("%d %d %d %d", &x, &y, &z, &k);

    for ( int i = 0; i < x; i++ ) {
        scanf("%ld", &A[i]);
    }
    
    for ( int i = 0; i < y; i++ ) {
        scanf("%ld", &B[i]);
    }
    
    for ( int i = 0; i < z; i++ ) {
        scanf("%ld", &C[i]);
    }
    
    for ( int i = 0; i < x; i++ ) {
        for ( int j = 0; j < y; j++ ) {
            D[y*i+j] = A[i] + B[j];
        }
    }

    sort(D, D+MAX, greater<long long>());

    for ( int i = 0; i < k; i++ ) {
        for ( int j = 0; j < z; j++ ) {
            E[z*i+j] = D[i] + C[j];
        }
    }

    sort(E, E+MAX, greater<long long>());

    for ( int i = 0; i < k; i++ ) {
        printf("%ld\n", E[i]);
    }
    
    return 0;
}



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

using namespace std;
typedef long long ll;

const int INF = 1e9;
int n, a[200010];

ll merge(int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1 + 1), R(n2 + 1);
    for (int i = 0; i < n1; i++)
        L[i] = a[left + i];
    for (int i = 0; i < n2; i++)
        R[i] = a[mid + i];
    L[n1] = R[n2] = INF;

    int i = 0, j = 0;
    ll cnt = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j])
            a[k] = L[i++];
        else {
            a[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

ll mergeSort(int left, int right) {
    ll v1, v2, v3;
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        v1 = mergeSort(left, mid);
        v2 = mergeSort(mid, right);
        v3 = merge(left, mid, right);
        return v1 + v2 + v3;
    } else
        return 0;
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    cout << mergeSort(0, n) << endl;

    return 0;
}


Measured memory_bytes: 4328
A, B, C, D, E, F = map(int, input().split())

memo = {}
memo.update(density=0, sugerwater=0, suger=0)
for a in range(F//(100*A) + 1):
    for b in range(F//(100*B) + 1):
        for c in range(E*(A*a + B*b)//C + 1):
            for d in range(E*(A*a + B*b)//D + 1):
                # print(100*(A*a + B*b) + C*c + D*d)
                if 100 * (A * a + B * b) + C * c + D * d <= F and C * c + D * d <= E * (A * a + B * b) and (100 * (A * a + B * b) + C * c + D * d) != 0:
                    dens_tmp = 100*(C*c + D*d)/(100*(A*a + B*b) + C*c + D*d)
                    if dens_tmp >= memo['density']:
                        memo.update(density=dens_tmp, sugerwater=100 *
                                    (A * a + B * b) + C * c + D * d, suger=C * c + D * d)

print(memo['sugerwater'], memo['suger'])

Measured memory_bytes: 44780
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	string s;
	cin >> s;
	int count = 0, res = 0;
	char now;
	for (int i = 0; i < s.size(); ++i)
	{
		if (count == 0)
		{
			now = s[i];
			++count;
		}
		else if (now == s[i])
		{
			++count;
		}
		else
		{
			++res;
			--count;
		}
	}
	cout << res * 2 << endl;
}



Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int x,y,z;
    cin >>x>>y>>z;
    
    if(x<=y&&y<=z){
        cout<<x<<" "<<y<<" "<<z<<endl;
    }
    else if(x<=z && z<=y){
        cout<<x<<" "<<z<<" "<<y<<endl;
    }
    else if(y<=x && x<=z){
        cout<<y<<" "<<x<<" "<<z<<endl;
    }
    else if(y<=z && z<=x){
        cout<<y<<" "<<z<<" "<<x<<endl;
    }
    else if(z<=x&& x<=y){
        cout<<z<<" "<<x<<" "<<y<<endl;
    }
    else if(z<=y&& y<=x){
        cout<<z<<" "<<y<<" "<<x<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3116
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	v := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		v[i], _ = strconv.Atoi(scanner.Text())
	}

	lvals := map[int]int{}
	for i := 0; i < n; i += 2 {
		lvals[v[i]] += 1
	}
	rvals := map[int]int{}
	for i := 1; i < n; i += 2 {
		rvals[v[i]] += 1
	}

	lmv, lmn := 0, 0
	for k, v := range lvals {
		if lmn < v {
			lmv = k
			lmn = v
		}
	}
	rmv, rmn := 0, 0
	for k, v := range rvals {
		if rmn < v {
			rmv = k
			rmn = v
		}
	}

	if lmv != rmv {
		fmt.Println(n - lmn - rmn)
		return
	}

	l2n := 0
	for k, v := range lvals {
		if k != lmv && l2n < v {
			l2n = v
		}
	}
	r2n := 0
	for k, v := range rvals {
		if k != rmv && r2n < v {
			r2n = v
		}
	}

	lr2 := lmn + r2n
	l2r := l2n + rmn

	if lr2 < l2r {
		fmt.Println(n - l2r)
	} else {
		fmt.Println(n - lr2)
	}
}


Measured memory_bytes: 6784
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
static const int NMAX = 10000;
#define INF (1 << 30)

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> adj[NMAX];

  for (int i = 0; i < n; i++) {
    int id, nn;
    cin >> id >> nn;
    for (int j = 0; j < nn; j++) {
      int to, weight;
      cin >> to >> weight;
      // use negative weights for priority_queue
      adj[id].push_back(make_pair(-weight, to));
    }
  }

  bool visited[n];
  int dist[n];
  for (int i = 0; i < n; i++) {
    visited[i] = false;
    dist[i] = -INF;
  }

  priority_queue<pair<int, int>> distQ;

  // add node 0
  for (int i = 0; i < adj[0].size(); i++) {
    distQ.push(adj[0][i]);
    int weight = adj[0][i].first;
    int id = adj[0][i].second;
    dist[id] = weight;
  }
  visited[0] = true;

  while (!distQ.empty()) {
    // find nearest node
    int minnode = distQ.top().second;
    distQ.pop();

    // add node
    visited[minnode] = true;

    // update dist
    for (int i = 0; i < adj[minnode].size(); i++) {
      int weight = adj[minnode][i].first;
      int id = adj[minnode][i].second;

      if (visited[id] == false) {
        int newWeight = dist[minnode] + weight;
        if (-newWeight < -dist[id]) {
          distQ.push(make_pair(newWeight, id));
          dist[id] = newWeight;
        }
      }
    }
  }

  dist[0] = 0;
  for (int i = 0; i < n; i++)
    cout << i << " " << -dist[i] << endl;
}

Measured memory_bytes: 7964
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	map<char, char>mp1, mp2;
	for (int i = 0;i < n;i++) {
		mp1[s[i]] = t[i];
	}
	for (int i = 0;i < n;i++) {
		mp2[t[i]] = s[i];
	}
	for (int i = 0;i < n;i++) {
		if (mp1[s[i]] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
		if (mp2[t[i]] != s[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

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

  int a = s.find("A");
  int z = s.rfind("Z");
  
  printf("%d\n",z - a + 1);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	string s;
	cin >> s;
	string::size_type pos = s.find("AC");
	if (pos == string::npos) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 3608
class Sum_Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def get_sum(self, i=None):
        if i is None:
            i = self.size
        m = 0  # -INF
        while i > 0:
            m += self.tree[i]
            i -= i & -i
        return m

    def update(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
X = [0]*N
X[0] = A[0]-K
for i in range(1,N):
    X[i] = X[i-1] + A[i] - K

Y = sorted(set(X))
dic = {y:i+1 for i,y in enumerate(Y)}

BIT = Sum_Bit(N)
ans = 0
for i in range(N):
    ans += BIT.get_sum(dic[X[i]])
    if X[i] >= 0: ans += 1
    BIT.update(dic[X[i]], 1)
    
print(ans)

Measured memory_bytes: 159316
D, N = [int(i) for i in input().split()]

list_ = []
for k in range(1, 101):
    str_ = str(k) + "00"*D
    int_ = int(str_)
    list_.append(int_)

if N == 100 and D == 0:
    print(101)
elif N == 100 and D == 1:
    print(10100)
elif N == 100 and D == 2:
    print(1010000)
else:
    print(list_[N-1])

Measured memory_bytes: 3316
//============================================================================
// Name        : e.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	string s,t;cin>>s>>t;
	vector<vector<int>> a(26);
	for(int i=0;i<s.size();i++){
		a[s[i]-'a'].push_back(i);
	}
	long long ans=-1;
	for(int i=0;i<s.size();i++){
		if(s[i]==t[0]){
			ans=i;
			break;
		}
	}
//	cout<<s<<t<<ans<<endl;
	if(ans==-1){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=1;i<t.size();i++){
		vector<int> v;
//		v=a[t[i]-'a'];
		if(a[t[i]-'a'].size()==0){
			cout<<-1<<endl;
			return 0;
		}
//		for(int j=0;j<v.size();j++){
//			cout<<v[j]<<' ';
//		}cout<<endl;
		int idx=upper_bound(a[t[i]-'a'].begin(),a[t[i]-'a'].end(),ans%s.size())-a[t[i]-'a'].begin();
		if(idx==a[t[i]-'a'].size()){
			ans=((ans)/s.size()+1)*s.size()+a[t[i]-'a'][0];
		}else{
			ans+=a[t[i]-'a'][idx]-ans%s.size();
		}
//		cout<<idx<<' '<<ans<<endl;
	}
	cout<<ans+1<<endl;
	return 0;
}

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

void testCase(){
    int n;
    cin>>n;
    string s;
    map<string, int> m;
    for(int i = 0; i < n; i++){
        cin>>s;
        m[s]++;
    }
    cout<<m.size()<<endl;
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



Measured memory_bytes: 19192
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

const int maxn = 100*1000+5;

int n, m, q, a[maxn], place[maxn], next[maxn];
std::vector<int> l[maxn];
bool seen[maxn];

int main() {
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 0; i < q; i++) scanf("%d", a+i);
    for (int i = q-1; i >= 0; i--) {
        int v = a[i];
        if (!seen[v]) {
            seen[v] = true;
            place[v] = sz(l[0]);
            l[next[v]++].pb(v);
        } else if (next[v] < n) {
            if (place[v] == sz(l[next[v]])) {
                l[next[v]++].pb(v);
            }
        }
    }
    std::fill(seen, seen+m+1, false);
    for (int &i : l[n-1]) seen[i] = true;
    for (int j = 1; j <= m; j++) if (!seen[j]) l[n-1].pb(j);
    for (int i = n-2; i >= 0; i--) {
        for (int k = 0; k < sz(l[i]); k++) if (l[i][k] != l[n-1][k]) {
            printf("No\n");
            exit(0);
        }
    }
    printf("Yes\n");
}


Measured memory_bytes: 6908
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=57;
const int dlu=5;
ll mod;

int n=50;

ll pot[nax][nax];

ll wyn;

int jeszkol[nax][nax];

void ff()
{
	fflush(stdout);
}

int pyt(int a, int b, int x, int y)
{
	printf("? %d %d %d %d\n", a, x, b, y);
	ff();
	int v;
	scanf("%d", &v);
	return v;
}

int los(int a, int b)
{
	return (rand()%(b-a+1))+a;
}

void szuk(int a, int b, int x, int y, int w)
{
	if (!w)
		return;
	if ((a/dlu)==(b/dlu) && !jeszkol[x][a/dlu])
	{
		szuk(a, b, x+1, y, w);
		return;
	}
	if ((a/dlu)==(b/dlu) && !jeszkol[y][a/dlu])
	{
		szuk(a, b, x, y-1, w);
		return;
	}
	if (w==(b-a+1)*(y-x+1))
	{
		for (int i=a; i<=b; i++)
		{
			for (int j=x; j<=y; j++)
			{
				wyn+=pot[i][j];
				jeszkol[j][i/dlu]--;
			}
		}
		return;
	}
	//~ if (x==y || (a!=b && (rand()&1)))
	if (a!=b)
	{
		int s=(a+b)>>1;
		//~ int s=los(a, b-1);
		int p=pyt(a, s, x, y);
		if (rand()&1)
		{
			szuk(a, s, x, y, p);
			szuk(s+1, b, x, y, w-p);
		}
		else
		{
			szuk(s+1, b, x, y, w-p);
			szuk(a, s, x, y, p);
		}
	}
	else
	{
		int s=(x+y)>>1;
		//~ int s=los(x, y-1);
		int p=pyt(a, b, x, s);
		if (rand()&1)
		{
			szuk(a, b, x, s, p);
			szuk(a, b, s+1, y, w-p);
		}
		else
		{
			szuk(a, b, s+1, y, w-p);
			szuk(a, b, x, s, p);
		}
	}
}

int main()
{
	int szit;
	scanf("%d%d%d%lld", &szit, &szit, &szit, &mod);
	ll trz=1;
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			pot[i][j]=trz;
			trz=(trz*2)%mod;
		}
	}
	for (int i=0; i<n; i++)
		for (int j=0; j<nax; j++)
			if (dlu*j<n)
				jeszkol[i][j]=pyt(dlu*j, min(dlu*j+dlu-1, n-1), i, i);
	szuk(0, n-1, 0, n-1, 250);
	printf("! %lld\n", wyn%mod);
	ff();
	return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      int n;
      cin >> n;
      if(n==1) cout << "Hello World" << endl;
      else{
        int a, b;
        cin >> a >> b;
        cout << a+b << endl;
      }
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    k--;
    int v = w - 1;

    ll p[8] = { 1 }, q[8], r[8];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            q[j] = 0;
        }
        for (int k = 0; k < 1 << v; k++) {
            int b = 1;
            for (int j = 0; j < v - 1; j++) {
                if (!(~(k >> j) & 3)) b = 0;
            }
            if (b) {
                for (int j = 0; j < w; j++) {
                    r[j] = p[j];
                }
                for (int j = 0; j < v; j++) {
                    if (k >> j & 1) swap(r[j], r[j + 1]);
                }
                for (int j = 0; j < w; j++) {
                    q[j] += r[j];
                }
            }
        }
        for (int j = 0; j < w; j++) {
            p[j] = q[j] % P;
        }
    }

    cout << p[k] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a=="----")
	    cout<<"-4";
	else if(a=="---+"||a=="--+-"||a=="-+--"||a=="+---")
	    cout<<"-2";
	else if(a=="--++"||a=="-+-+"||a=="+--+"||a=="-++-"||a=="+-+-"||a=="++--")
	    cout<<"0";
	else if(a=="+++-"||a=="++-+"||a=="+-++"||a=="-+++")
	    cout<<"2";
	else if(a=="++++")
	    cout<<"4";
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(x) x.begin(),x.end()
const ll INF = (1LL<<60);
const int MOD = 1000000007;


deque<int> Push(vector<int> &v){
    deque<int> res;
    int n = v.size();
    rep(i,n){
        if(i % 2) res.push_back(v[i]);
        else res.push_front(v[i]);
    }
    if(n % 2 == 0) reverse(all(res));
    return res;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    deque<int> ans = Push(a);
    for(auto it : ans) cout << it << " ";
    cout << endl;
}

Measured memory_bytes: 4712
#include<bits/stdc++.h>
using namespace std;
int dp[1000000];
int ans(vector<int> &v, int n, int i)
{
    if(i==0)
        return 0;
    if(i==1)
        return abs(v[1]-v[0]);
    if(dp[i]!=-1)
        return dp[i];
    int o=abs(v[i]-v[i-1]);
    int t=abs(v[i]-v[i-2]);
    return dp[i]=min(ans(v, n, i-1)+o, ans(v, n, i-2)+t);
}
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
    }
    for(int i=0; i<1000000; i++)
        dp[i]=-1;
    int a=ans(v, n, n-1);
    cout<<a;
}

Measured memory_bytes: 7680
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for(ll i=0;i<(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n;cin>>n;
    V<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll q;cin>>q;
    while(q--){
        int c;cin>>c;
        int l,r;cin>>l>>r;
        if(c==0){
            ll ans=INF;
            for(ll i=l;i<r;i++){
                chmin(ans,a[i]);
            }
            cout<<ans<<endl;
        }
        else{
            ll ans=-INF;
            for(ll i=l;i<r;i++){
                chmax(ans,a[i]);
            }
            cout<<ans<<endl;
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int r;
  cin >> r;
  cout << 3*r*r << endl;
  return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
 
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int temp;
    temp = x;
    x = y;
    y = temp;
    temp = x;
    x = z;
    z = temp;
    cout << x << " " << y << " " << z << endl;

    return 0;
}

Measured memory_bytes: 3628