akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
int main(){
  ll n;cin>>n;
  ll a[n+1];for(ll i=1;i<=n;i++)cin>>a[i];
  vector<pll> v;
  ll u=n,d=1;
  ll jud1,jud2;
  for(;;){
    ll ma=0;
    ll num;
    for(ll i=d;i<=u;i++){
      if(abs(a[i])>abs(ma)){
        ma=a[i];
        num=i;
      }
    }
    if(ma==0){
      jud1=d-1;
      jud2=u+1;
      break;
    }
    else if(ma>0){
      if(d==num){
        jud1=num-1;
        jud2=num;
        break;
      }
      else{
        u=num-1;
      }
    }
    else if(ma<0){
      if(u==num){
        jud1=num;
        jud2=num+1;
        break;
      }
      else{
        d=num+1;
      }
    }
  }
  for(ll i=jud1;i>1;i--){
    if(a[i-1]>0){
      v.push_back(make_pair(i,i-1));
      v.push_back(make_pair(i,i-1));
      a[i-1]+=2*a[i];
    }
    else{
      v.push_back(make_pair(i,i-1));
      a[i-1]+=a[i];
    }
  }
  for(ll i=jud2;i<n;i++){
    if(a[i+1]<0){
      v.push_back(make_pair(i,i+1));
      v.push_back(make_pair(i,i+1));
      a[i+1]+=2*a[i];
    }
    else{
      v.push_back(make_pair(i,i+1));
      a[i+1]+=a[i];
    }
  }
  cout<<v.size()<<endl;
  for(ll i=0;i<v.size();i++){
    cout<<v[i].first<<" "<<v[i].second<<endl;
  }
}
        

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

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

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
map<int, int> mp;
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) {
    int a;
    cin >> a;
    mp[a]++;
  }

  ll ans = 0;
  for(auto& x:mp) {
    if(x.second < x.first) ans += x.second;
    else ans += x.second - x.first;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

#define P pair<ll,ll>
#define fs first
#define sc second

int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    ll c[n] = {},a[n][m] = {};

    rep(i,0,n){
        cin >> c[i];
        rep(j,0,m){
            cin >> a[i][j];
        }
    }
    ll ans = LINF;
    ll level[m] = {};
    rep(i,0,(1 << n)){
        rep(j,0,m) level[j] = 0;

        ll memo = 0;
        rep(j,0,n){
            if((i >> j) & 1){
                memo += c[j];
                rep(k,0,m){
                    level[k] += a[j][k];
                }
            }
        }

        rep(j,0,m){
            if(level[j] < x) break;
            else if(j == m-1){
                ans = min(ans,memo);
            }
        }
    }

    if(ans != LINF) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001
#define int ll
int X,Y,a,b,c,A[maxn],B[maxn],C[maxn];



	
int32_t main(){
	fast;
	
	cin>>X>>Y>>a>>b>>c;
	
	FOR(i,1,a) cin>>A[i];
	FOR(i,1,b) cin>>B[i];
	FOR(i,1,c) cin>>C[i];
	
	sort(A + 1,A+a+1,greater<int>());
	sort(B+1,B+1+b,greater<int>());
	sort(C+1,C+c+1);

	multiset <int> S;
	
	FOR(i,1,X) S.insert(A[i]);
	FOR(i,1,Y) S.insert(B[i]);
	
	FOR(i,1,c){
		
		if (*(S.begin()) < C[i]){
			S.erase(S.begin());
			S.insert(C[i]);
		}
	}
	int ans = 0;
	aFOR(i,S) ans += i;
	cout<<ans;
		
}



Measured memory_bytes: 11136
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

X,Y = map(int,input().split())
ans = 0
flag = 0

for i in range(100):
  for j in range(100):
    if(i+j==X and 2*i+4*j==Y):
      flag = 1

if(flag==1):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 74996
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=1;i<n;i++){
		int x;
		cin>>x;
		a[x-1]++;
	}
	for(auto i:a) cout<<i<<endl;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,d;cin>>n>>d;
  int64_t x,y;
  int64_t tmp;
  int64_t ans=0;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    tmp=x*x+y*y;
    if(tmp<=d*d)ans++;
  }
  cout<<ans<<endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<ll,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

struct Edge{
	int to;
	ll cost;
};

int n,m,x;
ll h[100000],d[100000];
vector<Edge> g[100000];

void Djikstra(){
	fill_n((ll*)d,100000,INF_);
	priority_queue<pii,vector<pii>,greater<pii>> que;
	d[0]=0;
	que.push(mp(0,0));
	while(!que.empty()){
		pii u=que.top(); que.pop();
		if(d[u.second]>u.first) continue;
		rep(i,0,g[u.second].size()){
			Edge e=g[u.second][i];
			if(h[u.second]<e.cost) continue;
			ll pos=max(0LL,x-u.first);
			if(pos-e.cost>h[e.to]) e.cost+=pos-(h[e.to]+e.cost);
			else if(pos-e.cost<0) e.cost+=e.cost-pos;
			if(d[e.to]>u.first+e.cost){
				d[e.to]=u.first+e.cost;
				que.push(mp(d[e.to],e.to));
			}
		}
	}
}

