akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for(int i=0; i<N; i++){
      a[i] = sc.nextInt();
    }
    //System.out.println(a[0]);
    int sum = 0;
    for(int i=0; i<N; i++){
      sum += a[i];
    }
    //System.out.println(sum);
    int ans = 0;
    int min = 999;
    int avg = sum/N;
    //System.out.println(avg);
    for (int i = 0; i < N ; i++) {
      int sa = Math.abs(sum - N * a[i]);
      if (min > sa) {
        ans = i;
        min = sa;
      }
    }
    System.out.println(ans);
  }
}
   

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,cnt=0,p;
    cin >> n;
    rep(i,n){
        cin >> p;
        if(p!=i+1) cnt++;
    }
    cout << (cnt==2 || cnt==0?"YES\n":"NO\n");
    return 0;
}

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

const ll INF = 1e18;

vector<int> di = {1, 0, -1, 0};
vector<int> dj = {0, 1, 0, -1};
int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int si, sj, ti, tj;
    cin >> si >> sj >> ti >> tj;
    --si, --sj, --ti, --tj;
    vector<string> g(h);
    rep(i,h) cin >> g[i];

    auto toId = [&](int i, int j, int v) {
        return (i*w + j)*4 + v;
    };
    vector<ll> dist(h*w*4, INF);
    priority_queue<LP, vector<LP>, greater<LP>> q;
    auto push = [&](int i, int j, int v, ll x) {
        int id = toId(i,j,v);
        if (dist[id] <= x) return;
        dist[id] = x;
        q.emplace(x, id);
    };
    auto modCeilK = [&](ll x) {
        return (x+k-1)/k*k;
    };

    rep(v,4) push(si, sj, v, 0);
    while(!q.empty()) {
        ll d = q.top().first;
        int id = q.top().second;
        q.pop();
        if (dist[id] != d) continue;
        int i = id/w/4;
        int j = id/4%w;
        int v = id%4;
        rep(nv,4) {
            push(i,j,nv,modCeilK(d));
        }
        {
            int ni = i + di[v], nj = j + dj[v];
            if (ni < 0 || ni > h-1 || nj < 0 || nj > w-1) continue;
            if (g[ni][nj] == '.') {
                push(ni,nj,v,d+1);
            }
        }
    }
    ll ans = INF;
    rep(v,4) ans = min(ans, dist[ toId(ti,tj,v) ]);
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        ans = modCeilK(ans)/k;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 39908
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    vector<int> A(N), B(N), C(N);
    rep( i, N ) A[i] = in, B[i] = in, C[i] = in;

    vector<int> dpA(N+1,0), dpB(N+1,0), dpC(N+1,0);
    rep( i, N ) {
        dpA[i+1] = max( dpB[i], dpC[i] ) + A[i];
        dpB[i+1] = max( dpA[i], dpC[i] ) + B[i];
        dpC[i+1] = max( dpA[i], dpB[i] ) + C[i];
    }

    cout << max({ dpA[N], dpB[N], dpC[N] }) << "\n";
}


