akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std ; 

const int N = 1e2 + 7 ; 

int n , m , k ; 
int a[N] ; 
int b[N][N] ; 

int main(){
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
    //freopen("in.in" , "r" ,stdin) ; 
    cin>>n>>m>>k ; 
    for(int i = 0 ; i< n ;i ++){
        cin>>a[i] ; 
        for(int j = 0 ;j < m ;j ++){
            cin>>b[i][j] ; 
        }
    }
    int ans = 1e7 ; 
    for(int i = 0 ; i < (1<<n) ; i++){
        int sum = 0 ; 
        vector<int> v (m+1 , 0) ; 
        for(int j = 0 ; j < n ;j++){
            if(i & (1<<j) ){
                sum += a[j] ; 
                for(int k = 0 ; k < m ; k ++){
                    v[k] += b[j][k] ; 
                }
            }
        }
        for(int j = 0 ; j< m ;j++){
            if( v[j] < k ){
                sum = 1e7 ; 
            }
        }
        ans = min(ans , sum) ; 
    }
    if( ans ==1e7 ) cout<< -1 ; 
    else
    cout<< ans ; 
    return 0 ; 
}

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
const int mod = 1000000007;
int N, X, Y, Z, dp[44][2][131081];
int main() {
	cin >> N >> X >> Y >> Z;
	int p = (1 << (Z - 1)) + (1 << (Y + Z - 1)) + (1 << (X + Y + Z - 1));
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 1 << (X + Y + Z); j++) {
			for (int k = 1; k <= 10; k++) {
				int z = ((j * 2 + 1) << (k - 1)) & ((1 << (X + Y + Z)) - 1);
				dp[i + 1][1][z] = (dp[i + 1][1][z] + dp[i][1][j]) % mod;
				dp[i + 1][((z & p) == p ? 1 : 0)][z] = (dp[i + 1][((z & p) == p ? 1 : 0)][z] + dp[i][0][j]) % mod;
			}
		}
	}
	int ret = 0;
	for (int i = 0; i < 1 << (X + Y + Z); i++) {
		ret = (ret + dp[N][1][i]) % mod;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 42240
n , m = map(int, input().split())
id =[]
ch = 1
for i in range(m):
    p , y = map(int, input().split())
    id.append([p,y,i])
id.sort(key = lambda x:(x[0],x[1]))
id.append(['X','X','X'])
for i in range(m):
    id[i][1]=str(ch).zfill(6)
    if id[i][0]==id[i+1][0]:
        ch+=1
    else:
        ch=1
id.pop()
id.sort(key = lambda x:x[2])
for i in range(m):
    s = str(id[i][0]).zfill(6)+id[i][1]
    print(s)


Measured memory_bytes: 34524
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t;
    cin>>n>>x>>t;

    int q=n/x;
    int r=n%x;

    long long int sum=0;
    sum+=q*t;
    if(r!=0)
        sum+=t;

    cout<<sum<<endl;
    return 0;

}


Measured memory_bytes: 3628
A, B = map(int, input().split())

# 0 ^ 1 ^ ... ^ N
def xor_0_to_N(N):
    if (N+1) % 2 == 0:
        s = (N+1) // 2 % 2
    else:
        s = ((N+1) // 2 % 2) ^ N
    return s

"""
XOR = 0
for i in range(1, 20):
    print("idx", i)
    XOR ^= i
    print(XOR)
    print(xor_0_to_N(i))
"""

print(xor_0_to_N(A-1) ^ xor_0_to_N(B))

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int n, k;
int r[101];

int main( int argc, char *argv[] )
{
    int d;

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

    for( int i=1; i<=n; i++ ) r[i] = 0;

    for( int j=0; j<k; j++ ) {

        scanf( "%d", &d );
        for( int i=0; i<d; i++ ) {
            int a;
            scanf( "%d", &a );
            r[a] = 1;            
        }
    }

    int tot = 0;
    for( int i=1; i<=n; i++ )
        if( r[i] == 0 ) tot ++;

    printf( "%d\n", tot );
}


Measured memory_bytes: 1724
#include<cstdio>
#include<cstring>
using namespace std;
int pd,pd1;
int main()
{
	char s[105];
	gets(s);
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='C')
		{
			pd=1;
		}
		else
		if(s[i]=='F'&&pd==1)
		{
			pd1=1;
		}
	}
	if(pd==1&&pd1==1)
	{
		printf("Yes");
	}
	else
	printf("No");
	return 0;
}

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

