akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n;
int X;
const int maxn = 1e5 + 5;
int b[maxn];
int l[maxn], u[maxn];
ll sum[maxn];
ll pre[maxn];

bool cmp(int i, int j){
    return sum[i] < sum[j];
}

int id[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> X;
    ll base = 0;
    for(int i = 1;i <= n;i++){
        cin >> b[i] >> l[i] >> u[i];
        base += -1LL * b[i] * l[i];
        sum[i] = 1LL * b[i] * l[i] + 1LL * u[i] * (X - b[i]); 
        id[i] = i;
    }
    sort(id + 1, id + 1 + n, cmp);
    pre[0] = 0;
    for(int i = 1;i <= n;i++){
        pre[i] = pre[i - 1] + sum[id[i]];
    }
    ll L = 0, R = 1LL * X * n;
    while(L < R){
        ll mid = (L + R) / 2;
        ll x = mid / X;
        ll y = mid - 1LL * X * x;
        bool flag = false;
        for(int i = 1;i <= n;i++){
            ll tmp = 0;
            int j = id[i];
            if(y <= b[j]){
                tmp = y * l[j];
            }else{
                tmp = 1LL * b[j] * l[j] + 1LL * (y - b[j]) * u[j];
            }
            if(i <= n - x){
                tmp += pre[n] - pre[n - x];
            }else{
                tmp += pre[n] - pre[n - x - 1] - sum[j];
            }
            if(tmp + base >= 0){
                flag = true;
            }
        }
        if(flag){
            R = mid;
        }else{
            L = mid + 1;
        }
    }
    cout << L << endl;
    return 0;
}


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

//文字列tと，文字列sのr文字目から比較し，一致するかを返す
bool str_eql(string t, string s, int r){
  for(int i=t.size()-1; i>=0; i--)
    if(t[i] != s[r--])
      return false;
  return true;
}


int main(){
  string S;
  cin >> S;
  //ここまで入力

  map<string, int> str;
  str["dream"]   = 5;
  str["erase"]   = 5;
  str["dreamer"] = 7;
  str["eraser"]  = 6;

  int count;
  //前からだと重複文字があるため，後ろから見る
  for(int i=S.size()-1; i>0; i--){
    //cout<<i+1<<endl;
    count = 0;
    //4つの文字の一致を確認する
    for(auto s : str){
      //一致がなければカウント(41行目のため)
      if(str_eql(s.first, S, i) == false)
	count++;
      //一致があればその文字列長だけ前に進める
      else{
	i = i-s.second+1;
	//cout<<s.first<<"で一致"<<endl;
	break;
      }
    }
    //どの4つの文字列とも一致がなければ終了
    if(count == 4){
      cout << "NO" << endl;
      return 0;
    }
  }

  //上でreturnしなければOK
  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

typedef long long ll;
int main(void)
{
  ll n,m;
  scanf("%lld %lld",&n,&m);
  ll count=0;
  if(n<m/2){
    count+=n;
    m-=n*2;
    count+=m/4;
  }else{
    count+=m/2;
  }

  printf("%lld\n",count);
  return 0;
}


Measured memory_bytes: 1716
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int A,B,C; cin>>A>>B>>C;
    bool ok=true;
    if(A==B&&B==C) ok=false;
    else if(A!=B&&B!=C&&C!=A) ok=false;
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1e9+10;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin>>s;
    mp[s]++;
  }
  int max=0;
  for(auto m:mp){
    int t=m.second;
    chmax(max,t);
  }
  for(auto m:mp){
    if(m.second==max) cout<<m.first<<endl;
  }
  return 0;


}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;vi x(N),y(N),t(N);rep(i,N)cin>>t[i]>>x[i]>>y[i];
  vi z(N);z[0]=x[0]+y[0];
  for(int i=1;i<N;i++){
    z[i]=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
  }
  vi tt(N);tt[0]=t[0];f(i,1,N)tt[i]=t[i]-t[i-1];
  bool ok=true;
  for(int i=0;i<N;i++){
    if(!(z[i]<=tt[i] && z[i]%2==tt[i]%2)){
      ok=false;
    }
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}







Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
typedef long long int LL;
using namespace std;
int main()
{
    int n;
    LL sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
            continue;
        else
            sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  vector<pair<long long,int>> v(0);
  long long n = N;
  for(long long i = 2;i*i <= N;i++) {
    int num = 0;
    while(n%i == 0) {
      n /= i;
      num++;
    }

    if(num > 0) v.emplace_back(i,num);
  }

  if(n != 1) v.emplace_back(n,1);

  int ans = 0;
  for(int i = 0;i < v.size();i++) {
    int n = v.at(i).second;
    for(long long j = 1;j*(j+1)/2 <= n;j++) ans++;
  }

  cout << ans << endl;

  
  
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
const int MAX_N=1e5;
int divup(int x,int y){
    if(x%y==0)return x/y;
    else return x/y+1;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
typedef pair<int,int>P;

signed main(){
    int w,h,x,y;cin>>w>>h>>x>>y;
  	cout<<fixed<<setprecision(20.20);
    cout<<w*h/2.0<<" "<<(2*x==w&&2*y==h?1:0)<<endl;
}

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

#define vvi             vector<vector<int>>
#define ld              long double
#define mod             1000000007
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vpii            vector<pair<int,int>>
#define fr(i,a,b)       for(int i = a; i < b; i += 1)
#define all(x)          x.begin(),x.end()
#define sz(a)           (int)(a.size())
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define input(a)        for(auto it = a.begin(); it != a.end(); it++) { int value; cin >> value; *it = value;}
//#define print(a)        for(auto it = a.begin() ; it != a.end() ; it++){ cout << *it << " " ;}cout << '\n';
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
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...);
}