Measured memory_bytes: 2560
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (max(a,b)-min(a,b) <= d && max(c, b) - min(c, b) <= d) {
		
		cout << "Yes" << endl;
	}
	else if (max(a, c) - min(a, c) <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <ctype.h>
 
//#define DEBUG
 
int main (void){
 
 
    char strW[11];                      //10????????\????????????W????????´???????
    char strE[12] = "END_OF_TEXT";      //???????????????¨
    char strP[1001] ;                   //????????????????????????¨????????????
 
    int ans = 0 ;                       //???????????????°
    int cnt = 0 ;                       //W?????????°???????????????????????????°
    int end = 1 ;                       //?????????????????????°
 
    int i = 0 ;                         //????????????°
 
    /*W???????????????*/
    scanf("%s",strW);
    /*?????????W??????¨?????°????????????????*/
    for( i = 0 ; strW[i] != '\0' ; i++){
        if(isupper(strW[i])){
            strW[i] = tolower(strW[i]); //???§??????????????°????????????????
        }
    }
 
 
#ifdef DEBUG
        printf("?????????W???%s\n",strW);
#endif
 
    while(end){
 
        scanf("%s", strP);              //?????????????????????
 
 
#ifdef DEBUG
        printf("?????????P???%s\n",strP);
#endif
 
        /*strE???¨strP?????????????????????????????????????????????*/
 
        for( i = 0 ; (strE[i] != '\0') && (ans == 0) ; i++){
                    if( strE[i] != strP[i] ){
                        ans = 1 ;
                        }
                }
            if (strP[i] != '\0'){
                ans = 1 ;
            }
                if (ans == 0){              //??????´?????????????????????°
                end = 0;
            }
        ans = 0 ;                       //???????????????°????????????
 
 
 
        /*?????????????????????£??????????????????P??????¨?????°????????????????*/
        for( i = 0 ; strP[i] != '\0' ; i++){
            if(isupper(strP[i])){
                strP[i] = tolower(strP[i]); //???§??????????????°????????????????
            }
        }
 
#ifdef DEBUG
        printf("?????????P???%s\n",strP);
#endif
 
        /*strW???¨strP?????????*/
        for( i = 0 ; (strW[i] != '\0') && (ans == 0) ; i++){
                    if( strW[i] != strP[i] ){
                        ans = 1 ;
                        }
                }
            if (strP[i] != '\0'){
                ans = 1 ;
            }
 
            if (ans == 0){              //??????´?????????????????????¢??????
                cnt++;
            }
 
 
        ans = 0;                        //???????????????°????????????
 
    }
 
    printf("%d\n" ,cnt);
    return 0 ;
}

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

int main(int argc, char const *argv[])
{
	int a,b;
	string s;
	cin>>a>>b>>s;
	int f=1;
	for (int i = 0; i < a; ++i)
	{
		if (s[i]<'0'||'9'<s[i])
		{
			f=0;
		}
	}
	if (s[a]!='-')
	{
		f=0;
	}
	for (int i = a+1; i < a+b+1; ++i)
	{
		if (s[i]<'0'||'9'<s[i])
		{
			f=0;
		}
	}
	if (f)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    int N,i,j;
    cin>>N;
    int A[N],D[N],d;
    for(i=1;i<=N;i++){
        cin>>A[i];
        d=A[i];
        D[d]=i;
    }
    for(i=1;i<=N;i++){
        cout<<D[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 1536
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = ReadLine();
            if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3]))
                WriteLine("Yes");
            else
                WriteLine("No");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

//LIFE IS NOT A PROBLEM TO BE SOLVED

#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back

using namespace std;

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


int main(){
	
	int n, k; cin >> n >> k;
	int a[n];
	rep(i, 0, n) scanf("%d", &a[i]);
	int tt = 0x3f3f3f3f;
	sort(a, a+n);
	rep(i, 0, n-k+1){
		tt = min(tt, a[i+k-1]-a[i]);
	}
	cout << tt << '\n';
	return 0;
}


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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<double>> x(N, vector<double>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> x[i][j];
    }
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      double tmp = 0;
      for (int k = 0; k < D; k++) {
        tmp += pow(x[i][k]- x[j][k], 2);
      }
      double distance = sqrt(tmp);
      if (distance == floor(distance)) res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int x[9];
    int y[9];
    double ans=0;
    int tmpx=0;
    int tmpy=0;
    double tmp=0;
    int loop=0;
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> x[i] >> y[i];
        
    }
    
    for(int i=1; i<=n-1; i++){
        
        for(int j=i+1; j<=n; j++){
            
            tmpx = x[i] - x[j];
            tmpx *= tmpx;
            tmpy = y[i] - y[j];
            tmpy *= tmpy;
            
            tmp = tmpx + tmpy;
            
            ans += sqrt(tmp);
            // cout << sqrt(tmp) << endl; // debug
            
            loop += 1;
            
        }
        
    }
    
    ans *= n - 1;
    ans /= loop;
    
    printf("%.16f", ans);
    // cout << ans << endl;
    // cout << loop << endl; // debug

    return 0;
    
}

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

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, j;
	ll a = 0, b = 0;
	cin >> num;
	vector<vector<int>> d(2, vector<int>(num));
	for (i = 0; i < 2; i++) {
		for (j = 0; j < num; j++)
			scanf("%d", &d[i][j]);
	}
	for (i = 0; i < num; i++) {
		if (d[0][i] < d[1][i])
			a += (d[1][i] - d[0][i]) >> 1;
		else if (d[0][i] > d[1][i])
			b += d[0][i] - d[1][i];
	}
	if (a >= b)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();
    long long n,m;
    cin >> n >> m;
    long long w=2;
    long long ans=1;
    while(m>1&&w<330000){
      long long q=0;
      while(m%w==0){
        m/=w;
        q++;
      }
      if(q!=0)ans=ans*COM(n+q-1,q)%MOD;
      //cout << ans << endl;
      w++;
    }
    if(m>1)ans=ans*n%MOD;
  cout << ans << endl;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
#define MAXN 202020
using namespace std;



int n;
vector<vi> t(2 , vi(2 * MAXN , INF));


