akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 7;

ll x ,y; vpi vec;
ll cnt[MAX] , dp[102][MAX];

ll go( ll i , ll rem ){

    if ( i == x ){
        return rem == 0 ? 0 : OO;
    }

    ll& ret = dp[i][rem];
    if ( ~ret ) return ret;

    ll leave = go(i+1 , rem) , pick = OO;
    if ( vec[i].S <= rem ){
        pick = go(i+1 , rem - vec[i].S) + vec[i].F;
    }
    return ret = min( leave , pick );
}

int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> x >> y; vec.resize(x); mem(dp , -1);
    for ( auto& i : vec ) cin >> i.F >> i.S;

    ll mx = 0;
    for ( int i = 0; i < MAX; ++i ){
        cnt[i] = go(0 , i);
        if ( cnt[i] <= y ) mx = max( mx , (ll)i );
    }
    cout << mx;
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 80768
import java.util.Scanner;

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

    String s = sc.next();
    String t = sc.next();

    if (t.startsWith(s)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35768
import numpy as np
n, k = (int(x) for x in input().split())
if n%2==0:
  if k <= n/2:
    print("YES")
  else:
    print("NO")
if n%2!=0:
  if k <= np.ceil(n/2):
    print("YES")
  else:
    print("NO")


Measured memory_bytes: 12496
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <cstdio>
#include <string>
#include <fstream>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;
//ABC082.c

int main(void) {
	string N,t;
	getline(cin, N);
	getline(cin, t);
 //B
	sort(N.begin(), N.end()); //昇順ソート
	sort(t.rbegin(), t.rend());//降順ソート

	if (N < t)puts("Yes");//stringでは辞書式に比較される
	if (N >= t)puts("No");

	/* //C
	vector<int>b(N+1,0);
	int change = 0;
	
	for (int i = 1; i < N+1; i++) {
		cin >> t;
		if (t > N)change++;
		else b[t]++;
	}
	for (int i = 1; i < N+1; i++) {
		if (b[i] != i &&b[i]!=0) {
			if(b[i]>i)
			change +=abs( b[i] - i);
			else change += b[i];
		}
	}
	printf("%d", change);
	*/
	return 0;
}

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

#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <unordered_map>

#include <cmath>    //floor ceil pow
#include <cstdio>
#include <climits>  //INT_MAX
#include <cstring>  
#include <cstdlib>  //abs
#include <ctime>

#include <string>
#include <bitset>
#include <limits>

#include <fstream>
#include <numeric>
#include <sstream>

using namespace std;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define lli long long int
#define MOD 1000000000+7

lli fast_expo(int b, int e)
{
    // never use 1e9+7 in mod and 
    //pow func in fast Exponentiation bcoz (1e9,100) is inf if 1e9,200 is to be computed :)
    lli res=1;
    while(e>0)
    {
        if(e%2) res = (res*b)%MOD;
        b = (b*b)%MOD;
        e /= 2;
        cout<<res<<" "<<b<<" "<<e<<endl;
    }
    
    return res%MOD;
}

int main ()
{
    /*int tt;
    cin >> tt;
    while(tt--)
    {*/
        lli ans=0;
        string s,t;
        cin >> s >>t;
        int n=s.size();
        
        for (int i=0;i<n;i++) {
            if(s[i]!=t[i]) ans++;
        }
        
        cout<<ans<<endl;
        
    //}
    return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const ll mod = 1e9 + 7;
int main()
{
	SPEED
	int n, m;
	cin >> n >> m;
	int ht[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> ht[i];
	}

	vector<vector<int>> adj(n);
	int a, b;

	for (int i = 0; i < m; ++i)
	{
		cin >> a >> b;
		a--;b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	int count = 0;

	for (int i = 0; i < n; ++i)
	{
		bool condition = true;
		for (int j = 0; j < adj[i].size(); ++j)
		{
			if (ht[i] <= ht[adj[i][j]])
			{
				condition = false;
				break;
			}
		}

		if (condition)
		{
			count++;
		}
	}

	cout << count;

	return 0;
}

Measured memory_bytes: 8740
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[310][310][310] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll H[310];
    H[0] = 0;
    rep(i,0,N) cin >> H[i+1];
    // vector<ll> v;
    // rep(i,0,N) v.push_back(H[i]);
    // v.push_back(0);
    // sort(v.begin(), v.end());
    rep(i,0,N+1){
        rep(j,0,K+1){
            rep(k,0,N+2){
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    // rep(i,0,N+1){
    //     if(H[0] == v[i]){
    //         dp[1][0][i] = v[i];
    //     }else{
    //         dp[1][0][i] = INF;
    //     }
    // }
    // rep(i,0,N+1) dp[1][1][i] = 0;

    rep(i,0,N){ // i番目まで見てすでにj回操作した 最後の高さがv[k]
        rep(j,0,K+1){
            rep(k,0,N+1){
                if(dp[i][j][k] == INF) continue;
                // print(i,j,k);
                // 操作しない
                if(H[k] >= H[i+1]){
                    dp[i+1][j][i+1] = min(dp[i+1][j][i+1], dp[i][j][k]);
                }else{
                    dp[i+1][j][i+1] = min(dp[i+1][j][i+1], dp[i][j][k] + H[i+1] - H[k]);
                }
                // 操作する
                if(j == K) continue;
                // 0 or hidari or migi
                ll alt[2] = {0, k};
                rep(m,0,2){
                    ll l = alt[m];
                    if(l == N+1) continue;
                    // if(i == 2 && j == 0 && k == 2) print(l);
                    if(H[k] >= H[l]){
                        // if(i == 2 && j == 0 && k == 2) print(l);
                        dp[i+1][j+1][l] = min(dp[i+1][j+1][l], dp[i][j][k]);
                    }else{
                        dp[i+1][j+1][l] = min(dp[i+1][j+1][l], dp[i][j][k] + H[l] - H[k]);
                    }                   
                }
            }
        }
    }
    // print(dp[3][1][1]); // 2 0 2 => 3 1 3
    // print(dp[4][1][4]);
    ll ans = INF;
    rep(h,0,N+1){
        ans = min(ans, dp[N][K][h]);
    }
    print(ans);
    

}

Measured memory_bytes: 227584
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(0, i, N)
    {
        cin >> a.at(i);
    }

    ll S = a.at(0);
    rep(1, i, N)
    {
        S = S ^ a.at(i);
    }

    rep(0, i, N)
    {
        cout << (S ^ a.at(i)) << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 4672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, p, a;
  in2(n, p);
  vector<ll> c(n), d0(n, 0), d1(n, 0);
  rep(i, n)
    in(c[i]);
  if(c[0] % 2 == 1){
    d1[0] = 1;
    d0[0] = 1;
  }
  else
    d0[0] = 2;
  rep(i, n - 1){
    if(c[i + 1] % 2 == 1){
      d1[i + 1] = d0[i] + d1[i];
      d0[i + 1] = d0[i] + d1[i];
    }
    else{
      d1[i + 1] = d1[i] * 2;
      d0[i + 1] = d0[i] * 2;
    }
  }
  if(p == 1)
    out(d1[n - 1]);
  else
    out(d0[n - 1]);
  memi;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    n /= 200;
    cout << 10 - n << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int main()
{
    int dp[10005][1 << 4];
    int row[10005] = {}; //bit
    int H, N;
    cin >> H >> N;
    for(int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        row[y] |= (1 << x);
    }
    fill_n(*dp, 10005 * 16, -INF);
    dp[0][row[0]] = 0;
    for(int i = 0; i < H - 1; i++) {
        for(int j = 0; j < (1 << 4); j++) {
            if(dp[i][j] == -INF) continue;
            dp[i + 1][row[i + 1]] = max(dp[i + 1][row[i + 1]], dp[i][j]);
            if(j == 0 && row[i + 1] == 0) {
                dp[i + 1][(1 << 4) - 1] = max(dp[i + 1][(1 << 4) - 1], dp[i][j] + 2);
            }
            for(int k = 0; k < 3; k++) {
                int bit = (1 << k) | (1 << (k + 1));
                if((j & bit) == 0 && (row[i + 1] & bit) == 0) {
                    dp[i + 1][row[i + 1] | bit] = max(dp[i + 1][row[i + 1] | bit], dp[i][j] + 1);
                }
            }
        }
    }
    int maxv = 0;
    for(int i = 0; i < (1 << 4); i++) {
        maxv = max(dp[H - 1][i], maxv);
    }
    cout << maxv << endl;
    return (0);
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
	int n;
	cin >> n;
	double a[1010];

	double x=0;
	FOR(i,n){
		cin >> a[i];
		x+=1/a[i];
	}
	cout << fixed  << setprecision(10);
	cout << 1/x << endl;
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
vector<ll> getF(ll n){
  vector<ll> ret;
  for(ll i = 1; i*i <= n; ++i){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n) ret.push_back(n/i);
    }
  }
  sort(ret.rbegin(),ret.rend());
  return ret;
}
ll check(vector<ll>& a,ll f){
  deque<ll> q;
  for(ll i : a){
    ll rem = i%f;
    if(rem) q.push_back(rem);
  }
  sort(begin(q),end(q));
  ll left = 0,right = 0;
  while(!q.empty()){
    if(left <= right){
      left += q[0];
      q.pop_front();
    }
    else{
      right += f-q.back();
      q.pop_back();
    }
  }
  return max(left,right);
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,k,tot = 0;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
    tot += a[i];
  }
  vector<ll> v = getF(tot);
  for(ll i : v){
    if(check(a,i) <= k){
      cout << i;
      return 0;
    }
  }
  cout << 1;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int n, a, b;
  cin >> n >> a >> b;
    int ans = 0;
  for(int i= 1;i < n+1;i++){
      int sum = i/10000 +(i%10000)/1000 +(i%1000)/100 + (i%100)/10+(i%10);
      if(sum <= b && a <= sum) ans += i;
  }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll m=998244353;
int a[100005];
int b[100005];
ll cnt(int x,int y)
{
    ll ans=1;
    for(int i=1; i<=y; i++)
    {
        ans=ans*x%m;
    }
    return ans;

}
int main()
{
    int n;
    scanf("%d",&n);
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    int flag=1;
    int maxx=0;

    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>maxx)
            maxx=a[i];
        if(i==0&&a[i]!=0)
            flag=0;
        if(i!=0&&a[i]==0)
            flag=0;
        b[a[i]]++;
    }
    if(n==1&&a[0]==0)
    {
        cout<<"1"<<endl;
        return 0;
    }
    if(flag==0)
    {
        cout<<"0"<<endl;
        return 0;
    }
    ll ans=1;
        for(int i=2; i<=maxx; i++)
        {
            ans=ans*cnt(b[i-1],b[i])%m;
            if(i<=maxx)
            {
                if(b[i]==0)
                {
                    cout<<"0"<<endl;
                    return 0;
                }
            }
        }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    string S; cin >> S;
    reverse(S.begin(), S.end());
    vector<string> str = {"dream", "dreamer", "erase", "eraser"};
    rep(i,4){
        reverse(str[i].begin(), str[i].end());
    }

    int index = 0;
    while(true){
        int prev_index = index;
        rep(i,4){
            int n = str[i].size();
            bool isOK = true;
            rep(j,n){
                if (S[index+j] != str[i][j]){
                    isOK = false;
                }
            }
            if (isOK) {
                index += n;
                break;
            }
        }
        if (prev_index == index){
            cout << "NO" << endl;
            return 0;
        }
        if (index == S.size()){
            cout << "YES" << endl;
            return 0;
        }

    }
}

Measured memory_bytes: 3692
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
struct Point
{
	int x,y;
}p[303030];
bool cmpx(const Point &p1,const Point &p2)
{
	return p1.x<p2.x;
}
bool cmpy(const Point &p1,const Point &p2)
{
	return p1.y<p2.y;
}
struct Node
{
	Node *lch,*rch;
	int l,r;
	int ma,lz;
}*rt;
int nx[303030];
Node *Build(int l,int r)
{
	Node *ret=new Node;
	ret->l=l;
	ret->r=r;
	ret->lz=0;
	ret->ma=nx[l];
	if(l==r)
	{
		ret->lch=ret->rch=NULL;
		return ret;
	}
	int mid=(l+r)>>1;
	ret->lch=Build(l,mid);
	ret->rch=Build(mid+1,r);
	return ret;
}
void update(Node *x)
{
	x->ma=max(x->lch->ma,x->rch->ma);
}
void add(Node *x,int v)
{
	x->ma+=v;
	x->lz+=v;
}
void down(Node *x)
{
	if(x->lz)
	{
		add(x->lch,x->lz);
		add(x->rch,x->lz);
		x->lz=0;
	}
}
void modify(Node *x,int l,int r,int v)
{
	if(l<=x->l&&r>=x->r)
	{
		add(x,v);
		return;
	}
	int mid=(x->l+x->r)>>1;
	down(x);
	if(l<=mid)
		modify(x->lch,l,r,v);
	if(mid<r)
		modify(x->rch,l,r,v);
	update(x);
}
int query(Node *x,int l,int r)
{
	if(l<=x->l&&r>=x->r)
		return x->ma;
	int mid=(x->l+x->r)>>1,ret=-214748364;
	down(x);
	if(l<=mid)
		ret=max(ret,query(x->lch,l,r));
	if(mid<r)
		ret=max(ret,query(x->rch,l,r));
	return ret;
}
int st1[303030],stv1[303030],sn1;
int st2[303030],stv2[303030],sn2;
int main()
{
	int w,h,n,ans=0;
	scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&p[i].x,&p[i].y);
		if(p[i].x==0||p[i].x==w||p[i].y==0||p[i].y==h)
		{
			i--;
			n--;
		}
	}
	++n;
	p[n].x=0;
	p[n].y=0;
	++n;
	p[n].x=w;
	p[n].y=h;
	sort(p+1,p+1+n,cmpx);
	for(int i=1;i<=n;i++)
		nx[i]=h-p[i].x;
	rt=Build(1,n);
	st1[0]=st2[0]=0;
	st1[1]=1;
	stv1[1]=0;
	st2[1]=1;
	stv2[1]=h;
	sn1=sn2=1;
	for(int i=2;i<=n;i++)
	{
		ans=max(ans,p[i].x+query(rt,1,i-1));
		if(p[i].y<=h/2)
		{
			while(sn1&&p[i].y>=stv1[sn1])
			{
				modify(rt,st1[sn1-1]+1,st1[sn1],stv1[sn1]-p[i].y);
				sn1--;
			}
			st1[++sn1]=i-1;
			stv1[sn1]=p[i].y;
		}
		else
		{
			while(sn2&&p[i].y<=stv2[sn2])
			{
				modify(rt,st2[sn2-1]+1,st2[sn2],p[i].y-stv2[sn2]);
				sn2--;
			}
			st2[++sn2]=i-1;
			stv2[sn2]=p[i].y;
		}
		if(stv1[sn1]==0)
			sn1--;
		if(stv2[sn2]==h)
			sn2--;
		st1[++sn1]=i;
		stv1[sn1]=0;
		st2[++sn2]=i;
		stv2[sn2]=h;
	}
	sort(p+1,p+1+n,cmpy);
	for(int i=1;i<=n;i++)
		nx[i]=w-p[i].y;
	rt=Build(1,n);
	st1[0]=st2[0]=0;
	st1[1]=1;
	stv1[1]=0;
	st2[1]=1;
	stv2[1]=w;
	sn1=sn2=1;
	for(int i=2;i<=n;i++)
	{
		ans=max(ans,p[i].y+query(rt,1,i-1));
		if(p[i].x<=w/2)
		{
			while(sn1&&p[i].x>=stv1[sn1])
			{
				modify(rt,st1[sn1-1]+1,st1[sn1],stv1[sn1]-p[i].x);
				sn1--;
			}
			st1[++sn1]=i-1;
			stv1[sn1]=p[i].x;
		}
		else
		{
			while(sn2&&p[i].x<=stv2[sn2])
			{
				modify(rt,st2[sn2-1]+1,st2[sn2],p[i].x-stv2[sn2]);
				sn2--;
			}
			st2[++sn2]=i-1;
			stv2[sn2]=p[i].x;
		}
		if(stv1[sn1]==0)
			sn1--;
		if(stv2[sn2]==w)
			sn2--;
		st1[++sn1]=i;
		stv1[sn1]=0;
		st2[++sn2]=i;
		stv2[sn2]=w;
	}
	printf("%d",ans*2);
	return 0;
}

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

flg_inc = False
flg_dec = False

count = 1
for i in range(1, len(a)):
    if a[i] < a[i - 1]:
        flg_dec = True
        if flg_inc:
            count += 1
            flg_inc = False
            flg_dec = False
    elif a[i] > a[i - 1]:
        flg_inc = True
        if flg_dec:
            count += 1
            flg_inc = False
            flg_dec = False

print(count)

Measured memory_bytes: 14252
import math
list=[int(input()) for x in range(5)]
list.sort(key=lambda x:x%10)
count=0
for l in list:
  if l%10==0:
    count+=1
if count==5:
  print(sum(list))
else:
  a=list[count]
  del list[count]
  ans=[]
  for t in list:
    ans.append(math.ceil(t/10)*10)
  print(sum(ans)+a)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)