int main(){
    int N, Y;
    cin >> N >> Y;
    for(int i = 0; i <= N && i * 10000 <= Y; i++){
        for(int j = 0; j <= N - i && j * 5000 <= Y - i * 10000; j++)
            if(i * 10000 + j * 5000 + (N - i - j) * 1000 == Y){
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll n;
    cin>>n;
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        ans += (n/i)*(n/i + 1)*i/2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3600
package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"sort"
	"strconv"
	"strings"
)

type A []string

func (a A) Len() int      { return len(a) }
func (a A) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a A) Less(i, j int) bool {
	x, _ := strconv.Atoi(a[i])
	y, _ := strconv.Atoi(a[j])
	return x < y
}

func main() {
	in, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	s := strings.Split(string(in), "\n")
	a := strings.Split(s[1], " ")
	sort.Sort(A(a))
	var sum int
	for _, v := range a {
		w, _ := strconv.Atoi(v)
		sum += w
	}
	fmt.Println(a[0], a[len(a)-1], sum)
}



Measured memory_bytes: 1608
#include<stdio.h>
int main(void)
{
	int antena[5];
	int k;
	int i, j;
	int flag = 0;

	for (i = 0; i < 5; i++) {
		scanf("%d", &antena[i]);
	}
	scanf("%d", &k);
	for (i = 0; i < 5; i++) {
		for (j = i + 1; j < 5; j++) {
			if (antena[j] > antena[i]) {
				if (k < antena[j] - antena[i]) {
					flag = 1;
				}
			}
		}
	}
	if (flag == 1) {
		printf(":(\n");
	}
	else {
		printf("Yay!");
	}
	return 0;
}

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

using namespace std;

int main() {

    long long int a, b, k = 1;
    int flag = 0;
    cin >> a >> b;

    while(k <= a || k <= b){

        if (abs(a - k) == abs(b - k)) {
            flag = 1;
            break;
        }

        k++;
    }

    if(!flag)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << k << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int num_K;
	char str_S[100];
	int i;
	int word_count;

	scanf("%d", &num_K);
	scanf("%s", str_S);

	word_count = 0;

	for (i = 0; str_S[i] != '\0'; i++)
	{
		word_count++;
	}

	if (word_count > num_K)
	{
		for (i = 0; i < num_K; i++)
		{
			printf("%c", str_S[i]);
		}

		printf("...\n");
	}
	else
	{
		printf("%s", str_S);
	}

	return 0;
}

Measured memory_bytes: 1696
n, d = map(int, input().split())
x_l = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)


Measured memory_bytes: 9312
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define f(var,start,end) for(ll var = start; var <end ; ++var)
#define rf(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define nl cout<<"\n"
int main()
{
	ll c=0;
	string s;
	string t;
	cin>>s;
	cin>>t;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]==t[i])
			c++;
	}
	if(c==s.size())
	{
		if(t.size()-1==s.size())
		{
			cout<<"Yes";
		}
	}
	else cout<<"No";
	cout<<"\n";
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int main(){
	int n; cin>>n;
	vector<vector<int> > e;
	vector<int> id(n);
	FOR(i,n){
		cin>>id[i];
		int x; cin>>x;
		e.push_back(vector<int>(x));
		FOR(j,x) cin>>e[i][j];
	}

	map<int,int> mp;
	FOR(i,n) mp[id[i]] = i;
	FOR(i,n) FOR(j,sz(e[i])) e[i][j] = mp[e[i][j]];

	vector<vector<int> > dp(n,vector<int>(n,INF));
	FOR(i,n) FOR(j,sz(e[i])) dp[i][e[i][j]] = 1;

	FOR(k,n) FOR(i,n) FOR(j,n) dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);

	int m; cin>>m;
	while(m--){
		int s,t,tll; cin>>s>>t>>tll;
		s = mp[s],t = mp[t];
		int ans = dp[s][t] + 1;
		if(ans > tll) printf("NA");
		else printf("%d",ans);
		
		puts("");
	}

	return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	string s;
	cin >> s;
	sort(all(s));

	if (s == "abc") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n , i ;
	cin >> n ;
	vector<vector<int>> adj(n+1) ;
	for(i=1;i<n;++i){
	    int tmp1 ; cin >> tmp1 ;
	    adj[tmp1].push_back(i+1) ;
	}
	for(i=1;i<=n;++i) cout << adj[i].size() << "\n" ;
	return 0;
}


Measured memory_bytes: 13976
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include <math.h>

int main(){
  double r;
  std::cin >> r;
  std::cout << std::setprecision(6) << std::fixed << r*r*M_PI  << " " << 2*r*M_PI << std::endl;
  return 0;
}

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

using ll=long long;

int main(){

ll A, B, K;

cin >> A >> B >> K;

if(K<=A){cout<< A-K << " " << B << endl;}
else if(K>A && K<=A+B) {cout<< 0 << " " << A+B-K << endl;}
else { cout<< 0 << " " << 0 << endl; }

}

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

using namespace std;

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

  int ans = 0;
  int l = 0;
  int N; cin>>N;
  int h, ph;
  cin >> ph;
  for (int i = 1; i < N; i++) {
    cin >> h;
    if (h <= ph) {
      ans = max(ans, ++l);
    } else {
      l = 0;
    }
    ph = h;
  }
  cout << ans << endl;

  return 0;
}


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

