akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef pair<int, int> pii;
typedef long long LL;

const int maxm = 1e5+5;

vector<pii> G[maxm];
vector<int> ans;
pii a[maxm];
int b[maxm], pos[maxm], cnt[maxm], siz[maxm], fa[maxm];

int Find(int x) {
    return fa[x] == x?x:fa[x] = Find(fa[x]);
}

void dfs(int u, int fa, int id) {
    siz[u] = b[u];
    for(auto i : G[u]) {
        int v = i.first;
        if(v == fa) continue;
        dfs(v, u, i.second);
        siz[u] += siz[v];
    }
    if(siz[u] & 1) ans.push_back(id);
}

void run_case() {
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second;
    sort(a+1, a+1+n);
    for(int i = 1; i <= n; ++i) pos[i] = a[i].first;
    for(int i = 1; i <= n+1; ++i) {
        fa[i] = i;
        b[i] = a[i].second ^ a[i-1].second;
    }
    for(int i = 1; i <= m; ++i) {
        int l, r, tl, tr;
        cin >> l >> r;
        l = lower_bound(pos+1, pos+1+n, l) - pos;
        r = upper_bound(pos+1, pos+1+n, r) - pos;
        tl = Find(l), tr = Find(r);
        if(tl == tr) continue;
        fa[tl] = tr;
        G[l].push_back(make_pair(r, i));
        G[r].push_back(make_pair(l, i));
    }
    for(int i = 1; i <= n+1; ++i) if(b[i]) cnt[Find(i)]++;
    for(int i = 1; i <= n+1; ++i)
        if(Find(i) == i && (cnt[i]&1)) {
            cout << "-1";
            return;
        }
    for(int i = 1; i <= n+1; ++i) {
        if(Find(i) == i) dfs(i, 0, 0);
    }
    sort(ans.begin(), ans.end());
    cout << ans.size() << "\n";
    for(auto i : ans) cout << i << " ";
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    //cout.setf(ios_base::showpoint);cout.precision(8);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double r;
    cin>>r;
    cout<<setprecision(20)<<r*6.28318530717958623200<<endl;
}

Measured memory_bytes: 3800
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int t;
    while(cin>>t){
        if(t==0)break;
        
        int n;
        cin>>n;
        
        int sum=0;
        rep(i,n){
            int a,b;
            cin>>a>>b;
            sum+=b-a;
        }
        
        if(sum>=t){
            cout<<"OK"<<endl;
        }
        else{
            cout<<t-sum<<endl;
        }

    }
    return 0;
}

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

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

int x_flip[] = {0,1,0,1};
int y_flip[] = {0,0,1,1};