const int dirx[4] = {0, 0, -1, 1};
const int diry[4] = {-1, 1, 0, 0};

// 0 -> l, 1 - > r, 2 -> u , 3 -> down
void FASTIO()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int mxN = 2e3 + 10;
int n;
int dp[mxN][mxN];
// 0 -> none, 1-> 0 only, 2-> 9only, 3->0,9 only

void test_case()
{
	cin >> n;

	for(int i = 0; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			dp[i][j] = 0;
		}
	}

	dp[0][0] = 1;

	for(int j = 3; j <= n; j++)
		dp[1][j] = 1;

	for(int i = 2; i <= n; i++)
	{
		int sum = 0;
		for(int j = 0; j <= n - 3; j++)
			sum = (sum + dp[i-1][j]);

		for(int j = n; j >= 3; j--)
		{
			dp[i][j] = sum;
			sum -= dp[i-1][j-3];
		}

		for(int j = n; j >= 0; j--)
		{
			dp[i][j] %= mod;
		}
	}

	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans = (ans + dp[i][n]) % mod;

	// for(int i = )

	cout << ans;
}   


int32_t main()
{
    FASTIO();

    int t;
    t = 1;
    //cin >> t;

    for(int i = 1; i <= t; i++)
    {
        //cout << "Case #" << i << ": ";
        test_case();
    }
    return 0;
} 


Measured memory_bytes: 34880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF (ll)1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

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

ll calc(ll a, ll b, ll p) {
	if (b == 0)return 1;
	else if (b % 2 == 0) {
		ll d = calc(a, b / 2, p);
		return (d*d) % p;
	}
	else {
		return (a*calc(a, b - 1, p)) % p;
	}
}