void sort(int N, int *Ls){
    for(int i = N - 1; i >= 1; i --){
        for(int j = 0; j < i; j ++){
            if(Ls[j] > Ls[j + 1]){
                int tmp = Ls[j];

                Ls[j] = Ls[j + 1];
                Ls[j + 1] = tmp;
            }
        }
    }
}
int main(){
    int N;

    scanf("%d", &N);

    int *Ls = (int *) malloc(sizeof(int) * N);

    for(int i = 0; i < N; i ++){
        scanf("%d", Ls + i);
    }
    sort(N, Ls);

    long long int count = 0;

    for(int i = N - 1; i >= 2; i --){
        for(int j = i - 1; j >= 1; j --){
            for(int k = j - 1; k >= 0; k --){
                if(Ls[k] + Ls[j] > Ls[i]){
                    count ++;
                }
            }
        }
    }
    printf("%lld\n", count);
}

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

int main() 
{
    string s, t;
    cin>>s>>t;
    int lt = t.length(), flg =0;
    
    for(int i=0;i<lt-1; i++)
    {
        if(s[i] != t[i])
        {
            flg = 1;
            break;
        }
    }
    if(flg)
        cout<<"No";
    else
        cout<<"Yes";
    
}




Measured memory_bytes: 3624
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;

	cin >> n;
	set < string > a;
	For (i, 1, n) {
		cin >> s;
		a.insert(s);
	}	
	cout << sz(a) << '\n';

	return Accepted;
}

// B...a

Measured memory_bytes: 33324
#include<iostream>
using namespace std;
int main(){
	while(1){
		long int T,D,L,num=0,flag=0,i;
		cin>>T>>D>>L;
		if(T==0&&D==0&&L==0)	break;
		for(int y=0;y<T;y++){
			cin >> i;
			if(y!=T-1){
				if(i>=L){
					flag = D;
				}
				if(flag>0){
					num++;
					flag--;
				}		
			}
		}
		cout  << num <<"\n";
}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define mset(a,x) memset(a,x,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define mp make_pair

string s;

void solve(){
    int n = s.size();
    ll res = 0;
    rep(i,n-1) res += (s[i] != s[i+1]);
    cout << res << "\n";
}

int main() {
    while(cin>>s) solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i=0; i<N; i++) cin >> s.at(i);
  int M;
  cin >> M;
  vector<string> t(M);
  for(int i=0; i<M; i++) cin >> t.at(i);
  
  vector<int> count(N);
  int max = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(s.at(i)==s.at(j)){
        count.at(i) +=1;
      }
    }
    for(int j=0; j<M; j++){
      if(s.at(i)==t.at(j)){
        count.at(i) -=1;
      }
    }
    if(count.at(i) > max){
      max = count.at(i);
    }
  }
  cout << max << endl;
}



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

int main()
{
    int n,c=0,m=0;
    cin>>n;

    int b,f,r,p;
    int ar[4][3][10];

     memset(ar, 0, sizeof(ar));

    for(int l=0; l<n; l++)
    {
        cin>>b>>f>>r>>p;
        ar[b-1][f-1][r-1] = ar[b-1][f-1][r-1] + p;
    }


    for(int l=0; l<4; l++)
    {
        for(int i=0; i<3; i++)
        {
            for(int j=0; j<10; j++)
            {
                cout<<" "<<ar[l][i][j];
            }
            cout<<"\n";

        }

        if(l!=3) cout<<"####################"<<"\n";
    }


    return 0;
}



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

int main() {
	ll h;
	cin >> h;
	ll i = 1;
	while (h != 1) {
		h /= 2;
		i++;
	}
	ll ans = pow(2, i) - 1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  ll ans = 1;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return;
    }
  }
  REP(i, n) {
    if (ans > LINF / a[i]) {
      cout << -1 << endl;
      return;
    }
    ans *= a[i];
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main() {
    string s;
    cin >> s;
    int l = 0, r = (int)s.length()-1;
    int ans = 0;
    while(l < r){
        if(s[l] != s[r]){
            if(s[l] == 'x'){
                r++;
            }else if(s[r] == 'x'){
                l--;
            }else{
                ans = -1; break;
            }
            ans++;
        }
        l++; r--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  string S;
  ll K;
  cin >> S >> K;

  ll cnt_one = 0;
  while((S[cnt_one] == '1') && (cnt_one < S.size())) cnt_one++;

  if((cnt_one == S.size()) || (cnt_one >= K)){
    cout << 1 << endl;
    return 0;
  }

  cout << S[cnt_one] << endl;
  
  return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> num(N,0);
  int a,b;
  for (int i=0; i<M; i++) {
    cin >> a >> b;
    num[a-1]++;
    num[b-1]++;
  }
  for (int i=0; i<N; i++) {
    cout << num[i] << endl;
  }
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
const int M=1e4+10;
vector<int>g[M],rg[M],st;
int n,m,q,topol[M],c;
bool mark[M];
void dfs1(int v)
{
  mark[v]=true;
  for(auto u:g[v])
    if(!mark[u])
      dfs1(u);
  st.push_back(v);
}
void dfs2(int v,int t)
{
  topol[v]=t;
  for(auto u:rg[v])
    if(!topol[u])
      dfs2(u,t);
}
int main()
{
  cin>>n>>m;
  for(int i=0;i<m;i++)
    {
      int u,v;
      cin>>u>>v;
      u++;v++;
      g[u].push_back(v);
      rg[v].push_back(u);
    }
  for(int i=1;i<=n;i++)
    if(!mark[i])
      dfs1(i);
  for(int i=st.size()-1;i>=0;i--)
    if(!topol[st[i]])
      dfs2(st[i],++c);
  cin>>q;
  while(q--)
    {
      int u,v;cin>>u>>v;
      u++;v++;
      if(topol[v]==topol[u])
	cout<<1<<endl;
      else
	cout<<0<<endl;
    }
}

Measured memory_bytes: 4820
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true) {
			int a=scan.nextInt();
			String op=scan.next();
			int b=scan.nextInt();

			if(op.equals("+"))System.out.println(a+b);
			if(op.equals("-"))System.out.println(a-b);
			if(op.equals("*"))System.out.println(a*b);
			if(op.equals("/"))System.out.println(a/b);
			if(op.equals("?"))break;
		}
		scan.close();
	}

}