void build(int par){
    for(int i = n - 1 ; i > 0 ; --i){
        t[par][i] = min(t[par][2 * i] , t[par][2 * i + 1]);
    }
}
 
void modify(int par , int p , int val){
    for(t[par][p += n] = val ; p > 1 ; p /= 2){
        t[par][p / 2] = min(t[par][p] , t[par][p ^ 1]);
    }
}
 
int query(int par , int l , int r){//[l , r)
    int res = INF;
    for(l += n , r += n ; l < r ; l /= 2 , r /= 2){
        if(l % 2){
            res = min(res, t[par][l]);
            ++l;
        }
        if(r % 2){
            --r;
            res = min(res , t[par][r]);
        }
    }
    return res;
}

int last = 0;
map<int , pii> code;
map<pii , int> rcode;
vi pos;

vi g[MAXN / 2];

void solve(vi & p , int l , int r , int prev = -1){
	if(r - l < 1)return;
	if(r >= sz(p) || l < 0)return;
	if(r - l == 1){
		code[last] = {p[l] , p[r]};
		rcode[{p[l] , p[r]}] = last;
		
		if(prev != -1){
			g[prev].pb(last);
		}
		prev = last;
		++last;
	}else{
		pii o = {0 , 0};
		
		int par = l % 2;
		o.fi = query(par , l , r + 1);
		
		int pos1 = pos[o.fi];
		o.se = query((pos1 + 1) % 2 , pos1 + 1 , r + 1);
		
		code[last] = o;
		rcode[o] = last;
		
		if(prev != -1){
			g[prev].pb(last);
		}
		prev = last;
		++last;
		

		int pos2 = pos[o.se];
		
		rep(q , 2){
			modify(q , pos1 , INF);
			modify(q , pos2 , INF);

		}

		solve(p , pos1 + 1 , pos2 - 1 , prev);
		solve(p , l , pos1 - 1 , prev);
		solve(p , pos2 + 1 , r  , prev);
		
	}
}

vi restore(){
	vi res;
	priority_queue<pii , vector<pii> , greater<pii>> q; 
	q.push(code[0]);
	
	while(!q.empty()){
		pii u = q.top();
		q.pop();
		
		res.pb(u.fi);
		res.pb(u.se);
		
		for(int c : g[rcode[u]]){
			q.push(code[c]);
		}
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 


	cin >> n;
	
	pos.resize(n + 1);
	
	vi p(n);
	rep(i , n){
		cin >> p[i];
		pos[p[i]] = i;
		
		int par = i % 2;
		
		t[par][n + i] = p[i];
		t[par ^ 1][n + i] = INF;
	}

	
	build(0);
	build(1);
	
	solve(p , 0 , n - 1);
	
	for(int e : restore()){
		cout << e << " ";
	}
	
	return 0;
}

Measured memory_bytes: 38612
N = int(input())
H = list(map(int, input().split()))

flag = True
minH = 0
for x in range(len(H)):
    if H[x] < minH:
        flag = False
        break
    else:
        if minH < H[x]:
            minH = H[x] - 1
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 63856
#include <iostream>

using namespace std;

int main() 
{
    int w, h, x, y, r, a, b ,c ,d;
    cin >> w >> h >> x >> y >> r;
    if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h)
        cout<< "Yes" << endl;
    else
        cout<< "No" << endl;
}


Measured memory_bytes: 3092
/*Flamenco Sketches*/
#include<bits/stdc++.h>
using namespace std;
 
#define NL '\n'
#define xx first
#define yy second
#define ll long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define async() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 
//#define FayeValentine 
void dbg(){cerr<<NL;}template<typename H,typename... T> void dbg(H h,T... t){cerr<<' '<<h;dbg(t... );}
#ifdef  FayeValentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dbg(__VA_ARGS__)
#else
#define debug(...) 
#endif


const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101};

void absinthe() {
	int n; cin >> n;
	int n2 = 0, n4 = 0, n14 = 0, n24 = 0, n74 = 0;
	for(int i = 0; primes[i] <= 97; i++) {
		int p = primes[i], cnt = 0;
		while(p <= n){
			cnt += n/p;
			p *= primes[i];
		}
		if(cnt >= 2) n2++;
		if(cnt >= 4) n4++;
		if(cnt >= 14) n14++;
		if(cnt >= 24) n24++;
		if(cnt >= 74) n74++;
	}
	debug(n2, n4, n14, n24, n74);
	int c1 = (n2-2) * ((n4*(n4-1))/2);
	int c2 = (n4-1) * n14;
	int c3 = (n2-1) * n24;
	int c4 = n74;
	debug(c1, c2, c3, c4);
	cout << c1 + c2 + c3 + c4 << NL;
}