void Solve(){
	cin >> n >> m >> x;
	rep(i,0,n) cin >> h[i];
	rep(i,0,m){
		int a,b,t;
		cin >> a >> b >> t;
		--a; --b;
		g[a].push_back(Edge{b,t});
		g[b].push_back(Edge{a,t});
	}

	Djikstra();

	if(d[n-1]==INF_) cout << -1 << endl;
	else {
		ll pos=max(0LL,x-d[n-1]);
		cout << d[n-1]+h[n-1]-pos << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 21488
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque

#a, b = [int(v) for v in input().split()]


def main():
    N, K = map(int, input().split())

    for i in range(1, 1000000):
        v = K ** i
        if v > N:
            print(i)
            exit()


main()


Measured memory_bytes: 2940
h, w=map(int, input().split())
s=[input() for i in range(h)]
nuee1=[]
nuee2=[]
for i in range(h):
  nuee=False
  for j in range(w):
    if s[i][j]=='#':
      nuee=True
      break
  nuee1.append(nuee)
for j in range(w):
  nuee=False
  for i in range(h):
    if s[i][j]=='#':
      nuee=True
      break
  nuee2.append(nuee)
for i in range(h):
  if not nuee1[i]:
    continue
  for j in range(w):
    if not nuee2[j]:
      continue
    print(s[i][j], end="")
  print()

Measured memory_bytes: 4468
#include<bits/stdc++.h>
#define P pair<int,string>
using namespace std;

int main(){
   int a;
   while(cin>>a,a){
       string c;getline(cin,c);
       unordered_map<string,int>U;
       for(int b=0;b<a;b++){
	   getline(cin,c);c+=" ";
	   string r;
	   for(char e:c){
	       if(e==' '){U[r]++;r="";}
	       else r+=e;
	       }
	   }
	   char o;cin>>o;
	   vector<P>M;
	 for(auto x=U.begin();x!=U.end();x++){
	     if(x->first[0]!=o)continue;
	     M.push_back(P(-(x->second),x->first));
	     }  
	     int s=0;
	     sort(M.begin(),M.end(),[](P a,P b){if(a.first!=b.first)return a.first<b.first;return a.second<b.second;});
	 for(auto x=M.begin();x!=M.end()&&s<5;x++,s++){
	     if(s)cout<<" ";
	     cout<<x->second;
	     }    
	     if(M.size())cout<<endl;
	     else puts("NA");
       }
    }

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
long int n,answer,a[1009];
int main()
{
	scanf("%d",&n);
	n*=2;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i+=2) answer+=a[i];
	printf("%d",answer);
	return 0;
}

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

const int mod = 1e9 + 7;

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

const ll M=1e9+7;
ll power(ll a,ll n)
{
  if(n==0)
    return 1;
  else if(n==1)
  return n;
  ll z=power(a,n/2);
  if(n&1)
    return ((z%M*z%M)%M*a%M)%M;
  else
    return (z%M*z%M)%M;
}
 bool sortbysecdesc(const pair<int,int> &a,const pair<int,int> &b){
      return a.second>b.second;
}
// vl g[100010];
// void dfs(ll x,bool vis[],int*dp,map<ll,ll> black){
//   vis[x]=true;
//   for(auto it : g[x]){
//     if(!vis[it]){
//       dfs(it,vis,dp,black);
//       dp[x]+=dp[it];
//     }
//   }
//   if(black.find(x)!=black.end()){
//     dp[x]+=1;
//   }
// }

// vl a(1000000)      ;

int main(){
 ios_base::sync_with_stdio(0);
 ll a,b,c;
 cin >> a >> b >> c;
 ll ma=max(a,max(b,c));
 ll mini=min(a,min(b,c));
 ll mi;
 if(ma==a){
   mi=max(b,c);
 }
 else if(ma==b){
   mi=max(c,a);
 }
 else
  mi=max(a,b);
 cout << ma*10+mi+mini;
 return 0;
}

Measured memory_bytes: 256
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]

for i in range(len(a)-1):
    if a[i+1] == a[i]+1:
        print(0)
        exit()
x = []
temp=0
for i in range(m):
    x.append(a[i]-temp-1)
    temp = a[i]+1
x.append(n-temp)

temp = 1
div = 1000000007

for i in x:
    temp = (temp*Fib(i+1))%div

print(temp)

Measured memory_bytes: 12720
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 4
#define L 46
#define MAX 100000000

int result[N][N] = {
  {1,2,3,4},
  {5,6,7,8},
  {9,10,11,12},
  {13,14,15,0}};

int x[N*N] = {3,0,1,2,
	      3,0,1,2,
	      3,0,1,2,
	      3,0,1,2};