Measured memory_bytes: 26204
#include<stdio.h>
#define MAX 100
#define INF (1<<21)
#define B 2
#define G 1
#define W 0

int n,M[MAX][MAX];

int prim(){
  int i,u,v,min,sum,d[MAX],p[MAX],color[MAX];
  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=W;
  }
  d[0]=0;
  while(1){
    min=INF;
    u=-1;
    for(i=0;i<n;i++){
      if(min>d[i]&&color[i]!=B){
        u=i;
        min=d[i];
      }
    }
    if(u==-1) break;
    color[u]=B;
    for(v=0;v<n;v++){
      if(color[v]!=B&&M[u][v]!=INF){
        if(d[v]>M[u][v]){
          d[v]=M[u][v];
          p[v]=u;
          color[v]=G;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j,e;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1) ? INF :e;
    }
  }
  printf("%d\n",prim());
  return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
#include<string.h>
int main(){
char S[3], A1[]="AAA", A2[]="BBB";
int result1, result2;
  scanf("%s",&S);
  result1=strcmp(S, A1);
  result2=strcmp(S, A2);  
  if(result1==0||result2==0){
    printf("No");}
  else if(result1!=0||result2!=0) {
  printf("Yes");
  }
return 0;
}

Measured memory_bytes: 128
N = int(input())
T, A = input().split(' ')
T = int(T)
A = int(A)
H = input().split(' ')
H = [int(H[i]) for i in range(N)]
check = 10**9
for i in range(N):
  C = A - (T - H[i] * 0.006)
  if abs(C)<check:
    check = abs(C)
    point = i + 1
print(point)

Measured memory_bytes: 9200
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    int k, n;
    cin >> k >> n;
    int ans = k + 100;
    vector<int> a(n);
    for (int i = 0; i < n; i++) { cin >> a[i]; }
    for (int i = 0; i < n - 1; i++) {
        ans = min(ans, k - abs(a[i + 1] - a[i]));
    }
    ans = min(ans, k - abs(a[n - 1] - a[0] - k));
    cout << ans << endl;
}

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

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

    vector<int> a(N);

    rep(i, M) {
        int k; cin >> k;
        rep(j, k) {
            int s; cin >> s; s--;
            a[s] |= 1 << i;
        }
    }

    int p = 0;
    rep(i, M) {
        int x; cin >> x;
        p |= x << i;
    }

    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        int t = 0;
        rep(i, N) {
            if (bit >> i & 1) t ^= a[i];
        }
        if (t == p) ans++;
    }

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


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            if (s.compareTo("AAA") == 0 || s.compareTo("BBB") == 0)
                out.println("No");
            else
                out.println("Yes");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 22228
n = int(input())
ma,mb,mc=0,0,0
for i in range(n):
    a,b,c = map(int,input().split())
    ma1, mb1, mc1 = ma,mb,mc
    ma = max(mb1 + b, mc1 + c)
    mb = max(ma1 + a, mc1 + c)
    mc = max(mb1 + b, ma1 + a)
print(max(ma,mb,mc))

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