int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  async();
  int __t = 1; //cin >> __t;
  for(int __c = 1; __c <=__t; __c++) {
    //cout << "Case #" << __c << ": "; 
    absinthe();
  }
}  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	cout << max({a+b, a-b, a*b}) << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
F = np.array(sorted(list(map(int, input().split()))))

#A.sort(); F.sort(); 
F = F[::- 1]

left = - 1
right = 10**12

def f(x):
    l = x//F
    return A[A > l].sum() <= K + l[A > l].sum()

while right - left > 1:
    mid = (left + right)//2
    if f(mid):
        right = mid
    else:
        left = mid
    
print(right)

Measured memory_bytes: 37268
#include <algorithm>
#include <cstdio>

#define int long long
#define dotimes(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

signed main() {
  int A = rint();
  int B = rint();
  int K = rint();
  printf("%lld %lld\n", A - min(A, K), B - min(B, max(K - A, 0LL)));
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

bool is_kaibun(string s){
    bool res = true;
    for(int i=0; i < s.size() / 2; i++){
        if(s[i] != s[s.size() - 1 - i]) res = false;
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string t;
    rep(i, 0, s.size()){
        if(s[i] != 'x'){
            t += s[i];
        } 
    }
    bool f = is_kaibun(t);
    int ans = 0;
    int idx = 0;
    vector<int> l((int)t.size() + 1, 0);
    rep(i, 0, s.size()){
        if(s[i] == t[idx]) idx++;
        if(s[i] == 'x'){
            l[idx]++;
        }
    }
    rep(i, 0, (t.size() + 1) / 2){
        ans += max(l[i], l[t.size() - i]) - min(l[i], l[t.size() - i]);
    }
    if(f == false) ans = -1;    
    cout << ans << endl;
}

Measured memory_bytes: 1360
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
//#define REP(i,a,b) for(int i=a;i<=b;i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
long long MOD=1e9+7;
int new1[3][3];
int main()
{	
	ios_base:: sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int a,b,c,d;
	cin>>a>>b;
	int fact1=0;
	c=a;
	while(c>a-2){
		if(c==a) fact1=1;
		fact1*=c;
		c-=1;
	}
	fact1/=2;
	int fact2=0;
	d=b;
	while(d>b-2){
		if(d==b) fact2=1;
		fact2*=d;
		d-=1;
	}
	fact2/=2;
	cout<<fact1+fact2;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <random>

int main() {
  int n;

  std::cin >> n;

  std::vector<int> an(n);

  for (auto &a : an) {
    std::cin >> a;
  }

  std::vector<int> result(n, 0);
  int box_num = 0;

  for (int i = n; i >= 1; --i) {
    int check_num = n / i;

    auto target = an[i - 1];
    auto sum = 0;
    while (check_num > 0) {
      sum += result[i * check_num - 1];
      --check_num;
    }
    result[i - 1] = sum & 0x01 ^ target;
    box_num += result[i - 1];
  }

  std::cout << box_num << std::endl;
  auto out = false;
  for (int i = 0; i < n; ++i) {
    if (result[i] == 1) {
      std::cout << i + 1 << " ";
      out = true;
    }
  }
  if (out) std::cout << std::endl;
  return 0;
}

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

const int MAXN = 100010;

int N, M;

class Point {
public:
	int parent;
	int value;
	bool used;
};

bool byParentThenValue(const Point& a, const Point& b) {
	if (a.parent != b.parent) {
		return a.parent < b.parent;
	}
	return a.value < b.value;
}

bool byValue(const Point& a, const Point& b) {
	return a.value < b.value;
}

Point point[MAXN];

int find_parent(int a) {
	if (point[a].parent != a) {
		point[a].parent = find_parent(point[a].parent);
	}
	return point[a].parent;
}

void merge(int a, int b) {
	int pa = find_parent(a);
	int pb = find_parent(b);
	point[pa].parent = pb;
}


int main() {
	cin >> N >> M;
	int missing = N - 1 - M;
	missing *= 2;
	if (missing > N) {
		cout << "Impossible" << endl;
		return 0;
	} else if (missing == 0) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		cin >> point[i].value;
		point[i].parent = i;
		point[i].used = false;
	}
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		merge(a, b);
	}
	for (int i = 0; i < N; i++) {
		point[i].parent = find_parent(point[i].parent);
	}
	sort(point, point + N, byParentThenValue);
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0 || point[i].parent != point[i - 1].parent) {
			ans += point[i].value;
			point[i].used = true;
			missing--;
		}
	}
	sort(point, point + N, byValue);
	for (int i = 0; missing && i < N; i++) {
		if (point[i].used) {
			continue;
		}
		ans += point[i].value;
		missing--;
	}
	cout << ans << endl;
	//system("pause");
}