int y[N*N] = {3,0,0,0,
	      0,1,1,1,
	      1,2,2,2,
	      2,3,3,3};

int min = L;


void dfs(int p1[N][N], int p2[N][N],int n){
  int i,j,i1,j1;
  int f = 0, d = 0;
  int tmp[N][N];

  for(i = 0; i<N ; i++){
    for(j = 0; j<N; j++){
      if(result[i][j] != p1[i][j]){
	f++;
      }
      if(p1[i][j] == 0){
	i1 = i;
	j1 = j;
      }
      else {
	d += abs(j - x[p1[i][j]]) + abs(i -y[p1[i][j]]);
      }
    }
  }
  if(f == 0){
    if(min > n){
      min = n;
    }
    return;
  }
  if(d + n> min){
    return;
  }
  if( i1>0&& i1<N){
    memcpy(tmp,p1,sizeof(int) * N *N);
    f = tmp[i1][j1];
    tmp[i1][j1] = tmp[i1-1][j1];
    tmp[i1-1][j1] = f;
    if(memcmp( tmp,p2,sizeof(int)*N*N) != 0){
      dfs(tmp,p1,n+1);
    }
  }

  if( j1>0&& j1<N){
    memcpy(tmp,p1,sizeof(int) * N *N);
    f = tmp[i1][j1];
    tmp[i1][j1] = tmp[i1][j1-1];
    tmp[i1][j1-1] = f;
    if(memcmp( tmp,p2,sizeof(int)*N*N) != 0){
      dfs(tmp,p1,n+1);
    }
  }


 if( i1>=0&& i1<N-1){
    memcpy(tmp,p1,sizeof(int) * N *N);
    f = tmp[i1][j1];
    tmp[i1][j1] = tmp[i1+1][j1];
    tmp[i1+1][j1] = f;
    if(memcmp( tmp,p2,sizeof(int)*N*N) != 0){
      dfs(tmp,p1,n+1);
    }
 }

 if( j1>=0&& j1<N-1){
    memcpy(tmp,p1,sizeof(int) * N *N);
    f = tmp[i1][j1];
    tmp[i1][j1] = tmp[i1][j1+1];
    tmp[i1][j1+1] = f;
    if(memcmp( tmp,p2,sizeof(int)*N*N) != 0){
      dfs(tmp,p1,n+1);
    }
 }
}

void aaaaa(int a){
  int i, count=0;
  for(i=0; i<a; i++)count++;
}

int main(){
  int i,j, a=100;
  int p[N][N];
  for(i = 0;i<N; i++){
    for(j = 0;j<N;j++){
      scanf("%d",&p[i][j]);
    }
  }
  dfs(p,p,0);
  printf("%d\n",min);
  aaaaa(a);
  return 0;
}




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

#define int long long
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define fs first
#define sc second
#define mpr make_pair
#define iter iterator
#define all(X) X.begin(),X.end()
#define sau(X) sort(all(X)),X.resize(unique(all(X))-X.begin())
#define exist(X,ele) binary_search(all(X),ele)
#define y0 I_love_Ryougi_Shiki_0
#define y1 I_love_Ryougi_Shiki_1

template<typename T1,typename T2>
ostream& operator << (ostream& out,const pair<T1,T2>& X)
{
	out<<"{"<<X.fs<<","<<X.sc<<"}";
	return out;
}

template<typename T>
ostream& operator << (ostream& out,const vector<T>& X)
{
	for(auto i:X) out<<i<<" ";
	return out;
}

template<typename T>
inline void cmin(T& x,T y)
{
	if(!(x<y)) x=y;
}

template<typename T>
inline void cmax(T& x,T y)
{
	if(x<y) x=y;
}

const int inf=5000000000000000ll;

main()
{
	ios::sync_with_stdio(false);
	
	int k,a,b; cin>>k>>a>>b;
	if(a/k==b/k && a%k!=0) cout<<"NG"<<endl;
	else cout<<"OK"<<endl;
	
	return 0;
}






















Measured memory_bytes: 3652
n,c=map(int,input().split())
d=[list(map(int,input().split())) for i in range(c)]
g=[list(map(int,input().split())) for i in range(n)]
mod0=set()
mod1=set()
mod2=set()
for i in range(n):
  for j in range(n):
    if (i+j+2)%3==0:
      mod0.add((i,j))
    elif (i+j+2)%3==1:
      mod1.add((i,j))
    else:
      mod2.add((i,j))
cost1=[0]*c
for c1 in range(c):
  tmp=0
  for y,x in mod0:
    tmp+=d[g[y][x]-1][c1]
  cost1[c1]+=tmp
cost2=[0]*c
for c2 in range(c):
  tmp=0
  for y,x in mod1:
    tmp+=d[g[y][x]-1][c2]
  cost2[c2]+=tmp
cost3=[0]*c
for c3 in range(c):
  tmp=0
  for y,x in mod2:
    tmp+=d[g[y][x]-1][c3]
  cost3[c3]+=tmp
