akhauriyash/Code-Regression huggingface dataset:
from collections import deque


def dfs(field, s):
    MOVE = [(0, 1), (1, 0), (0, -1), (-1, 0)]
    q = deque([(0, s)])
    dist = [[-1] * w for _ in range(h)]

    d, i, j = -1, -1, -1
    while q:
        d, (i, j) = q.popleft()
        if dist[i][j] != -1:
            continue
        dist[i][j] = d
        for di, dj in MOVE:
            ni, nj = i + di, j + dj
            if not 0 <= ni < h or not 0 <= nj < w:
                continue
            if field[ni][nj] == '#':
                continue
            if dist[ni][nj] != -1:
                continue
            q.append((d + 1, (ni, nj)))
    return d, i, j


h, w = map(int, input().split())
field = [input() for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == '.':
            d, i, j = dfs(field, (i, j))
            ans = max(ans, d)
print(ans)


Measured memory_bytes: 3316
L=[2,11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,
  401,421,431,461,491,521,541,571,601,631,641,661,701,751,761,811,821,
  881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,
  1201,1231,1291, 1301,1321,1361,1381,1451,1471]
N = int(input())
A = []
for i in range(N):
    A.append(L[i])
print(' '.join(map(str, A)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
 
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
 
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");

inline ll ceil(ll a,ll b)
{
  return (a+b-1)/b;
}



void func()
{ 
  ll k,n;
  cin>>k>>n;
  ll arr[n];
  f(i,0,n) cin>>arr[i];
  sort(arr,arr+n);
  ll mx=-infl;
  f(i,0,n-1)
  {
    mx=max(arr[i+1]-arr[i],mx);
  }
  mx=max(mx,arr[0]+k-arr[n-1]);
  ll ans=k-mx;
  pr(ans) nl
} 

int main() 
{
    //fast
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE*/
    
    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }
 
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

long cmp(const void *a, const void *b)
{
	return *(long *)a - *(long *)b;
}

int main()
{
    int i,f=1,n;
    long a[200010]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%ld",&a[i]);
    qsort(a,n,sizeof(long),cmp);
    for(i=0;i<n-1;i++)
        if(a[i] == a[i+1])
        {
            f=0;break;
        }
    if(f)
        printf("YES");
    else
        printf("NO");
    return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint N;
	cin >> N;
	vector<lint> data(50, N / 50 + 49);

	for (int i = 0; i < 50; i++)
	{
		if (i < N % 50)
			data[i] += 1;
		else
			data[i] -= N % 50;
	}

	cout << 50 << endl;

	for (auto out : data)
	{
		cout << out << " ";
	}
	cout << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,m;
 cin>>n>>m;
 
 int arr[m];
 int sum=0;
 for(int i=0;i<m;i++)
 {
     cin>>arr[i];
     sum+=arr[i];
 }
 
 if(sum<=n)
 cout<<n-sum<<endl;
 else
 cout<<-1<<endl;
 
 
 
 return 0; 
}


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

Measured memory_bytes: 580
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int N,sum=0,msum=0;
	cin >> N;
	int a[2][N];
	for(int i=0;i<2;i++){
		for(int j=0;j<N;j++){
			cin >> a[i][j];
		}
	}

	for(int k=0;k<N;k++){
		sum =0;
		for(int p=0;p<=k;p++){
			sum =sum + a[0][p];
		}
		for(int q=N-1;q>=k;q--){
			sum = sum + a[1][q];
		}
		msum = max(sum, msum);
	}
	cout << msum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;


int main(void){
    int n;
    cin>>n;
    long long int a[n],b[n];
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    
    long long int ans=0;
    for(int i=n-1;i>=0;i--){
        a[i]+=ans;
        int c=a[i]%b[i];
        while(1){
            if(a[i]%b[i]==0){
                break;
            }else{
                ans+=b[i]-c;
                a[i]+=ans;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int N;
	long long M = 0, A = 0, R = 0, C = 0, H = 0;
	long long cnt;
	vector<string> name;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		name.push_back(s);
	}
	/*
	sort(name.begin(), name.end());
	name.erase(unique(name.begin(), name.end()), name.end());
	*/
	cnt = 0;
	for (vector<string>::iterator i = name.begin();i != name.end();i++) {
		if ((*i)[0] == 'M') {
			M++;
		}else if ((*i)[0] == 'A') {
			A++;
		}
		else if ((*i)[0] == 'R') {
			R++;
		}
		else if ((*i)[0] == 'C') {
			C++;
		}
		else if ((*i)[0] == 'H') {
			H++;
		}
	}

	cnt += M * R * C;
	cnt += M * R * A;
	cnt += M * R * H;
	cnt += M * C * A;
	cnt += M * C * H;
	cnt += M * A * H;
	cnt += H * A * C;
	cnt += H * R * C;
	cnt += A * R * H;
	cnt += A * R * C;

	cout << cnt << endl;

	return 0;
}

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

int func(int x)
{
    if(x%2==0)
    {
        return x/2;
    }
    else
    {
        return 3*x+1;
    }
}
int main()
{
    int n;
    cin>>n;
    int maxV = 0;
    string s;
    cin>>s;
    char a[n];
    for(int i=0;i<n;i++)
    {
        a[i]=s[i];
    }

    int container[n];   //毎回のpositionを記録
    int pos = 0;        //現在地
    for(int i=0;i<n;i++)
    {
        if(a[i]=='I')
        {
            pos++;
        }
        else
        {
            pos--;
        }
        container[i]=pos;
    }
    for(int i=0;i<n;i++)
    {
        maxV = max(container[i],maxV);
    }
    cout<<maxV<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
data_xy = []
for i in range(N):
    A = int(input())
    xy = []
    for i in range(A):
        [x,y] = list(map(int,input().split()))
        xy.append([x-1, y])
    data_xy.append(xy)
ans = 0
for i in range(2**N):
    p_list = [0]*N
    for j in range(N):
        if (i>>j) & 1 == 1:
            p_list[j] = 1
    flag = True
    for j in range(N):
        if p_list[j] == 1:
            for k in range(len(data_xy[j])):
                x = data_xy[j][k][0]
                y = data_xy[j][k][1]
                if p_list[x] != y:
                    flag = False
    if flag == True:
        ans = max(sum(p_list),ans)
print(ans)

Measured memory_bytes: 12508
/*input
8 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	if(n<1200) cout<<"ABC";
	else if(n<2800) cout<<"ARC";
	else cout<<"AGC";
	return 0;
}


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

int n, a, b;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
//  freopen("in.txt", "r", stdin);
#endif  // ONLINE_JUDGE
  cin >> n >> a >> b;
  cout << min(b, n * a) << '\n';
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N, x = map(int,input().split())
b = sorted(list(map(int,input().split())))
a = np.cumsum(b)
if x == sum(b):
    print(N)
    exit()
for i in range(N):
    if x < a[i]:
        print(i)
        exit()
print(N-1)


Measured memory_bytes: 12392
#include<stdio.h>
#include<string.h>
int main()
{
	char a[20],b[20],c[20];
	scanf("%s%s%s",a,b,c);
	int len1=strlen(a);
	int len2=strlen(b);
	if(a[len1-1]==b[0]&&b[len2-1]==c[0])
	printf("YES\n");
	else
	printf("NO\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int N;
string S;
int DP[5005][5005];

void solve(int start){
    int from1=-1, to1=-1;
    int from, to;
    for(int i=1;i<N;++i){
        from = start + i;
        if((from1==-1) || (to1<from)){
            to = 0;
            while(from+to<N && S[start+to]==S[from+to]){
                to++;
            }
            DP[start][from] = to;
            from1 = from;
            to1 = from+to;
        }
        else{
            int k = from - from1;
            if(from + DP[start][start+k]<to1){
                DP[start][from] = DP[start][start+k];
            }
            else if(from + DP[start][start+k]>to1){
                DP[start][from] = to1 - from;
            }
            else{
                to = 0;
                while(to1+to<N && S[to1+to]==S[start+to1-from1-k+to]){
                    to++;
                }
                DP[start][from] = to + to1 - from;
                to1 = to1 + to;
                from1 = from;
            }
        }
    }
    DP[start][start] = N - start;
}

int main() {
    cin>>N>>S;
    for(int i=0;i<N;++i){
        solve(i);
    }
    int ans = 0;
    /**
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            cout<<DP[i][j]<<" ";
        }
        cout<<endl;
    }
    **/
    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            ans = max(ans, min(j-i, DP[i][j]));
        }
    }
    cout<<ans<<endl;
}


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define random_shuffle(...) shuffle(__VA_ARGS__, rng)
#define rand() rng()

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n = nxt();
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		a[i] = nxt();
	}

	vector<int> ans;
	for (int i = 0; i < n; ++i) {
		int opt = -1;
		for (int j = 0; j < (int)a.size(); ++j) {
			if (a[j] > j + 1) {
				puts("-1");
				return 0;
			}
			if (a[j] == j + 1) {
				opt = j;
			}
		}
		if (opt == -1) {
			puts("-1");
			return 0;
		}

		ans.push_back(opt + 1);
		a.erase(a.begin() + opt);
	}

	reverse(all(ans));

	for (itn x : ans) {
		cout << x << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;//2e9
const ll LLMAX=9223372036854775807;//9e17


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    
    vvll P;
    ll M=sqrt(N);
    for(ll i=2;i<=M;i++){
        ll count=0;
        while(N%i==0){
            count++;
            N/=i;
        }
        if(count>0){
            P.push_back(vll{i,count});
            if(N==1)break;
        }
    }
    if(N>1)P.push_back(vll{N,1});
    
    ll ans=0;
    for(ll i=0;i<P.size();i++){
        //printf("%d,%d\n",P[i][0],P[i][1]);
        for(ll j=1;;j++){
            //printf("%d,%d,%d\n",j*(j+1)/2,P[i][1],(j+1)*(j+2));
            if(j*(j+1)/2<=P[i][1]&&P[i][1]<(j+1)*(j+2)/2){
                ans+=j;
                break;
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


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

using namespace std;
int main(){
    int s,t;
    s=0,t=0;
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >>a[i][j];
            t+=a[i][j];
            if(i==j) s+=a[i][j];
        }
    }
    if(t==3*s){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}

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 R;
  cin >> R;
  printf("%.10f\n", 2 * R * M_PI);
  return 0;
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int x, a; cin >> x >> a;

    if(x < a){
        cout << 0 << endl;
    }
    else{
         cout << 10 << endl;
    }

    return 0;
}


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

using namespace std;

int main() {
  int N,M; cin >> N >> M;
  int s[60],t[60],ans[60] = {0};
  for(int i = 0; i < M; i++) {
  cin >> s[i] >> t[i];
  }
  for(int i = 0; i < M; i++) {
  ans[s[i]]++; ans[t[i]]++;
  } 
  for(int i = 1; i <= N; i++) {
  cout << ans[i] << endl;
  }  
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <iterator>

int main() {
  std::int_fast64_t n;
  std::cin >> n;
  std::vector<std::int_fast64_t> a(n);
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), n, a.begin());
  std::transform(a.begin(), a.end(), a.begin(), [](const std::int_fast64_t a_i) { return a_i - 1; });

  std::unordered_set<std::int_fast64_t> visited;
  std::int_fast64_t result = 0;
  std::int_fast64_t current = 0;
  while (true) {
    if (current == 1) {
      std::cout << result << std::endl;
      break;
    }
    if (visited.find(current) != visited.end()) {
      std::cout << -1 << std::endl;
      break;
    }
    visited.insert(current);
    current = a[current];
    ++result;
  }
  return 0;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N,D,X; cin >> N >> D >> X;
    rep(i,N) {
        int a; cin >> a;
        rep(j,D) {
            if (j%a == 0) ++X;
        }
    }
    cout << X << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#define DBL_MIN 0.000000000000001
using namespace std;

long euclid(long a,long b){
    long big = max(a,b);
    long small  =min(a,b);
    while(big % small){
        long amari = big%small;
        big = small;
        small = amari;
    }
    return small;
}

long euclidean_gcd(long a, long b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(void){
    vector<long> mati;

    long N,X;
    cin >> N >> X;
    for(long i =0; i < N; i++){
        long tmp;
        cin >> tmp;
        long dis = abs(tmp -X);
        mati.push_back(dis);
    }
    sort(mati.begin(), mati.end());

    if(N == 1){
        cout <<  mati[0] << endl;
        return 0;
    }

    long minstep = *(mati.end()-1);
    long begin = 0;
    for(long i =0; i < mati.size()-1; i++){
        long step = mati[i+1] - mati[i];
        if(step < minstep && step != 0){
            minstep = step;
            begin = mati[i];
        }
    }

    long neko = euclidean_gcd(minstep,begin);
    
    for(long i =0; i < mati.size(); i++){
        if(mati[i] % neko){
            neko = euclidean_gcd(mati[i],neko);
        }
    }
    cout << neko << endl;
}

Measured memory_bytes: 4268
N,K=map(int,input().split())
cnt=[0]*100001
for i in range(N):
    a,b=map(int,input().split())
    cnt[a]+=b
ans=0
tmp=0
for i in range(100001):
    tmp+=cnt[i]
    if(tmp>=K):
        ans=i
        break
print(ans)

Measured memory_bytes: 5748
#include <stdio.h>
#include <string.h>

int main(void) {
	char str[20];
	int len,i;
	scanf("%s",str);
	len = strlen(str);
	for(i=len-1;i>=0;i--){
		printf("%c",str[i]);
	}
	printf("\n");
	return 0;
}



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

int main() {
  int N; string S; cin >> N >> S;
  int c = 0;
  for (int b = 0; b < 1000; b++) {
    int i = 0;
    for (; i < N; i++) if (S[i] == (char)('0'+b/100)) break;
    for (i++; i < N; i++) if (S[i] == (char)('0'+b/10%10)) break;
    for (i++; i < N; i++) if (S[i] == (char)('0'+b%10)) break;
    c += (i < N);
  }
  cout << c << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main() {
  char s[11];
  scanf("%s", s);
  int flag = 1;
  for (int i = 0; i < 11; i++) {

    if (s[i] == '\0' && i % 2 == 0) {
      break;
    }
    if (i % 2 == 0) {
      if (s[i] != 'h' && s[i] != '\0') {
        printf("No\n");
        flag = 0;
        break;
      }
    }

    if (i % 2 == 1) {
      if (s[i] != 'i' || s[i] == '\0') {
        printf("No\n");
        flag = 0;
        break;
      }
    }
  }
  if (flag == 1) {
    printf("Yes\n");
  }
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

int N, A[100'010], Q, B, C;
lli ans;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		int t; cin >> t;
		A[t]++;
		ans += t;
	}
	cin >> Q;
	while (Q--)
	{
		cin >> B >> C;
		ans += 1LL * A[B] * (C - B);
		A[C] += A[B];
		A[B] = 0;
		cout << ans << "\n";
	}
}

Measured memory_bytes: 4052
using System;
using System.Linq;
namespace Wandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var @in = Console.ReadLine();
            var c = int.Parse(Console.ReadLine());
            for (int i = 0; i < c; i++)
            {
                var line = Console.ReadLine().Split(' ');
                var a1 = int.Parse(line[1]);
                var a2 = int.Parse(line[2]);
                switch (line[0])
                {
                    case "replace":
                    var a3 = line[3];
                    @in = @in.Substring(0, a1) + a3 + @in.Substring(a2 + 1);
                    break;
                    case "reverse":
                    @in = @in.Substring(0, a1) + string.Join("", @in.Substring(a1, a2 - a1 + 1).Reverse().Select(x => x.ToString()).ToArray()) + @in.Substring(a2 + 1);
                    break;
                    case "print":
                    Console.WriteLine(@in.Substring(a1, a2 - a1 + 1));
                    break;
                }
            }
        }
    }
}



Measured memory_bytes: 9664
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    lint N, K;
    cin >> N >> K;
    lint low = 0, high = K + 1; // [low, high)
    while(low + 1 < high){
        lint mid = (low + high) / 2;
        lint sum = 0, tmp = mid;
        for(int i = 0; i < N; i++){
            sum += tmp;
            tmp /= 2;
            if(tmp == 0){
                break;
            }
        }
        if(sum <= K){
            low = mid;
        }else{
            high = mid;
        }
    }
    cout << low << endl;
}



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

int main(){
  int N;
  string S;
  cin >> N >> S;
  
  int ans=0;
  for(int i=0; i<N-2; i++){
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
      ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  var A = [];
  var fst = 0;
  var snd = 0;
  var now = 0;
  var pos = 0;
  //パラメータを配列に確保しつつ最大値と２番目の値を変数に格納
  for( i=0 ; i<N ; i++ ){
    inputStr = input[i+1].split(" ");
    now = Number.parseInt(inputStr[0]);
    A.push(now);
    if( snd <= now ){
      snd = now;
    }
    if( fst <= now ){
      snd = fst;
      fst = now;
      pos = i;
    }
  }
  //結果表示
  for( j = 0 ; j < N ; j++){
    if( j === pos ){
      console.log(snd);
    } else {
      console.log(fst);
    }
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 37736
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

enum DIST{
	LEFT,
	RIGHT,
};

struct Info{
	Info(int arg_x,int arg_line_num){
		x = arg_x;
		line_num = arg_line_num;
	}
	bool operator<(const struct Info &arg) const{
			return x > arg.x;
	};
	int x,line_num;
};

int main(){

	int n,m,tmp_x,tmp_line_num;

	scanf("%d %d",&n,&m);

	int** dp = new int*[n+1];
	for(int i = 1; i <= n; i++){
		dp[i] = new int[2];
		dp[i][LEFT] = 0;
		dp[i][RIGHT] = 0;
	}

	priority_queue<Info> Q;

	for(int i = 0; i < m; i++){
		scanf("%d %d",&tmp_x,&tmp_line_num);
		Q.push(Info(tmp_x,tmp_line_num));
	}

	while(!Q.empty()){
		tmp_line_num = Q.top().line_num;
		dp[tmp_line_num+1][RIGHT] = max(dp[tmp_line_num+1][RIGHT],dp[tmp_line_num][RIGHT]+1);
		dp[tmp_line_num][LEFT] = max(dp[tmp_line_num][LEFT],dp[tmp_line_num+1][LEFT]+1);
		Q.pop();
	}

	printf("%d",dp[1][LEFT]+dp[1][RIGHT]+1);
	for(int i = 2; i <= n; i++){
		printf(" %d",dp[i][LEFT]+dp[i][RIGHT]+1);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 11176
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

const int inf = 100000000000000;
const int mx = 2525;
int N, M, P;

int dist[mx];
bool negative[mx];

struct edge{
    int from, to, cost;
    edge(int f = 0, int t = 0, int c = 0) : from(f), to(t), cost(c) {}
};
edge graph[mx * 2];

//ABC137
signed main(void){

    cin >> N >> M >> P;
    rep(i, M){
        int a, b, c; cin >> a >> b >> c; a--; b--; c -= P;
        graph[i] = edge(a, b, -c);
    }

    fill(dist, dist + N, inf);
    dist[0] = 0;
    rep(i, N - 1){
        rep(j, M){
            if(dist[graph[j].from] == inf)continue;
            chmin(dist[graph[j].to], dist[graph[j].from] + graph[j].cost);
        }
    }

    rep(i, N){
        rep(j, M){
            if(dist[graph[j].from] == inf)continue;
            if(chmin(dist[graph[j].to], dist[graph[j].from] + graph[j].cost)){
                negative[graph[j].to] = true;
            }
            if(negative[graph[j].from])negative[graph[j].to] = true;
        }
    }

    int ans = -dist[N - 1];
    if(negative[N - 1])cout << -1 << endl;
    else cout << max<int>(ans, 0) << endl;

}


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

using namespace std;

int arr[100005];
int n;

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin >> x;
		arr[x]=i;
	}
	for(int i=1;i<=n;i++)
		cout << arr[i] << " \n"[i==n];
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int N; cin >> N; //書類にN個の整数
    vector <int> A(N);
    bool ans=true;
    rep(i,N){
        cin >> A[i];
        if (A[i]%2==0){
            if (!(A[i]%3==0 || A[i]%5==0)) ans=false;
        }
    }
    if (ans) cout << "APPROVED";
    else cout << "DENIED";
}

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

int H, W, C, M, Nw, Nc, Nm, Win, Wout, Cin, Cout, Mio, s, t, res;
int cap[310][310];
bool used[310];
enum { source = 300, sink, nwin, nwout, ncin, ncout, nmio };

bool dfs(int v)
{
    used[v] = true;
    for(int i = 0; i < 310; ++i)
        if(cap[v][i] > 0 && !used[i])
            if(i == sink || dfs(i)) {
                --cap[v][i]; ++cap[i][v]; return true;
            }
    return false;
}

int main()
{
    while(cin >> H >> W >> C >> M >> Nw >> Nc >> Nm && H >= 0)
    {
        Win  = H;
        Wout = Win  + W;
        Cin  = Wout + W;
        Cout = Cin  + C;
        Mio  = Cout + C;

        memset(cap, 0, sizeof(cap));
        for(int i = 0; i < H; ++i) {
            cap[source][i] = 1;
            cap[i][nwin] = 1;
        }
        for(int i = 0; i < W; ++i) {
            cin >> s;
            for(int j = 0; j < s; ++j) { cin >> t; cap[t-1][Win+i] = 1; }
            cap[Win+i][Wout+i] = 1;
            cap[Wout+i][ncin] = 1;
        }
        for(int i = 0; i < C; ++i) {
            cin >> s;
            for(int j = 0; j < s; ++j) { cin >> t; cap[Wout+t-1][Cin+i] = 1; }
            cap[nwout][Cin+i] = 1;
            cap[Cin+i][Cout+i] = 1;
            cap[Cout+i][nmio] = 1;
        }
        for(int i = 0; i < M; ++i) {
            cin >> s;
            for(int j = 0; j < s; ++j) { cin >> t; cap[Cout+t-1][Mio+i] = 1; }
            cap[ncout][Mio+i] = 1;
            cap[Mio+i][sink] = 1;
        }
        cap[nwin][nwout] = Nw;
        cap[ncin][ncout] = Nc;
        cap[nmio][sink]  = Nm;

        res = 0;
        do fill_n(used, 310, false);
        while(dfs(source) && ++res);
        cout << res << endl;
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  vector<int> l(n);
  int maxLength = 0;
  int sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> l[i];
    maxLength = max(maxLength, l[i]);
  }
  int used = 0;
  for(int i = 0; i < n; i++) {
    if(used == 0 && l[i] == maxLength) {
      used = 1;
    } else {
      sum += l[i];
    }
  }
  if(maxLength < sum) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
x_ls = list(map(int, input().split()))
x_ls.sort()

d_ls = [0] * m
for i in range(1,m):
    d_ls[i] = x_ls[i] - x_ls[i-1]
d_ls.sort(reverse = True)
print(x_ls[-1] - x_ls[0] - sum(d_ls[:n-1]))

Measured memory_bytes: 13968
// #include<bits/stdc++.h>
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
//#include<stdio.h>
//#include<cmath>
//#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define umii unordered_map<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define pws(x) cout<<x<<" ";
#define pwe(x) cout<<x<<endl;
#define all(arr) arr.begin(),arr.end()
using namespace std;

vector<pair<bool,int> > common(vector<pair<bool,int> > a,vector<pair<bool,int> > b)
{
	for(int i=0;i<26;i++)
	{
		if(a[i].first && b[i].first)
		{
			a[i].second=min(a[i].second,b[i].second);
		}
		else
		{
			a[i].first=0;
		}
	}
	return a;
}

int main()
{
	
	int t=1;
	cin>>t;
	vector< pair<bool, int> > a(26,make_pair(0,0));
	string str;
	cin>>str;
	t--;
		for(int i=0;i<str.length();i++)
		{
			a[str[i]-'a'].first=1;
			a[str[i]-'a'].second++;			
		}
	while(t--)
	{
		string str;
		cin>>str;
		vector< pair<bool, int> > b(26,make_pair(0,0));
		for(int i=0;i<str.length();i++)
		{
			b[str[i]-'a'].ff=1;
			b[str[i]-'a'].ss++;			
		}
		a=common(a,b);
	}
   	for(int i=0;i<26;i++)
   	{
   		if(a[i].first)
   		{
			while(a[i].second--)
			{
				cout<<char(i+'a');
			}
   		}
   	}
	return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<28;
const int MAXH = 12;
const int MAXW = 12;
int H, W;
char C[MAXH][MAXW];
map<deque<int>, int> dp[2];

deque<int> normalize(deque<int> v) {
  map<int, int> m;
  for(int i = 0; i < v.size(); ++i) {
    if(v[i] == -1 || v[i] == 0) continue;
    if(!m.count(v[i])) {
      m[v[i]]; m[v[i]] = m.size();
    }
    v[i] = m[v[i]];
  }
  return v;
}

int rotate() {
  int t[MAXH][MAXW];
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      t[j][i] = C[i][j];
    }
  }
  swap(H, W);
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      C[i][j] = t[i][j];
    }
  }
}

int main() {
  while(cin >> H >> W) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> C[i][j];
      }
    }
    if(W == 1) rotate();
    if(H == 1 && W == 1) {
      if(C[0][0] == '.') cout << 0 << endl;
      else cout << 1 << endl;
      continue;
    }
    dp[0] = dp[1] = map<deque<int>, int>();
    dp[0][deque<int>(W, -1)] = 0;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        const int now = (i * W + j) % 2;
        const int next = 1 - now;
        dp[next] = map<deque<int>, int>();
        //cout << "(" << i << "," << j << "):" << dp[now].size() << endl;
        for(map<deque<int>, int>::iterator it = dp[now].begin();
            it != dp[now].end(); ++it) {
          //for(int k = 0; k < it->first.size(); ++k) {
          //cout << it->first[k] << " ";
          //}
          //cout << endl;
          int left = j == 0 ? -1 : it->first.back();
          int top = it->first.front();
          if(C[i][j] == '?' || C[i][j] == '.') do {
              if(left && top) {
                deque<int> nv = it->first;
                nv.push_back(0);
                int tmp = nv.front();
                nv.pop_front();
                if(tmp > 0 && find(nv.begin(), nv.end(), tmp) == nv.end()) {
                  continue;
                }
                nv = normalize(nv);
                dp[next][nv] = max(dp[next][nv], it->second);
              }
            } while(0);
          if(C[i][j] == '?' || C[i][j] == '#') do {
              if(left <= 0 || top <= 0 || left != top) {
                deque<int> nv = it->first;
                nv.push_back(INF);
                if(left > 0) replace(nv.begin(), nv.end(), left, INF);
                if(top  > 0) replace(nv.begin(), nv.end(), top,  INF);
                int tmp = nv.front();
                nv.pop_front();
                if(tmp > 0 && find(nv.begin(), nv.end(), tmp) == nv.end()) {
                  continue;
                }
                nv = normalize(nv);
                dp[next][nv] = max(dp[next][nv], it->second + 1);
              }
            } while(0);
        }
      }
    }
    int now = H * W % 2;
    int res = -1;
    for(map<deque<int>, int>::iterator it = dp[now].begin();
        it != dp[now].end(); ++it) {
      if(*max_element(it->first.begin(), it->first.end()) > 1) continue;
      res = max(res, it->second);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 5828
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        for(int i = 0; i < n; i++)
        	sum += sc.nextLong();

        System.out.println(sum - n);
    }
}