Measured memory_bytes: 1408
n=int(input())
a=list(map(int,input().split()))
l1=[0]*100001
l2=[0]*100001
if a.count(a[0])==n:
    print(n//2)
    exit()

for i in range(0,n,2):
    l1[a[i]]+=1
for i in range(1,n,2):
    l2[a[i]]+=1

x,y=max(l1),max(l2)
#print(x,y)
i_x,i_y=l1.index(x),l2.index(y)
#print(i_x,i_y)

L1=sorted(l1,reverse=True)
L2=sorted(l2,reverse=True)

if i_x == i_y:
    #奇数番目を2番目に多い数でそろえる場合
    ans=min(((n//2-L1[1])+(n//2-L2[0])),((n//2-L1[0])+(n//2-L2[1])))
else:
    ans=((n//2-L1[0])+(n//2-L2[0]))
print(ans)


Measured memory_bytes: 20612
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (2999)
// #define MOD (1000000007)
int64_t MOD;

// べき乗余
int64_t modpow(int64_t b, int64_t e)
{
    int64_t result = 1;
    while(e>0)
    {
        if(e&1) result = (result * b) % MOD;
        e >>= 1;
        b = (b * b) % MOD;
    }
    return result;
}

// 組み合わせ数
// nCk % MOD
// c[i] : i = 0～n
void getComb(int64_t* c, int n)
{
    c[0] = 1;
    for(int i=1;i<=n;i++)
    {
        // モジュラ逆数 = a^-1 = a^m-2 (m=素数のとき)
        c[i] = (((c[i-1] * (n-i+1) ) % MOD) * modpow(i, MOD-2)) % MOD;
    }
}

int64_t a[MAXN];
int64_t b[MAXN];
int64_t ncj[MAXN];

int main(void)
{
    int64_t p;

    scanf("%ld",&p);
    MOD = p;

    for(int i=0;i<p;i++) scanf("%ld",&(a[i]));

    getComb(ncj, p-1);

    for(int64_t i=0;i<p;i++)
    {
        if(a[i]==0) continue;
        b[0] += 1;
        b[0] %= p;

        int64_t pw = 1;
        for(int64_t j=p-1;j>=0;j--)
        {
            b[j] -= (pw * ncj[j]) %p;
            b[j] = (b[j] + (p*p)) % p;
            pw = ((pw * -i) + (p*p)) % p;
        }
    }

    for(int i=0;i<p;i++) printf("%ld ", b[i]);

    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n, cnt=0;
  cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }
  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])){
      cnt++;
    }
  }
  cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,ta,ak,ta1,ak1;
    cin>>a>>b>>c>>d;
        ta=c/b;
        ak=a/d;
        ta1=c%b;
        ak1=a%d;
        if(ta1)
            ta++;
        if(ak1)
            ak++;
        if(ta>ak)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
        return 0;
}


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int a, b;
	cin >> a >> b;
	int now = 1, ans = 0;
	while (1) {
		if (b <= now) {
			cout << ans << endl;
			return 0;
		}
		now += a - 1;
		ans++;
	}
		
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string S, T;
  while (cin >> S >> T) {
    string S2 = S + S;
    vec<int, 2> nxt = make_v(S2.size() + 1, 26, -1);
    for (int i = S2.size() - 1; i >= 0; i--) {
      for (int j = 0; j < 26; j++) nxt[i][j] = nxt[i + 1][j];
      nxt[i][S2[i] - 'a'] = i;
    }
    int cur = -1;
    ll res = 0;
    for (char c : T) {
      int to = nxt[cur + 1][c - 'a'];
      if (to == -1) {
        res = -1;
        break;
      }
      res += to - cur;
      cur = to % S.size();
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 27264
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions
fn init_fact(n: u64, MOD: u64) -> (Vec<u64>, Vec<u64>, Vec<u64>){
    let mut fact = vec![1; n as usize];
    let mut finv = vec![1; n as usize];
    let mut inv  = vec![1; n as usize];
    for i in 2..n as usize{
        fact[i] = (fact[i-1] * i as u64) % MOD;
        inv[i]  = MOD - inv[(MOD as usize)%i] * (MOD/(i as u64))%MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
    return (fact,finv,inv);
}

fn nCr(n: u64, r: u64, MOD: u64, fact: &Vec<u64>, finv: &Vec<u64>) -> u64{
    if n<r { return 0; }
    return fact[n as usize] * (finv[r as usize] * finv[(n-r) as usize] % MOD) % MOD;
}

// Main
fn main(){
    input!{
        H: u64,
        W: u64,
        A: u64,
        B: u64,
    }
    let modulo = 1_000_000_007;
    let f = init_fact(200_000,modulo);
    let fact = f.0;
    let finv = f.1;

    let mut ans: u64 = 0;
    for i in 0..H-A{
        ans += nCr(i+B-1,i,modulo,&fact,&finv) * nCr(H-i-1+W-B-1,W-B-1,modulo,&fact,&finv);
        ans %= modulo;
    }
    println!("{}", ans);
}

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

int main()
{
    int N, X, bounce = 1, D = 0;
    cin >> N >> X;
    int L[N];

    for(int i = 0; i < N; i++)
    {
        cin >> L[i];
        if((D += L[i]) <= X)
            bounce++;
    }

    cout << bounce << endl;
    return 0;
}


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

int main(void){
        int d,w,h;
        int size;
        int n,r;
        while(1) {
                cin>>d>>w>>h;
                if(d==0 and w==0 and h==0) return 0;
                cin>>n;
                size=min(d*d+w*w,min(d*d+h*h,w*w+h*h));
                for(int i=0;i<n;i++){
                    cin>>r;
                    if(size<4*r*r){//size**0.5<2*r;
                        cout<<"OK"<<endl;
                    }
                    else{
                        cout<<"NA"<<endl;
                    }
                }
        }

}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
 
int n;
long long dp[402][402];
//long long sum[402][402];
int a[402];
long long smasm[402];
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		smasm[i] = smasm[i-1]+a[i];
	}
	
	memset(dp,0x7f,sizeof dp);
	
	//for(int i=1;i<=n;i++){
	//	for(int j=i;j<=n;j++){
	//		sum[i][j] = sum[i][j-1] + a[j];
	//	}
	//}
	
	for(int j=1;j<=n;j++){
		dp[j][j] = 0;
		for(int i=j-1;i>0;i--){
			for(int k=i+1;k<=j;k++){
				dp[i][j] = min(dp[i][j], dp[i][k-1]+dp[k][j]);
			}
			//dp[i][j] += sum[i][j];
			dp[i][j] += smasm[j] - smasm[i-1];
		}
	}
	
	cout<<dp[1][n];
	
	return 0;
}


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

vector<int> TopologicalSort(vector<vector<int> > &G, vector<int> &indegree){
	vector<int> va;
	queue<int> qa;
	for(int i = 0; i < G.size(); i++){
		if(indegree[i] == 0) qa.push(i);
	}
	while(!qa.empty()){
		int u = qa.front(); qa.pop();
		va.push_back(u);
		for(int i = 0; i < G[u].size(); i++){
			int v = G[u][i];
			indegree[v]--;
			if(indegree[v] == 0) qa.push(v);
		}
	}
	return va;
}

int main(){
	int V, E;
	cin >> V >> E;
	vector<vector<int> > G(V, vector<int>());
	vector<int> indegree(V, 0);
	for(int i = 0; i < E; i++){
		int s, t;
		cin >> s >> t;
		G[s].push_back(t);
		indegree[t]++;
	}
	vector<int> res = TopologicalSort(G, indegree);
	if(res.size() != V) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}




Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N;
    LL K;
    cin >> N >> K;
    vector<LL> P(N);
    vector<LL> C(N);
    REP(i,N)cin>>P[i];
    REP(i,N)cin>>C[i];

    vector<int> loop_count(N);
    REP(i,N){
        LL init = P[i];
        LL count = 1;
        LL index = P[i] - 1;
        while(true){
            LL Pi = P[index];
            if(Pi==init){
                break;
            }
            index = Pi - 1;
            count++;
        }
        loop_count[i] = count;
    }
    // priority_queue<LL> que;
    LL max_point = C[P[0]-1];

    REP(i,N){
        LL loop = loop_count[i];
        LL point = 0;
        LL index = P[i]-1;
        if(loop > K){
            for(LL j=0; j<K; j++){
                point += C[index];
                if(max_point<point)max_point=point;
                index = P[index]-1;
            }
        }else{
            for(LL j=0; j<loop; j++){
                point += C[index];
                // que.push(point);
                index = P[index]-1;
            }
            // if(point < 0){continue;}

            LL one_loop_point = point;
            LL max_count = K / loop;
            LL r_count = K % loop;

            point = (one_loop_point >0)? one_loop_point*(max_count-1) : 0;
            for(LL j=0; j<loop; j++){
                point += C[index];
                if(max_point<point)max_point=point;
                index = P[index]-1;
            }

            for(LL j=0; j<r_count; j++){
                point += C[index];
                if(max_point<point)max_point=point;
                // que.push(point);
                index = P[index]-1;
            }

        }
        
    }

    cout << max_point << endl;

    return 0;
    
}

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

const int mod = 998244353;
int sum(int x, int y) { return (x+y) % mod; }
int mul(int x, int y) { return (x*(long long)y) % mod; }
int power(int x, int y) {
	if (!y) return 1;
	if (y&1) return mul(x, power(x, y-1));
	int k = power(x, y/2);
	return mul(k, k);
}

int m[4004][4004];
int c(int x, int y) {
	if (x<0 or y<0 or y>x) return 0;
	if (x==0 or y==0 or y==x) return 1;
	if (m[x][y]) return m[x][y];
	return m[x][y] = sum(c(x-1, y-1), c(x-1, y));
}

int f(int g, int l, int n) {
	int ans = 0;
	for (int i=0; i<=g; i++) {
		int now = power(2, i);
		now = mul(now, c(g, i));
		now = mul(now, c(n+l-1, n-i));
		ans = sum(ans, now);
	} return ans;
}

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

	for (int i=2; i<=2*k; i++) {
		int g = min((i-1)/2, (2*k-i+1)/2), c = (i%2==0);

		int ans = f(g, k-c-2*g, n);
		if (c) ans = sum(ans, f(g, k-c-2*g, n-1));
		cout << ans << '\n';
	}
}