ans=10**18
for c1 in range(c):
  for c2 in range(c):
    for c3 in range(c):
      if c1==c2 or c2==c3 or c3==c1:
        continue
      ans=min(ans,cost1[c1]+cost2[c2]+cost3[c3])
print(ans)

Measured memory_bytes: 59100
import sys
sys.setrecursionlimit(500000)
N = int(input())
E = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    E[a].append((b,i))
    E[b].append((a,i))
#最大の次数を見つける
K = max(len(e) for e in E)
print(K)
ans = [-1] * (N-1)
def dfs(v=1,p=0,p_col=-1):
    col = 1
    for u, idx in E[v]:
        if u != p:
            if col == p_col:
                col += 1
            ans[idx] = col
            dfs(u,v,col)
            col += 1
dfs()
print("\n".join(map(str,ans)))

Measured memory_bytes: 85652
#include <stdio.h>

int main (){
  int a,b,c,d;

  scanf("%d%d%d%d", &a, &b, &c, &d);

  int ab, bc, ca;
  ab = b - a;
  bc = b - c;
  ca = c - a;
  
  if(( abs(ab) <= d && abs(bc) <= d ) || abs(ca) <= d){
    printf("Yes");  
  } else {
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
const int N=101;
int n,a[N],Num[N],maxn=INT_MIN,minn=INT_MAX;
int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),maxn=max(maxn,a[i]),minn=min(minn,a[i]);
	if(maxn>n||minn<1){printf("Impossible");return 0;}
	if((maxn+1)/2!=minn){printf("Impossible");return 0;}
	for(int i=1;i<=n;i++) Num[a[i]]++;
	if(Num[maxn]==1){printf("Impossible");return 0;}
	if(Num[minn]!=(maxn%2)+1){printf("Impossible");return 0;}
	for(int i=minn+1;i<=maxn;i++)
	     if(!Num[i]||Num[i]==1){printf("Impossible");return 0;}
	printf("Possible");
}


Measured memory_bytes: 256
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))
t = 0
for i in b:
    t += (bisect.bisect_left(a, i) * (n - bisect.bisect_right(c, i)))
print(t)

Measured memory_bytes: 24224
def process(n, m, x)
  return 0 if m == 1
  return 0 if n >= m

  x = x.sort
  sum_distance = x[-1] - x[0]
  return sum_distance if n == 1

  distance = []
  move_counter = 0
  for i in 1..(m-1) do
    distance[i-1] = x[i] - x[i-1]
  end
  distance = distance.sort.reverse
  move_counter = sum_distance
  distance[0..(n-2)].each { |distan| move_counter -= distan }
  move_counter
end
def main()
  n, m = gets.chomp.strip.split(' ').map(&:to_i)
  inputX = gets.chomp.strip
  x = inputX.split(' ').map(&:to_i)
  move_counter = process(n, m, x)

  puts "#{move_counter}"
end
main


