akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
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;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DCaracalVsMonster {
public:
    lint dfs(lint h){
        if(h==1) return 1;
        return 2 * dfs(h/2) + 1;
    }

    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        lint H;
        in>>H;
        out<<dfs(H)<<'\n';
    }
};


int main() {
	DCaracalVsMonster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3664
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 10e-8;

struct IC{
	int fare;
	int dist;
};

int main(){
	int dpt,arv;

	struct IC ic[] = {
		300,6,
		500,13,
		600,18,
		700,23,
		1350,43,
		1650,58,

		350,7,
		450,12,
		600,17,
		1150,37,
		1500,52,

		250,5,
		400,10,
		1000,30,
		1350,45,

		250,5,
		850,25,
		1300,40,

		600,20,
		1150,35,

		500,15,
	};

	while(~scanf("%d",&dpt)){
		if(dpt==0) break;
		
		int hDpt,mDpt;
		scanf("%d %d",&hDpt,&mDpt);
		scanf("%d",&arv);
		int hArv,mArv;
		scanf("%d %d",&hArv,&mArv);

		int DptT = hDpt*60+mDpt;
		int ArvT = hArv*60+mArv;


		int idx=0;
		int fare=0,dist=0;
		for(int i=1;i<=7;i++){
			for(int j=i+1;j<=7;j++){
				if(i==dpt && j==arv){
					fare = ic[idx].fare;
					dist = ic[idx].dist;
					goto found;
				}
				idx++;
			}
		}

found:;

		if(((17*60+30 <= DptT && DptT <= 19*60+30)
			|| (17*60+30 <= ArvT && ArvT <= 19*60+30))
			&& dist <= 40){
				fare /=2;
		}

		int tmp = fare / 50;
		if(fare % 50) fare = 50 * (tmp+1);

		printf("%d\n",fare);
	}
}

Measured memory_bytes: 3116
using System;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[] S = new bool[13] { false, false, false, false, false, false, false, false, false, false, false, false, false};
            bool[] H = new bool[13] { false, false, false, false, false, false, false, false, false, false, false, false, false};
            bool[] C = new bool[13] { false, false, false, false, false, false, false, false, false, false, false, false, false};
            bool[] D = new bool[13] { false, false, false, false, false, false, false, false, false, false, false, false, false};
            int n = int.Parse(Console.ReadLine());
            for (int m = 0; m < n; m++)
            {
                string[] str = Console.ReadLine().Split(' ');
                if (str[0] == "S")
                {
                    S[int.Parse(str[1]) - 1] = true;
                }
                else if (str[0] == "H")
                {
                    H[int.Parse(str[1]) - 1] = true;
                }
                else if (str[0] == "C")
                {
                    C[int.Parse(str[1]) - 1] = true;
                }
                else if (str[0] == "D")
                {
                    D[int.Parse(str[1]) - 1] = true;
                }
            }
            for (int m = 0; m < 13; m++)
            {
                if (S[m] == false)
                {
                    Console.WriteLine("S " + (m + 1));
                }
            }
            for (int m = 0; m < 13; m++)
            {
                if (H[m] == false)
                {
                    Console.WriteLine("H " + (m + 1));
                }
            }
            for (int m = 0; m < 13; m++)
            {
                if (C[m] == false)
                {
                    Console.WriteLine("C " + (m + 1));
                }
            }
            for (int m = 0; m < 13; m++)
            {
                if (D[m] == false)
                {
                    Console.WriteLine("D " + (m+1));
                }
            }
        }
    }
}

Measured memory_bytes: 19924
s = list(input())
even_s = s[0::2]
odd_s = s[1::2]
cnt = 0
for i in range(len(even_s)):
    if even_s[i] != '0':
        cnt += 1

for i in range(len(odd_s)):
    if odd_s[i] != '1':
        cnt += 1

print(min(len(s)-cnt, cnt))

Measured memory_bytes: 4652
r=j=x=1
M=10**9+7
`sed 1d`.split.map{x=$*[k=_1.to_i]||x+1
$*[k]=$.+=1}.map{p (-j+r=r*$.%M*s=_1.pow(M-2,M))%M
$.-=1
j=j*s%M*x-=1}

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