Measured memory_bytes: 60672
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int k = scanner.nextInt();
    final int a = scanner.nextInt();
    final int b = scanner.nextInt();

    if (k * (a / k + 1) <= b || a % k == 0) {
      System.out.println("OK");
    } else {
      System.out.println("NG");
    }

  }
}


Measured memory_bytes: 27084
using System;
using System.Linq;
using System.Security.Cryptography;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, M) = (NM[0], NM[1]);
        var s = new int[M];
        var c = new char[M];
        for (int i = 0; i < M; i++)
        {
            var sc = ReadLine().Split(' ').ToArray();
            (s[i], c[i]) = (int.Parse(sc[0]) - 1, sc[1][0]);
        }

        var cStr = Enumerable.Repeat('*', N).ToArray();
        var impossible = false;

        for (int i = 0; i < M; i++)
        {
            if (cStr[s[i]] == '*')
            {
                cStr[s[i]] = c[i];
            }
            else if (cStr[s[i]] == c[i])
            { }
            else
            {
                impossible = true;
                break;
            }
        }

        for (int i = 0; i < N; i++)
        {
            if (cStr[i] == '*')
            {
                if(i == 0 && N > 1)
                {
                    cStr[i] = '1';
                }
                else
                {
                    cStr[i] = '0';
                }
            }
        }

        if (impossible)
            cStr = "-1".ToCharArray();

        var str = new string(cStr);
        var n = int.Parse(str);
        var digit = n.ToString().Length;

        if (digit != N)
            n = -1;

        WriteLine(n);
    }
}