Measured memory_bytes: 11896
use itertools::Itertools;
fn main() {
    proconio::input! {
        n: usize,
        ss: [proconio::marker::Chars; n],
    }
    let v = ss
        .iter()
        .map(|s| {
            let mut current = 0;
            let mut min = 0;
            s.iter().for_each(|c| {
                if *c == ')' {
                    current -= 1;
                    min = std::cmp::min(min, current);
                } else {
                    current += 1;
                }
            });
            (min, current)
        })
        .collect::<Vec<_>>();
    let positive = v.iter().filter(|(min, _current)| *min >= 0).collect_vec();
    let nega_posi = v
        .iter()
        .filter(|(min, current)| *min < 0 && *current >= 0)
        .sorted_by(|l, r| r.0.cmp(&l.0))
        .collect_vec();
    let negative = v
        .iter()
        .filter(|(min, current)| *min < 0 && *current < 0)
        .sorted_by(|l, r| (r.1 - r.0).cmp(&(l.1 - l.0)))
        .collect_vec();
    let mut current = 0;
    for (l, r) in positive.iter().chain(&nega_posi).chain(&negative) {
        if current + l < 0 {
            println!("No");
            return;
        }
        current += r;
    }
    if current == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 74492
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t A,B;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> A>>B;
	if (B%A == 0) {
		out << A + B << endl;
	}
	else {
		out << B-A << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ii, ll>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define tam 120000
#define offset 
const ll MOD= 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,x=100;
    cin>>n;
    int c=0;
    while(x<n)
    {
        c++;
        x+=ll(x/100);
    }
    cout<<c<<endl;
}
// PLUS ULTRA!
    


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque> 
#include <algorithm>
 
using namespace std;
 
#define     lli                 long long int
#define     ulli                unsigned long long int

#define     ifor(st,lim)        for(int i=st;i<lim;i++)
#define     jfor(stt,llim)      for(int j=stt;j<llim;j++)
#define		Test(tt)			for(int test=1;test<=tt;test++)
#define		For(var,srt,nnd)	for(var=srt;var<nnd;var++)
#define		Rfor(var,srt,nnd)	for(var=srt;var>=nnd;var--)
 
#define     pb                  push_back
#define     mkp                 make_pair
 
#define     pi                  acos(-1)
#define     mod                 100000007
 
#define     Clear(var,val)      memset(var,val,sizeof(var))
#define     len(var)            (int)(var.length())
#define     vlen(vect)          (int)(vect.size())
#define     line(ss)            getline(cin,ss)

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

#define		sclock				int start_s=clock()
#define		eclock				int end_s=clock()
#define		pclock				printf("\nRuntime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC)
 
/****************************** IO ************************************/
#define		ina(a)				scanf("%d",&a)
#define		inb(a,b)			scanf("%d %d",&a,&b)
#define		inc(a,b,c)			scanf("%d %d %d",&a,&b,&c)
#define		ins(chr)			scanf("%s",s)
#define		inlla(a)			scanf("%lld",&a)
#define		inllb(a,b)			scanf("%lld %lld",&a,&b)
#define		inllc(a,b,c)		scanf("%lld %lld %lld",&a,&b,&c)
 
#define		outa(a)				printf("%d",a)
#define		outlla(a)			printf("%lld",a)

#define		yn(b)				puts(b ? "YES" : "NO") 

#define		outar(ar,ln,c)		for(int i=0;i<ln;i++){printf("%d%c",ar[i],c);}

#define		outCase()			printf("Case %d:",test)
 
#define		blank				printf("\n")
/**********************************************************************/


int main()
{
    FIO;
/******************************* A ************************************/
	
	
	int a,b,c;
	inc(a,b,c);
	swap(a,b);
	swap(a,c);
	
	printf("%d %d %d",a,b,c);
	
/**********************************************************************/
    return 0;
}


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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t; cin >> s >> t;
    int S=s.size();
    int T=t.size();
    int cnt=T;
    int ans=T;
    rep(i,0,S-(T-1)){
        cnt=T;
        rep(j,0,T){
            if(s[i+j]==t[j]) cnt--;
        }
        ans=min(ans,cnt);
        //cout << ans ENDL;
    }
    
    cout << ans ENDL;
    return 0;
}

Measured memory_bytes: 6000
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int n,ans;
char s[50];

int main(){
	scanf("%s",s+1),n=strlen(s+1);
	ans=15-n;
	For(i,1,n) ans+=s[i]=='o';
	if (ans>=8) puts("YES");
		else puts("NO");
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  string S;
  int w;
  cin >> S >> w;
  for(int i=0; i<S.size(); i+=w) cout << S[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string s;
    cin >> s;
    vector<bool> v(26, false);
    bool ans = true;
    rep(i, s.size()){
        if(v[s[i]-'a']){
            ans = false;
            break;
        }
        v[s[i]-'a'] = true;
    }
    if(ans){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = list(map(int, input().split()))
a = n[0]
b = n[1]
c = n[2]

i = 0

if a+b==c:
  i += 1
if b+c==a:
  i += 1
if c+a==b:
  i += 1
  
if i ==1:
  print('Yes')
else:
  print('No')

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

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	vector<vector<int>> G(N, vector<int>(K));
	vector<int> is(N);
	vector<int> D(M);
	for (int i = 0; i < M; i++) {
		cin >> D[i]; D[i]--;
		is[D[i]] = 1;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) {
			cin >> G[i][j]; G[i][j]--;
		}
	}
	vector<int> res(1 << M, 10000);
	int s = (1 << M) - 1; res[s] = 0;
	queue<int> q; q.push(s);
	while (!q.empty()) {
		int p = q.front(); q.pop();
		for (int i = 0; i < K; i++) {
			int t = 0;
			for (int j = 0; j < M; j++) {
				if (p & (1 << j)) {
					if (is[G[D[j]][i]]) {
						int id = 0;
						for (int k = 0; k < M; k++) {
							if (D[k] == G[D[j]][i]) {
								id = k;
								break;
							}
						}
						t |= 1 << id;
					}
				}
			}
			if (res[t] == 10000) {
				res[t] = res[p] + 1;
				q.push(t);
			}
		}
	}
	cout << res[0] << endl;
	return 0;
}

Measured memory_bytes: 3444
def mysum(A, B):
    C = [0] * len(A)
    for i in range(len(A)):
        C[i] = A[i] + B[i]
    return C


def mytruthy(A, X):
    for a in A:
        if a < X:
            return False
    return True


def c():
    N, M, X = map(int, input().split())
    R = {}
    costs = []

    for i in range(N):
        V = list(map(int, input().split()))
        if i == 0:
            R['0'*N] = [0] * (M + 1)
            R['1' + '0'*(N-1)] = V
            if mytruthy(V[1:], X):
                costs.append(V[0])
        else:
            newR = {}
            for k in R.keys():
                k2 = k[:i] + '1' + k[i+1:]
                newR[k2] = mysum(R[k], V)
                if mytruthy(newR[k2][1:], X):
                    costs.append(newR[k2][0])
            R.update(newR)

    if len(costs) == 0:
        print(-1)
    else:
        print(min(costs))


##########
if __name__ == "__main__":
    c()


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

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

        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            int count=0;
            int min = n+1;

            var p = cin.ReadIntArray(n);
            
            for(int k = 0; k < n; k++)
            {
                if (min > p[k])
                {
                    min = p[k];
                    count++;
                }
            }
            WriteLine(count);
        }
    }

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