int main() {
	ll n, a, b, k, ans = 0, mod = 998244353;
	cin >> n >> a >> b >> k;
	vector<ll> v(n+1,(ll)1),vv(n + 1, (ll)1);
	ll tmp = 1;
	v[0] = 1;
	rep(i, n) {
		tmp *= (i + 1);
		tmp %= mod;
		v[i + 1] = tmp;
	}
	rep(i, n + 1) {
		vv[i] = calc(v[i], mod - 2, mod);
	}
	rep(i, n + 1) {
		ll tmp = 0;
		if ((k - a*i) % b == 0 && ((k - a*i) / b) >= 0 && ((k - a*i) / b) <= n) {
			ll jj = (k - a*i) / b;
			//cout << (((v[n] * vv[i]) % mod)*vv[n - i]) % mod;
			//cout << "            ";
			//cout << (((v[n] * vv[jj]) % mod)*vv[n - jj] % mod) % mod;
			//cout << endl;
			tmp = ((((v[n] * vv[i]) % mod )*vv[n - i])%mod)*(((v[n] * vv[jj]) % mod)*vv[n - jj] % mod) % mod;
			ans += tmp;
			ans %= mod;
			//cout << i << " " << jj << " " << ans << endl;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4992
while n = gets.to_i
  break if n == 0
  table = {}
  n.times do
    sh, sm, ss, th, tm, ts = gets.split(/\s|:/).map(&:to_i)
    p = sh * 3600 + sm * 60 + ss
    q = th * 3600 + tm * 60 + ts
    table[p] ||= 0 ; table[p] += 1
    table[q] ||= 0 ; table[q] -= 1
  end
  table = table.sort.transpose[1]
  (1...table.size).each{ |i| table[i] += table[i-1]}
  p table.max
end

Measured memory_bytes: 12676
//int a = s - '0'; 文字から数字
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;

//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main() {
	ll r, D, n; cin >> r >> D >> n;

	for(int i = 1; i <= 10; i++){
		n = r*n - D;
		cout << n << endl;
	}
}	

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

int main() {
  int N, sat;
  cin >> N;
  vector<int> A(N), C(N-1);
  for (int i = 0; i < N; i++)  cin >> A.at(i);
  for (int i = 0; i < N; i++) {
    int bi;
    cin >> bi;
    sat += bi;
  }
  for (int i = 0; i < N-1; i++) cin >> C.at(i);
  
  for (int i = 0; i < N-1; i++) {
    if (A.at(i) + 1 == A.at(i+1)) sat += C.at(A.at(i)-1);
  }

  cout << sat << endl; 
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	m := max(a, b, c)
	fmt.Println(a + b + c - m)
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 512
n, m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]

cnt = [1] * n
red = [0] * n
red[0] = 1

for x, y in xy:
    x -= 1
    y -= 1
    if red[x]:
        if cnt[x] == 1:
            red[x] = 0
        red[y] = 1

    cnt[x] -= 1
    cnt[y] += 1

ans = sum(red)
print(ans)


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

#define FOR(i,k,n)  for(int i=(k);i<(int)(n);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(x)  begin(x),end(x)

using namespace std;

int main() {
  int64_t x,y;
  cin>>x>>y;
  int cnt = 0;
  while (x <= y) {
    ++cnt;
    x *= 2;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll = long long;

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

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

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

	ll x = 1e10;
	for (int i = 0; i < n; i++) {
		if (abs(x - (a[n - 1] + 1) / 2) > abs(a[i] - (a[n - 1] + 1) / 2))
			x = a[i];
	}

	cout << a[n - 1] << " " << x << endl;
	
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    int w,h,n;
    cin>>w>>h>>n;
    int x,y,a;
    int lx=0,ly=0,bx=w,by=h;
    while(n--)
    {
        cin>>x>>y>>a;
        if(a==1)
            lx=max(lx,x);
        if(a==3)
            ly=max(ly,y);

        if(a==2)
            bx=min(bx,x);
        if(a==4)
            by=min(by,y);
    }
    cout<<max(0,bx-lx)*max(0,by-ly)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for (int i=x;i<=y;i++)
#define per(i,x,y) for (int i=x;i>=y;i--)
typedef long long ll;

inline int read()
{
    int x=0;
    char c=getchar();
    bool flag=0;
    while(c<'0'||c>'9')
	{
		if(c=='-') flag=1;
		c=getchar();
	}
    while(c>='0'&&c<='9')
	{
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
    return flag?-x:x;
}

int main()
{
	int red=read(),green=read(),blue=read(),n=read();
	ll ans;
	ans=0;
	int r,g;
	double b;
	rep(i,0,n/red)
	{
		rep(j,0,n/green)
		{
			r=i;
			g=j;
			b=((n-i*red-j*green)*1.0)/blue;
			if (b==int(b) && b>=0)
			{
				ans++;
				//cout<<i<<" "<<j<<endl;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

    int n, k, q;
    int* ps = new int[n];
    cin >> n >> k >> q;
    for (int i = 0; i < q; i++)
    {
        int a;
        cin >> a;
        ps[a - 1]++;
    }
    for (int i = 0; i < n; i++)
    {
        if (k - q + ps[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		String S = stdIn.next();
		if(S.substring(0,N/2).equals(S.substring(N/2,N))){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}

		stdIn.close();
	}
}


Measured memory_bytes: 35744
#include <stdio.h>

int main(void){
  int i,a[3],max;
  int A,B;
  scanf("%d %d",&A,&B);
  a[0] = A + B;
  a[1] = A - B;
  a[2] = A * B;
  max = a[0];
  for(i = 1;i < 3; ++i){
    if(max < a[i])	max = a[i];
  }
  printf("%d\n",max);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> S(n); 
    for(int i=0;i<n;i++){
        cin >> S[i].first.first >> S[i].first.second;
        S[i].first.second = -1*S[i].first.second;
        S[i].second = i+1;
    }

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

    for(int i=0;i<n;i++){
        cout << S[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def s()
  gets()
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end

n, h = li()
as = []
max = 0
n.times{
  temp =  li()
  max = temp[0] > max ? temp[0] : max
  as << temp
}
as.sort_by!{|i| -i[1]}

strong_list = as.map{|i| i[1]}.select{|i| i > max}
sum = 0
strong_list.each{|s|
  sum += s
}

if h <= sum
  strong_list.length.times{|i|
    h -= strong_list[i]
    if (h <= 0)
      puts i+1
      break
    end
  }
else
  puts strong_list.length + ((h-sum).to_f/max).ceil
end



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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll k,t=0;
	string s;
	cin>>s>>k;
	for (t=0;t<s.size();t++){
		if (s[t]!='1'){
			break;
		}
	}
	if (k-1>=t){
		cout<<s[t];
	}
	else {
		cout<<"1";
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,m,h,w,a[502][502],v,i,j;
long long sum;
int main(){
	scanf("%d%d%d%d",&n,&m,&h,&w),v=(1-h*w)*1000-1;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) a[i][j]=(i%h==0 && j%w==0?v:1000),sum+=a[i][j];
	if (sum<=0) return puts("No"),0;
	puts("Yes");
	for (i=1;i<=n;i++,puts(""))
		for (j=1;j<=m;j++) printf("%d ",a[i][j]);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

string s[30];
int h,w;
int dist[30][30];

bool is_pos(int i,int j){
   return i<h and j<w and i>=0 and j>=0 and s[i][j] == '.';
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cin >> h >> w;
   f(i,0,h){
      cin >> s[i];
   }
   int ans = 0;
   f(i,0,h){
      f(j,0,w){
         if(s[i][j] == '.'){
            set<array<int,3>> q;
            int mx = 0;
            q.insert({0,i,j});
            vector<vector<int>> dist(h,vector<int>(w,MOD));
            dist[i][j] = 0;
            while(!q.empty()){
               auto v = *q.begin();
               q.erase(q.begin());
               int ff = v[1];
               int ss = v[2];
               vector<pii> itr = {{ff+1,ss},{ff-1,ss},{ff,ss+1},{ff,ss-1}};
               for(auto &e : itr){
                  if(is_pos(e.F,e.S)){
                     if(dist[ff][ss]+1<dist[e.F][e.S]){
                        q.erase({dist[e.F][e.S],e.F,e.S});
                        dist[e.F][e.S] = dist[ff][ss]+1;
                        mx = max(mx,dist[e.F][e.S]);
                        q.insert({dist[e.F][e.S],e.F,e.S});
                     }
                  }
               }
            }
            ans = max(ans,mx);
         }
      }
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>


string s,t,u;
int a,b;

int main(){
    cin>>s>>t>>a>>b>>u;
    if(s==u)a--;
    if(t==u)b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=22;
vector<pair<pair<int,int>,int> > ans;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,cnt;
	cin>>l;
	n=__lg(l)+1;
	for(i=1;i<n;i++){
		ans.push_back({{i,i+1},0});
		ans.push_back({{i,i+1},(1<<(i-1))});
	}
	l-=(1<<(n-1));
	cnt=(1<<(n-1));
	while(l){
		j=__lg(l);
		ans.push_back({{j+1,n},cnt});
		l-=(1<<j);
		cnt+=(1<<j);
	}
	cout<<n<<' '<<ans.size()<<'\n';
	for(i=0;i<ans.size();i++){
		cout<<ans[i].first.first<<' '<<ans[i].first.second<<' '<<ans[i].second<<'\n'; 
	}
}

Measured memory_bytes: 256
#coding: utf-8

group={'a':[1,3,5,7,8,10,12],'b':[4,6,9,11],'c':[2]}

input_lines=raw_input()
input_numbers=input_lines.split()
n=map(int,input_numbers)#n[0]とn[1]に数字

first_group = False
second_group = False

for i in group:
    for j in range(0,len(group[i])):
        if group[i][j] == n[0]:
            first_group = True
        if group[i][j] == n[1]:
            second_group = True
    if first_group == True and second_group==False or first_group == False and second_group == True:
        print "No"
        break

if first_group and second_group:
    print "Yes"

Measured memory_bytes: 2692
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;
LL a[200010];

void init() {

}

void input() {
	cin >> n;
	REP(i, n) {
		cin >> a[i];
		a[i] = a[i] - i - 1;
	}
	sort(a, a+n);
}

void solve() {
	LL p = a[n/2];
	LL res = 0;
	REP(i, n) {
		res += abs(a[i] - p);
	}
	cout << res << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ans=1e18+7;
int a[200007];
ll sum[200007];
int main(){
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",a+i);
	for (int i=0;i<n;i++) sum[i]=(i?sum[i-1]:0)+a[i];
	for (int i=0;i<n;i++){
		ans=min(ans,abs(sum[n-1]-sum[i]-sum[i]));
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var bs = NewBufScanner(in)
	var bw = NewBufWriter(out)
	defer bw.w.Flush()

	line := bs.Scan()
	c := strings.Count(line, "1")

	bw.Printf("%d\n", c)
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n & 1 ==1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return result;
}



int32_t main()
{
    IOS

    string s,t;
    cin>>s>>t;
    if(s.length()>=t.length())
    	cout<<"No"<<endl;
    else
    {
    	for(int i=0;i<s.length();i++)
    	{
    		if(s[i]!=t[i])
    		{
    			cout<<"No"<<endl;
    			return 0;
    		}
    	}
    	cout<<"Yes"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  vector<int>a(55);
  cin >> N;
  for(int i=0; i<N; i++) {
   cin >> a.at(i);
  }
  int cnt=0;
  for(int i=0; i<N; i++){
    if(a[i]!=i+1) cnt++;
  }
  string ans;
  if(cnt==0 || cnt==2){
    ans = "YES";
  } else {
    ans = "NO";
  }
  cout << ans << endl;
  
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int H; cin >> H;
    int div = log2(H);
    cout << ((int)pow(2,div+1)-1) << endl;
}

Measured memory_bytes: 256
def main():
  N, M = map(int,input().split())
  dct = {}
  ans = [0]*N
  for _ in range(M):
    s, c = map(int,input().split())
    ans[s-1]=c
    if s==1 and c==0 and N>=2:
      print(-1)
      return
    elif s not in dct:
      dct[s] = c
    else:
      if dct[s]!=c:
        print(-1)
        return 
  if ans[0]==0 and N>=2:
    ans[0]=1
  res = 0
  for i in ans:
    res*=10
    res+=i
  print(res)
  return
main()

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

bool debug = 0;

void solve() {
    ll x, y;
    cin >> x >> y;
    ll ans = INF;
    if (y >= x) {
        ans = min(ans, y - x);
    }
    if (y >= x * (-1)) {
        ans = min(ans, y + x + 1);
    }
    if (y * (-1) >= x) {
        ans = min(ans, -y - x + 1);
    }
    if (y * (-1) >= x * (-1)) {
        ans = min(ans, -y + x + 2);
    }
    cout << ans << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
void solve();

signed main () {
	cout.precision(10);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		solve();
	}
	return 0;
}
int arr[100];
void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	s = '$' + s;
	char cur = s[1];
	int ans = 1;
	for (int i = 1; i <= n; ++i) {
		if (s[i] != cur) {
			++ans;
			cur = s[i];
		}
	}
	cout << ans;
}		


Measured memory_bytes: 512
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        k: usize,
        r: usize,
        s: usize,
        p: usize,
        mut t: Chars,
    }

    let mut ans = 0;

    for num in 0..n {
        if num >= k && t[num] == t[num - k] {
            t[num] = 'c';
        }
        match t[num] {
            'r' => ans += p,
            's' => ans += r,
            'p' => ans += s,
            _ => {},
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2548
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,k;
    cin >> n >> k;
    vector<int> x(n),y(n);
    vector<int> xary,yary;
    
    rep(i,n){
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }

    sort(xary.begin(),xary.end());
    sort(yary.begin(),yary.end());

    ll ans = 1LL * (xary[n-1]-xary[0]) * (yary[n-1]-yary[0]);

    rep(xi,n){
        for (int xj=xi+1;xj<n;xj++){
            rep(yi,n){
                for (int yj=yi+1;yj<n;yj++){
                    int num = 0;
                    ll ix = xary[xi], jx = xary[xj];
                    ll iy = yary[yi], jy = yary[yj];

                    rep(i,n){
                        if (ix<=x[i]&&x[i]<=jx&&iy<=y[i]&&y[i]<=jy){
                            num++;
                        }
                    }
                    if (num >= k) ans = min (ans , 1LL * (jx -ix) * (jy - iy) );
                }
            }
        }
    }

    cout << ans ;




    // vector<pair<ll,ll>> q(n);
    // rep(i,n){
    //     ll a,b;
    //     cin >> a >> b;
    //     pair <ll,ll>  w(a,b);
    //     q[i]=w;
    // }
    // sort(q.begin(),q.end());
    // ll ans = 3999999996000000001;
    // for (int i=0;i<n-k+1;i++){
    //     ll xmin = q[i].first;
        
    //         ll ymin = 1000000000;
    //         ll ymax = -1000000000;
    //     for (int l=i+k-1;l<n;l++){
    //         ll xmax = q[l].first;
    //         for (int j=i;j<l+1;j++){
    //             ymin = min(ymin,q[j].second);
    //             ymax = max(ymax,q[j].second);
                
    //         }
    //         ans = min (ans,(xmax-xmin)*(ymax-ymin));
    //     }     
    // }
    // cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

//https://abc048.contest.atcoder.jp/tasks/abc048_a

using namespace std;

int main(){
    string str1, str2, str3;
    cin >> str1 >> str2 >> str3;

    cout << str1.at(0) << str2.at(0) << str3.at(0) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

min_comfort = max(a)
sum_comfort = max(a)
i = 0
j = 1
counter=0
while i < n - 2:
    tmp = a[j]
    sum_comfort += tmp
    counter+=1
    if counter ==2:
        counter=0
        j+=1
    i+=1
    # print(i,j)
print(sum_comfort)

Measured memory_bytes: 31612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <memory>
#include <climits>

constexpr long long MOD = 1000000007;

int main()
{
  int N;
  std::cin >> N;
  std::string s;
  std::cin >> s;
  N = s.size();
  std::vector<int> accB(N, 0);
  std::vector<int> accW(N, 0);
  int cB = 0;
  int cW = 0;
  for (int i = 0; i < N; ++i)
  {
    if (s[i] == '.')
      ++cW;
    else
      ++cB;
    accB[i] = cB;
    accW[i] = cW;
  }

  int i = N - 1;
  while (0 <= i && s[i] == '#')
    --i;
  if (i < 0)
  {
    std::cout << 0 << std::endl;
    return 0;
  }
  int ans = INT_MAX;
  int count = 0;
  while (0 <= i)
  {
    int j = i;
    while (0 <= j && s[j] == '.')
      --j;
    if (j < 0)
    {
      ans = std::min(ans, count);
      break;
    }
    ans = std::min(ans, accB[j] + count);
    count += i - j;
    while (0 <= j && s[j] == '#')
      --j;
    i = j;
  }
  ans = std::min(ans, count);
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 2180
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll n;
	cin >> n;
	vector<pair<ll,ll>> a(n);
	rep(i, n)
	{
		cin >> a[i].first;
		a[i].second = i;
	}
	vector<ll> tb(n+1);
	ll m = 0;
	sort(a.begin(), a.end());
	pair<ll, ll> tmtm;
	tmtm.first = a[0].first;
	tmtm.second = 1;

	for(int i=0;i<n;i++)
	{
		tb[a[i].first]++;
	}

	vector<ll> ans(n, 0);
	vector<ll> t(n, 0);

	ll sum = 0;

	for (int i = 1; i <= n; i++)
	{
		ll tmp = (tb[i] - 1) * tb[i];
		tmp /= 2;
		sum += tmp;
	}

	for (int i = 0; i < n; i++)
	{
		ans[a[i].second] = sum;
		ans[a[i].second] -= tb[a[i].first] - 1;
	}
	for (int i = 0; i < n; i++)
	{
		cout << ans[i] << endl;
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

vector<ll> a, p;

ll calc_p(int n, ll x) {
	if (n == 0) return 1;
	if (x == 1) return 0;
	else if (x <= 1 + a[n-1]) return calc_p(n-1, x-1);
	else if (x == 2 + a[n-1]) return p[n-1] + 1;
	else if (x <= 2 + 2 * a[n-1]) return p[n-1] + 1 + calc_p(n-1, x-a[n-1]-2);
	else return 2 * p[n-1] + 1;
}

int main(int argc, char const *argv[]) {
	ll N, X; cin >> N >> X;
	a.resize(N+1, 1);
	p.resize(N+1, 1);
	REP(i, 1, N+1) {
		a[i] = 2 * a[i - 1] + 3;
		p[i] = 2 * p[i - 1] + 1;
	}
	cout << calc_p(N, X) << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k, t int
	fmt.Scan(&k, &t)
	a := make([]int, t)
	max := 0
	maxIndex := 0
	for i := range a {
		fmt.Scan(&a[i])
		if max < a[i] {
			max = a[i]
			maxIndex = i
		}
	}

	ans := max - 1
	for i := range a {
		if i == maxIndex {
			continue
		}
		ans -= a[i]
	}

	if ans < 0 {
		fmt.Println(0)
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 512
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;

            var S = cin.ReadLine;

            var count = 0;

            for (var i = 0; i <= N - 3; i++)
            {
                 if (S[i].ToString() == "A")
                 {
                     if (S[i + 1].ToString() == "B")
                     {
                        if (S[i + 2].ToString() == "C")
                        {
                            count++;
                        }
                    }
                 }
            }


            WriteLine(count);
    


        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 27900
#include<bits/stdc++.h>
#define ll long long
#define mod (1000000000+7)
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int main()
{
    ll int n,w; cin>>n>>w;
    ll int W[n],v[n];
    for(ll int i=0;i<n;i++)
        cin>>W[i]>>v[i];
    ll int T[n+1][w+1];
    for(ll int i=0;i<=n;i++)
    {
        for(ll int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
                T[i][j] = 0;
            else if(W[i-1] <= j)
                T[i][j] =   max(v[i-1] + T[i-1][j-W[i-1]] , T[i-1][j]);
            else
                T[i][j] = T[i-1][j];
        }
    }
    cout<<T[n][w];
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

const int SZ= 51;
int add(int a, int b)
{
	int res = a + b;
	if(res >= MOD)
		return res - MOD;
	return res;
}

int mult(int a, int b)
{
	long long res = a;
	res *= b;
	if(res >= MOD)
		return res % MOD;
	return res;
}


struct matrix
{
	int arr[SZ][SZ];

	void reset()
	{
		memset(arr, 0, sizeof(arr));
	}

	void makeiden()
	{
		reset();
		for(int i=0;i<SZ;i++)
		{
			arr[i][i] = 1;
		}
	}

	matrix operator + (const matrix &o) const
	{
		matrix res;
		for(int i=0;i<SZ;i++)
		{
			for(int j=0;j<SZ;j++)
			{
				res.arr[i][j] = add(arr[i][j], o.arr[i][j]);
			}
		}
		return res;
	}

	matrix operator * (const matrix &o) const
	{
		matrix res;
		for(int i=0;i<SZ;i++)
		{
			for(int j=0;j<SZ;j++)
			{
				res.arr[i][j] = 0;
				for(int k=0;k<SZ;k++)
				{
					res.arr[i][j] = add(res.arr[i][j] , mult(arr[i][k] , o.arr[k][j]));
				}
			}
		}
		return res;
	}
};


matrix power(matrix a, int b)
{
	matrix res;
	res.makeiden();
	while(b)
	{
		if(b & 1)
		{
			res = res * a;
		}
		a = a * a;
		b >>= 1;
	}
	return res;
}

int32_t main(){
	fast;
	int n,k;
	cin >> n >> k;
	
	matrix mt;
	f(i,1,n+1)
		f(j,1,n+1)
			cin >> mt.arr[i][j];
			
	matrix ans = power(mt , k);
	
	int res = 0;
	f(i,1,n+1)
		f(j,1,n+1)
			res  = (res + ans.arr[i][j])%MOD;
	cout << res;
}



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

using namespace std;
const int N = 100010;
int _w;

int n, x, a[N+N], m, v[N+N];

int main() {
	cin >> n >> x, m = n+n-1;
	if( x == 1 || x == m )
		return puts("No"), 0;
	puts("Yes");
	if( n == 2 ) {
		puts("1");
		puts("2");
		puts("3");
		return 0;
	} else if( x == 2 ) {
		a[n] = x;
		a[n+1] = x-1;
		a[n+2] = x+1;
		a[n-1] = x+2;
		v[x] = v[x-1] = v[x+1] = v[x+2] = 1;
	} else {
		a[n] = x;
		a[n+1] = x+1;
		a[n+2] = x-1;
		a[n-1] = x-2;
		v[x] = v[x+1] = v[x-1] = v[x-2] = 1;
	}
	int p = 1;
	for( int i = 1; i <= m; ++i )
		if( !a[i] ) {
			while( v[p] ) ++p;
			a[i] = p++;
		}
	for( int i = 1; i <= m; ++i )
		printf( "%d\n", a[i] );
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define int long long
using namespace std;
long long tmp;
long long trans(long long b,long long n){
	if(n<b){
		return n;
	}
	return trans(b,n/b)+n%b;
}
vector<long long> divi;
signed main(){
	long long n,s;
	cin>>n>>s;
	tmp=n;
	if(s==n){
		cout<<n+1;
		return 0;
	}
	long long k=sqrt(n);
	for(int i=2;i*i<=n;i++){
		if(trans(i,tmp)==s){
			cout<<i;
			return 0;
		}
		else{
			tmp=n;
		}
	}
	for(int i=1;i*i<=n-s;i++){
		if((n-s)%i==0){
			divi.push_back(i);
			divi.push_back((n-s)/i);
			if(i*i==(n-s)){
				divi.pop_back();
			}
		}
	}
	sort(divi.begin(),divi.end());
	for(int i=0;i<divi.size();i++){
		if(trans(divi[i]+1,n)==s&&(n-s)/(divi[i])<divi[i]+1){
			cout<<divi[i]+1;
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;

    if (a > 9 || b > 9) {
        cout << -1;
    } else {
        cout << a * b;
    }

//    std::cout << "Hello, World!" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.1415926535
 
 
int main()
 {
	int a,b,h,m;
	double answer,deg,adeg,bdeg,rad;
	
	scanf("%d%d%d%d",&a,&b,&h,&m);

	adeg=30.0*h+m*0.50;
	
	bdeg=6.0*m;

	deg=fabs(adeg-bdeg);

	rad=deg*PI/180.0;
	
	answer=sqrt(a*a+b*b-2.0*a*b*cos(rad));

	printf("%.10lf",answer);

			return 0;
	}


	







Measured memory_bytes: 2604
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		String t = sc.next();
		
		// 計算
		String result = "UNRESTORABLE";
		for(int i = s.length()-t.length(); i >= 0; i--){
		    boolean flg = true;
		    for(int j = 0; j < t.length(); j++){
		        if(i+j >= s.length()){
		            flg = false;
		            break;
		        }
		        if(s.charAt(i+j) != t.charAt(j) && s.charAt(i+j) != '?'){
		            flg = false;
		        }
		    }
		    if(flg){
		        String newS = s.replace('?', 'a');
		        result = newS.substring(0, i) + t + newS.substring(i+t.length());
		        break;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 21716
#include <set>
#include <functional>
#include <iostream>
#include <vector>
#include <string>

using namespace std;


int main() {
	int a, n;
	cin >> n >> a;
	int c1 = n / 500;

	for (int i = 0; i <= c1; ++i) {
		for (int j = 0; j <= a; ++j) {
			if (i * 500 + j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}

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

int main(void){
  long long n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i] -= (i + 1);
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for(int i = 0; i < n; i++){
    ans += abs(a[i] - a[n / 2]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792