akhauriyash/Code-Regression huggingface dataset:
#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>;

void dfs() {}

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  vector<int> cnt(N);
  for (int l = 0; l < N - 1; l++)
  {
    
    if (S[l] == 'A' && S[l + 1] == 'C')
    {
      cnt[l + 1]++;
    }
    if (l == 0)
    {
      continue;
    }
    cnt[l] += cnt[l - 1];
  }
  cnt[N - 1] += cnt[N - 2];

  while (Q--)
  {
    int l, r;
    cin >> l >> r;
    --l;--r;
    if (l == 0)
    {
      cout << cnt[r] << endl;
      continue;
    }
    
    cout << cnt[r] - cnt[l] << endl;
  }
  
  return 0;
}


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

int main(){
  int A,B,K,count=0;
  cin >> A >> B >> K;
  for(int i=min(A,B);i>0;i--){
    int C=i;
    if(A%C==0 && B%C==0){
      count++;
      if(count==K){
        cout << C << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3632
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数

int main() {
  int N, M, a = 0;
  ci(N, M);
  ve<int> L(M), R(M);
  rep(i, M){
    ci(L.at(i), R.at(i));
  }
  so(L);
  so(R);
  if(R.at(0) - L.at(M - 1) >= 0){
    co(R.at(0) - L.at(M - 1) + 1);
  }
  else{
    co(0);
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define forN(i, n) for(int i = 1; i <=n ; ++i)
#define endl "\n"
typedef long long ll;
using namespace std;
const ll INF = 1e18;

const int N = 405;
ll A[N],DP[N][N],prefix[N],n;

ll cost(int i ,int j){
    if(i-1>=0)return prefix[j]-prefix[i-1];
    return prefix[j];
}

ll calc(int L , int R){
    if (L == R)return 0;
    ll &ans  = DP[L][R];
    if(ans != -1)return ans;
    ans = INF;
    for(int k = L ; k<R+1 ; k++){
        ans = min(ans , calc(L,k) + calc(k+1,R) + cost(L,R));
    }
    return ans;
}

int main(){
    fastIO;
    cin>>n;
    for(int i = 0 ; i<n ; i++){
        cin>>A[i];
        prefix[i] = A[i];
        if(i>0)prefix[i]+=prefix[i-1];
    }
    memset(DP,-1,sizeof DP);
    cout<<calc(0,n-1);
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> t(n+1), x(n+1), y(n+1);
    x.at(0) = 0;
    y.at(0) = 0;
    t.at(0) = 0;
    rep(i, n){
        cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
    }
    string ans = "Yes";
    rep(i, n){
        if(t.at(i+1)-t.at(i)>=x.at(i+1)+y.at(i+1)-x.at(i)-y.at(i)){
            if((t.at(i+1)-t.at(i)-x.at(i+1)+y.at(i+1)-x.at(i)-y.at(i))%2){
                ans = "No";
            }
        }
        else{
            ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>
using namespace std;
int h[200], v[200];
long long dp[100200];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &h[i], &v[i]);
		for (int j = k; j >= h[i]; j--) {
			dp[j] = max(dp[j], dp[j-h[i]] + v[i]);
		}
	}
	printf("%lld\n", dp[k]);
	return 0;
}


Measured memory_bytes: 896
#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>;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i = 0; i < a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend istream& operator>>(istream& is, mint& m){
        is >> m.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint dp[105][20];

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    k--;
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            rep(k,1<<(w-1)){
                bool ng=false;
                //棒隣り合ってないか判定
                rep(l,w-1)if((k>>l)%4==3)ng=true;
                if(ng)continue;
                for(int l=-1; l<=1; ++l){
                    //真下
                    if(l==0){
                        bool ok=true;
                        //左に棒あったらダメ
                        if(j>0)if(k&(1<<(w-1-j)))ok=false;
                        //右に棒あったらダメ
                        if(j<w-1)if(k&(1<<(w-2-j)))ok=false;
                        if(ok){
                            dp[i+1][j]+=dp[i][j];
                        }
                    }
                    //右下、左下
                    else{
                        //行き先
                        int to=j+l;
                        if(to>=0&&to<w){
                            //左右に対応させる
                            int d=(l==-1)?to:j;
                            if(k&(1<<(w-2-d))){
                                dp[i+1][to]+=dp[i][j];
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<dp[h][k]<<endl;
}

Measured memory_bytes: 3568
/**THE_SHYAMP_IS_HERE**/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<bits/stdc++.h>
#include<iomanip>
#define lld long long int
#define ld long double
#define pii pair<lld,lld>
#define psi pair<string,lld>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define nl '\n'
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin())  i= (c).begin(); i!=(c).end(); i++)
#define MOD 1000000007
#define pi 3.1415926536
#define tod 1
#define itr(i,a,b) for(lld i=a;i<=b;i++)
#define itrn(i,a,b) for(lld i=a;i>=b;i—)
using namespace std;
int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
    lld N; cin>>N;
 float f=N;
 float k=0.00;
 itr(i,1,N){
     if(i%2!=0) k=k+1.00;
 }
 float z=k/f;
 printf("%4.10f",z);
}



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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_H = 85;
const int MAX_W = 85;
const int AB = 4*MAX_H*MAX_H;

int H, W;
int A[MAX_H][MAX_W];
int B[MAX_H][MAX_W];
int F[MAX_H][MAX_W];

bitset<AB> dp[MAX_H][MAX_W];

signed main()
{
  cin >> H >> W;
  REP(h,H) {
    REP(w,W) {
      cin >> A[h][w];
    }
  }

  REP(h,H) {
    REP(w,W) {
      cin >> B[h][w];
      F[h][w] = A[h][w] - B[h][w];
    }
  }

  dp[0][0].set(AB/2 + F[0][0]);
  REP(h,H) {
    REP(w,W) {
      if(F[h+1][w] >= 0) {
        dp[h+1][w] |= (dp[h][w] << F[h+1][w]) | (dp[h][w] >> F[h+1][w]);
      } else {
        dp[h+1][w] |=  (dp[h][w] << (-1*F[h+1][w])) | (dp[h][w] >> (-1*F[h+1][w]));
      }

      if(F[h][w+1] >= 0) {
        dp[h][w+1] |= (dp[h][w] << F[h][w+1]) | (dp[h][w] >> F[h][w+1]);
      } else {
        dp[h][w+1] |= (dp[h][w] << (-1*F[h][w+1])) | (dp[h][w] >> (-1*F[h][w+1]));
      }
    }
  }

  int ans = INF_LL;
  REP(ab,AB) {
    if(dp[H-1][W-1].test(ab)) {
      ans = min(ans, abs(ab - AB/2));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 24960
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    vector<lli> a(n), b(n);
    for(int i=0; i<n; i++){
        cout << "? " << 1 << " " << i+1 << endl;
        cin >> a[i];
        cout << "? " << i+1 << " " << n << endl;
        cin >> b[i];
    }
    for(int i=0; i<n-1; i++){
        a[n-1-i] -= a[n-2-i];
        b[i] -= b[i+1];
    }
    cout << "!";
    for(int i=0; i<n; i++){
        cout << " " << b[i]+1 +(i-a[i]);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 288960
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
ll dp[200000];
int main(){
int n,m;
cin>>n>>m;
vector<bool> a(n+3,true);
for(int i=0;i<m;i++){
  int t;cin>>t;
  a[t]=false;
}
dp[0]=1;
for(int i=0;i<n;i++){
    if(a[i+1])dp[i+1]+=dp[i];
    if(a[i+2])dp[i+2]+=dp[i];
    dp[i+1]%=mod;dp[i+2]%=mod;
}
cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

int box[100005];

bool solve() {
	int n,k; cin >>n >> k;
	REP (i,n) {
		int a,b; cin >> a >> b;
		box[a] += b;
	}
	int tmp = 0;
	REP (i,100005) {
		if (tmp + box[i] >= k) {
			cout << i << endl;
			return 0;
		}
		tmp += box[i];
	}
}

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

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<vector>
using namespace std;
#define fr first
#define sc second
typedef pair<string,int> P;
int main(){
  vector< vector<P> > info;
  int n,a,s,g;
  string d[40][400];
  while(cin >> n >> a >> s >> g , n){
    info.resize(n);
    for(int i = 0 , x , y ; i < a ; i++ ){
      string s;
      cin >> x >> y >> s;
      info[x].push_back(P(s,y));
    }
    priority_queue< P,vector<P>,greater<P> > que;
    for(int i=0;i<n;i++) for(int j=0;j<400;j++) d[i][j] = "";
    que.push(P("",s));
    d[s][0] = "";
    while(!que.empty()){
      P p = que.top();
      int now = p.sc;
      string nowstr = p.fr;
      if( now == g ){
        cout << (nowstr.size() >= 300 ? "NO" : p.fr) << endl;
        break;
      }
      que.pop();
      if( d[now][nowstr.size()] != "" && d[now][nowstr.size()] < nowstr ) continue;
      for(int i = 0 ; i < info[now].size() ; i++ ){
        P e = info[now][i];
        string next_str = nowstr + e.fr;
        if( next_str.size() >= 400 ) continue;
        if( d[e.sc][next_str.size()] == "" || next_str < d[e.sc][next_str.size()] ){
          d[e.sc][next_str.size()] = next_str;
          que.push(P( next_str , e.sc ));
        }
      }
    }
    if(que.empty()) cout << "NO" << endl;
    info.clear();
  }
}

Measured memory_bytes: 15520
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  vector<int> w(n);
  for(int i=0; i<n; i++) cin >> w[i];
  
  int sum = 0;
  for(int i=0; i<n; i++) if(v[i] > w[i]) sum += v[i]-w[i];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3624
import sys


def call(n):
    for i in range(1, n + 1):
        x = i
        if x % 3 == 0:
            print(f' {i}', end='')
            continue
        while True:
            if x % 10 == 3:
                print(f' {i}', end='')
                break
            x //= 10
            if not x:
                break
    print()


call(int(sys.stdin.read()))



Measured memory_bytes: 5892
import java.util.Scanner;

public class Main {
	
	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int ans = Integer.MAX_VALUE;
		for(int i=0;i*9<=N;i++) {
			ans = Math.min(ans, countOperation(i*9,9)+countOperation(N-i*9,6));
		}
		
		System.out.println(ans);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	public int countOperation(int value,int base) {
		int count = 0;
		while(value!=0) {
			count += value%base;
			value = value/base;
		}
		return count;
	}
}


Measured memory_bytes: 21588
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

ll c[100][100];
ll w,h;

void dfs(ll y,ll x){
    c[y][x]=0;
    for(ll p=-1;p<=1;p++){
        for(ll q=-1;q<=1;q++){
            if(p==0 && q==0) continue;
            ll ny=y+p;
            ll nx=x+q;
            if(0<=ny && ny<=h-1 && 0<=nx && nx<=w-1 && c[ny][nx]==1){
                dfs(ny,nx);
            }
        }
    }
}

int main()
{
    while(true){
        cin >> w >> h;
        if(w==0 && h==0){
            break;
        }
        rep(i,h){
            rep(j,w){
                cin >> c[i][j];
            }
        }
        ll cnt=0;
        rep(i,h){
            rep(j,w){
                if(c[i][j]==1){
                    dfs(i,j);
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
} 


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n,m;

int a[1000],b[1000];




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

   if(x>=30) cout <<"Yes"<<endl;
   else cout <<"No"<<endl;
       
}



 

    
 

Measured memory_bytes: 3636
let checkTravel ((lst1,lst2) : int [] * int []) =
  let steps = abs (lst2.[1] - lst1.[1]) + abs (lst2.[2] - lst1.[2])
  let times = lst2.[0] - lst1.[0]
  times >= steps && (times - steps) % 2 = 0

let rec getInps (res : int [] list) (i : int) (n : int) =
  if i=n then
    List.rev res
  else
    let inp = stdin.ReadLine().Split(' ') |> Array.map int
    getInps (inp::res) (i+1) n

let N = stdin.ReadLine() |> int
let inps = getInps [[|0;0;0|]] 0 N
let initInps = List.take (List.length inps - 1) inps
let tailInps = List.tail inps
let tuples = List.zip initInps tailInps

printfn "%s" <| if (List.map checkTravel tuples |> List.reduce (&&)) then "Yes" else "No"

Measured memory_bytes: 42080
from sys import stdin 
n = int(stdin.readline().rstrip())
l = [int(x) for x in stdin.readline().rstrip().split()]
l.sort()
answer = 0
for i in range(len(l)):
    for j in range(i):
        if i != j:
            low = i+1
            high = n
            c = l[i] + l[j]
            while low < high:
                mid = (low + high) // 2
                if l[mid] < c:
                    low = mid + 1
                else:
                    high = mid
            answer += low - i - 1
print(answer)



Measured memory_bytes: 41452
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    getLine
    as <- fmap read . words <$> getLine :: IO [Int]
    let bs = take 2 . filter ((>= 2) . length)
           . group . sortBy (flip compare) $ as
    let ans = case bs of
            []   -> 0
            [xs] -> 0
            [xs, ys] | length xs >= 4 -> head xs ^ 2
                     | otherwise      -> head xs * head ys
    print ans

Measured memory_bytes: 52604
S = input()
 
# 前から順に消すと詰む
# 後ろから順に消すと一意に定まる
while True:
  if S[-5:] == 'erase': S = S[:-5]
  else:
    if S[-6:] == 'eraser': S = S[:-6]
    else:
      if S[-5:] == 'dream': S = S[:-5]
      else:
        if S[-7:] == 'dreamer': S = S[:-7]
        else: break

if len(S) == 0: print('YES')
else: print('NO')

Measured memory_bytes: 9072
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
using namespace std;

int main(){
  long long N, K, sum = 0;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++){
    cin >> H[i];
  }
  sort(H.begin(),H.end(),greater<int>());
  for (int i = K; i < N; i++){
    sum += H[i];
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] b = new int[a];
		int[] d = new int[a];
		long ans = 1;
		int judge=0;
		b[0]=0;
		for(int i = 0 ; i < a; i++){
			d[i] = sc.nextInt();
			b[d[i]]++;
			if(b[d[i]]==2 && d[i]!=0){
					judge++;
				}
		}
		if((a/2!=judge) || (a%2==1 && b[0]==0)){
			System.out.println(0);
			return;
		}
			for(int i = 0; i < a; i++){
				
				ans*=b[d[i]];
				ans%=1000000007;
				b[d[i]]--;
			}
		System.out.println(ans);
	}
}

Measured memory_bytes: 61608
#include<bits/stdc++.h>
using namespace std;
int n,k;
int f(int x,int y){
    if(x>=n)return y;
    return min(f(x+1,y*2),f(x+1,y+k));
}
int main(){
    scanf("%d %d",&n,&k);
    printf("%d\n",f(0,1));
    return 0;
}

Measured memory_bytes: 256
/*
 * zyrch - Rupanshu Yadav
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) 

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 1e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
	a %= mo;
	if(a < 0) a+=mo;
	return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
	return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}

//=========================CODE STARTS HERE=============================//

int main() {
	fast_cin();
	ll n;
	cin >> n;
	
	cout << setprecision(10) <<  db(n) * 2 * M_PI << "\n";
	
	return 0; 
}


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
const int N=201000;
const int K=20;
double EPS=1e-7;
typedef long long ll;
#define lef(x) (x<<1)
#define rig(x) (lef(x)+1)
vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int32_t main()	
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int k;
	cin>>k;
	cout<<a[k-1]<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>

using namespace std;

#define N 251

int parent(int i){
  return i/2;
}

int leftc(int i){
  return 2*i;
}

int rightc(int i){
  return 2*i+1;
}

int main(){
  int n,data;
  int h;
  //array
  int key[N];
  //load number
  scanf("%d",&n);
  //load data and set key
  for(int i=1;i<=n;i++){
    scanf("%d",&data);
    key[i]=data;
  }
 
  //print
  for(int i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,key[i]);
    h=parent(i);
    if(h>0 && h<=n) printf("parent key = %d, ",key[h]);
    h=leftc(i);
    if(h>0 && h<=n) printf("left key = %d, ",key[h]);
    h=rightc(i);
    if(h>0 && h<=n) printf("right key = %d, ",key[h]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
s = input()
s_list = [i for i in s]
az = [chr(i) for i in range(97,97+26)]
min_ans = 10*5
for i in az:
    count = 0
    temp = [i for i in s]
    while temp.count(i)!=len(temp):
        ans = []
        for j in range(len(temp)-1):
            if temp[j]==i or temp[j+1]==i:
                ans.append(i)
            else:
                ans.append(temp[j])
        count += 1
        temp = ans
    min_ans = min(min_ans,count)
print(min_ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = (n / (a + b)) * a;
  ll res = n % (a + b);
  if (res <= a) ans += res;
  else ans += a;
  cout << ans << endl;
}


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

int main(){
	string s;
	cin >> s;
	if(s=="Sunny") cout << "Cloudy" << endl;
	if(s=="Cloudy") cout << "Rainy" << endl;
	if(s=="Rainy") cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 256
#define _ 2<<17
n,i;A[_],B[_],T[_],F[_];long M,D[_],P[_],R[_];s(u,p,i,I){D[u]=1;for(i=F[u];I=B[i];i=T[i])I-p?s(I,u),D[u]=D[u]*-~D[I]%M:0;}S(u,p,x,i,I){for(m(i=F[u],p);I=B[i];I-p?S(I,u,R[i]*x%M+1),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}m(i,p){i?m(T[i],p),R[i]=R[T[i]]*(B[i]-p?-~D[B[i]]:1)%M:0;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,0);S(1,0,1);for(;i++<n;)printf("%d\n",P[i]);}

Measured memory_bytes: 15744
list1 = []
N = int(input())
# Looping in the range (N+1)-1
for i in range((N-1)+1):
  X=input()
  S, P = map(str, X.split())
  list1.append((i+1, S, int(P)))
# lamda sorting
list2 = sorted(list1, key=lambda x:(x[1], -x[2])) 
for all in list2:
  print(all[0])

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

#define int long long

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n, m;
    cin>>n>>m;
    int s=0;
    int a[n];
    for (int i=0;i<n;++i)
    {
    	cin>>a[i];
    	s+=a[i];
    }
    long double d =  (s*1.0)/(4*m);
    sort(a, a+n, greater <int>());
    if (a[m-1]<d)
    	cout<<"No\n";
    else
    	cout<<"Yes\n";
    

    return 0;
}

Measured memory_bytes: 256
class SWAG():
    __slots__='unit','f','fold_r','fold_l','data_r','data_l'
    def __init__(self,unit,f,data):
        self.unit=unit
        self.f=f
        self.construct(data)
    def construct(self,data):
        self.fold_r=[self.unit]
        self.fold_l=[self.unit]
        self.data_r=[]
        self.data_l=[]
        sep=0--len(data)//2
        for t in data[sep:]:
            self.append(t)
        for t in data[sep-1::-1]:
            self.appendleft(t)
    def append(self,x):
        self.fold_r.append(self.f(self.fold_r[-1],x))
        self.data_r.append(x)
    def appendleft(self,x):
        self.fold_l.append(self.f(self.fold_l[-1],x))
        self.data_l.append(x)
    def pop(self):
        if not self.data_r:
            self.construct(self.data_l[::-1])
        self.fold_r.pop()
        return self.data_r.pop()
    def popleft(self):
        if not self.data_l:
            self.construct(self.data_r)
        self.fold_l.pop()
        return self.data_l.pop()
    def fold_all(self):
        return self.f(self.fold_r[-1],self.fold_l[-1])
n,k,*p=map(int,open(0).read().split())
c=[0]
for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
*c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
x=not f
s_min=SWAG(10**18,min,p[:k-1])
s_max=SWAG(0,max,p[1:k])
for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    s_min.append(p[i+k-1])
    s_max.append(b)
    if not c and(a!=s_min.fold_all()or b!=s_max.fold_all()):x+=1
    s_min.popleft()
    s_max.popleft()
print(x+f)

Measured memory_bytes: 120764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vl A(N);
	rep(i, N)
		cin >> A[i];
	sort(A.begin(), A.end(), greater<ll>());
	ll ans = 0;
	rep(i, N) {
		if (i == 0)
			ans += 0;
		else
			ans += A[i / 2];
	}
	cout << ans << endl;
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end

template<typename M,typename N=M>struct SegmentTree{
   using F=function<M(M,M)>; using G=function<M(M,N)>;
   int sz; vector<M> data; const F f; const G g; const M m1;
   SegmentTree(int n,const F f,const G g,const M &m1):f(f),g(g),m1(m1){
      sz=1; while(sz<n)sz<<=1; data.assign(2*sz,m1);
   }
   void build(vector<M> v){
      rep(i,0,v.size())data[i+sz]=v[i];
      rrep(k,sz-1,0)data[k]=f(data[2*k],data[2*k+1]);
   }
   void update(int k,const N &x){
      k+=sz; data[k]=g(data[k],x);
      while(k>>=1)data[k]=f(data[2*k],data[2*k+1]);
   }
   M query(int a,int b){
      M L=m1,R=m1;
      for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
         if(a&1)L=f(L,data[a++]);
         if(b&1)R=f(data[--b],R);
      } return f(L,R);
   }
   M operator[](const int &k)const{return data[k+sz];}
};

int main(){
   int n,q; scanf("%d%d",&n,&q);
   SegmentTree<ll> seg(n,
   [](ll a,ll b){return a+b;},
   [](ll a,ll b){return a+b;},0);
   rep(i,0,n){int tmp; scanf("%d",&tmp); seg.update(i,tmp);}
   rep(i,0,q){
      int t,l,r; scanf("%d%d%d",&t,&l,&r);
      if(t==0)seg.update(l,r);
      else printf("%lld\n",seg.query(l,r));
   }
   return 0;
}

Measured memory_bytes: 12504
#include<bits/stdc++.h>
#define all(x) x.begin() , x.end()
#define ll long long 
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n ; cin>>n;
    vector<int>p(n + 1);
    int c = 0 ;
    for(int i = 0 ; i < n; ++i){
        int x ; cin>>x;
        c += x;
        p[i + 1] = c;
    }
    int mn = INT_MAX;
    //for(int& i : p)cout<<i<<" ";
    for(int i = 1 ; i<= n; ++i){
       mn = min(abs(p[n] - 2*p[i]) , mn);
    }
    cout<<mn<<endl;

}

Measured memory_bytes: 256
from collections import defaultdict, deque
N = int(input())
dic = defaultdict(list)
for i in range(N):
  inf = [int(c) for c in input()]
  for j in range(N):
    if inf[j]:
      dic[i] += [j]
      dic[j] += [i]
ans = 0
for i in range(N):
  q = deque([i])
  dist = [float('inf')]*N
  dist[i] = 0
  m = 0
  while q:
    p = q.popleft()
    for e in dic[p]:
      if dist[e]==dist[p]:
        print(-1)
        import sys
        sys.exit()
      if dist[e]>dist[p]+1:
        dist[e] = dist[p]+1
        q += [e]
        m = max(m,dist[e])
  ans = max(ans,m)
print(ans+1)

Measured memory_bytes: 42860
#include <stdio.h>

int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    int integer_number = a / b;
    double mod_number = a % b;
    double result = (double)a / (double)b;
    printf("%d %.0lf %lf\n",integer_number,mod_number,result);
    return 0;
}


Measured memory_bytes: 2132
N = int(input())
A = [0]*N
P = [0]*N
for i in range(N):
  D = list(map(str, input().split()))
  A[i] = D[0]
  P[i] = int(D[1])

for i in range(N):
  A.insert(2*i+1, P[i])

for i in range(N):
  A.insert(3*i+2, i+1)

#print(A)  
B = [A[i:i + 3] for i in range(0, len(A), 3)]

B = sorted(B, key=lambda x:(x[0],-x[1]))
for i in range(N):
  print(B[i][2])




Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
signed main() {
	while (1) {
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		cout << min(x, y) << " " << max(x, y) << endl;
	}
	ggr
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N;
	cin >> N;
	int x = 800 * N;
	int y = 200 * (N / 15);
	cout << x - y << endl;
}



Measured memory_bytes: 256
/**
 *      purpose : ABC 45 C
 *      author  : kyomukyomupurin
 *      created : 2018-11-17 05:09:16
**/

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
#define print(x) cout << (x) << '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin >> s;
    int64 n = s.size() - 1;

    int64 ans = 0;

    for (int bit = 0; bit < (1<<n); ++bit){
        int64 temp = s[0] - '0';
        for (int i = 0; i < n; ++i){
            if (bit & (1<<i)){
                ans += temp; temp = 0;
            }
            temp = temp * 10 + s[i + 1] - '0';
        }
        ans += temp;
    }
    print(ans);
    
    return 0;
}

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

using namespace std;

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << "A" << s2[0] << "C" << endl;
	return 0;
}

Measured memory_bytes: 3608
#include"stdio.h"
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==b){
      printf("Draw\n");
      return 0;
    }
    if(a==1)a=14;
    if(b==1)b=14;
    if(a>b)printf("Alice\n");
    else printf("Bob\n");
}


Measured memory_bytes: 1660
use proconio::input;
#[derive(Debug)]
struct UnionFind {
    par: Vec<usize>,
    sizes: Vec<usize>
}
impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let par = (0..n).collect();
        let sizes = vec![1; n];
        UnionFind{par, sizes}
    }
    fn find(&mut self, x: usize) -> usize {
        if x == self.par[x] { x } else {
            self.par[x] = self.find(self.par[x]);
            self.par[x]
        }
    }
    fn unite(&mut self, x: usize, y: usize) {
        let mut x = self.find(x);
        let mut y = self.find(y);
        if x == y { return; }
        if self.sizes[x] < self.sizes[y] {
            std::mem::swap(&mut x, &mut y);
        }
        self.par[y] = x;
        self.sizes[x] += self.sizes[y];
    }
    fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }
    fn size(&mut self, x: usize) -> usize {
        let t = self.find(x);
        self.sizes[t]
    }
}
fn main() {
    input! {
        (n, m): (usize, usize),
        ab: [(usize, usize); m]
    }
    let mut uf = UnionFind::new(n);
    for (a, b) in ab {
        uf.unite(a - 1, b - 1);
    }
    println!("{}", uf.par.iter().enumerate().filter(|(i, e)| i == *e).count() - 1);
}

Measured memory_bytes: 6220
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <utility>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define MOD 1000000007

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int A = -1;
  int Z = -1;
  REP(i, s.size()){
    if(s[i] == 'Z'){
      Z = i;
    }else if(s[i] == 'A' && A == -1){
      A = i;
    }
  }
  cout << (Z-A+1) << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }


int main() {
    int a, b;
    while(cin >> a >> b){
        string s = to_string((a + b));
        cout << s.length() << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3272
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();

		System.out.println(x >= a && a + b >= x ? "YES" : "NO");
	}

}


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------


//def function
//------------------------------------------

//main
//------------------------------------------

signed main(){
  VI num(5);
  REP(i, 5){
    cin >> num.at(i);
  }

  int ans=0;
  int mini=10;
  REP(i, 5){
    if(num.at(i)%10!=0){
      ans += (num.at(i)/10+1)*10;
      mini = min(mini, num.at(i)%10);
    }else{
      ans += num.at(i);
    }
  }
  if(mini!=10) ans += mini%10 - 10;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int A, B, T, sumA=0, ans=0, i=1; cin >> A >> B >> T;
  while(sumA<T+0.5) {
    sumA+=A;
    if (sumA < T+0.5) ans += B;
    i++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


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

	public void solve(Scanner sc) {
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		List<Integer> results = new ArrayList<>();
		results.add(1);
		for(int i=2; i<=a && i<=b; i++) {
			if(a%i==0 && b%i==0){
				results.add(i);
			}
		}
		
		int index = results.size() - k;
		System.out.println(results.get(index));
	}
}


Measured memory_bytes: 21844
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

sys.setrecursionlimit(1000000)

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

class Node:
    def __init__(self):
        self.children0 = []
        self.parent0 = -1
        self.depth = -1

    def get_depth(self):
        if self.depth == -1:
            childdepths = sorted([nodes[ch0].get_depth() for ch0 in self.children0], reverse=True)
            res = 0
            for i0, cd in enumerate(childdepths):
                res = max(res, cd + i0 + 1)
            self.depth = res
        return self.depth

def main():
    for i0 in range(1, N):
        pa1 = int(input())
        assert pa1 >= 1
        pa0 = pa1 - 1
        nodes[i0].parent0 = pa0
        nodes[pa0].children0.append(i0)

    print(nodes[0].get_depth())

N = int(input())
nodes = [Node() for i in range(N)]
main()


Measured memory_bytes: 248300
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int h, w, n, a, j = 0, k;
    cin >> h >> w >> n;
    vector<int> c(h * w);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a);
        while(a-- > 0) c[j++] = i;
    }
    for(int i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            k = c[i*w + (i % 2 == 0 ? j : w - 1 - j)];
            printf("%d%c", k, (j != w - 1 ? ' ' : '\n'));
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	unsigned long long N;
	int K;
	cin >> N;
	cin >> K;

	unsigned long long ans;

	ans = (unsigned long long)(log((double)N) / log((double)K)) + 1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)

int main(){
    int N,M;
    cin >> N >> M;
    if(M==N){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.Integer.parseInt;
//import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		sc.close();
		out.println((double)((n/2)+(n%2))/n);
	}
}


Measured memory_bytes: 22224
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<climits>
#include<queue>
 
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<long long>> a(n,vector<long long>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			bool b = true;
			for (int k = 0; k < n; k++) {
				if (k == i || k == j)continue;
				if (a[i][k] + a[j][k] < a[i][j]) {
					cout << -1 << endl;
					return 0;
				}
				if (a[i][k] + a[j][k] == a[i][j]) {
					b = false;
				}
			}
			if (b) ans += a[i][j];
		}
	}

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

Measured memory_bytes: 1024