Measured memory_bytes: 35468
//https://www.youtube.com/watch?v=8LusJS5-AGo
//https://www.geeksforgeeks.org/0-1-knapsack-problem-dp-10/
#include<bits/stdc++.h>
#define int long long
#define scf(n) scanf("%lld",&n)
#define rep1(n) for(int i=1;i<=n;i++)
#define prf(n) printf("%lld",n)
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)

#define nl printf("\n")
#define spc printf(" ")
#define file freopen("in.txt","rt",stdin)
#define pii pair<int,int>
#define piii pair<pii,int>
#define MOD 10000007
const int INF = 1e18L + 5;
using namespace std;

/*bool sortBySec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/******************************************/

int arr[100009];
int temp[100009];

int32_t main()
{

//  int n,m;
//  cin>>n>>m;
//  int cnt = 1;
//  int sum = n;
//  while(sum<=m)
//  {
//      if(sum>=m)
//        break;
//      cnt++;
//      sum=sum+(n-1);
//  }
//  pri(cnt),nl;
    int n;
    sci(n);
    for(int i=1;i<=n;i++)
        sci(arr[i]);
    temp[n] = 0;
    for(int i=n-1;i>=1;i--)
    {
        if(arr[i]>=arr[i+1])
        {
            temp[i] = temp[i+1] + 1;
        }
        else
            temp[i] = 0;
    }
    int mx = -1;
    for(int i=1;i<=n;i++)
    {
       mx = max(mx,temp[i]);
    }
    if(mx!=0)
        pri(mx),nl;
    else
        printf("0\n");




    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long N;

// ゼロ以下が一つも無い時
void foo(vector<long> A) {
  vector<pair<long, long>> tejun;
  sort(A.begin(), A.end());
  for (long i = 0; i < N-2; i++) {
    tejun.push_back(make_pair(A[i], A[i+1]));
    A[i+1] = A[i] - A[i+1];
  }
  tejun.push_back(make_pair(A[N-1], A[N-2]));
  long result = A[N-1] - A[N-2];
  cout << result << endl;
  for (auto it: tejun) cout << it.first << " " << it.second << endl;
}

// マイナスのやつしかない時
void bar(vector<long> A) {
  vector<pair<long, long>> tejun;
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  for (long i = 0; i < N-1; i++) {
    tejun.push_back(make_pair(A[i], A[i+1]));
    A[i+1] = A[i] - A[i+1];
  }
  cout << A[N-1] << endl;
  for (auto it: tejun) cout << it.first << " " << it.second << endl;
}

// マイナスもプラスもあるとき
void baz(vector<long> A) {
  vector<pair<long, long>> tejun;
  vector<long> plus;
  vector<long> not_plus;
  for (auto it: A) if (it > 0) plus.push_back(it); else not_plus.push_back(it);
  for (long i = 0; i < plus.size() - 1; i++) {
    tejun.push_back(make_pair(not_plus[0], plus[i]));
    not_plus[0] -= plus[i];
  }
  for (long i = 0; i < not_plus.size(); i++) {
    tejun.push_back(make_pair(plus[plus.size() - 1], not_plus[i]));
    plus[plus.size() - 1] -= not_plus[i];
  }
  cout << plus[plus.size() - 1] << endl;
  for (auto it: tejun) cout << it.first << " " << it.second << endl;
}

int main(void) {
  cout.precision(12);

  cin >> N;
  vector<long> A(N);
  rep (i, N) cin >> A[i];

  long le_zero_count = 0; // マイナスかゼロ
  long gt_zero_count = 0; // プラス

  rep (i, N) if (A[i] > 0) gt_zero_count++; else le_zero_count++;

  if (le_zero_count == 0) foo(A);
  else if (gt_zero_count == 0) bar(A);
  else baz(A);

  return 0;
}


Measured memory_bytes: 6768
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int a,b,c;
    while(cin >> a >> b >> c,a|b|c){
        int N;
        cin >> N;
        vector<int> parts(a+b+c,2);
        vector<int> A(N),B(N),C(N),D(N);
        rep(i,N){
            int s,t,u,v;
            cin >> s >> t >> u >> v;
            s--,t--,u--;
            A[i]=s;
            B[i]=t;
            C[i]=u;
            D[i]=v;
            if(v==1){
                parts[s]=1;
                parts[t]=1;
                parts[u]=1;
            }
        }
        rep(i,N){
            if(D[i]==0){
                if(parts[A[i]]==1&&parts[B[i]]==1)parts[C[i]]=0;
                if(parts[B[i]]==1&&parts[C[i]]==1)parts[A[i]]=0;
                if(parts[C[i]]==1&&parts[A[i]]==1)parts[B[i]]=0;
            }
        }
        rep(i,a+b+c){
            cout << parts[i] << endl;
        }
    }

    return 0;
}


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