Measured memory_bytes: 25804
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i] >> b[i];
  rrrep(i, n - 1, 0) {
    a[i] += ans;
    if (a[i] % b[i] == 0) continue;
    ans += b[i] - (a[i] % b[i]);
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 5756
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	cin >>S;
	vector<int>RL(S.size());
	vector<int>place(0);
	for(int i=0;i<S.size()-1;i++){	
		if(S.at(i)=='R' && S.at(i+1)=='L'){
			RL.at(i)=1;
			RL.at(i+1)=2;
			place.push_back(i);
			i++;
		}
		
		else{
			if(S.at(i)=='R'){
			RL.at(i)=0;}
			else {RL.at(i)=-1;}
		}
	}
	if(RL.at(S.size()-1)!=2 && S.at(S.size()-1)=='L'){
		RL.at(S.size()-1)=-1;
	}
	
	for(int i=0;i<place.size();i++){
		int k=place.at(i)-2;
		int count =1;
		if(k>=0){
			while(RL.at(k)==0){
					count++;
					k=k-2;
					if(k<0){
						break;
					}
			}
		}
		int j=place.at(i)+2;
		if(j<=RL.size()-1){
			while(RL.at(j)==-1){	
				count++;
				j=j+2;
					if(j>RL.size()-1){
						break;
					}
				}
			}
		
		
		RL.at(place.at(i))=count;
		
		k=place.at(i)-1;
		count=1;
		if(k>=0){	
			while(RL.at(k)==0){
				count++;
				k=k-2;
				if(k<0){break;}
			}
		}
		j=place.at(i)+3;
		if(j<=RL.size()-1){
			while(RL.at(j)==-1){
				count ++;
				j=j+2;
				if(j>RL.size()-1){break;}
			}
		}
		RL.at(place.at(i)+1)=count;
	}
	
	
	for(int i=0;i<RL.size();i++){
		if(i!=RL.size()-1){
			if(RL.at(i)==-1){
				cout << 0<<' ';
			}
			else{
				cout << RL.at(i)<<' ';
			}
		}
		else{
			if(RL.at(i)==-1){
				cout << 0<<endl;
			}
			else{
				cout << RL.at(i)<<endl;
			}
		}
	}
}
	


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
using Graph = vector<vector<int>>;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, n - 2) {
        if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') {
            ans++;
        }            
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		
		String a= sc.next();
		
		String b="";
		
		
		for(int i=0;i<4;i++)
		{	
			 b=b+a.charAt(i);
		}
		b=b+" ";
		for(int i=4;i<a.length();i++)
		{	
			 b=b+a.charAt(i);
		}
		System.out.println(b);
		sc.close();
			
	}

}


