akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main(){
  int N;
  cin >> N;
  int ans = 900;
  rep2(i, 1, N){
    string s = to_string(i);
    string t = to_string(N-i);
//    cout << s << " " << t << endl;
    int sdA = 0, sdB = 0;
    rep(j, s.size()){
//      cout << j << ":" << s.at(j) - '0' << endl;
      sdA += s.at(j) - '0';
    }
    rep(j, t.size()){
      sdB += t.at(j) - '0';
    }
//    cout << sdA << " " << sdB << endl;
    chmin(ans, (sdA+sdB));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner (System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();

		while (h!=0 || w!=0){
			for (int i=1;i<=h;++i){
				for (int j=1;j<=w;++j){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
			h=sc.nextInt();
			w=sc.nextInt();
		}

	}
}


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


typedef  long long ll;

ll n,m=0,k=0;

bool test=false,test1=false;

ll const N=1e5+7;

ll const oo=1000000007 ;

ll nChoosek( ll n, ll k )
{
    if (k > n) return 0;
    if (k * 2 > n) /*return*/ k = n-k;  //remove the commented section
    if (k == 0) return 1;

    ll result = n;
    for( ll i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}

vector<ll> v,v1;

vector<pair<ll,ll> > vv;

//ll  t[oo][oo];

map<pair<ll,ll> ,ll> my;

map<ll,ll> my1;

priority_queue<ll> q;

ll t[N];

ll t1[N];

ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};



bool in_da_prison(ll x,ll y)
{
    return (x<9   && x>=0  && y<9 && y>=0);
}
//ll mem[]

ll dp(ll a ,ll b,ll c ,ll x)
{ll choice1,choice2,choice3;
if(x==0) return 1;
    if(a   && x>=500 ) choice1= dp(a-1,b,c,x-500);
else choice1=0;
if(b   && x>=100 )choice2= dp(a,b-1,c,x-100);
else choice2=0;
if(c   && x>=50 )choice3= dp(a,b,c-1,x-50);
else choice3=0;
    return choice1+choice2+choice3;
}
bool cont(ll x)
{
    if(x%10==7 || x/10==7) return true;
    else return false;
}


vector<ll> v2[N];
ll z[N];
void dfs(ll s)
{
    if (z[s]) return;
 z[s] = 1;
 for (ll u=0;u<v2[s].size();u++)
    { dfs(v2[s][u]); }
 }

int main() {


ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll i=0,j=0,a=0,b=0,c=0,d=-1e18,x=0,y=0,s=0;
string s1,s2,s3,s4,s5;
cin>>a>>b>>c>>x;
for(i=0;i<=a;i++)
    for(j=0;j<=b;j++)
    for(k=0;k<=c;k++)
    if(i*500+j*100+k*50==x) y++;
cout<<y;
   return 0;

}


Measured memory_bytes: 3584
//場合分け6通り
#include<iostream>
using namespace std;

main(){
  int N;
  cin >> N;
  int a[N],b[N],c[N];
  for(int ii=0;ii<N;ii++){
    cin >> a[ii] >> b[ii] >> c[ii];
  }
  int dp[N+1][3];
  for(int ii=0;ii<N+1;ii++){
    for(int jj=0;jj<3;jj++){
      dp[ii][jj]=0;
    }
  }
  for(int jj=0;jj<3;jj++){
    dp[0][jj]=0;
  }
  for(int ii=0;ii<N;ii++){
    dp[ii+1][0]=max(dp[ii+1][0],dp[ii][1]+b[ii]);
    dp[ii+1][0]=max(dp[ii+1][0],dp[ii][2]+c[ii]);
    dp[ii+1][1]=max(dp[ii+1][1],dp[ii][0]+a[ii]);
    dp[ii+1][1]=max(dp[ii+1][1],dp[ii][2]+c[ii]);
    dp[ii+1][2]=max(dp[ii+1][2],dp[ii][0]+a[ii]);
    dp[ii+1][2]=max(dp[ii+1][2],dp[ii][1]+b[ii]);
  }
  int ans=0;
  for(int jj=0;jj<3;jj++){
    ans=max(ans,dp[N][jj]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN

    ll a,b,q;cin>>a>>b>>q;
    set<ll> s, t;
    s.insert(1e18);
    s.insert(-1e18);
    t.insert(1e18);
    t.insert(-1e18);

    REP(i,a){
        ll sa; cin>>sa;
        s.insert(sa);
    }
    REP(i,b){
        ll tb; cin>>tb;  
        t.insert(tb);
    }


    REP(i, q){
        ll x; cin>>x;
        ll rs = *s.lower_bound(x);
        ll rt = *t.lower_bound(x);
        auto it = s.lower_bound(x);
        it--;
        ll ls = *it;
        it = t.lower_bound(x);
        it--;
        ll lt = *it;
        ll ans = min({
            max(x-ls, x-lt),
            max(rs-x, rt-x),
            min(rt-ls+x-ls, rt-x+rt-ls),
            min(rs + x - 2 * lt, 2 * rs - x - lt)
        });
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 10752
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  string s;
  cin>>s;

  int n=s.size();
  rep(i,n){
    cout<<"x";
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a, x = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0) {
      x *= 2;
    }
  }
  cout << pow(3, n) - x << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>k>>n;
    	vi v(n),ans;
    	cin>>v;
    	sort(all(v));
    	for(i=1;i<n;i++)
    	{
    		ans.pb(v[i]-v[i-1]);
    	}
    	ans.pb(-v[n-1]+v[0]+k);
    	sort(all(ans));
    	ll x=ans.back();
    	cout<<k-x;
    }
    return 0;
}

Measured memory_bytes: 4596
#include<iostream>
using namespace std;
int main() {
    int n, m, l;
    int x[100][100];
    int y[100][100];
    long long z[100][100];
    cin >> n >> m >> l;
    for (int prime1 = 0; prime1 < n; prime1++) {
        for (int prime2 = 0; prime2 < m; prime2++) {
            cin >> x[prime1][prime2];
        }
    }
    for (int prime2 = 0; prime2 < m; prime2++) {
        for (int prime3 = 0; prime3 < l; prime3++) {
            cin >> y[prime2][prime3];
        }
    }
    for (int prime1 = 0; prime1 < n; prime1++) {
        for (int prime3 = 0; prime3 < l; prime3++) {
            z[prime1][prime3] = 0;
            for (int prime2 = 0; prime2 < m; prime2++) {
                z[prime1][prime3] += x[prime1][prime2] * y[prime2][prime3];
            }
        }
    }
    for (int prime1 = 0; prime1 < n; prime1++) {
        for (int prime3 = 0; prime3 < l; prime3++) {
            if(prime3<l-1){
                cout << z[prime1][prime3] << " ";
            }else{
                cout << z[prime1][prime3];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
const int maxn=(1<<21)+10;
int n,m,f[21][maxn],lg[maxn],tr[maxn][2];
int main()
{
	scanf("%d%d",&n,&m);
	for(int j=0;j<=n;j++)
		for(int i=0;i<(1<<j);i++)
			scanf("%1d",&f[j][i^(1<<j)]);
	for(int i=2;i<(1<<(n+1));i++) lg[i]=lg[i>>1]+1;
	for(int i=2;i<(1<<(n+1));i++)
		if((i>>(lg[i]-1))&1)
			tr[i][1]=i^(1<<lg[i]),tr[i][0]=tr[tr[i][1]][0];
		else
			tr[i][0]=i^(3<<(lg[i]-1)),tr[i][1]=tr[tr[i][0]][1];
	for(int j=n;j;j--)
		for(int i=(1<<j);i<(1<<(n+1));i++)
		{
			int k = i >> j, l = (i & ((1 << j) - 1)) ^ (1 << j);
			if(tr[l][0]) f[lg[tr[l][0]]][(((k << 1) ^ 1) << lg[tr[l][0]]) ^ tr[l][0]] += f[j][i];
			if(tr[l][1]) f[lg[tr[l][1]]][(((k << 1) ^ 0) << lg[tr[l][1]]) ^ tr[l][1]] += f[j][i];
			f[0][k] += f[j][i];
		}
	int ans=1;
	for(int i=2;i<(1<<(n+1));i++)
		if(f[0][i]>=m && lg[i]>lg[ans]) ans=i;
	int j=n;
	while((~ans>>j)&1) j--;
	while(j--) putchar(((ans>>j)&1)+'0');
	putchar('\n');
	return 0;
}

Measured memory_bytes: 192168
N, X, Y = map(int, input().split())
A = [0] * N
for i in range(1, N):
  for j in range(i + 1, N + 1):
    if i <= X and X < j < Y and (j - i) > (X - i + 1 + (Y - j)):
      t = (X - i + 1 + (Y - j))
      #print(f'{i},{j}/if1:{t}')
    elif X < i < Y and X < j < Y and (j - i) > (i - X + 1 + Y - j):
      t = (i - X + 1 + Y - j)
      #print(f'{i},{j}/if2:{t}')
    elif j >= Y and X <= i < Y and j - i > (i - X + 1 + (j - Y)):
      t = (i - X + 1 + (j - Y))
      #print(f'{i},{j}/if3:{t}')
    elif i <= X and Y <= j:
      t = j - i - (Y - X - 1)
      #print(f'{i},{j}/if4:{t}')
    else:
      t = j - i
      #print(f'{i},{j}/else:{t}')
    A[t] += 1
A.pop(0)
[print(i) for i in A]

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

typedef long long int ll;




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll x;
    cin >> x;
    ll ans = ((x/500)*1000) + ((x%500)/5)*5;
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
import numpy as np

h, n = map(int, input().split())
m = np.array([list(map(int, input().split())) for _ in range(n)])

max_a = np.max(m[:,0])
dp = np.zeros(h+max_a+1, dtype='i8')
for i in range(max_a+1, h+max_a+1):
    dp[i] = np.min(dp[i-m[:,0]] + m[:,1])
print(dp[h+max_a])


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

long long int ans;
long long int W, H, sz;
vector<pair<int, int> > pq;
int passepartout;

int main(){
    cin >> W >> H;
    int sz = W + H;
    for(int i = 0; i < W; i++){
        scanf("%d", &passepartout);
        pq.push_back(make_pair(passepartout, 0));
    }
    for(int i = 0; i < H; i++){
        scanf("%d", &passepartout);
        pq.push_back(make_pair(passepartout, 1));
    }
    sort(pq.begin(), pq.end());
    for(int i = 0; i < sz; i++){
        pair<int, int> pas = pq[i];
        if(pas.second == 0){
            ans += pas.first * (H + 1);
            W--;
        }else{
            ans += pas.first * (W + 1);
            H--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
N, K = map(int, input().split())
R, S, P = map(int, input().split())
score = {'r':P, 's':R, 'p':S}
# rならP点、sならR点、pならS点
T = input()

rCount = T.count('r')
sCount = T.count('s')
pCount = T.count('p')
maxValue = rCount*P + sCount*R + pCount*S

if N <= K:
    print(maxValue)
else:
    A = []
    for i in range(K):
        A.append(T[i::K])
    
    for a in A:
        minus = {'r':0, 's':0, 'p':0}
        listA = list(a)
        for i in range(len(listA)-1):
            if listA[i] == listA[i + 1]:
                minus[listA[i]] += score[listA[i]]
                listA[i+1] = 'chenge'
        maxValue -= (minus['r'] + minus['s'] + minus['p'])

print(maxValue)








Measured memory_bytes: 8828
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int n,a[100000+10],t=1,dg;
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	for(int i=1; i<n; i++)
	{
		if(a[i]==a[i+1])t++;
		else
		{
			if(t>a[i])dg+=t-a[i];
			if(t<a[i])
			{
				dg+=t;
			}
			t=1;
		}
	}
	if(t>a[n])dg+=t-a[n];
	if(t<a[n])		
	{
		dg+=t;
	}
	t=1;
	cout<<dg<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
using namespace std;
int main(){
  string S;
  cin>>S;
  deque<char>dS(S.size());
  for(int i=0;i<S.size();++i) dS[i]=S[i];
  int q;
  cin>>q;
  int rev=0;
  for(int i=0;i<q;i++){
    int type;
    cin>>type;
    if(type==2){
      int f;
      char c;
      cin>>f>>c;
      --f;
      if(rev) f=1-f;
      if(f==0) dS.push_front(c);
      else dS.push_back(c);
    }
    else rev=1-rev;
  }
  if(rev) reverse(dS.begin(),dS.end());
  for(auto c:dS) cout<<c;
  cout<<endl;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

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

    int P[n];

    for (int i = 0; i < n; i++)
    {
        cin >> P[i];
    }

    int count =0;
    for (int i = 1; i < n - 1; i++) {
        if ((P[i - 1] < P[i] && P[i] < P[i + 1]) || 
        (P[i - 1] > P[i] && P[i] > P[i + 1]) ) {
            count++;
        }

    }


    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
P = list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
    s = P[i-1]+P[i]+P[i+1]
    if s-min(P[i-1],P[i],P[i+1])-max(P[i-1],P[i],P[i+1]) == P[i]:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
using TU = tuple<int,int,int>;

int main(){
  int n, ann;
  cin >> n;
  priority_queue<TU,vector<TU>,greater<TU>> que;
  vector<vector<int>> dis(n, vector<int>(n,INF));
  for(int i=0; i<n; ++i) for(int j=0; j<n; ++j){
    cin >> ann;
    if(i < j){
      que.push(TU(ann,i,j));
    }
    if(i == j) dis[i][i] = 0;
  }
  int d, x, y;
  long long ans = 0;
  while(!que.empty()){
    tie(d,x,y) = que.top();
    que.pop();
    int nd = INF;
    for(int i=0; i<n; ++i){
      nd = min(nd, dis[x][i] + dis[i][y]);
    }
    dis[x][y] = d;
    dis[y][x] = d;
    if(nd == d) continue;
    else if(nd > d) ans += d;
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4604
s = input().split(" ")
nums = list(map(int, s))
W = nums[0]
H = nums[1]
x = nums[2]
y = nums[3]
r = nums[4]
if x - r >= 0 and x + r <= W and y - r >=0 and y + r <= H:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7640
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>


using namespace std;


int main() {

	bool ans = true;

	long long int N, t, x, y, t0 = 0, x0 = 0, y0 = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> t >> x >> y;
		
		if (t % 2 != (x + y) % 2) {
			ans = false;
		}
		else if (t < x + y) {
			ans = false;
		}
		else if (t - t0 < abs(x - x0) + abs(y - y0)) {
			ans = false;
		}
		t0 = t;
		x0 = x;
		y0 = y;
	}

	if (ans) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    vector<int> v(3);
    for(int i = 0; i < 3; i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    if(v[0]+v[1] == v[2]){
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long A, long long B, long long N) {
    ll res;
    if (N >= B)
        res = A * (B - 1) / B - A * ((B - 1) / B);
    else
        res = A * N / B - A * (N / B);
    cout << res << endl;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long N;
    scanf("%lld", &N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3656
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

// i: index, n: size, a: start, b: end
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

// x: container(array, vector etc..)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5

#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main() {
  int a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;

  // Aのほうが速度が遅い場合
  if (v <= w) {
    cout << "NO" << endl;
    return 0;
  }

  // Aが追いつける範囲内にいない場合
  int dist = abs(a - b);
  int max_dist = abs((v * t) - (w * t));
  if (dist > max_dist) {
    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int ans = 0;
    string S, T;
    cin >> S >> T;
    if (S[0] == T[0]) ans++;
    if (S[1] == T[1]) ans++;
    if (S[2] == T[2]) ans++;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int N;

int main(int argc, char** argv) {
    cin >> N;
    stack<int> s;
    while (N != 0) {
        int b = N % 4;
        if (b < -2) b += 4;
        if (1 < b) b -= 4;
        if (b == -2) {
            s.push(0);
            s.push(1);
        } else if (b == -1) {
            s.push(1);
            s.push(1);
        } else if (b == 0) {
            s.push(0);
            s.push(0);
        } else if (b == 1) {
            s.push(1);
            s.push(0);
        }
        N = (N - b) / 4;
    }
    if (s.empty()) {
        cout << 0;
    } else {
        if (s.top() != 0) {
            cout << 1;
        }
        s.pop();
        while (!s.empty()) {
            cout << s.top();
            s.pop();
        }
    }
    cout << endl;
}

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

namespace std {
template <>
struct hash<pair<int, int>> {
  size_t operator()(const pair<int, int>& v) const noexcept {
    return hash<int>()(v.first << 16 | v.second);
  }
};
}  // namespace std

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

int H, W;
vector<string> S;

int search(pair<int, int> pos) {
  unordered_map<pair<int, int>, int> s;
  queue<pair<int, int>> q;
  s[pos] = 1;
  q.push(pos);
  int d;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    d = s[p];
    rep(i, 4) {
      int x = p.first + dx[i], y = p.second + dy[i];
      auto np = make_pair(x, y);
      if (x < 0 || x >= W || y < 0 || y >= H || S[y][x] != '.' || s[np])
        continue;
      s[np] = d + 1;
      q.push(np);
    }
  }
  return d - 1;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W;
  S.resize(H);
  rep(i, H) cin >> S[i];
  int ans = 0;
  rep(y, H) rep(x, W) if (S[y][x] == '.') ans = max(ans, search({x, y}));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
void input()
{
	cin >> n;
}

void calculation()
{
	input();
	if(n <= 111)
		cout << 111;
	if(n > 111 && n <= 222)
		cout << 222;
	if(n > 222 && n <= 333)
		cout << 333;
	if(n > 333 && n <= 444)
		cout << 444;
	if(n > 444 && n <= 555)
		cout << 555;
	if(n > 555 && n <= 666)
		cout << 666;
	if(n > 666 && n <= 777)
		cout << 777;
	if(n > 777 && n <= 888)
		cout << 888;
	if(n > 888 && n <= 999)
		cout << 999;
}

int main()
{
	calculation();	
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;

using qul = queue<ll>;

int main() {
    ll X,N,ans = 0,num,ansnum = 1000;
    cin >> X >> N;
    vel p(N);
    vel check(100);
    REP(i, N){
        cin >> p[i];
        check[p[i]-1] = p[i];
    }

    REP(i,100) {
        num = abs(X - i -1);
        if(ansnum > num && check[i] == 0){
            ans = i+1;
            ansnum = num;
        }
    }

    if(ansnum >= X){
        ans = 0;
        ansnum = X;
    }
    if(ansnum > 101 - X)
        ans = 101;


    cout << ans << endl;
    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define int long long int
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll m = 998244353;
int power(int x,int y, int m) 
{ 
    if (y == 0) 
        return 1;
    int p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
int modInverse(int a, int m) 
{     
        return power(a, m-2, m); 
}
int mod(int x)
{
	if(x<0)return -x;
	else return x;
 } 
int nearestint(int a[],int n,int x)
{
	if(binary_search(a,a+n,x))
	return x;
	else
	{
		if(x-a[(upper_bound(a+1,a+n+1,x)-a-1)]>a[(upper_bound(a+1,a+n+1,x)-a)]-x)
		return a[(upper_bound(a+1,a+n+1,x)-a)];
		else return a[(upper_bound(a+1,a+n+1,x)-a-1)];
	}
}
signed main()
{
ios::sync_with_stdio(0); 
cin.tie(0);
readb(n,k);
readarr(h,n);
int dp[n+1]={0};
FOR(i,2,n)
{
	 dp[i]=dp[i-1]+mod(h[i]-h[i-1]);
	FOR(j,1,k)
	{
	  if(i>j)
	  dp[i]=min(dp[i],dp[i-j]+mod(h[i]-h[i-j]));
	}
}
cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;
  
public class Main{
      
    public static void main(String[] args){
                 
        Scanner sc = new Scanner(System.in);
                  
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
          
        int[] sort = {a,b,c};  
          
        Arrays.sort(sort);
        
        System.out.println(sort[0]+" "+sort[1]+" "+sort[2]);
    }
  
}

Measured memory_bytes: 26040
N, X, Y = map(int, input().split())
k_list = [0]*N

for p in range(1, N):
  for q in range(p, N+1):
    p2X = abs(p-X)
    q2Y = abs(q-Y)
    
    distance = min(q-p, p2X+q2Y+1)
    k_list[distance] += 1
    
for k in range(1, N):
  print(k_list[k])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll n;cin>>n;
    ll ans = 0;
    ll d;
    for(int i=1;i<=n;i++){
        cin>>d;
        if(d%2==1 && i%2==1){
            ans++;
        }
    }
    cout<<ans<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(c-b>a) {
    cout << "OK" << endl;
    return 0;
  }
  for(int i = b;i < c + 1; i++) {
    if(i%a==0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3636
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    string s;
    cin >> n >> s;

    int r = 0;
    int b = 0;
    rep(i, n){
        if(s[i] == 'R'){
            r++;
        }else{
            b++;
        }
    }

    if(r > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;

int main(){
    ll ans=0,in;
    int n; cin>>n;
    for(int i=0;i<n;i++){
        cin>>in;
        if(in%2==0){
            int temp=in;
            while(temp%2==0){
                temp/=2; ans++;
            }
        }
    }
    cout<<ans<<"\n";

}


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

int main(){
string w;   cin >> w;
vector<char> S(w.size());
for (int i = 0; i < S.size(); i++) {
    S[i] = w[i];
}
if (S.size() % 2 != 0) {
    cout << "No" << endl;
    return 0;
}
sort(S.begin(), S.end());

for (int i = 0; i < S.size()/2; i++) {
    if (S[2*i] != S[2*i + 1]) {
        cout << "No" << endl;
        return 0;
    }
}
cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
 
using namespace::std;
 
long long int dp[1005][1<<13];
pair<int,int> ar[1005];
 
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
		for(int j=0;j<(1<<13);j++)
			dp[i][j]=1e9;
	for(int i=0,t;i<m;i++){
		cin>>ar[i].first>>t;
		for(int j=0,l;j<t;j++)
			cin>>l,ar[i].second|=(1<<(l-1));
	}
	
	dp[0][0]=0;
	
	for(int i=0;i<m;i++)
		for(int j=0;j<(1<<13);j++)
			dp[i+1][j]=min(dp[i][j],dp[i+1][j]),dp[i+1][j|ar[i].second]=min(dp[i+1][j|ar[i].second],dp[i][j]+ar[i].first);
 
	//for(int i=0;i<m;cout<<'\n',i++)
	//	for(int j=0;j<=(1<<n)-1;j++)
	//		cout<<dp[i][j]<<' ';
	//cout<<'\n';
	//for(int i=0;i<m;i++)
	//	cout<<ar[i].first<<' '<<ar[i].second<<'\n';
 
	cout<<(dp[m-1][(1<<n)-1]==1e9?-1:dp[m-1][(1<<n)-1])<<'\n';
}

Measured memory_bytes: 64256
N = int(input())
S =  input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
    r = S[i]
    for j in range(i+1,N-1):
        g = S[j]
        if r == g:
            continue
        k = 2*j - i
        if k >= N:
            continue
        b = S[k]
        if r != b and g != b:
            ans -= 1
print(ans)

Measured memory_bytes: 73468
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int n, m, a[50], b[50], road[50];

int main() {
	
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		road[a[i]]++;
		road[b[i]]++;
	}


	rep(i, n) {
		cout << road[i+1] << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,a;
    while (cin>>n>>m) {
        if (n==0&&m==0) {
            break;
        } else {
            std::deque<int> taro;
            std::deque<int> hanako;
            std::deque<int> ans_taro;
            std::deque<int> ans_hanako;
            for (int i=0;i<n;i++) {
                cin>>a;
                taro.emplace_back(a);
            }
            for (int j=0;j<m;j++) {
                cin>>a;
                hanako.emplace_back(a);
            }
            for (int k=0;k<taro.size();k++) {
                for (int l=0;l<hanako.size();l++) {
                    int sum_taro=0;
                    int sum_hanako=0;
                    swap(taro[k],hanako[l]);
                    for (int fuga=0;fuga<taro.size();fuga++) {
                        sum_taro+=taro[fuga];
                    }
                    for (int piyo=0;piyo<hanako.size();piyo++) {
                        sum_hanako+=hanako[piyo];
                    }
                    swap(taro[k],hanako[l]);
                    if (sum_taro==sum_hanako) {
                        ans_taro.emplace_back(taro[k]);
                        ans_hanako.emplace_back(hanako[l]);
                    }
                }
            }
            if (ans_taro.size()==1) {
                cout<<ans_taro[0]<<" "<<ans_hanako[0]<<endl;
            } else if (ans_taro.size()!=0) {
                int min=10000;
                int tmp_taro;
                int tmp_hanako;
                for (int hoge=0;hoge<ans_taro.size();hoge++) {
                    if (ans_taro[hoge]+ans_hanako[hoge]<min) {
                        min=ans_taro[hoge]+ans_hanako[hoge];
                        tmp_taro=ans_taro[hoge];
                        tmp_hanako=ans_hanako[hoge];
                    }
                }
                cout<<tmp_taro<<" "<<tmp_hanako<<endl;
            } else {
                cout<<-1<<endl;
            }
        }
    }
}



Measured memory_bytes: 3172
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
using namespace std;

int main()
{
    std::cout<<std::fixed<<std::setprecision(10);
    
    long long N, K;
    cin >> N >> K;
    
    long long len = 0;
    long long max = 0;
    long long current = 0;
    vector<long long> p = vector<long long>(200000, 0);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        current += 1 + p[i];
        if (len < K) {
            len++;
        } else {
            current -= 1 + p[i - K];
        }
        
        if (max < current) {
            max = current;
        }
    }
    
    cout << (double)max * 0.5;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
template<typename T, int N, T F(const T& a, const T& b)>
struct SegTree
{
public:
    SegTree()
    {
        dat = vector<T>(N * 2 - 1, 0);
    }

    void update(int i, T x)
    {
        i += N - 1;
        dat[i] = x;
        while (i > 0)
        {
            i = (i - 1) / 2;
            dat[i] = F(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    T query(int a, int b, int k = 0, int l = 0, int r = N)
    {
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return dat[k];
        else
        {
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return F(vl, vr);
        }
    }

    vector<T> dat;
};

/*------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
------------------------------------------------------------------------------*/











//------------------------------------------------------------------------------
using Edge = struct { int to; ll cost; };
vector<vector<Edge>> tree;
vector<ll> dists;
//------------------------------------------------------------------------------
void DFS(int curr, int prev, ll dist)
{
    dists[curr] = dist;
    for (const auto& edge : tree[curr])
    {
        if (edge.to == prev) continue;
        DFS(edge.to, curr, dist + edge.cost);
    }
}

void _main()
{
    int N;
    cin >> N;
    tree.resize(N);
    int a, b, c;
    rep(i, 0, N - 1)
    {
        cin >> a >> b >> c;
        --a; --b;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }

    int Q, K;
    cin >> Q >> K;
    --K;

    dists.resize(N);

    DFS(K, -1, 0);

    int x, y;
    rep(i, 0, Q)
    {
        cin >> x >> y;
        --x; --y;
        cout << dists[x] + dists[y] << endl;
    }
}


Measured memory_bytes: 14336
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
	  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
	   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
		   # #  # # #                   # #      ###### #    # #    # #      #####
	  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
	   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LL i = 0; i < (n); i++)
#define FOR(in) for(LL i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 
 
LL concate(LL a, LL b)
{
	ostringstream os;
	os <<a <<b;
	istringstream is(os.str());
	LL c;
	is>> c;
	return c;
}
 
 
LL check(char c)
{
	return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
}
LL mod = 1e9+7;
 
 
int main()
{
	//LL q,t;
	//cin>>t;
	//while(t--)
	//{
	   LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
		LL aa[1000];
		LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
		LL ma=0, mi=100000000;
		LL mid=0, temp=0, stop=0, start=0;
		double pi= 3.141592653589793;
		double d1=0.0, d2, d3, d4;
		VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
		VS vs, vs1, vs2, vs3, vs4;
		VP vp, vp1,vp2;
		char ch, ch1, ch2[1001];
		string str, str1, str2, str3, str4, str5;
		pair<LL, LL> pa;
		list<LL> li, li1;
		map<LL, LL> mp, mp1;
		set<LL> st;
		map<LL ,LL> :: iterator imll;
		VLL :: iterator ivll;
		set<LL> :: iterator isll;
		VP :: iterator ivp;
 
		cin>>str;
		for(i=0; i<str.size(); i++)
		{
			for(j=i; j<str.size(); j++)
			{
				if(j==i)con
				if(str[i]==str[j])
				{
					flag=1;
					break;
				}
			}
		}
		if(flag==1)cout<<"no"<<endl;
		else cout<<"yes"<<endl;
		
	//}
	exit()
 
 
}


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

int main(void) {
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i=0;i<n;i++) {
        cin >> a.at(i);
    }

    ll dp[n+1][2];
    dp[0][0] = 0;
    dp[0][1] = -1e18;

    for(int i=0;i<n;i++) {
        dp[i+1][0] = max(dp[i][0]+a.at(i), dp[i][1]-a.at(i));
        dp[i+1][1] = max(dp[i][0]-a.at(i), dp[i][1]+a.at(i));
    }

    cout << dp[n][0] << endl;

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K, N, C;
  int cnt = 0;
  string S;
  cin >> N >> K >> C >> S;
  vi table(N);
  vi L(K), R(K);
  REP(i, N) {
    if (S.at(i) == 'x') continue;
    L.at(cnt) = i;
    cnt++;
    if (K == cnt) {
      break;
    }
    i += C;
  }
  cnt = 0;
  for (int j = N - 1; j >= 0; j--) {
    if (S.at(j) == 'x') continue;
    R.at(K - cnt - 1) = j;
    cnt++;
    if (K == cnt) {
      break;
    }
    j -= C;
  }

  REP(i, K) {
    // cout << L.at(i) << " " << R.at(i) << endl;

    if (L.at(i) == R.at(i)) cout << L.at(i) + 1 << endl;
  }
}

Measured memory_bytes: 5692
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,K;
    cin >> N >> K;
    map<int, int> m;
    REP(i, K){
        int s;
        cin >> s;
        REP(i, s){
            int a;
            cin >> a;
            m[a]++;
        }
    }
    int ans = 0;
    Rep(i, 1,N+1){
        if(m[i]==0)ans++;
    }
    pr(ans);
}

Measured memory_bytes: 3564
#include <iostream>

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

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

    int ans = 1;
    int highest = H[0];
    for(int i = 1; i < N; i++){
        if(highest <= H[i]){
            highest = H[i];
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int a[5010];
bool f[5010][5010], g[5010][5010];
int main()
{
    int n, k, T;
    int i, j, p1, p2;
 //   scanf("%d", &T);
 //   while(T--)
 //   {
        scanf("%d%d", &n, &k);
        memset(f, 0, sizeof(f));
        memset(g, 0, sizeof(g));
        int ans = 0;
        int num = 0;
        for(i = 1; i <= n; ++i)
        {
            scanf("%d", &a[++num]);
            if(a[i] >= k)
            {
                ans++;
                --num;
            }
        }
        f[0][0] = 1;
        for(i = 1; i <= num; ++i)
        {
            for(j = 0; j <= k - a[i]; ++j)
            {
                if(f[i - 1][j])
                    f[i][j + a[i]] = 1;
            }
            for(j = 0; j <= k; ++j)
            {
                if(f[i - 1][j])
                    f[i][j] = 1;
            }
        }
        for(i = 0; i <=  num + 1; ++i) g[i][0] = 1;
        for(i = num; i >= 1; --i)
        {
            for(j = 0 ; j <= k - a[i]; ++j)
            {
                if(g[i + 1][j])
                    g[i][j + a[i]] = 1;
            }
            for(j = 0; j <= k; ++j)
            {
                if(g[i + 1][j])
                    g[i][j] = 1;
            }
        }

        for(i = 1; i <= num; ++i)
        {
            p2 = k - 1;
            int ok = 0;
            for(j = 0; j <= k-1; ++j)
            {
                if(!f[i-1][j]) continue;
                p2 = k - j - 1;
                while(p2 >= 0 && p2 >= k - a[i] - j)
                {
                    if(g[i+1][p2])
                    {
                        ok = 1;
                        goto c;
                    }
                    --p2;
                }
            }
            c:;
            if(ok) ++ans;
        }
        printf("%d\n", n - ans);
//    }
    return 0;
}


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

int main(void) {
  ll N, D;
  cin >> N >> D;
  vector<ll> A(N);
  REP(i, 0, N) cin >> A[i];

  ll x = 0;
  REP(i, 0, N) {
    x ^= ((A[i] - 1) % (D + 1));
  }

  cout << (x ? "First" : "Second") << endl;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

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

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b; cin >> a >> b;
    if (a > 8 || b > 8) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!";
    }
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define VI vector<int>
#define VII vector<pair<int, int>>
#define PII pair<int, int>
#define MP make_pair
// #define log(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define log(fmt, ...)
// #define check(...) assert(##__VA_ARGS__)
#define check(...)

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

    string s;
    cin >> s;
    string ss(s);
    reverse(ss.begin(), ss.end());
    bool ok = true;
    if (s != ss) {
        ok = false;
    } else {
        int n = s.length();
        string s1(s.substr(0, (n - 1) / 2));
        // cout << s1 << el;
        string ss1(s1);
        reverse(ss1.begin(), ss1.end());
        if (s1 != ss1) {
            ok = false;
        } else {
            string s2(s.substr((n + 3) / 2 - 1, n - (n + 3) / 2 + 1));
            // cout << s2 << el;
            string ss2(s2);
            reverse(ss2.begin(), ss2.end());
            if (s2 != ss2) {
                ok = false;
            }
        }
    }
    if (ok) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
class Program
{
    static List<int> s = new List<int>();
static long result;
static string S,T;
    static void Main()
    {
        S=Console.ReadLine();
T=Console.ReadLine();
      for(int i=0;i<3;i++){if(S[i]==T[i]){result++;}}
                    Console.WriteLine(result.ToString());

    }

}

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

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

int main(void){
  int a, b,c;
  cin >> a >> b >> c;

  a-=b;
  c-=a;
  if(c < 0){
    c = 0;
  }
  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
# AOJ 2806: Weight Range
# Python3 2018.7.11 bal4u

def gcd(a, b):
	while b != 0:
		r = a % b
		a, b = b, r
	return a

N, M = map(int, input().split())
a = list(map(int, input().split()))
a.extend(a)
step = gcd(N, M)
group = N // step;
ans = 0
for i in range(group):
	k = i*step
	mi = ma = a[k];
	for j in range(1, M):
		mi = min(mi, a[k+j])
		ma = max(ma, a[k+j])
	ans += ma-mi
print(ans)


Measured memory_bytes: 5628