int main(){
	char s[10];
	cin>>s;

	int a=(s[0]-'0')*10+s[1]-'0';
	int b=(s[2]-'0')*10+s[3]-'0';

	int f1=0,f2=0;
	if(0<a && a<13)f1=1;
	if(0<b && b<13)f2=1;

	if(f1==1 && f2==1)cout<<"AMBIGUOUS"<<endl;
	if(f1==1 && f2==0)cout<<"MMYY"<<endl;
	if(f1==0 && f2==1)cout<<"YYMM"<<endl;
	if(f1==0 && f2==0)cout<<"NA"<<endl;

	return(0);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;

int main()
{
	int x, y;
	int sol = 0;
	int prize[4] = { 0,300000,200000,100000 };

	scanf("%d %d", &x, &y);

	if (x <= 3)
	{
		sol += prize[x];
	}

	if (y <= 3)
	{
		sol += prize[y];
	}

	if (x == 1 && y == 1)
	{
		sol += 400000;
	}

	printf("%d\n", sol);

	return 0;
}


Measured memory_bytes: 128
N, A, B, C, D= map(int, input().split())
S = str(input())

A = A-1
B = B-1
C = C-1
D = D-1

ref = 1

if C < D:
    for i in range(B+1, D-1):
        if S[i]=='#' and S[i+1]=='#':
            ref = 0
            break
        else:
            continue

    for j in range(A+1, C-1):
        if S[j]=='#' and S[j+1]=='#':
            ref = 0
            break
        else:
            continue

    if ref == 1:
        print('Yes')
    else:
        print('No')
        
else:
    ref = 0
    for i in range(B, D+1):
        if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.' : 
            ref = 1
            break
        else:
            ref = 0
    for j in range(A+1, C-1):
        if S[j]=='#' and S[j+1]=='#':
            ref = 0
            break
        else:
            continue
    if ref == 1:
        print('Yes')
    else:
        print('No')


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

#define F first
#define S second
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll gcd(ll x,ll y){
return y? gcd(y,x%y):x;
}

int main(){
  db r;
  cin>>r;
  cout<<2*3.141592653589*r<<endl;
return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char const* argv[])
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(abs(a-c) <= d || (abs(a - b) <= d && abs(b - c) <= d)){
			cout << "Yes" << endl;
	}else{
			cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
M=2**61-1;eval"N,*A="+`dd`.split*?,;C=[0,N].map{|z|(A[z,N]*3).each_cons(2).map{|x,y|x^y}};e,f=C.map{|z|z[b=0,N].map{|x|b=b*9+x&M};b};q=1-9**N&M;N.times{|i|e==f&&p(i,A[i]^A[N]);e=e*9+C[0][i]*q&M}

Measured memory_bytes: 134140
S = input()

length_S = len(S)

wrong_10 = 0
wrong_01 = 0

for i in range(length_S):
	if i%2 == 0:
		if S[i] == '1':
			wrong_01 += 1
		else:
			wrong_10 += 1
	else:
		if S[i] == '1':
			wrong_10 += 1
		else:
			wrong_01 += 1
			
print(min(wrong_01, wrong_10))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int s,i=0; cin>>s;
  while(s>4 ||s==3){
    if(s%2==0) s/=2;
    else s=3*s+1;
    i++;
  }
  cout<<i+4<<endl;
}
  

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

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

    string st;
    cin >> st;
    
    int s=0;
    int n=0;
    int w=0;
    int e=0;
    rep(i, st.size()){
        if(st[i] == 'S') ++s;
        if(st[i] == 'N') ++n;
        if(st[i] == 'W') ++w;
        if(st[i] == 'E') ++e;
    }

    bool sn;
    bool we;

    if(s){
        if(n) sn = true;
        else sn = false;
    }
    else{
        if(n) sn = false;
        else sn = true;
    }

    if(w){
        if(e) we = true;
        else we = false;
    }
    else{
        if(e) we = false;
        else we = true;
    }

    if(sn && we) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
ll mod=1000000007;
const ll N=100005;
int main()
{
fast;
    ll a,b,c;
    cin>>a>>b>>c;
    ll k;
    cin>>k;
    ll f=1;
    while(b<=a && k!=0)
    {
        b*=2;
        k--;
    }
    if(k<=0 && c<=b)
        f=0;
    while(c<=b && k!=0)
    {
        c*=2;
        k--;
    }
    if(c>b && b>a && f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
    return 0;
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair

vector<int> prefix(string s){
        int n = s.length();
        vector<int> pi(n);
        for(int i = 1; i < n; i++){
                int j = pi[i - 1];
                while(j > 0 && s[j] != s[i]) j = pi[j - 1];
                if(s[i] == s[j]) j++;
                pi[i] = j;
        }
        return pi;
}

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

        string tmp = t;
        tmp.pb('#');
        for(int i = 0; i < n; i++) tmp.pb(s[i]);
        vector<int> pi = prefix(tmp);
        int ans = 2 * n;
        int mx = 0;
        for(int i = n + 1; i <= 2 * n; i++){
                mx = max(mx, pi[i]);
        }
        cout << ans - mx;
        return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[225816],dp[225816];
map<ll, ll> mp;

int main(void){
	int n,i,j;
	string s;
	fill(dp,dp+225816,INFLL);
	cin >> s;
	n = s.l_ength();
	for(i=0; i<n; ++i){
		a[i] = (1ll<<(s[i]-'a'));
	}
	for(i=1; i<n; ++i){
		a[i] ^= a[i-1];
	}
	for(i=0; i<n; ++i){
		mp[a[i]] = INFLL;
	}
	mp[0] = 0ll;
	for(i=0; i<n; ++i){
		if(mp.count(a[i])){
			dp[i] = min(mp[a[i]]+1,dp[i]);
		}
		for(j=0; j<26; ++j){
			if(mp.count(a[i]^(1ll<<j))){
				dp[i] = min(mp[a[i]^(1ll<<j)]+1,dp[i]);
			}
		}
		mp[a[i]] = min(mp[a[i]],dp[i]);
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 17540
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define erep(i, n) for (ll i = 1; i <= (n)i++)
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
// input
ll h[100010];
// dp tabel
ll dp[100010];

int main(void) {
  ll n;
  cin >> n;
  rep(i, n) cin >> h[i];
  rep(i, 100010) dp[i] = 1e9;
  dp[0] = 0;
  rep(i, n) {
    mins(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    mins(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }
  cout << dp[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 5124
# -*- coding: utf-8 -*-
#O[|w|]:|w|???????´¢???????????????????????????
#??\????????¨??\?°????????????´??????????????¨????????????????????????????????????nx[i]????????????????¨????
#???????????????????´¢??§?????????????????±???,????´¢??????????????¨??????????????¨??????,?????????????´¢??????
def kmpTable(w):
    lw = len(w)
    nx = [-1] * (lw + 1)   #nx[i]:=w[0:i](i?????????????????????)?????§?????\????????¨??\?°????????????´??????????????¨?????????????????????????????????
    j = -1
    for i in xrange(lw):
        while j >= 0 and w[i] != w[j]:
            j = nx[j]
        j += 1
        nx[i + 1] = j
    return nx

#O[|s|]:|s|???????´¢????????????????????????????????????
#s????????§,w??¨?????´????????????????????????????????????index???list?????????(0-index)
#???????????°??????list([])????????????
def kmpSearch(s, w):  #????´¢???????????????????????????s,????´¢??????????????????w
    ls = len(s)
    start = 0     #?????????s????????????,w??¨??????????????§??????????§????????????¨???(0-index)
    w_idx = 0     #?????????w????????????,??????s??¨??§??????????????¨????????????????????????????????¨???(0-index)(?°????????¨??????°,?????????????????????????????????????????¨????????°)
    ret = []
    nx = kmpTable(w)
    while start + w_idx < ls:              #ls??\????????¨w???????????????????????????????????£??????????????§??¢?????????????§?
        if s[start + w_idx] == w[w_idx]:
            w_idx += 1
            if w_idx == len(w):    #w??¨?????´????????¨???
                ret.append(start)
                start = start + w_idx - nx[w_idx]  #??????start??????????????´???????????£??????????????§?????????,??\????????¨??\?°????????????§?????´????????????????????????
                w_idx = nx[w_idx]
        else:
            if w_idx == 0:         #??????????????????????????´???????????¨???,start??????1?????????
                 start += 1
            else:                  #????????§?????´???????????£?????¨???
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
    return ret

T = raw_input()
P = raw_input()
ans = kmpSearch(T, P)
for i in ans:
    print(i)

Measured memory_bytes: 38892
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()




int main(){
  
  ll n;
  cin>>n;
  
  vector<ll> as(n);
  vector<ll> bs(n);
  vector<pair<ll,ll>> limit(n,pii());
  
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    as.at(i)=a;
    bs.at(i)=b;
    auto tmp=make_pair(b,a);
    limit.at(i)=tmp;
  }
  
  sort(ALL(limit));
  
  ll time=0;
  string answer="Yes";
  
  rep(i,n){
    if (time+limit.at(i).second<=limit.at(i).first){
      time+=limit.at(i).second;
    }
    else {
      answer="No";
      break;
    }
  }
  
  cout<<answer<<endl;
  

  

}










Measured memory_bytes: 6528