int main(){
	long N, K;
	long count = 0;
	long buff = 0;
	long sum = 0;
	long num = 0;
	cin >> N >> K;

	if(K%2 == 1){
		for(int c=K; c <= N; c += K){
			count += 1;
		}
		sum = count * count * count;
	}else{
		for(int c=K/2; c <= N; c += K){
			count += 1;
		}
		sum = count * count * count;
		buff = count;
		count = 0;

		for(int c=K; c <= N; c += K){
			count += 1;
		}
		sum += count * count * count;
	}
	
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
h,n = map(int,input().split())
a = np.zeros(n,np.int)
b = a.copy()
for i in range(n):
    a[i],b[i] = map(int,input().split())
    

attack_max = np.max(a)
majik_min = min(b)
dp = np.zeros(h+attack_max,np.int)

for i in range(1,len(dp)):
    c = dp[i-a[i-a>=0]]
    e = i-a[i-a>=0]
    d = c[(c!=0)+(e==0)]+b[i-a>=0][(c!=0)+(e==0)]
    if len(d)>0:
        dp[i] = np.min(d)
    
print(np.min(dp[h:][dp[h:]>0]))

Measured memory_bytes: 14588
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;
signed main (){
  //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ll n,b,a; cin>>n>>a>>b;
  if ((b-a)%2==1){
    ll dif=((b-a)-1)/2;
    cout<<min(a-1,n-b)+1+dif<<endl;
  }
  else cout<<(b-a)/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define 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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int C[3][3];
int A[3], B[3];
//---------------------------------------------------------------------------------------------------
void _main() {
    rep(i, 0, 3) rep(j, 0, 3) cin >> C[i][j];

    rep(a1, 0, 101) rep(a2, 0, 101) rep(a3, 0, 101) {
        int b1 = C[0][0] - a1;
        int b2 = C[0][1] - a1;
        int b3 = C[0][2] - a1;

        A[0] = a1;
        A[1] = a2;
        A[2] = a3;
        B[0] = b1;
        B[1] = b2;
        B[2] = b3;

        int ok = 1;
        rep(i, 0, 3) rep(j, 0, 3) if (A[i] + B[j] != C[i][j]) ok = 0;
        if (ok) {
            printf("Yes\n");
            return;
        }
    }

    printf("No\n");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void BubbleSort(int*,int,char*);
void SelectionSort(int*,int,char*);
void judge(char*,char*);
void swap(int*,int*,char*,char*);
typedef struct{
	int *value; 
	char *kind;
}Arr;
	
int main(void){
	int i,num,*temp_int;
	char temp_chr,*temp;
	Arr arr;
	scanf("%d%c",&num,&temp_chr);
	arr.value = (int *)malloc(num * sizeof(int));
	arr.kind = (char *)malloc(num * sizeof(char));
	temp_int = (int *)malloc(num * sizeof(int));
	temp = (char *)malloc(num *sizeof(char));
	for(i=0;i<num;i++)scanf("%c%d%c",&arr.kind[i],&arr.value[i],&temp_chr);
	//for(i=0;i<num;i++)printf("%c%d \n",arr.kind[i],arr.value[i]);
	strcpy(temp,arr.kind);
	for(i=0;i<num;i++)temp_int[i] = arr.value[i];
	BubbleSort(arr.value,num,arr.kind);
	SelectionSort(temp_int,num,temp);
	judge(temp,arr.kind);
	free(temp_int);
	free(arr.value);
	free(arr.kind);
	free(temp);
	//judge(temp,arr.kind);
	return 0;
}	
void BubbleSort(int *arr,int num,char *chr){
	int i,j;
	for(i=0;i<num;i++){
		for(j=num-1;j>0;j--) if(arr[j] < arr[j-1]) swap(&arr[j],&arr[j-1],&chr[j],&chr[j-1]);
		}
	for(i=0;i<num;i++) i != num-1 ? printf("%c%d ",chr[i],arr[i]) : printf("%c%d\nStable\n",chr[i],arr[i]);
}	
void SelectionSort(int *arr,int num,char *chr){
  int i,j,min;
  for(i=0;i<num;i++){
    min = i;
    for(j=i;j<num;j++)if(arr[j]<arr[min]) min = j; 
    if(arr[min] != arr[i])swap(&arr[i],&arr[min],&chr[i],&chr[min]); 
 }
  for(i=0;i<num;i++) {
    i != num-1 ? printf("%c%d ",chr[i],arr[i]) : printf("%c%d\n",chr[i],arr[i]);
  }
}
	
void swap(int *arr,int *arr_arr,char *chr,char *chr_chr){
	int temp = 0;
	char temp_chr;
	temp = *arr;
	*arr = *arr_arr;
	*arr_arr = temp;
	temp_chr = *chr;
	*chr = *chr_chr;
	*chr_chr = temp_chr;
}	
void judge(char *temp,char *tmp){
  strcmp(temp,tmp)?printf("Not stable\n"):printf("Stable\n");
}

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

void bfs(vector<vector<int>> &grid, int x, int y){
    vector<int> nx = {1,-1,0,0};
    vector<int> ny = {0,0,1,-1};
    vector<bool> check(4,false);
    for(int i=0; i<4; i++){
        if(
            grid[x+nx[i]][y+ny[i]] != -1 &&
            grid[x+nx[i]][y+ny[i]] > grid[x][y]+1){
                grid[x+nx[i]][y+ny[i]] = grid[x][y] + 1;
                check[i] = true;
            }
    }
    for(int i=0; i<4; i++){
        if(check[i]){
            bfs(grid, x+nx[i], y+ny[i]);
        }
    }
}

int main(){
    int h,w;
    cin >> h >> w;
    int white = 0;
    vector<vector<int>> grid(h+2,vector<int>(w+2,-1));

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            char in;
            cin >> in;
            if(in == '.'){
                white++;
                grid[i][j] = 10000;
            }
        }
    }
    grid[1][1] = 1;
    bfs(grid,1,1);
    if(grid[h][w] == 10000){
        cout << -1 << endl;
    }else{
        cout << white - grid[h][w] << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n ;
    cin >> n ;
    vll a(n) ;
    REP(i,n){
        cin >> a[i] ;
    }
    ll hoge = 0 ;
    vll ans(n) ;
    REP(i,n){
        if(i%2==0){
            hoge += a[i] ;
        }
        else{
            hoge -= a[i] ;
        }
    }
    ans[0] = hoge ;

    FOR(i,1,n){
        ans[i] = 2*a[i-1] - ans[i-1];
    }


    REP(i,n){
        cout << ans[i] <<" " ;
    }
    cout << endl;


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 4712
datas = gets.split(" ").map{|n|n.to_i}
l = datas[0]
r = datas[1]


if r - l >= 2019
  puts "0"
else
  test_l = l % 2019
  test_r = r % 2019
  if l > r || test_l == 0 || test_r == 0
    puts "0"
  else
    ans = 2020
    for lll in test_l..(test_r-1)
      for rrr in (lll+1)..(test_r)
        if ans > (lll * rrr) % 2019
          ans = (lll * rrr) % 2019
        end
      end
    end

    puts ans.to_s
  end
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
typedef long long ll;
const int maxn=4e6+7;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;

ll quick(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=(res*x)%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
ll inv(ll x) {return quick(x,mod-2);}

ll fac[maxn];
void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;++i) fac[i]=(fac[i-1]*i)%mod;
}

ll C(int n,int m)
{
    return fac[n]*inv(fac[m])%mod*inv(fac[n-m])%mod;
}

ll dp[2007][2007];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    init();
    int n,k;
    cin>>n>>k;
    if(k==1) cout<<1<<endl;
    else
    {
        dp[0][0]=1;
        for(int i=1;i<=n;++i)
        {
            for(int j=0;j<=i;++j)
            {
                if(j==0) dp[i][j]=1;
                else
                {
                    assert(n*k-i-(j-1)*(k-1)-1>=k-2);
                    dp[i][j]=(dp[i-1][j]+1ll*dp[i][j-1]*(n-j+1)%mod*C(n*k-i-(j-1)*(k-1)-1,k-2)%mod)%mod;
                }
            }
        }
        cout<<dp[n][n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 61568
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,i,j;
	double a,b;
	double c;
	cin>>n;
	priority_queue <double, vector<double>, greater<double>> q;
	for(i=0;i<n;i++){
	    cin>>j;
	    q.push(j);
	}
	while(q.size()>1){
	    a=q.top();
	    q.pop();
	    b=q.top();
	    q.pop();
	    c=(a+b)/2.0;
	    q.push(c);
	}
	cout<<q.top();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int K , S ; 
  int ans = 0 ;
  cin >> K >> S ;
  rep(X,K+1){
    rep(Y,K+1){
      if(S - X  - Y <= K && S - X - Y >= 0 )ans++ ;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line

ll h, w, k;
vector<string> choco(11);

int main()
{
	cin >> h >> w >> k; // h <= 10 , w<= 1000 , k <= 10,000;
	rep(i,h){
		cin >> choco[i];
	}
	ll white = 0 ;
	rep(i,h){
		rep(j,w){
			if(choco[i][j] == '1') white ++;
		}
	}
	if(white <= k){
		cout << 0 << endl;
		return 0;
	}
	ll ans = 101010;;
	for(ll tmp = 0; tmp < ( 1 << h-1);  tmp++){
		//横に1個ずつ進めるか見ていく。
		bitset<10> bit(tmp);
		//debug(bit);
		ll ret = 0;
		rep(i,h){
			if(bit.test(i)) {
				ret ++;
			}
		}
		//debug(ret);
		vector<ll> count(11,0);
		ll til_w = 0; // どこまで完成したか。
		ll til_h = 0;
		ll change = 0; //count[change]に入れていく
		bool cant = false;

		for(ll x = 0 ; x < w  ; x++){
			change = 0;
			for(ll y = 0; y < h ; y++){
				if(choco[y][x] =='1') count[change] ++;

				if(count[change] > k){
					if(x == til_w){
						// このbitは無理
						cant = true;
						break;
					} else {
						// ret + 1して countを全て0にする
						ret++;
						rep(i,11) count[i] = 0; 
						x--;
						break;
					}
				}
				//debug(count[change]);
				if(bit.test(y)) change ++ ;
			}
			if(cant) break;
		}
		if(cant) continue;
		chmin(ans,ret);
		//debug(ret);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define SLAY ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LL long long
#define PII pair<int , int>
#define PLL pair<long long , long long>
#define INPUT freopen("input.txt", "r", stdin);

using namespace std;
 
const LL MOD = 1e9+7;

LL c,d,e,f,g,x,y,z,m,n,temp,cnt,ans,sum,t,q,k,mx;
string str,str1,str2;
vector< int > nums;
const int MAXW = 1e5+1;
LL dp[3001][3001];
// LL w[10001];
// LL solve(int i , int j  ){

//     if(i>=str1.length() || j>=str2.length()){
//         return 0;
//     }

//     LL &ret = dp[i][j];
//     if(~ret)return ret;

//     if(str1[i]==str2[j]){
//         ret= 1+solve(i+1 , j+1);
//         return ret;
//     }
//     LL choice1= solve(i+1,j);
//     LL choice2= solve(i,j+1);
//     ret=max(ret,max(choice1,choice2));
    
//     return ret;
// }
int main()
{
    bool readfromfile=false; if(!readfromfile){SLAY} else{INPUT}

    
    cin>>str1>>str2;
    n=str1.length();
    m=str2.length();
    memset(dp , -1 , sizeof(dp));
    for(int i = 0 ; i<=n ; i++)dp[i][0]=0;
    for(int i = 0 ; i<=m ; i++)dp[0][i]=0;
    str="";
    // solve(0,0);
    for(int i = 1 ; i<=n;i++){
        for(int j = 1 ; j <= m ; j++){
            if(str1[i-1]==str2[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    // for(int i = 0 ; i<=n;i++){
    //     for(int j = 0; j <=m ; j++){
    //         cout<<dp[i][j]<<"";    
    //     }cout<<endl;
    // }
    int i=n , j=m;
    while(i>0&&j>0){
        if(dp[i][j]==dp[i-1][j]){
            i--;
        }else if(dp[i][j]==dp[i][j-1]){
            j--;
        }else{
            j--; i--;
            str+=str2[j];

        }
    }
    
    reverse(str.begin(),str.end());
    cout<<str;
    cout<<endl;
    
    return 0;
}
/*
2
4 7
17 5 -21 15
4 5
17 5 -21 15

*/

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

int main() {
	vector<char> pd;
	char x;
	while(cin>>x){
		if(x=='?')pd.push_back('D');
		else pd.push_back(x);
	}
	for(int i=0;i<pd.size();i++){
		cout<<pd[i];
	}
}

Measured memory_bytes: 3724
let ioc c = int_of_char c - int_of_char 'a'

let s = read_line()
let t = read_line()
let n = String.length s
let m = String.length t
let d = Array.init 26 (fun _ -> Array.make (n + 1) ~-1)

let rec f i j s =
  if i = m then s + j
  else
    let k = ioc t.[i] in
    if d.(k).(0) = -1 then -1
    else
      let j = d.(k).(j) in
      if j = -1 then f (i + 1) (d.(k).(0) + 1) (s + n)
      else f (i + 1) (j + 1) s

let () =
  for i = 0 to n - 1 do
    d.(ioc s.[i]).(i) <- i
  done;

  Array.iter (fun d ->
    for i = 0 to n - 1 do
      let j = n - 1 - i in
      if d.(j) = -1 then
        d.(j) <- d.(j + 1)
      done
  ) d;

  d.(ioc s.[0]).(0) <- 0;

  Printf.printf "%d\n" (f 0 0 0)


Measured memory_bytes: 24764
#include<iostream>
#include<math.h>
using namespace std;
int n,m;
int broken[100005];
int memo[100005];
int o = (int)1e9+7;
int dp(int idx){
//	cout<<idx<<"\n";
	if(idx == n) return 1;
	if(memo[idx]!=-1) return memo[idx];
	int one = 0, two = 0;
	if(broken[idx+1]!=1){
		one = dp(idx+1);
	}
	if(broken[idx+2]!=1 && idx+2<=n){
		two = dp(idx+2);
	}
	return memo[idx] = ((one%o) +(two%o))%o;
}
int main(){
	int a;
	cin>>n>>m;
	for(int i = 0;i<m;i++){
		cin>>a;
		broken[a] = 1;
	}
	for(int i = 0;i<=n;i++)memo[i] = -1;
	cout<<dp(0)%o<<"\n";
	return 0;
}

Measured memory_bytes: 4096
#!/usr/bin/env python3
H, W = [int(str) for str in input().strip().split()]
S = [input().strip() for _ in range(H)]

def cost(h, w):
    return 1 if S[h][w] == '#' else 0

inf = 100000

# init
dp = [[inf] * W for _ in range(H)]
dp[0][0] = cost(0, 0)
for w in range(1, W):
    # dp[0][w] = dp[0][w - 1] + cost(0, w)
    dp[0][w] = dp[0][w - 1] + int(S[0][w - 1] == '.' and S[0][w] == '#')

for h in range(1, H):
    # dp[h][0] = dp[h - 1][0] + cost(h, 0)
    dp[h][0] = dp[h - 1][0] + int(S[h - 1][0] == '.' and S[h][0] == '#')
    for w in range(1, W):
        # dp[h][w] =  min(dp[h][w - 1], dp[h - 1][w]) + cost(h, w)
        if S[h][w] == '.':
            dp[h][w] = min(dp[h][w - 1], dp[h - 1][w])
        else:
            dp[h][w] = min(dp[h][w - 1] + int(S[h][w - 1] == '.'), dp[h - 1][w] + int(S[h - 1][w] == '.'))

# [print(l) for l in S]
# [print(l) for l in dp]
print(dp[H - 1][W - 1])

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

struct StExpr
{
  StExpr() : m_nPerson(0), m_nAttr(0) { }

  int m_nPerson;
  int m_nAttr;
};

void fnInput(vector<vector<StExpr>>& rvvoExpr)
{
  int nPersonSiz;
  cin >> nPersonSiz;
  rvvoExpr.resize(nPersonSiz + 1);

  for (int i = 1; i < rvvoExpr.size(); i++)
  {
    int nAttrSiz;
    cin >> nAttrSiz;
    rvvoExpr[i].resize(nAttrSiz);

    for (int j = 0; j < rvvoExpr[i].size(); j++)
      cin >> rvvoExpr[i][j].m_nPerson >> rvvoExpr[i][j].m_nAttr;
  }
}
 
int fnHonestCheck(const vector<vector<StExpr>>& cnrvvoExpr, 
                  const vector<int>& cnrvnHonest, int nMan)
{
  if (cnrvnHonest[nMan])               // Honest
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson ] )
        return 0;

    return 1;
  }
  else                                 // UnKind
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson ] )
        return 1;

    return 0;
  }
}
  
int fnMaxHonestGet(const vector<vector<StExpr>>& cnrvvoExpr)
{
  vector<int> vnHonest(cnrvvoExpr.size());
  int nMaxHonestCnt = 0;
  
  for (int n = 1; n < ( 1 << (cnrvvoExpr.size() - 1) ); n++)
  {
    int nHonestCnt = 0;

    for (int i = 0; i < cnrvvoExpr.size() - 1; i++)
      if (n & (1 << i))
      {
        vnHonest[i + 1] = 1;           // Honest
        nHonestCnt++;
      }
      else
        vnHonest[i + 1] = 0;           // UnKind

    bool bReslt = true;
    for (int nMan = 1; nMan < vnHonest.size(); nMan++)
      if (!fnHonestCheck(cnrvvoExpr, vnHonest, nMan))
      {
        bReslt = false;
        break;
      }

    if (bReslt) nMaxHonestCnt = max(nMaxHonestCnt, nHonestCnt);
  }
  return nMaxHonestCnt;
}

int main()
{
  vector<vector<StExpr>> vvoExpr;

  fnInput(vvoExpr);
  cout << fnMaxHonestGet(vvoExpr) << endl;

  return 0;
}

Measured memory_bytes: 3580
#include  <stdio.h>
int expr();
int term();
int fact();
int number();

int n,idx;

char s[105];
int expr(void){
    int res=term();
        for(;s[idx] == '+' || s[idx]=='-';){
        char ope=s[idx++];
        int  temp=term();
        ope=='+'?(res+=temp):(res-=temp);
    }
    return res;
}
int term(void){
    int res=fact();
    for(;s[idx]=='*' || s[idx]=='/';){
        char ope=s[idx++];
        int temp=fact();
        ope=='*'?(res*=temp):(res/=temp);
    }
    return res;
}
int fact(void){
    int res;
    if(s[idx]=='('){
        idx++;
        res=expr();
        idx++;
    }
    else
        res=number();
    return res;
}
int number(void){
    int res=0;
    for(;'0' <= s[idx] && s[idx] <= '9';idx++){
        res=res*10+s[idx]-'0';
    }
    return res;
}
int main(void){
    int i;
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        idx=0;
        fgets(s,105,stdin);
        printf("%d\n",expr());
    }
    return 0;
}
    

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

int main(){
  int h, n, sum = 0;
  cin >> h >> n;
  int *a = new int[n];
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  for(int i=0;i<n;++i){
    sum += a[i];
    if(sum >= h){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  string ans;
  if (S.size() == 2) {
    ans = S;
  }
  else {
    ans = S.at(2);
    ans += S.at(1);
    ans += S.at(0);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)

int main( void ){
	int n;
	if (!scanf( "%d", &n ))
		return -1;
	int* array = new int[ n ];
	int max = 0;
	rep( i, 0, n ){
		if (!scanf( "%d", array + i ))
			return -1;
	}
	std::sort( array, array + n );
	int k = array[ n - 1 ] / 2;
	int m = 0;
	bool is_sub = false;
	for(int i = n - 2; i >= 0; i--){
		if(array[ i ] > k){
			if (m < array[ n - 1 ] - array[ i ]){
				is_sub = true;
				m = array[ n - 1 ] - array[ i ];
			}
		}
		else {
			if (m < array[ i ]){
				is_sub = false;
				m = array[ i ];
			}
		}
	}
	if (is_sub){
		m = array[ n - 1 ] - m;
	}
	printf( "%d %d\n", array[ n - 1 ], m );
	return 0;
}


Measured memory_bytes: 640