Measured memory_bytes: 28396
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}

signed main() {
	int ans = 0;
	string s;
	cin >> s;
	rep(i, 3) {
		if (s[i] == '1')ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;


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

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		double a1=0;
		double a2=0;
		double a3=0;
		double max=0;
		int x[]=new int[a];
		int y[]=new int[a];
		for(int i=0;i<a;i++) {
			x[i]=scan.nextInt();
		}for(int i=0;i<a;i++) {
			y[i]=scan.nextInt();
		}
		for(int i=0;i<a;i++) {
			a1 += Math.abs(x[i]-y[i]);
		}System.out.println(a1);
		for(int i=0;i<a;i++) {
			a2 +=Math.pow(Math.abs(x[i]-y[i]), 2);
		}System.out.println(Math.sqrt(a2));
		for(int i=0;i<a;i++) {
			a3 +=Math.pow(Math.abs(x[i]-y[i]), 3);
		}System.out.println(Math.cbrt(a3));
		for(int i=0;i<a;i++) {
			a1 =Math.abs(x[i]-y[i]);
			max=Math.max(a1, max);
		}System.out.println(max);
	}
}


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

int main(){
int n,sum=0,p,x;
cin>>n;
    int t[n];
    for(int i=1;i<=n;i++){
        cin>>t[i];
        sum+=t[i];}
    int m;
    cin>>m;

    for(int j=0;j<m;j++)
        {
cin>>p>>x;
cout<<sum-(t[p]-x)<<endl;
    }
   return 0;
}



Measured memory_bytes: 256
import math

A,B = map(int, input().split())

eight = math.ceil(A / 0.08)
ten = math.ceil(B / 0.1)