signed main(){
    int x, y; cin >> x >> y;
    int ans = INT_MAX;
    rep(i, 4){
        int tx = x_flip[i] ? -x : x;
        int ty = y_flip[i] ? -y : y;
        int btn = ty - tx + x_flip[i] + y_flip[i];
        if(btn > 0) ans = min(ans, btn);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int x, y;
    cin >> x >> y;
    if(x == y){
        output(0);
        return 0;
    }
    
    int ret = inf;
    if(x < y){
        ret = min(ret, y - x);
        if(y >= -x) ret = min(ret, 1 + y + x);
        if(-x >= y) ret = min(ret, 1 + -x - y);
    }
    else{ // x > y
        if(y >= -x) ret = min(ret, 1 + y + x);
        if(-y >= x) ret = min(ret, 1 - y - x);
        if(-y >= -x) ret = min(ret, 2 + x - y);
    }
    
    
    output(ret);
    
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int a[410],dp[410][410],sum[410];
int rec(int l, int r){
	if(l==r)return 0;
	if(dp[l][r]!=0)return dp[l][r];
	dp[l][r]=1e18;
	for(int i=l;i<r;i++)
		dp[l][r]=min(dp[l][r],rec(l,i)+rec(i+1,r)+sum[r]-sum[l-1]);
	return dp[l][r];
}
main(){
	int n,i;
	cin>>n;
	for (i=1;i<=n;i++){
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	cout<<rec(1,n);
}

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

const int N = 2e5+7;
typedef long long LL;
LL a[N];
LL sum[N];
int main() {
    LL n, x, d;
    cin>>n>>x>>d;

    a[1] = x;
    for (int i=2; i<=n; i++) a[i] = a[i-1] + d;

    if ( d < 0) {
        reverse(a+1, a+n+1);
        x = a[1];
        d = -d;
    }

    if (d == 0) {
        if (x == 0) cout<<1<<endl;
        else        cout<<n+1<<endl;
        return 0;
    }

    for (int i=1; i<=n; i++)    sum[i] = sum[i-1] + a[i];
    LL m = 2*d;

    map<LL, vector<pair<LL, LL>>> mp;

    for (int i=0; i<=n; i++) {
        LL mn = 2*sum[i] - sum[n];
        LL mx = sum[n] - 2*sum[n-i];

        LL dd = (mn%m+m)%m;
        LL a = (mn-dd)/m;
        LL b = (mx-dd)/m;

        if (a > b)  swap(a, b);
        mp[dd].push_back({a,b});
    }

    LL ans = 0;
    for (auto pr: mp) {
        auto v = pr.second;
        sort(v.begin(), v.end());

        LL st = -1e18, cur = 0;
        for (auto pr: v) {
            if (pr.second < st) continue;
            cur += pr.second - max(pr.first, st)+1;
            st = pr.second+1;
        }
        ans += cur;
    }
    cout<<ans<<endl;
}


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

double pi = acos(-1);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    double a,b,x;
    cin>>a>>b>>x;
    if(a*a*b/2 <= x) cout <<  180.0 * atan(2*(a*a*b-x)/(a*a*a))/pi << endl;
    else cout << 180.0 * atan(a*b*b/(2*x))/pi << endl;
}

Measured memory_bytes: 256
import numpy as np
n,m = map(int , raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())

sum_x = 0
sum_y = 0

for i in range(n):
    sum_x += i*x[i]-(n-i-1)*x[i]
for i in range(m):
    sum_y += i*y[i]-(m-i-1)*y[i]
print (sum_x*sum_y) % (10**9+7)

Measured memory_bytes: 21992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define REP(i,n) for (int i=1;i<=(n);i++)
typedef long long ll;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n+1);
    REP(i,n){
        cin >> a[i];
    }
    for(int i=k+1;i<=n;i++){
        if(a[i]>a[i-k]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

int main() {
    int N, M;
    std::cin >> N >> M;

    char A[N][N];
    char B[M][M];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            std::cin >> A[i][j];
        }
    }

     for (int i = 0; i < M; ++i) {
        for (int j = 0; j < M; ++j) {
            std::cin >> B[i][j];
        }
    }
    
    
    for (int i = 0; i <= N - M; ++i) {
        for (int j = 0; j <= N - M; ++j) {
            bool found = true;
            for (int k = 0; k < M; ++k) {
                for (int l = 0; l < M; ++l) {
                    if (A[i + k][j + l] != B[k][l]) {
                        found = false;
                        break;
                    }
                }
                if (found == false) {
                    break;
                }
            }
            
            if (found == true) {
                std::cout << "Yes\n";
                return 0;
            }
        }
    }

    std::cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
S=str(input())
lst=['A','C','G','T']
ans=0

for i in range(len(S)):
    cnt=0
    if S[i] in lst:
        cnt+=1
        if i==len(S)-1:
            ans = max(ans,cnt)
            break
        while S[i+1] in lst:
            cnt+=1
            i+=1
            if i+1==len(S):
                break
    ans=max(ans,cnt)

print(ans)

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

int main() {

	int N,K,R,S,P,score=0;
  string T;
  cin>>N>>K>>R>>S>>P>>T;
  map<char,int> es;
  es['r']=P;
  es['s']=R;
  es['p']=S;
  for(int i=0; i<N;i++){
    
    if(i>=K){char a,b,c; a=T.at(i-K); b=T.at(i);if(i+K<N){c=T.at(i+K);}
       if(a==b){T.at(i)='l';}
       else{score += es.at(b);}     
             }
    else{score+=es.at(T.at(i));}
  }
cout<<score<<endl;
}

Measured memory_bytes: 512
icase=0
if icase==0:
    n=int(input())
    s=input()
elif icase==1:
    n=3
    s="())"
elif icase==2:
    n=6
    s=")))())"
elif icase==3:
    n=8
    s="))))(((("

l=[]
r=[]
sim=s[0]
if sim=="(":
    lidx=0
    l.append(1)
    ridx=-1
elif sim==")":
    lidx=0
    l.append(0)
    ridx=0
    r.append(1)

for i in range(1,len(s)):
    if s[i]=="(" and s[i-1]=="(":
        l[lidx]+=1
    elif s[i]=="(" and s[i-1]==")":
        lidx+=1
        l.append(1)
    elif s[i]==")" and s[i-1]==")":
        r[ridx]+=1
    elif s[i]==")" and s[i-1]=="(":
        ridx+=1
        r.append(1)

ll=sum(l)
rr=sum(r)
ds=ll-rr

if len(l)>len(r):
    r.append(0)
xmin=0
x=0
for i in range(len(l)):
    x=x+l[i]-r[i]
    xmin=min(x,xmin)
    
strs="("*(-xmin) + s + ")"*(ds-xmin)
print(strs)
    


Measured memory_bytes: 9204
import collections
n=int(input())
arr=list(map(int,input().split()))
cnt=collections.defaultdict(int)
for val in arr:#あらかじめ各Aiの個数を数えておく
  cnt[val]+=1
sums=sum(arr) #あらかじめAiの総和を求めておく
q=int(input())
for _ in range(q):
  b,c=map(int,input().split())
  diff=(c-b)*(cnt[b])
  sums+=diff
  print(sums)
  cnt[c]+=cnt[b]#CiがBiに変更されたので、Biの数をCiの数に加える
  cnt[b]=0 #Biの数はゼロになる。

Measured memory_bytes: 24116
N = int(input())
A_list = list(map(int, input().split()))


num_2n = sum([(a%2==0) for a in A_list])
num_4n = sum([(a%4==0) for a in A_list])
num_2n1 = sum([(a%2==1) for a in A_list])

if num_2n == N:
    print('Yes')
else:
    # 4n と 2n1のみ
    if num_4n + num_2n1 == N:
        if num_4n >= N//2:
            print('Yes')
        else:
            print('No')
    # 4n と 2n1 と 2n
    else:
        if num_4n >= num_2n1:
            print('Yes')
        else:
            print('No')

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

using namespace std;

int main() {
  int A, B, C, d, ans{};
  cin >> A >> B >> C;
  d = max({A, B, C}) * 3 - A - B - C;
  if (d%2==0) {
    ans = d/2;
  } else {
    ans = (d+3)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
struct node{
    int u,w;
};
node p;
vector<node>q[100005];
int visit[100005];
int dis[100005],flag;
void query(int x){
    if(flag==1) return ;
    for(int i=0;i<q[x].size();i++){
        node y=q[x][i];
        if(visit[y.u]==1){
            if(dis[y.u]!=dis[x]+y.w) {
                flag=1;
                return ;
            }
            else continue;
        }
        visit[y.u]=1;
        dis[y.u]=dis[x]+y.w;
        query(y.u);
    }

}
int main(){
    int n,m,k,u,w;
    while(scanf("%d%d",&n,&m)!=EOF){
        memset(visit,0,sizeof(visit));
        for(int i=0;i<m;i++){
            scanf("%d%d%d",&k,&u,&w);
            p.u=u,p.w=w;
            q[k].push_back(p);
            p.u=k,p.w=-w;
            q[u].push_back(p);
        }
        for(int i=0;i<n;i++){
            if(visit[i]==0){
                flag=0;
                visit[i]=1;
                query(i);
            }
            if(flag==1){
                printf("No\n");
                break;
            }

        }
        if(flag==0) printf("Yes\n");
    }
    return 0;
}



Measured memory_bytes: 12416
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for i in range(n)]
xh.sort()
r,tama=[float('inf')]*n,[0]

for i in range(n):
    x,h=xh[i]
    tmpr=bisect.bisect_left(r,x)
    h-=(tama[-1]-tama[tmpr])*a
    tmp=0
    if h>0:
        tmp=math.ceil(h/a)
    tama.append(tmp)
    tama[i+1]+=tama[i]
    r[i]=x+2*d

print(tama[-1])
# print(r)

Measured memory_bytes: 124120
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);


int main() {
	ll N;
	cin >> N;
	vector<ll> cnt(2, 0L);

	if(N%2==1) {
		cout << 0 << endl;
		return 0;
	}

		N = N/10;
		cnt[1] += N;
	while(true) {
		N = N/5;
		cnt[1] += N;
		if(N==0) break;
	}

	cout << cnt[1] << endl;

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

main = do
  (l,r) <- (\vec -> (vec VU.! 0, vec VU.! 1)) <$> getIntVector

  print $ solve l r

solve l r
  | 2019 <= r-(l-1) = 0
  | otherwise = head list
    where
      list = sort [i*j `mod` 2019 | i <- [l..(r-1)], j <- [(i+1)..r]]


Measured memory_bytes: 242044
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int x,a;cin>>x>>a;
  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    if(a+b <= 2*c) {
        out(a*x + b*y);
        re0;
    }
    
    ll ans;
    if(x <= y) {
        if(2*c <= b) {
            ans = 2*c*y;
        }
        else {
            ans = 2*c*x + b*(y - x);
        }
    }
    else {
        if(2*c <= a) {
            ans = 2*c*x;
        }
        else {
            ans = 2*c*y + a*(x - y);
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int a,b,c;
int ans = 0x3f3f3f3f;

int main(){
	cin>>a>>b>>c;
	
	ans = min(ans, abs(b-a) + abs(c-b));
	ans = min(ans, abs(c-a) + abs(b-c));
	ans = min(ans, abs(a-b) + abs(c-a));
	ans = min(ans, abs(c-b) + abs(a-c));
	ans = min(ans, abs(a-c) + abs(b-a));
	ans = min(ans, abs(b-c) + abs(a-b));
	
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


    
     int solve()
     {  
        int n;cin>>n;
        vi a(n);
        map<string,int> m;
        rep0(n){
            string s;cin>>s;m[s]=i;
            cin>>a[i];
        }
        string s;cin>>s;
        int in=m[s]+1;
        int ans=0;
        rep(in,n) ans+=a[i];
        cout<<ans<<endl;    

        r0   
     }
    signed main()
    {   
        asdf
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N, K;
    string s;
    cin >> N >> s >> K;
    char c = s[K-1];

    rep(i, N){
        if(s[i] != c) s[i] = '*';
    }

    cout << s << endl;


    return 0;
}

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

int main(){
    int n;
    cin >> n;
    ll ans=0,ma=0,p;
    rep(i,n){
        cin >> p;
        ma=max(ma,p);
        ans+=p;
    }

    cout << ans-ma/2 << endl;
    
    

    return 0;
}

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

int main() {
  int n,c,k; cin>>n>>c>>k;
  vector<int> t(n);
  rep(i, n) cin>>t[i];

  int ans=0;
  sort(t.begin(), t.end());
  for (int i=0; i<n;) {
    int tmp=t[i]+k;
    int cnt=1;
    while (i<n) {
      if (cnt>c) break;
      if (t[i]>tmp) break;
      i++;
      cnt++;
    }
    ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;
#define ABS(x) ((x) >= 0 ? (x) : -(x))

int main() {
    int N, t[100000], x[100000], y[100000];
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    int time = 0;
    int pos[2] = {0, 0};
    int yn = 1;
    for (int i = 1; i <= N; i++) {
        if ((ABS(x[i] - pos[0]) + ABS(y[i] - pos[1])) % 2 == (t[i] - time) % 2) {
            if ((ABS(x[i] - pos[0]) + ABS(y[i] - pos[1])) <= (t[i] - time)) ;
            else {
                yn = 0;
                break;
            }
        } else {
            yn = 0;
            break;
        }
        //時刻と位置を更新
        time = t[i];
        pos[0] = x[i];
        pos[1] = y[i];
    }

    if (yn == 1) cout << "Yes" << endl;
    else         cout << "No"  << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define INT long long int
using namespace std;
int n, ans;
map<int, int> d;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 0 ; i < n ; i++ )
    {
        int t;
        cin>>t;
        d[t]++;
    }
    for(map<int, int>::iterator it = d.begin(); it != d.end() ; it++ )
        if( it->first > it->second ) ans += it->second;
        else ans += (it->second - it->first);
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N, M, V, P;
    cin >> N >> M >> V >> P;
    --P;
    vector<unsigned long> A(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    partial_sort(A.begin(), A.end() - P, A.end());
    A.erase(A.end() - P, A.end());
    V -= min(V, P);
    N -= P;
    unsigned long ans{P};
    for(unsigned long i{0}, s{accumulate(A.begin(), A.end(), 0UL)}; i < N; ++i){
        s -= A[i];
        if(!V--)V = 0;
        if(A[i] + M < A.back())continue;
        ans += (A[i] + M) * (N - i - 1) >= s + M * V;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H, W = MI()
    N = I()
    A = [(int(a),i) for i,a in enumerate(input().split(), start=1)]
    A.sort()

    stack = []
    for a,i in A:
        stack.extend([i] * a)

    ans = [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            c = stack.pop()
            if i % 2 == 0:
                ans[i][j] = c
            else:
                ans[i][W - 1 - j] = c
    for a in ans:
        print(*a)


    
if __name__ == '__main__':
    main()


Measured memory_bytes: 42352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  ll t[n],a[n];
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  for(int j=0;j<n;j++){
    cin>>a[j];
  }
  ll dp[n];
  dp[0]=1;
  if(n==1&& t[0]==a[0]){
    cout<<1<<endl;
  }else if(t[n-1]!=a[0]){
    cout<<0<<endl;
  }else{
    if(t[0]>a[0]||t[n-1]<a[n-1]){
      cout<<0<<endl;
      return(0);
    }
    for(int i=1;i<n-1;i++){
      if(t[i-1]<t[i]){
	dp[i]=dp[i-1];
	if(t[i]>a[i]){
	  cout<<0<<endl;
	  return(0);
	}
      }else if(t[i-1]==t[i]){
	if(a[i]>a[i+1]){
	  dp[i]=dp[i-1];
	  if(a[i]>t[i]){
	    cout<<0<<endl;
	    return(0);
	  }
	}else if(a[i]==a[i+1]){
	  dp[i]=(dp[i-1]*min(t[i],a[i]))%1000000007;
	}
      }
    }
    cout<<dp[n-2]<<endl;
  }
  return(0);
}


Measured memory_bytes: 2560
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			printf("\n")
#define nl			cout<<'\n'

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define Frst	first
#define Sec		second

#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

vector<pair<lli,lli> >V[100001];
bool visited[100001];
lli dist[100001];
lli N;

void Djikstra(lli A)
{
    lli i;
    
    memset(visited,0,szof(visited));
    
    rep(i,1,N+1)
    {
        dist[i]=Inf;
    }

    dist[A]=0;

    multiset<pair<lli,lli> >M;

    M.insert({0,A});

    while(!M.empty())
    {
        pair<lli,lli> s = *M.begin();

        M.erase(M.begin());

        lli x=s.Frst,y=s.Sec;

        if(visited[y])
        {
            continue;
        }

        visited[y]=1;

        rep(i,0,V[y].sz())
        {
            lli e=V[y][i].Frst,f=V[y][i].Sec;

            if(dist[y]+f<dist[e])
            {
                dist[e]=dist[y]+f;
                M.insert({dist[e],e});
            }
        }
    }
}

lli Power(lli a,lli b)
{
    lli result=1;
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;
    
    lli T;
    T=1;
    
    while(T--)
    {
        lli M,i;
        cin>>N;
        M=N-1;

        while(M--)
        {
            lli x,y,w;
            cin>>x>>y>>w;

            V[x].pb(mp(y,w));
            V[y].pb(mp(x,w));
        }
        
        lli Q,A;
        cin>>Q;
        
        cin>>A;

        Djikstra(A);

        while(Q--)
        {
            lli x,y;
            cin>>x>>y;
            
            cout<<dist[x]+dist[y];
            nl;
        }
        
        rep(i,1,N+1)
        {
            visited[i]=0;
            dist[i]=0;
            V[i].clear();
        }    
    }

 return 0;
}


Measured memory_bytes: 15472
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int r,c;
    cin >> r >> c;
    vector<vector<int>>rc1(r,vector<int>(c));
    
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin >> rc1.at(i).at(j);
        }
    }
    vector<int>r_plus(c);
    
    for(int i=0; i<c; i++){
        for(int j=0; j<r; j++){
            r_plus.at(i) += rc1.at(j).at(i);
        }
    }
    
    
    rc1.push_back(r_plus);
    
    
    for(int i=0;i<rc1.size();i++){
        int sum=0;
        for(int j=0;j<rc1.at(i).size();j++){
            sum+=rc1.at(i).at(j);
        }
        rc1.at(i).push_back(sum);
    }
    
    for(int i=0;i<rc1.size();i++){
        for(int j=0;j<rc1.at(i).size();j++){
            cout << rc1.at(i).at(j);
            
            if(j!=rc1.at(i).size()-1){
                cout << ' ';
            }
            
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N, K; cin >> N >> K;
	vector<long long> x(N);
	bool z = 0, y = 0;
	long long ans = 1e9;
	for (int i = 0; i < N; i++) cin >> x[i];
	for (int i = 0; i <= N - K; i++) {
		ans = min(ans, abs(x[i]) + abs(x[i + K - 1] - x[i]));
		ans = min(ans, abs(x[i + K - 1]) + abs(x[i + K - 1] - x[i]));
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];

    int m;
    cin >> m;

    vector<int> t(m);
    for(int i = 0; i < m; i++) cin >> t[i];

    map<int,int> mp;
    for(int i = 0; i < n; i++) mp[d[i]]++;

    for(int i = 0; i < m; i++){
        if(mp[t[i]] <= 0){
            cout << "NO" << endl;
            return 0;
        }

        mp[t[i]]--;
    }

    cout << "YES" << endl;
}


Measured memory_bytes: 11136
// AOJ DPL_4_A Coin Combination Problem
// 2018.5.9 bal4u
 
#include <stdio.h>
 
// 数値のハッシュ関数
#define HASHSIZ 3456781
typedef struct { long long v; int f; } HASH;
HASH hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int lookup(long long n)
{
	HASH *p = hash + (int)(n % HASHSIZ);
	while (p->v) {
		if (p->v == n) return p->f;
		if (++p == hashend) p = hash;
	}
	return 0;
}

void insert(long long n)
{
	HASH *p = hash + (int)(n % HASHSIZ);
	while (p->v) {
		if (p->v == n) { p->f++; return; }
		if (++p == hashend) p = hash;
	}
	p->v = n, p->f = 1;
}

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}

long long inLL()
{
    long long n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}

int N;
long long V, V2, V3;
long long a[1002], b[1002], c[1002], d[1002];
int wa, wb, wc, wd;

int input(long long *x)
{
	int i, w;
	long long t;

	w = 0; for (i = 0; i < N; i++) {
		t = inLL();
		if (t <= V3) x[w++] = t;
	}
	return w;
}

int main()
{
	int i, j;
	long long t, ans;

	N = in();
	V = inLL(), V2 = V - 2, V3 = V - 3;
	wa = input(a);
	wb = input(b);
	wc = input(c);
	wd = input(d);

	for (i = 0; i < wa; i++) for (j = 0; j < wb; j++) {
		t = a[i] + b[j];
		if (t <= V2) insert(t);
	}

	ans = 0;
	for (i = 0; i < wc; i++) for (j = 0; j < wd; j++) {
		t = c[i] + d[j];
		if (t <= V2) ans += lookup(V - t);
	}

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


Measured memory_bytes: 55804
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll) 1000000007
#define P pair<ll, ll>



ll n, m, dp[110000];
bool b[110000];
int main() {
	cin >> n >> m;
	dp[0] = 1;
	REP(i, m) {
		ll a;
		cin >> a;
		//a--;
		b[a] = true;
	}
	REP(i, n) {
		if (b[i])dp[i] = 0;
		dp[i + 1] += dp[i];
		dp[i + 2] += dp[i];
		dp[i + 1] %= MOD;
		dp[i + 2] %= MOD;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define N 50
#define M 300
using namespace std;
typedef pair<string,int> P;
vector<P> G[N];

string dijkstra(int S,int T){
  string D[M][N];  
  for(int i=0;i<M;i++) for(int j=0;j<N;j++) D[i][j]="{";
  
  priority_queue<P,vector<P>,greater<P> > Q;
  Q.push(P("",S));
  D[0][S] = "";

  while(!Q.empty()){
    P t = Q.top();Q.pop();
    string cost = t.first;
    int len = cost.size();
    int pos = t.second;
    
    if(len>M-10) return "NO";
    if(pos==T) return cost; 
    if(D[len][pos]<cost) continue;
    
    for(int i=0;i<(int)G[pos].size();i++){
      int npos = G[pos][i].second;
      string ncost = cost+G[pos][i].first;
      int nlen = ncost.size();
      if(D[nlen][npos]<=ncost)continue;
      Q.push(P(ncost,npos));
      D[nlen][npos] = ncost;
    }
  }
  return "NO";
}

int main(){
  int cnt=0;
  while(1){
    cnt++;
    int n,m,s,g;
    cin>>n>>m>>s>>g;
    if(!n&&!m&&!s&&!g) return 0;
    
    for(int i=0;i<N;i++) G[i].clear();

    int D[N][N]={};
    for(int i=0,a,b;i<m;i++){
      string c;
      cin>>a>>b>>c;
      G[a].push_back(P(c,b));
      D[a][b] = 1;
    }

    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  D[i][j] |=D[i][k]+D[k][j]==2;
  
    for(int i=0;i<n;i++)if(!D[i][g]) G[i].clear();

    cout<<dijkstra(s,g)<<endl;
  }
  return 0;
}

Measured memory_bytes: 9332
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  bool ju=false;
  int k,s;
  for(int i=0;i<=h;i++){
    for(int j=0;j<=w;j++){
      if((w-a)*i+a*(h-i)==(h-b)*j+b*(w-j)){
        ju=true; k=i; s=j; break;
      }
    }
  }
  if(ju!=true){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j<(w-a)&&i<(h-b)){
        cout<<1;
      }
      else if(j>=(w-a)&&i<(h-b)){
        cout<<0;
      }
      else if(j<(w-a)&&i>=(h-b)){
        cout<<0;
      }
      else{
        cout<<1;
      }
    }
    cout<<endl;
  }
}
        

Measured memory_bytes: 1280
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    ans += bisect_left(L, L[i]+L[j]) - (j + 1)

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> v(n); {
		rep(i, n) cin >> v[i];
	}
	sort(all(v));

	ll ans = 0;
	rep(i, n) {
		if (i == n - 1) {
			ans += v[i] / 2;
		} else {
			ans += v[i];
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define s second
#define f first
#define MOD 1000000007
using namespace std;


int main()
{
  
    ll knap[105][100005], i, j, a, b, n, w;
    vector<pair<ll, ll>> vec;
    cin >> n >> w;
    for (i = 0; i < n; i++)
    {
        cin >> a >> b;
        vec.pb({a, b});
    }
    sort(vec.begin(),vec.end());
    
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=w;j++)
        {
            if(i==0||j==0)
                knap[i][j]=0;
            else
            {
                if(vec[i-1].f<=j)
                {
                    knap[i][j]=max(knap[i-1][j],knap[i-1][j-vec[i-1].f]+vec[i-1].s);
                    // cout<<vec[i-1].f<<"*"<<vec[i-1].s<<"*";
                }
                else
                {
                    knap[i][j]=knap[i-1][j];
                }
                
            }
            // cout<<knap[i][j]<<" ";
            
        }
        // cout<<endl;
    }
    cout<<knap[n][w];
    return 0;
}


Measured memory_bytes: 80640
//  RAKSHIT KADAM
 #include <bits/stdc++.h>
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
 #warning !!!check the size of arrayss!!!
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define newMOD  998244353
 #define MAX 300006
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define INF 2000000000000000005

 #define vi vector<ll>
#define pi 3.1415926535897932384626433832795
#define Endl endl
#define lb lower_bound
#define ub upper_bound

using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
 //ddfdsfdfs

//ll modInverse(int a, int m){ return power(a, m-2, m);} // if a and m are relativelyprime

void solve()
{
    ll a,b;cin>>a>>b;
    ll price=(a*100)/8;ll i;
    ll lim=0;
    ll f=0;
    for( i=1;i<100000;i++)
    {
         if((i*8)/100!=a){lim=1;}
         else lim=0;
        if(i/10==b && !lim){ f=1;break;}
       
    }
    if(!f)cout<<"-1"<<endl;
    else
    cout<<i<<endl;
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }


 solve();
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace caddi2018b
{
    class A_1222
    {
        static void Main(string[] args)
        {
            // 文字列の入力
            string s = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < s.Length; i++) {
                if (s.Substring(i, 1) == "2") ans++;
            }

            //出力
            Console.WriteLine(ans);
        }
    }
}

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

long long X[ 100010 ];

int main()
{
int i;
int j;
int a;
int N;
int K;
long long iMin;
bool b;
int P;
int M;
int p;
int m;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> K;

	for( i = 0; i < N; i++ ) cin >> X[ i ];

	sort( X, X + N );

	b = false;
	P = - 1;
	M = N - 1;
	for( i = 0; i < N; i++ )
	{
		if( X[ i ] == 0 )
		{
			b = true;
			P = i;
			M = i;

			break;
		}
		else if( X[ i ] > 0 )
		{
			P = i;
			M = i - 1;

			break;
		}
	}

	if( M < 0 )
	{
		cout << X[ K - 1 ] << endl;
		return 0;
	}
	else if( P < 0 )
	{
		cout << - X[ N - K ] << endl;
		return 0;
	}

	iMin = 1000000000;
	for( i = 0; i < N; i++ )
	{
		p = i - P + 1;
		m = M - i + 1;
		if( m > K ) continue;
		if( p > K ) break;

		if( m == K )
		{
			iMin = min( iMin, - X[ i ] );
		}
		else if( p == K )
		{
			iMin = min( iMin, X[ i ] );
		}
		else if( i <= M )
		{
			a = K - m + P;
			if( ! b ) a--;
			if( a < 0 ) continue;
			if( a >= N ) continue;

			iMin = min( iMin, - 2 * X[ i ] + X[ a ] );
		}
		else if( i >= P )
		{
			a = M - ( K - p );
			if( ! b ) a++;
			if( a < 0 ) continue;
			if( a >= N ) continue;

			iMin = min( iMin, 2 * X[ i ] - X[ a ] );
		}
	}

	cout << iMin << endl;

	return 0;
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A,B;
void input(){
    fast_io();
    cin >> N;
    map<ll,ll> cntA,cntB;
    for (int i = 0; i < N; i++)
    {
        ll a; cin >> a;
        cntA[a]++;
    }
    for (int i = 0; i < N; i++)
    {
        ll b; cin >> b;
        cntB[b]++;
    }
    for(auto p:cntA) if(p.second%2) A.push_back(p.first);
    for(auto p:cntB) if(p.second%2) B.push_back(p.first);
}

int solve(){
    ll ans = 0;
    for (int bit = 0; bit < 30; bit++)
    {
        vector<ll> Amod,Bmod;
        ll T = (1LL<<bit);
        for(auto a:A) Amod.push_back(a%(1LL<<(bit+1)));
        for(auto b:B) Bmod.push_back(b%(1LL<<(bit+1)));
        sort(Bmod.begin(),Bmod.end());
        int cnt = 0;
        for(auto a:Amod){
            cnt += lower_bound(Bmod.begin(),Bmod.end(),2*T-a)-lower_bound(Bmod.begin(),Bmod.end(),T-a);
            cnt += lower_bound(Bmod.begin(),Bmod.end(),4*T-a)-lower_bound(Bmod.begin(),Bmod.end(),3*T-a);
        }
        if(cnt%2) ans ^= (1<<bit);
    }
    cout << ans << endl;
    return 0;
}   

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

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int tmp = 0;
    int ans = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'I'){
            tmp ++;
            if(ans < tmp){
                ans = tmp;
            }
        }
        else{
            tmp --;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

std::string s1 = "dream";
std::string s2 = "dreamer";
std::string s3 = "erase";
std::string s4 = "eraser";
int s1length;
int s2length;
int s3length;
int s4length;
std::stack<int > stack;

bool dfs(std::string s){
  while(stack.size()>0){
    int i = stack.top();
    stack.pop();
    if (i==s.length()){
      return true;
    } else {
      if (i + s1length <= s.length()){
        if (s.substr(i,s1length)==s1){
          stack.push(i+s1length);
        }
      }
      if (i + s2length <= s.length()){
        if (s.substr(i,s2length)==s2){
          stack.push(i+s2length);
        }
      }
      if (i + s3length <= s.length()){
        if (s.substr(i,s3length)==s3){
          stack.push(i+s3length);
        }
      }
      if (i + s4length <= s.length()){
        if (s.substr(i,s4length)==s4){
          stack.push(i+s4length);
        }
      }
    }
  }
  return false;
}

int main(){
  s1length = s1.length();
  s2length = s2.length();
  s3length = s3.length();
  s4length = s4.length();
  std::string S;
  std::cin >> S;
  stack.push(0);
  bool ans = dfs(S);
  printf("%s\n",ans?"YES":"NO");
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

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

 bool eq(vi& a, vi& b) {
 	rep(i,0,sz(a)) {
 		if (a[i] != b[i]) return false;
 	}
 	return true;
 }

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vi p(n), q(n), per(n);
	rep(i, 0, n) {
		cin >> p[i];
		--p[i];
	}
	rep(i, 0, n) {
		cin >> q[i];
		--q[i];
		per[i] = i;
	}
	int a = -1, b= -1;
	int cnt = 0;
	do {
		if (eq(per, p)) {
			a = cnt;
		}
		if (eq(per, q)) {
			b = cnt;
		}
		++cnt;
	} while (next_permutation(per.begin(), per.end()));
	cout << abs(a - b) << endl;
}

Measured memory_bytes: 256