int main()
{
	int n,m,a,b,c,d,x1,x2,y1,y2;
	char ch;
	cin >> n >> m;
	vector< vector<int> > road(n+1,vector<int>(n+1,100001));
	for (int i = 0; i < m; i++) {
		cin >> a >> ch >> b >> ch >> c >> ch >> d;
		road[a][b] = c;
		road[b][a] = d;
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (road[i][k] != 100001 && road[k][j] != 100001)
					if(road[i][j] > road[i][k] + road[k][j]) road[i][j] = road[i][k] + road[k][j];
			}
		}
	}
	cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;
	cout << y1 - y2 - road[x1][x2] - road[x2][x1] << endl;
	return 0;
}

Measured memory_bytes: 1212
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
a,b,c = gets.chomp.split.map(&:to_i)

if (a+b==c) || (a==b+c) || (a+c==b)
  puts 'Yes'
else
  puts 'No'
end



Measured memory_bytes: 2428
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

int main() {
  string s;cin >> s;
  if(s=="SUN")cout << 7;
  if(s=="MON")cout << 6;
  if(s=="TUE")cout << 5;
  if(s=="WED")cout << 4;
  if(s=="THU")cout << 3;
  if(s=="FRI")cout << 2;
  if(s=="SAT")cout << 1;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int n,m;
int ans=0;

void solve(){
  int g[3]={0};
  int check=0,nex=1,nan=2;
  bool start=true;
  while(m/2 >= n){
    // bool odd=false;
    //if(m%2==1) odd=true;
    if(m%4==0){
      int f=nan;
      nan=check;
      check=f;
    }
    if(m%4==1){
      int f=nan;
      nan=nex;
      nex=check;
      check=f;
    }
    if(m%4==2){
      int a,b,c=check;
      a=min(nex,nan);
      b=max(nex,nan);
      check=a;
      nex=b;
      nan=c;
    }
    if(m%4==3){
      int a,b,c=nex;
      a=min(check,nan);
      b=max(check,nan);
      check=a;
      nex=b;
      nan=c;
    }
    m/=2;
    
  }
  if((m-n)%2) ans^=nex;
  else ans^=check;
}


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int k;
  cin>>k;
  rep(i,k){
    //cout<<1<<endl;
    cin>>n>>m;
    if(n==0 && m==0){cout<<endl;return 0;}
    solve();
  }
  if(ans) cout<<"mo3tthi"<<endl;
  else cout<<"tubuann"<<endl;
  return 0;
}