eight2 = math.ceil((A+1)/0.08 - 0.0001)
ten2 = math.ceil((B+1)/0.1 - 0.01)

eight_range = set(range(eight, eight2, 1))
ten_range = set(range(ten, ten2, 1))


if eight_range.isdisjoint(ten_range):
    out = -1
else:
    out = min(eight_range & ten_range)

print(out)

Measured memory_bytes: 3188
import math
import copy
from collections import Counter
from _ast import Or
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 

a=nCast(inputArr(5))
b=int(input())

                   
   

def func():
    global a
    for idx in range(len(a)):
        for idy in range(idx+1,len(a)):
            k=a[idx]-a[idy]
            if(b<abs(k)):
                return ":("
    return "Yay!"
print(func())


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

int main() {
  int a, b, c; cin >> a >> b >> c;
  if(a >= b && a >= c) cout << b+c << endl;
  else if( b >= a && b >= c ) cout << a+c << endl;
  else cout << a+b << endl;

  return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> cnt;
	rep(i,n){
		int a;
		cin >> a;
		cnt[a]++;
	}
	int ans = 0;
	for(auto p : cnt){
		if(p.second%2 == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
def main():
    x = int(input())
    dp = [0 for _ in range(x+1)]

    for i in range(1,x+1):

        dp[i] = 1 + dp[i-1]

        sup = 0
        while 1:
            if i - 6**sup < 0:
                break
            tmp = 1 + dp[i-6**sup]
            dp[i] = min(dp[i],tmp)
            sup += 1

        sup = 0
        while 1:
            if i - 9**sup < 0:
                break
            tmp = 1 + dp[i-9**sup]
            dp[i] = min(dp[i],tmp)
            sup += 1

    print(dp[x])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	
	int N, M, R;
	cin >> N >> M >> R;
	int r[9];
	rep1(i, R) cin >> r[i];

	int D[201][201];
	rep1(i, 200) {
		rep1(ii, 200) {
			D[i][ii] = 30000000;
		}
	}

	rep(i, M) {
		int A, B, C;
		cin >> A >> B >> C;
		D[A][B] = C;
		D[B][A] = C;
	}

	rep1(k, N) {
		rep1(i, N) {
			rep1(j, N) {
				if (D[i][j] > D[i][k] + D[k][j]) D[i][j] = D[i][k] + D[k][j];
			}
		}
	}

	int kumiawase = 1;
	rep1(i, R) kumiawase *= i;

	int saishou = 1e9;
	rep(i, kumiawase) {
		int machi[9] = {};
		int machi2[9] = {};
		int kumi = i;
		for (int ii = R; ii >= 1; ii--) {
			int kari = 1 + kumi % ii;
			kumi /= ii;
			int susumu = 0;
			rep1(iii, kari) {
				while (machi2[iii + susumu]) susumu++;
			}
			kari += susumu;
			machi[ii] = kari;
			machi2[kari] = 1;
		}
		rep1(ii, R) machi[ii] = r[machi[ii]];
		
		int goukei = 0;
		rep1(i, R - 1) goukei += D[machi[i]][machi[i + 1]];
		saishou = min(saishou, goukei);
	}


	co(saishou);

	Would you please return 0;
}

Measured memory_bytes: 384
_, *a = map(str.split, open(0))
U, R, D, L = "URDL"
d = {}
for *z, u in a:d.setdefault(u, []).append([*map(int, z)])
N = 1e9
for A, B, S in [(U, D, "x, y"), (R, L, "y, x"), (R, U, "x+y, x-y"), (D, L, "x+y, x-y"), (U, L, "x-y, x+y"), (R, D, "x-y, x+y")]:
  n = p = -1e9
  L = eval(f"[({S}, Q) for P, Q in [(A, 1), (B, 0)] for x, y in d.get(P, [])]")
  for x, y, r in sorted(L):
    if r:n,p = x,y
    elif x==n:N = min(N, (y - p)*5)
print(N if N < 1e9 else "SAFE")

Measured memory_bytes: 136608
#include <iostream>
#include <stdio.h>
using namespace std;

int selectionSort(int A[], int N){
    int count = 0;
    for(int i = 0; i <= N - 1; i++){
        int minj = i;
        for(int j = i; j <= N - 1; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i != minj){
            swap(A[i], A[minj]);
            count++;
        }
    }
    return count;
}

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    int ans = selectionSort(A, N);
    for(int i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << ans << endl;
    
    return 0;
}



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

using namespace std;

int main() {
	long long int a, b, c;
	cin >> a >> b >> c;
	if (a % 2 && b % 2 && c % 2) {
		cout << min({ a*b, b*c, c*a }) << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256