Measured memory_bytes: 10192
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll L,R,D;
	while(cin>>L>>R>>D) {
		ll ans=0;
		RANGE(i, L, R+1) {
			if(i%D==0) ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3160
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
for i in range(n):
    a = list(map(int, input().split()))
    ans = 0
    for (j, k) in zip(a, B):
        ans += j * k
    if ans + c > 0:
        cnt += 1
print(cnt)

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

/*
Aiは
任意のAjで割り切れない
sortすれば自分より小さいものだけ見ればよい
小さい方からみて、エラトステネスの篩をする
*/

int	main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	vector<bool> is_prime(1e6 + 1, true);
	vector<bool> is_used(1e6 + 1, false);
	for (int i = 0; i < n; i++)
	{
		if (is_used[a[i]]) is_prime[a[i]] = false;
		else
		{
			is_used[a[i]] = true;
			for (int j = 2; a[i] * j <= 1e6; j++) is_prime[a[i] * j] = false;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) ans += is_prime[a[i]];
	cout << ans << endl;
	return (0);
}


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

int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  if(s.at(k-1)=='A') s.at(k-1)='a';
  else if(s.at(k-1)=='B') s.at(k-1)='b';
  else s.at(k-1)='c';
  cout << s << endl;
}

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

int main(){
  int n; cin >> n;
  int v[50], c[50];
  int ans = 0;
  for(int i = 0; i < n; i++) cin >> v[i];
  for(int i = 0; i < n; i++) cin >> c[i];
  for(int i = 0; i < n; i++){
    if(v[i] > c[i]) ans += v[i] - c[i];
  }
  cout << ans << endl;
}
    

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

using namespace std;

const long long INF = 1e18;
const long long nax = 1e5 + 7;

long long n, dp[nax], arr[nax];

int main() {
	cin >> n;

	for (long long i = 0; i < n; i++) cin >> arr[i];
	for (int i = 1; i < n; i++) dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), (i > 1 ? dp[i - 2] + abs(arr[i] - arr[i - 2]) : INF));
	

	cout << dp[n - 1];	
}


Measured memory_bytes: 5176