Measured memory_bytes: 3216
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll n;
    cin>>n;
    ll f[110][12];
    ll p[110][13];
    rep(i,n){
        rep(j,10){
            cin>>f[i][j];
        }
    }
    rep(i,n){
        rep(j,11){
            cin>>p[i][j];
        }
    }
    ll ans=-LLINF;
    rep2(bit,1,(1<<10)){
        ll sum=0;
        rep(i,n){
            ll cnt=0;
            rep(j,10){
                if(f[i][j]==1&&(bit&(1<<j))){
                    cnt++;
                }
            }
            sum+=p[i][cnt];
        }
        chmax(ans,sum);
    }
    cout<<ans<<endl;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int t[1000100]={0};
	int n;
	cin>>n;
	rep(i,n){
		int a;cin>>a;t[a]++;
	}
	int out=0;
	rep(i,1000100)if(t[i]){
		if(t[i]==1)out++;
		for(int j=i*2;j<1000100;j+=i)t[j]=0;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 11420
#include<bits/stdc++.h>
#define M 100005
using namespace std;
int n;
multiset<int>Q;
multiset<int>::iterator it;
int main() {
	int ans=0;
	scanf("%d",&n);
	for(int x,i=1; i<=n; i++) {
		scanf("%d",&x);
		it=Q.upper_bound(-x);
		if(it!=Q.end())Q.erase(it);
		else ans++;
		Q.insert(-x);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64

signed main() {
  string s;cin>>s;
  int n=s.size();

  vector<int> memo(n,0);
  
  bool hasL=false;
  int cnt=0,odd=0,even=0,bias,lid,rid;
  for(int i=0;i<=n;++i){
    if (i==n || hasL && s[i]=='R'){
      if ((cnt+bias)%2==0) {
        memo[rid] = even;
        memo[lid] = odd;
      }else{
        memo[rid] = odd;
        memo[lid] = even;
      }
     
      odd=even=cnt=0;
      hasL=false;
    }
    if (!hasL && s[i]=='L'){
      bias = cnt;
      lid=i-1;
      rid=i;
      hasL=true;
    }
    if (cnt%2==0)
      ++odd;
    else
      ++even;
    
    ++cnt;
  }

  for(int i=0;i<n;++i){
    if (i>0) cout<<" ";
    cout<<memo[i];
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 1408
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  ll x;cin>>x;
  ll dp[10000],i=0;
  dp[0]=100;
  while(dp[i]<x){
    dp[i+1]=dp[i]+dp[i]*0.01;
    //cout<<dp[i+1]<<endl;
    i++;
  }
  cout<<i<<endl;
}


Measured memory_bytes: 3640
/**
 *   created: 13 July 2019  09:12:11
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================


int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		cout<<3*n*n;
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        a[i] = 0;
    }
    for(int i=0;i<n-1;i++){
        int b;
        cin >> b;
        b--;
        a[b]++;
    }
    for(int i=0;i<n;i++){
        cout << a[i] << endl;
    }
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    bool tmp = true;

    for (int i = 0; i < 3;i++){
        if(S[i] == S[i+1])
            tmp = false;
    }
    string ans;
    ans = "Good";
    if(!tmp)
        ans = "Bad";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define NO  puts("No"),exit(0)
using namespace std;

const int N=100010;
int n,a[4][N],b[N],t[N],rev[2],swp[2];

void modify(int x){for (; x<=n; t[x]^=1,x+=x&-x);}
int ask(int x){int s=0;  for (; x; s^=t[x],x-=x&-x);  return s;}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=3; i++)
		for (int j=1; j<=n; j++)
			scanf("%d",&a[i][j]);
	for (int i=1; i<=n; i++)
		{
			if (((a[1][i]-1)/3!=(a[2][i]-1)/3)||((a[1][i]-1)/3!=(a[3][i]-1)/3))  NO;
			if (a[2][i]%3!=2)  NO;
			if (a[2][i]/3%2==i%2)  NO;
			if (a[1][i]>a[3][i])  rev[i&1]^=1;
			b[i]=a[2][i]/3+1;
		}
	for (int i=n-1+(n&1); i>0; i-=2)  swp[1]^=ask(b[i]),modify(b[i]);
	memset(t,0,sizeof(t));
	for (int i=n-(n&1); i>0; i-=2)  swp[0]^=ask(b[i]),modify(b[i]);
	if ((rev[0]!=swp[1])||(rev[1]!=swp[0]))  NO;
	puts("Yes");
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
 
int main(){
  ll N,K;
  cin>>N>>K;
  VL A(N);
  rep(i,N) cin>>A[i];
  if(K==0){
    ll sum=0;
    rep(i,N) sum+=A[i];
    cout<<sum<<endl;
    return 0;
  }
  VL X(40);
  rep(i,40) X[i]=(K>>i)&1;
  ll keta;
  rep(i,40){
    if(X[39-i]){
      keta=40-i;
      break;
    }
  }
  VVL Y(N,VL(40));
  rep(i,N) rep(j,40) Y[i][j]=(A[i]>>j)&1;
  int F=1;
  VL ans(40);
  rep(i,40){
    int cnt=0;
    rep(j,N) cnt+=Y[j][39-i];
    if(cnt*2>N){
      ans[39-i]=0;
      if(X[39-i]) F=0;
    }else if(cnt*2<N){
      if(F) ans[39-i]=X[39-i];
      else ans[39-i]=1;
    }else{
      if(F){
        if(X[39-i]){
          ans[39-i]=0;
          F=0;
        }else ans[39-i]=0;
      }else ans[39-i]=0;
    }
  }
  ll Z=0;
  rep(i,40) Z+=(1ll<<i)*ans[i];
  ll B=0;
  rep(i,N) B+=Z^A[i];
  cout<<B<<endl;
}

Measured memory_bytes: 36224
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/arc091/tasks/arc091_a
# 角に存在するのは4回→表になる
# 端にあるのは6回→表になる
# 内側に存在するカードは9回フリップする→全部裏になる
# よって答えは基本的にN-2 * M-2 ただし(N,M>=2)
# コーナーケース N and M ==1のとき→1
# N == 1のとき M-2が答え


N, M = read_ints()
N, M = (N, M) if N < M else (M, N)

if N == 1 and M == 1:
    print(1)
    exit()
if N == 1:
    print(M - 2)
    exit()
print((N - 2) * (M - 2))


Measured memory_bytes: 38256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	fast();
	ll s,w;
	cin>>s>>w;
	cout<<(w>=s?"unsafe":"safe");
}

Measured memory_bytes: 3596
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, m = 0, x = 0, y = 0;
	cin >> n >> m;
	vector<int> v[n + 1];
	deque<int> dq;
	vector<bool> vis(n + 1, false);
	for (int i = 0; i < m; ++i)
	{
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	dq.pb(1); vis[1] = true;
	while (true)
	{
		bool flag = false;
		int f = dq.front();
		for (auto i : v[f])
			if (!vis[i])
			{
				dq.push_front(i); vis[i] = true; flag = true; break;
			}
		int b = dq.back();
		for (auto i : v[b])
			if (!vis[i])
			{
				dq.pb(i); vis[i] = true; flag = true; break;
			}
		if (!flag)
			break;
	}
	cout << (int)dq.size() << endl;
	for (auto i : dq)
		cout << i << " ";
}

Measured memory_bytes: 9476
//aea ctmr https://codeforces.com/contest/1271/submission/66946806
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
    
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define PI 3.14159265358979323846
 
typedef long double ld;
typedef long long ll;
const ll N = 105000;
const ll mod = 1e9 + 7;
using namespace std;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
 
vector <pair <int, int>> xd;

int main(){

    int n;
    cin >> n;
    int u = 1;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;

        if(a == u) u++;
    }

    if(u == 1) {cout << -1 << endl; return 0;}
    u--;
    cout << n - u << endl; 
}

Measured memory_bytes: 380
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  x=pI(readline())
  if x>=2000
    println(1)
  elseif x%100<=fld(x,100)*5
    println(1)
  else
    println(0)
  end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 109600
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] playerA = ReadLine().ToArray();
            char[] playerB = ReadLine().ToArray();
            char[] playerC = ReadLine().ToArray();

            WriteLine(Test(playerA, playerB, playerC));
        }
        static string Test(char[] playerA, char[] playerB, char[] playerC)
        {
            int cntA = 0;
            int cntB = 0;
            int cntC = 0;

            char parent = 'a';

            while (true)
            {
                if (parent == 'a')
                {
                    if (playerA.Length == cntA)
                        return parent.ToString().ToUpper();

                    parent = playerA[cntA];
                    cntA++;
                }
                else if (parent == 'b')
                {
                    if (playerB.Length == cntB)
                        return parent.ToString().ToUpper();

                    parent = playerB[cntB];
                    cntB++;
                }
                else
                {
                    if (playerC.Length == cntC)
                        return parent.ToString().ToUpper();

                    parent = playerC[cntC];
                    cntC++;
                }
            }
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;

int dignum(ll n){
int res = 0;
while(n > 0){
  res ++;
  n /= 10;
}
return res;
}

int main (){
    ll n;   cin >> n;
    ll a,b;
    ll mini = INF;
     ll ans;
     vector<ll>j;

    for(int i=1;i<=pow(n,0.5);i++){

        if(n % i == 0){
            a = i;
            b = n/i;
            ll f;
            f = max( dignum(a) , dignum(b));
            if(f < mini){
                mini = f;
            }
            
        }
    }
    

    cout << mini << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n,k;
    cin >> n >> k;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    rep(i,n-k){
        if(a.at(k+i) > a.at(i)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s == "SUN")
    {
        cout << 7 << endl;
    }
    else if (s == "MON")
    {
        cout << 6 << endl;
    }
    else if (s == "TUE")
    {
        cout << 5 << endl;
    }
    else if (s == "WED")
    {
        cout << 4 << endl;
    }
    else if (s == "THU")
    {
        cout << 3 << endl;
    }
    else if (s == "FRI")
    {
        cout << 2 << endl;
    }
    else if (s == "SAT")
    {
        cout << 1 << endl;
    }
    else
    {
        cout << "ERROR" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

ll find(ll a[],int n)
{
  ll c[n+1][n+1];
  ll sums[n+1][n+1];
  for(int i = 1; i<=n; i++)
  {
    ll s = 0;
    for(int j = i; j<=n; j++)
    {
      s+=a[j];
      sums[i][j] = s;
    }
  }

  for(int s = 0; s<n; s++)
  {
    for(int i = 1,j = i+s; i<=n && j<=n; i++,j++)
    {
        if(i==j)
            c[i][j] = 0;
        else if(j==i+1)
            c[i][j] = sums[i][j];
        else
        {
            c[i][j] = INT64_MAX;
            for(int k = i; k<j; k++)
            {
                ll temp = c[i][k] + c[k+1][j] + sums[i][k]+sums[k+1][j];
                c[i][j] = min(c[i][j],temp);
            }
        }
    }
  }
  return c[1][n];
}

int main()
{
  int n;
  cin>>n;
  ll a[n+1];
  for(int i = 1; i<=n; i++)
    cin>>a[i];
  cout<<find(a,n);
  return 0;
}


Measured memory_bytes: 6092
#include <bits/stdc++.h>
#define ULL unsigned long long
#define LL long long
#define LD long double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define loop(i,a,b) for(int i=a;i<=b;++i)
#define pool(i,a,b) for(int i=a;i>=b;--i)
#define int long long
using namespace std; const int N = 300000 + 5, N2 = 50000 + 5, LOG = 9 + 1, INF = 1e9;

LL f(LL a, LL b, LL x){ a+=(x-a%x)%x; if(b<a) return 0; return (b-a+1+x-1)/x; }

signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	LL a,b,c,d; cin>>a>>b>>c>>d;
	cout<<b-a+1 - (f(a,b,c)+f(a,b,d)-f(a,b,c*d/__gcd(c,d)))<<'\n';
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

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

        System.out.println(solve(a));

        sc.close();
    }

    static long solve(int[] a) {
        long total = Arrays.stream(a).asLongStream().sum();

        long result = Long.MAX_VALUE;
        long leftSum = 0;
        for (int i = 0; i < a.length - 1; ++i) {
            leftSum += a[i];
            long rightSum = total - leftSum;

            result = Math.min(result, Math.abs(leftSum - rightSum));
        }

        return result;
    }
}

Measured memory_bytes: 65052
#include<stdio.h>
#include<stdlib.h>
int comp(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}
int main(void) {
	int n, s[110];
	int ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &s[i]);
		ans = ans + s[i];
	}

	if (ans % 10 == 0)
	{
		qsort(s, n, sizeof(int), comp);
		for (int i = 0; i < n; i++)
		{
			if (s[i] % 10 != 0)
			{
				ans = ans - s[i];
				break;
			}
		}
		if (ans % 10 == 0)
		{
			ans = 0;
		}
	}

	printf("%d", ans);
	return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int ans,c;
  	ans = t.size();
  	c = t.size();
    for(int i=0; i<=s.size()-t.size();i++){
        for(int j=0; j<t.size();j++){
            if(s[i+j]==t[j]){
                c--;
            }
        }
        if(ans>c){
            ans = c;
        }
        c = t.size();
    }
    cout << ans;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_117
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int[] xs = ReadInts();
            int n = nm[0];
            int m = nm[1];
            if (n >= m)
            {
                Console.WriteLine(0);
                return;
            }
            Array.Sort(xs);
            int delta = xs[m - 1] - xs[0];
            int[] deltas = new int[m - 1];
            for(int i = 0; i+1 < m; i++)
            {
                deltas[i] = xs[i + 1] - xs[i];
            }
            Array.Sort(deltas);
            Array.Reverse(deltas);
            for(int i = 0; i < n - 1; i++)
            {
                delta -= deltas[i];
            }
            Console.WriteLine(delta);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 19552
#include <iostream>
#include <cstdio>

using namespace std;

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


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[110];
int main()
{
	scanf("%s", s);
	int len = strlen(s), ans = 0;
	for (int i = 0; i < len; i++) {
		if (len - 1 - i <= i) break;
		if (s[i] != s[len - 1 - i]) ans++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int N = saori.saori_hayami();
		int[][] abc = new int[N][3];
		for(int i = 0;i < N;i++){
			for(int j = 0;j < 3;j++){
				abc[i][j] = saori.saori_hayami();
			}
		}
		int[][] dp = new int[N+1][3];
		for(int i = 0;i < 3;i++){
			dp[0][i] = abc[0][i];
			//System.out.println(abc[0][i]);
		}
		for(int i = 1;i < N;i++){
			for(int j = 0;j < 3;j++){
				for(int k = 0;k < 3;k++){
					if(j == k)continue;
					//System.out.println(dp[i-1][j] + abc[i][k]);
					dp[i][k] = Math.max(dp[i-1][j] + abc[i][k], dp[i][k]);
				}
			}
		}
		int ans = 0;
		for(int i = 0;i < 3;i++){
			ans = Math.max(ans, dp[N-1][i]);
		}

		System.out.println(ans);
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 30172
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  list($s1) = explode(" ", trim(fgets(STDIN)));
  list($s2) = explode(" ", trim(fgets(STDIN)));

  $mod = 1000000007;
  $ans = 1;
  if($s1[0] != $s2[0]){
    $ans = 6;
    $init = 2;
  }else{
    $ans = 3;
    $init = 1;
  }
  for($i=$init; $i<$n; $i++){
    if($s1[$i] != $s2[$i]){
      if($s1[$i-1] == $s2[$i-1]){
        $ans = $ans * 2 % $mod;
      }else{
        $ans = $ans * 3 % $mod;
      }
      $i++;
    }else{
      if($s1[$i-1] == $s2[$i-1]){
        $ans = $ans * 2 % $mod;
      }
    }
  }

  echo $ans;


Measured memory_bytes: 16080
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N,W;
  cin>>N>>W;
  int NUM = 4;
  vector<vector<int> > data(NUM);
  int FW,FV;
  cin>>FW>>FV;
  data[0].push_back(FV);
  for (int i = 0; i < N-1; i++)
  {
    int A,B;
    cin>>A>>B;
    data[A - FW].push_back(B);
  }
  for (int i = 0; i < NUM; i++)
  {
    data[i].push_back(INF);
    sort(data[i].begin(),data[i].end(),std::greater<int>());
    data[i][0] = 0;
    for (int j = 0; j < data[i].size()-1; j++)
    {
      data[i][j+1] = data[i][j] +data[i][j+1];
    }
    // DEBUG(data[i]);
    
  }
  int ANS = 0;
  for (int i = 0; i <= N; i++)
  {
    if(i*FW > W || i >= data[0].size()) continue;
    for (int j = 0; j <= N; j++)
    {
      if(i*FW + j*(FW+1) > W || j >= data[1].size()) continue;
      for (int k = 0; k <= N; k++)
      {
        if(i*FW + j*(FW+1) + k*(FW+2) > W || k >= data[2].size()) continue;
        for (int l = 0; l < N; l++)
        {
          if(i*FW + j*(FW+1) + k*(FW+2) + l*(FW+3)> W || l >= data[3].size()) continue;
          if(chmax(ANS,data[0][i]+data[1][j]+data[2][k]+data[3][l]))
          {
            // cout<<data[0][i]<<" "<<data[1][j]<<" "<<data[2][k]<<" "<<data[3][l]<<endl;
          }
        }
        
      }
    }
  }
  cout<<ANS<<endl;
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<< #X <<": "<<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};

const int INF=100000000;
int mode=0;

int main(){
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		if(ans*2<ans+k){
			ans*=2;
		}
		else{
			ans+=k;
		}
		DEB(ans)END
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <istream>
#include <set>
#include <queue>
#define rep0(i,n) for (long long int i = 0; i <= (n); ++i)
#define rep1(i,n) for (long long int i = 1; i <= (n); ++i)
#define REP(a,b) for (long long int i = a; i <= (b); ++i) 
#define ps push_back 
using namespace std;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll k, n;
	ll ans = 37203685475807;
	cin >> n >> k;
	vector<ll>a(n);
	REP(0, n - 1)cin >> a[i];
	sort(a.begin(), a.end());
	REP(0, n - k) {
		ans = min(ans, a[i + k - 1] - a[i]);
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=1005,inf=5005;
int dp[2][N],val[N],dp2[N][inf];
vi v[N];
bool pos;
int fun(int ind,int sz,int col,int curr,int done=0)
{
  if(done>val[curr]) return inf;
  if(ind==sz) { pos=true; return 0;}
  if(dp2[ind][done]!=-1) return dp2[ind][done];
  int ans=inf,v1=v[curr][ind];
  //take this of same col
  ans=dp[1-col][v1]+fun(ind+1,sz,col,curr,done+val[v1]);
  //take this of other col
  ans=min(ans,val[v1]+fun(ind+1,sz,col,curr,done+dp[col][v1]));
  return dp2[ind][done]=ans;
}
void dfs(int u)
{
  for(int v1:v[u])
    dfs(v1);
  pos=false;
  rep(k,0,2)//assign colour i to this node, and minimise other colour
    {
      rep(i,0,sz(v[u])) rep(j,0,inf) dp2[i][j]=-1;
      dp[1-k][u]=fun(0,sz(v[u]),k,u);
    }
  if(!pos)
    {
      cout<<"IMPOSSIBLE"<<endl;
      exit(0);
    }
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,x;
  cin>>n;
  rep(i,2,n+1)
    {
      cin>>x;
      v[x].pb(i);
    }
  rep(i,1,n+1) cin>>val[i];
  dfs(1);
  cout<<"POSSIBLE"<<endl;
  return 0 ;
}


Measured memory_bytes: 19968
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")
 
#include <bits/stdc++.h>
using namespace std;
 
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ost tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL),cout.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp(x)                    __builtin_popcount(x)
#define    endl                     "\n"
int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}
vector<int>v[200005];
int a[200005],ans[200005];
bool vis[200005];
set<int>s;
void dfs(int r )
{
    vis[r]=true;
    int cc=-1,ff=-1;
    set<int>::iterator it;
    if (s.insert(a[r]).second) 
    { 
        it= s.find(a[r]); 
        it++;
        if (it!=s.end())
        {
            ff=*it;
             s.erase(it); 
            
        }
        cc=a[r];
    }
   ans[r]=sz(s);
    for(auto i : v[r])
        if(!vis[i])
        {
            dfs(i);
        }
    if(cc!=-1)
    {
        s.erase(s.find(cc));
        if(ff!=-1)
            s.insert(ff);
    }
}
int32_t main()
{
    speed upp
    int n,x,y;
    cin>>n;
    f(i,1,n)
        cin>>a[i];
    f(i,1,n-1)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    
    dfs(1);
    f(i,1,n)
    {
        cout<<ans[i];
        cout<<endl;
    }
}


Measured memory_bytes: 29792
#include <iostream>
using namespace std;
int main() {
	int a[6][20] = {};
	int n, b, d, e;
	char c;
	cin >> n;
	for (b = 1; b <= n; b++) {
		cin >> c >> d;
		if (c == 'S') {
			a[1][d] = 1;
		}
		if (c == 'H') {
			a[2][d] = 1;
		}
		if (c == 'C') {
			a[3][d] = 1;
		}
		if (c == 'D') {
			a[4][d] = 1;
		}
	}
	for (b = 1; b <= 13; b++) {
		if (a[1][b] == 0) {
			cout << "S " << b << endl;
		}
	}
	for (b = 1; b <= 13; b++) {
		if (a[2][b] == 0) {
			cout << "H " << b << endl;
		}
	}
	for (b = 1; b <= 13; b++) {
		if (a[3][b] == 0) {
			cout << "C " << b << endl;
		}
	}
	for (b = 1; b <= 13; b++) {
		if (a[4][b] == 0) {
			cout << "D " << b << endl;
		}
	}
	return 0;
}

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

int main() {
  int A,B;
  cin >>A>>B;

  int z=0;

  while (A<=B){
    if((A%10==A/10000)&&((A/1000)%10==((A/10)%10))){
    z++;
    }
    
    A++;
  }

  cout <<z<<endl;

}


Measured memory_bytes: 3624
#include <iostream>
#include <string.h>
using namespace std;
 
int main() {
	string s;
	int i,rest;
	cin>>s>>rest;
	for(i=0;rest>0&&s[i]!='\0';i++){
		if(s[i]!='a'&&'z'-s[i]<rest){
			rest-='z'-s[i]+1;
			s[i]='a';
		}
	}
 
	s[s.size()-1]+=rest%26;
 
	cout<<s<<endl;
}

Measured memory_bytes: 512