int main()
{
    fast;
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>v1(n),v2(m);
    vector<ll>sumv1(n+1),sumv2(m+1);
    for(ll i=0;i<n;i++)
    {
        cin>>v1[i];
        i?v1[i]+=v1[i-1]:v1[i]+=0;
        sumv1[i+1]=v1[i];
    }
    for(ll i=0;i<m;i++)
    {
        cin>>v2[i];
        i?v2[i]+=v2[i-1]:v2[i]+=0;
        sumv2[i+1]=v2[i];
    }
    ll ans=0,j=m;
    for(ll i=0;i<n+1;i++)
    {
        if(sumv1[i]>k)break;
      //  int j=0;
        while(sumv2[j]>k-sumv1[i])
        {
            j--;
        }
       // cout<<i<<" "<<j<<" ";
        ans=max(ans,i+j);
    }
    cout<<ans<<endl;

}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n < 3200) cout << "red" << '\n';
  else {
    string s;
    cin >> s;
    cout << s << '\n';
    
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>

using namespace std;

#define D(x) x
#define REP(i,a,b) for (int i = (a); i < (b); ++i)
#define REPR(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int> > VII;

void solve() {
    int T, K; cin >> T >> K;
    int m = 0;
    REP(k,0,K) {
        int x; cin >> x;
        m = max(m, x);
    }
    if (m > T - m) {
        cout << m - (T-m) - 1 << endl;
    } else  {
        cout << 0 << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    solve();

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if((C - A) * (C - B) < 0) Print("Yes");
    else Print("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll modpow(ll a, ll b, ll m) {
  if (b == 0) return 1;
  ll ret;
  if (b % 2 == 0) {
    ll t = modpow(a, b / 2, m) % m;
    ret = t * t % m;
  } else {
    ll t = modpow(a, (b - 1) / 2, m) % m;
    ret = a * t % m * t % m;
  }
  ret %= m;
  return ret;
}

ll inv(ll a, ll m) { return modpow(a, m - 2, m); }

int main() {
  ll n, p;
  cin >> n >> p;
  string s;
  cin >> s;

  ll ans = 0;
  if (p == 2) {
    REP(i, n) {
      if ((ll)(s[i] - '0') % 2 == 0) {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  } else if (p == 5) {
    REP(i, n) {
      ll x = s[i] - '0';
      if (x == 0 || x == 5) {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  vector<ll> f(n + 1, 0);
  REP(i, n) { f[i + 1] = ((f[i] * 10) % p + (ll)(s[i] - '0') % p) % p; }
  ll c = 1;
  ll inv10 = inv(10, p);
  vector<ll> cnt(p, 0);

  cnt[0] = 1;
  REP(i, n) {
    (c *= inv10) %= p;
    (f[i + 1] *= c) %= p;
    cnt[f[i + 1]]++;
  }
  REP(i, p) {
    ll d = cnt[i];
    ans += d * (d - 1) / 2;
  }
  cout << ans << endl;
}

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

 
int main(){
    
    int n,ans=0;
    cin>>n;
    vector<int> a(n),b(n),c(n-1);
    rep(i,n)cin>>a.at(i);
    rep(i,n)cin>>b.at(i);
    rep(i,n-1)cin>>c.at(i);
     
     rep(i,n){
         ans+=b.at(a.at(i)-1);
     }
     rep(i,n-1){
         if(a.at(i+1)==a.at(i)+1)ans+=c.at(a.at(i)-1);
     }
    cout<<ans;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


ll N, ans;
int len;

void dfs(int depth, bool th, bool fi, bool se, ll val){
    if(depth == len){
        if(th && fi && se && val <= N) ans++;
        return;
    }
    dfs(depth + 1, true, fi, se, val * 10 + 3);
    dfs(depth + 1, th, true, se, val * 10 + 5);
    dfs(depth + 1, th, fi, true, val * 10 + 7);
}

signed main(){
    cin >> N;
    len = (to_string(N)).length();
    REP(i, len) dfs(i, false, false, false, 0);
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int n;
    cin >> n;
    vector<int> hs(n);
    rep(i, 0, n) {
        int h;
        cin >> h;
        hs[i] = h;
    }

    int ans = 1;
    rep(i, 1, n) {
        bool ok = true;
        rep(j, 0, i) {
            if (hs[i] >= hs[j]) {
                
            }
            else
                ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//..1..2..3:Correct:Solved by F2tekkz:)
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
int main(){
	sonic;
	str a , b;
	cin >> a >> b;
	cout << b << a;	
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	pair<int, pair<int, int> > p[1000];
	for (int n, m, a; cin >> n >> m >> a&&n;) {
		memset(p, 0, sizeof(p));
		for (int i = 0; i < m; i++) {
			cin >> p[i].first >> p[i].second.first >> p[i].second.second;
		}
		sort(p, p + 1000, greater < pair<int, pair<int, int> > >());
		int tmp = -1;
		for (int i = 0; i < m; i++) {
			if (tmp == p[i].first)continue;
			if (p[i].second.first == a) {
				a = p[i].second.second;
				tmp = p[i].first;
				continue;
			}
			if (p[i].second.second == a) {
				a = p[i].second.first;
				tmp = p[i].first;
				continue;
			}
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC117D();

#if 1
int main()
{
	ABC117D();
	fflush(stdout);
	return 0;
}
#endif

static void ABC117D()
{
	int N;
	LLONG K;
	getint(N);
	getint(K);

	std::vector<LLONG> an(N);
	std::vector<int> bitSum(64, 0), kBits(64, 0);
	for (int i = 0; i < N; i++) {
		getint(an[i]);

		LLONG bit = 1;
		int pos = 0;
		while (bit <= an[i]) {
			if (bit & an[i]) {
				bitSum[pos]++;
			}
			bit <<= 1LL;
			pos++;
		}
	}

	LLONG bit = 1;
	int pos = 0;
	while (bit <= K) {
		if (bit & K) {
			kBits[pos]++;
		}
		bit <<= 1;
		pos++;
	}

	bool small = false;
	std::vector<int> bits(64, 0);
	for (int p = pos - 1; p >= 0; p--) {
		int better = 0;
		if (bitSum[p] * 2 < N) {
			better = 1;
		}

		if (!small) {
			if (kBits[p]) {
				bits[p] = better;
				if (better == 0) {
					small = true;
				}
			}
			else {
				bits[p] = 0;
			}
		}
		else {
			bits[p] = better;
		}
	}
	LLONG X = 0;
	for (int i = 0; i < pos; i++) {
		if (bits[i]) {
			X |= 1LL << i;
		}
	}

	LLONG ans = 0;
	for (int i = 0; i < N; i++) {
		ans += X ^ an[i];
	}
	printf("%lld\n", ans);
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA"<<endl;
    return 0;
  }
  int c=0;
  for(int i=1;i<s.size();i++){
    if(2<=i&&i<s.size()-1){
      if(s[i]=='C')c++;
      else if(isupper(s[i])){
        cout<<"WA"<<endl;
        return 0;
      }
    }
    else if(isupper(s[i])){
      cout<<"WA"<<endl;
      return 0;
    }
  }
  if(c==1)cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

def _get_distance(p1, p2):
    return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5

def _get_min_distance(points):
    min_d = 400
    for p1, p2 in itertools.combinations(points, 2):
        min_d = min(min_d, _get_distance(p1, p2))
    return min_d

def closest_pair_distance(points):
    n = len(points)
    if n <= 3:
        return _get_min_distance(points)
    else:
        mid = n // 2
        px, py = zip(*points)
        if len(set(px)) > len(set(py)):
            points.sort(key = lambda p: p[0])
            # axis: x; 0, y; 1
            axis1 = 0
            axis2 = 1
        else:
            points.sort(key = lambda p: p[1])
            axis1 = 1
            axis2 = 0
        A_points = points[:mid]
        B_points = points[mid:]
        d_Amin = closest_pair_distance(A_points.copy())
        d_Bmin = closest_pair_distance(B_points.copy())
        dist = min(d_Amin, d_Bmin)
        min_d = dist
        for ap in A_points[::-1]:
            if B_points[0][axis1] - ap[axis1] >= dist:
                break
            for bp in B_points:
                if bp[axis1] - ap[axis1] >= dist:
                    break
                if ap[axis2] - dist < bp[axis2] < ap[axis2] + dist:
                    min_d = min(min_d, _get_distance(ap, bp))
        return min_d

# Acceptance of input
import sys

file_input = sys.stdin

n = int(file_input.readline())

P = [tuple(map(float, line.split())) for line in file_input]

# Solve
ans = closest_pair_distance(P)

print('{:f}'.format(ans))

Measured memory_bytes: 30776
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	else if (s == "Cloudy")cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int count = 0;
    REP(i, A + 1) {
        REP(j, B + 1) {
            REP(k, C + 1) {
                if (500 * i + 100 * j + 50 * k == X) {
                    count++;
                }
            }
        }
    }
    cout << count;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3584
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  int n;
  string x;
  cin>>n;
  vector<int> t(n);
  vector<string> S(n);
  rep(i,n){cin>>S[i]>>t[i];}
  cin>>x;
  int k=0;
  rep(i,n){if(S[i]==x){k=i;}}
  int j=0;
  REP(l,k+1,n){j+=t[l];}
  cout<<j<<endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

class PrimeNumber{
public:
    int N;
    vector<ll> table;

    void makeTable(int n){
        N = n;
        vector<bool> v(n+1, true);
        v[0] = false;
        v[1] = false;
        int m = sqrt(n);
        for(int i=2; i<=m; i++){
            if(v[i]){
                int j = i*2;
                while(j <= n){
                    v[j] = false;
                    j += i;
                }
            }
        }
        for(int i=0; i<=n; i++){
            if(v[i]){
                table.push_back(i);
            }
        }
    }

    static bool is_prime(ll n){
        if(n < 2){
            return false;
        }
        ll m = sqrt(n);
        for(ll i=2; i<=m; i++){
            if(n%i == 0){
                return false;
            }
        }
        return true;
    }

    static map<ll,int> factorization(ll n){
        map<ll,int> mp;
        for(ll i=2; i*i<=n; i++){
            while(n%i == 0){
                n /= i;
                mp[i]++;
            }
        }
        if(n > 1){
            mp[n]++;
        }
        return mp;
    }
};

signed main(){
    ll a, b;
    cin >> a >> b;

    ll g = __gcd(a, b);

    ll ans = 1;

    if(g > 1){
        auto mp = PrimeNumber::factorization(g);
        ans += mp.size();
    }

    cout << ans << endl;    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

int x[5];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   rep(i, 0, 5) { cin >> x[i]; }
   rep(i, 0, 5) {
      if (x[i] == 0) {
         cout << i + 1 << endl;
         return 0;
      }
   }
   return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			10005
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
	ll maxv = 0,i,n,j;
	cin>>n;
	string s;
	unordered_map<string,ll> freq;
	for(i = 0;i<n;i++)
	{
		cin>>s;
		freq[s]++;
		maxv = max(maxv,freq[s]);
	}
	
	vector<string> a;
	for(auto x : freq)
	{
		if(x.s == maxv)
		a.pb(x.f);
	}
	sort(a.begin(),a.end());
	for(auto x : a)
	cout<<x<<endl;
}

Measured memory_bytes: 26692
N, K = map(int, input().split())
A = list(map(int, input().split()))

visited = [0] * N
cnt = 0
i = 0
loop = 0
while True:
    visited[i] = cnt
    i = A[i] - 1
    cnt += 1
    if visited[i] > 0 or i == 0:
        loop = cnt - visited[i]
        break

m = 0
if K < visited[i]:
    m = K
    i = 0
else:
    m = (K - visited[i]) % loop

for _ in range(m):
    i = A[i] - 1
print(i+1)


Measured memory_bytes: 92156
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
INF=10**9

def bamboo(count,a,b,c):
  if count==N:
    if min(a,b,c)>0:
      return abs(a-A)+abs(b-B)+abs(c-C)-30
    else:
      return INF
  rot0=bamboo(count+1,a,b,c)
  rot1=bamboo(count+1,a+l[count],b,c)+10
  rot2=bamboo(count+1,a,b+l[count],c)+10
  rot3=bamboo(count+1,a,b,c+l[count])+10
  return min(rot0,rot1,rot2,rot3)
print(bamboo(0,0,0,0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef  unsigned long long lli;
int main() {
	lli a;
    double b;
    lli c;
    cin >> a >> b;
    c = b*100 + 0.1;
    a = a*c;
    a = a/100;
    cout << a << endl;
}

Measured memory_bytes: 3684
import numpy as np
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m,x=MI()
    caa=LLI(n)
    caa=np.array(caa,dtype="i8")
    ans=10**9
    for bit in range(1<<n):
        cost = 0
        aa = np.zeros(m, dtype="i8")
        for i in range(n):
            if bit>>i&1:
                cost+=caa[i][0]
                aa+=caa[i][1:]
        if np.sum(aa>=x)==m and cost<ans:ans=cost

    if ans==10**9:print(-1)
    else:print(ans)

main()

Measured memory_bytes: 27316
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  int N, c=1;
  string S;
  cin >> N >> S;
  for (int i=0; i<N-1; i++) {
    if (S[i]!=S[i+1]) {c++;}
  }
  cout << c << endl;
}

Measured memory_bytes: 3692
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int a, b;
int n, m;

void no() {
	cout << "NO\n";
	exit(0);
}

char ans[1200][1200];
void run(int fl = 0) {
	for (int i = 0; i + 1 < n; i += 2)
		for (int j = 0; j + 1 < m; j += 2) {
			if (fl && a == 1 && b == 1) {
				ans[i][j] = '<', ans[i][j + 1] = '>';
				ans[i + 1][j] = '^';
				ans[i + 2][j] = 'v';
				--a, --b;
			}
			else if (a >= 2) {
				ans[i][j] = '<', ans[i][j + 1] = '>';
				ans[i + 1][j] = '<', ans[i + 1][j + 1] = '>';
				a -= 2;
			}
			else if (b >= 2) {
				ans[i][j] = '^';
				ans[i + 1][j] = 'v';
				ans[i][j + 1] = '^';
				ans[i + 1][j + 1] = 'v';
				b -= 2;
			}
			else if (a == 1) {
				ans[i][j] = '<', ans[i][j + 1] = '>';
				a -= 1;
			}
			else if (b == 1) {
				ans[i][j] = '^';
				ans[i + 1][j] = 'v';
				b -= 1;
			}
		}
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> m >> a >> b;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			ans[i][j] = '.';
	if (2 * (a + b) > n * m) {
		no();
	}
	if (a > (m / 2) * n)
		no();
	if (b > (n / 2) * m)
		no();
	if (a + b == (n * m) / 2) {
		if (n % 2 == 0 && m % 2 == 0) {
			if (a % 2 == 1)
				no();
			run();
		}
		else if (n % 2 == 0) {
			if (a % 2 == 1)
				no();
			int now = 0;
			while (now + 1 < n && b)
				ans[now][m - 1] = '^', ans[now + 1][m - 1] = 'v', now += 2, --b;
			run();
		}
		else if (m % 2 == 0) {
			if (b % 2 == 1)
				no();
			int now = 0;
			while (now + 1 < m && a)
				ans[n - 1][now] = '<', ans[n - 1][now + 1] = '>', now += 2, --a;
			run();
		}
		else {
			if (a) {
				ans[n - 1][m - 1] = '>';
				ans[n - 1][m - 2] = '<';
				--a;
			}
			int now = 0;
			while (now + 1 < m - 2 && a)
				ans[n - 1][now] = '<', ans[n - 1][now + 1] = '>', now += 2, --a;
			now = 0;
			while (now + 1 < n && b)
				ans[now][m - 1] = '^', ans[now + 1][m - 1] = 'v', now += 2, --b;
			run(1);
		}
	}
	else {
		if (n % 2 == 1) {
			int now = 0;
			while (now + 1 < m && a)
				ans[n - 1][now] = '<', ans[n - 1][now + 1] = '>', now += 2, --a;
		}
		if (m % 2 == 1) {
			int now = 0;
			while (now + 1 < n && b)
				ans[now][m - 1] = '^', ans[now + 1][m - 1] = 'v', now += 2, --b;
		}
		run();
	}
	cout << "YES\n";
	for (int i = 0; i < n; ++i)
		cout << ans[i] << "\n";
	return 0;
}




Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	long long k;
	cin>>a>>b>>c>>k;
	if(k%2==0)
	{
		cout<<a-b;
	}
	else
	{
		cout<<b-a;
	}
	return 0;
} 

Measured memory_bytes: 256