akhauriyash/Code-Regression huggingface dataset:
public class Main {
  private static void solve() {
    char[] s = ns();
    int n = s.length;
    int ptr = n - 1;

    int count = 0;
    for (int i = 0; i < ptr; i ++) {
      if (s[i] == 'x') {
        if (s[ptr] != 'x') {
          count ++;
        } else {
          ptr --;
        }
      } else {
        if (s[i] != s[ptr]) {
          if (s[ptr] == 'x') {
            count ++;
            ptr --;
            i --;
          } else {
            System.out.println(-1);
            return;
          }
        } else {
          ptr --;
        }
      }
    }
    System.out.println(count);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 25300
// Many Medians

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int N;
	cin >> N;
	int X[N];
	int sortedX[N];

	for(int i = 0; i < N; ++i){
		cin >> X[i];
		sortedX[i] = X[i];
	}

	sort(sortedX, sortedX+N);

	for (int i = 0; i < N; ++i){
		if (X[i] < sortedX[(N+1)/2])
			cout << sortedX[(N+1)/2] << endl;
		else
			cout << sortedX[(N+1)/2-1] << endl;
	}

	return 0;
}

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

#define ll long long 
#define mkp make_pair 
#define fi first 
#define se second

using namespace std ;

int z ;

int	 main ( ) {

	int n , k ;
	cin >> n >> k ;
	int m = 1 ;
	while( n > 0 ){
		if( m * 2 <= m + k ){
			m *= 2 ; 
			n -- ;
		}
		else{
			m += k ;
			n -- ;
		}
	}

	cout << m ;

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

	ll ans = k;
	FOR(i, 1, n) {
		ans *= (k-1);
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
n=int(input())
c=0.0
list = []
for i in range(n):
    a,b=input().split()
    list.append((float(a), b))

for i in range(n):
    if list[i][1]=='BTC':
        c+=float(list[i][0])*380000.0
    else:
        c+=float(list[i][0])
print(c)

Measured memory_bytes: 3316
#include <stdio.h>

int main(void){
  int i,j,k,n,m,l,a[100][100],b[100][100];
  long int s;
  scanf("%d%d%d",&n,&m,&l);

//行列A
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);

//行列B
  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      scanf("%d",&b[i][j]);

//行列C
  for(i=0;i<n;i++)
    for(j=0;j<l;j++){
      s = 0;
      for(k=0;k<m;k++)
        s += a[i][k] * b[k][j] ;
      printf("%ld", s);
      if(j+1 == l)
        printf("\n");
      else
        printf(" ");
    }

  return 0;
}


Measured memory_bytes: 2132
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

class Ruisekiwa2D { // {{{
    using i64 = long long;
    vector<vector<i64>> s;
public:
    Ruisekiwa2D() {}
    Ruisekiwa2D(int h, int w) : s(h+1, vector<i64>(w+1, 0)) {}

    inline void build() {
        const int h = s.size();
        const int w = s[0].size();
        for (int j = 1; j < w; ++j) {
            s[0][j] += s[0][j-1];
        }
        for (int i = 1; i < h; ++i) {
            s[i][0] += s[i-1][0];
            for (int j = 1; j < w; ++j) {
                s[i][j] += s[i-1][j] + s[i][j-1] - s[i-1][j-1];
            }
        }
        return;
    }

    inline i64 at(int y, int x) const {
        return (y < 0) || (x < 0) ? 0 : s[y][x];
    }

    inline i64 sum(int sy, int sx, int gy, int gx) const {
        return s[gy][gx] - at(sy-1, gx) - at(gy, sx-1) + at(sy-1, sx-1);
    }

    inline void resize(int h, int w) { s.assign(h+1, vector<i64>(w+1, 0)); }
    inline const vector<i64>& operator[] (size_t i) const { return s[i]; }
    inline vector<i64>&       operator[] (size_t i)       { return s[i]; }
}; // }}}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N, M, Q;
    cin >> N >> M >> Q;

    Ruisekiwa2D mat(N, N);

    for (int i = 0; i < M; ++i) {
        int l, r;
        cin >> l >> r;
        ++mat[l][r];
    }

    mat.build();

    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << mat.sum(l, 0, N, r) << "\n";
    }
    return 0;
}

// vim: set foldmethod=marker :


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n;
    cin >> n;
    vector<Int> a(3 * n);
    for (Int i = 0; i < 3 * n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    Int res = 0;
    for (Int i = n; i < 3 * n; i += 2) {
        res += a[i];
    }
    print(res);
}

int main() {
    solve();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int A,B,M;
    cin>>A>>B>>M;
    vector<int> a(A),b(B),x(M),y(M),c(M);
    rep(i,A)cin>>a[i];
    rep(i,B)cin>>b[i];
    rep(i,M)cin>>x[i]>>y[i]>>c[i];
    int MIN=*min_element(ALL(a))+*min_element(ALL(b));
    rep(i,M){
        int s=a[x[i]-1]+b[y[i]-1]-c[i];
        MIN=min(MIN,s);
    }
    cout<<MIN<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 2176
var a,b:longint;
tmp:int64;
begin
        readln(a, b);
        if b>a then begin
                tmp:=a;
                a:=b;
                b:=tmp;
        end;
        tmp:=a;
        while true do begin
                if tmp mod b = 0 then begin
                        writeln(tmp);
                        break;
                end;
                tmp:=tmp+a;
        end;
end.


Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	fmt.Scan(&x)

	var i, j, result float64
	result = 1

	root := math.Sqrt(x)

	for i = 2; i < root; i++ {
		j = 2
		for {
			pow := math.Pow(i, j)
			if pow > x {
				break
			}
			if pow > result {
				result = pow
			}
			j++
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
/* fucklove - when you give everything to someone and it's stil not enough */
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
 
const ll N=1e3 + 5 ,  INF = 1e6 + 10 , md=1e9+7;
 
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);} 
int takemod(int a, int mod ){a%=mod;if(a<0)a+=mod;return a;}
int fast_exp(int base, int expo, int mod ) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;}
	return res;}
int modinv(int a, int mod ){return takemod(fast_exp(takemod(a,mod), mod-2, mod), mod);}


int main()
{
	fast_cin();
	int t=1;
//	cin >> t;
	while(t--){
		int n,k; cin>>n>>k;
		vector<double> p(n+1,0.0);
		for(int i=1;i<=n;i++){
			int x; cin>>x;
			double y=(x+1.0)/2.0+p[i-1];
			p[i]+=y;
		}
		double mx=0;
		for(int i=k;i<=n;i++){
			mx=max(mx, p[i]-p[i-k]);
		}
		cout <<setprecision(10)<<mx<<endl;

		
	
	}
	return 0;
}
 


Measured memory_bytes: 1792
S=input()
start=0
end=len(S)-1
for i in range(len(S)):
  if S[i]=="A":
    start=i
    break
S=S[::-1]
for i in range(len(S)):
  if S[i]=="Z":
    end = len(S)-i
    break
print(end-start)

Measured memory_bytes: 65056
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  int mx = pow(10, 5) * 2+20;
  string x;
  cin >> n >> x;
  int original_pc = 0;
  rep(i, n) {
    if (x[i] == '1') {
      original_pc++;
    }
  }
  int one_pc = original_pc - 1;
  int zero_pc = original_pc + 1;

  vector<int> one_pow2_mod(mx, 1);
  vector<int> zero_pow2_mod(mx, 1);
  vector<int> pcs(mx, 0);
  reps(i, 1, mx) {
    if (one_pc != 0) {
      one_pow2_mod[i] = one_pow2_mod[i-1] * 2 % one_pc;
    }
    zero_pow2_mod[i] = zero_pow2_mod[i-1] * 2 % zero_pc;
  }
  int one_mod = 0;
  int zero_mod = 0;
  rep(i,n) {
    if (one_pc != 0) {
      one_mod = (one_mod * 2 + x[i] - '0') % one_pc;
    }
    zero_mod = (zero_mod * 2 + x[i] - '0') % zero_pc;
  }

  vector<int> f(mx, 0);
  reps(i, 1, mx) {
    pcs[i] = pcs[i / 2] + (i % 2);
    f[i] = f[i%pcs[i]] + 1;
  }
  
  repr(i, n-1) {
    if (x[n-1-i] == '1') {
      if (one_pc == 0) {
        cout << 0 << endl;
        continue;
      }
      int r = one_mod + one_pc;
      r -= one_pow2_mod[i];
      r %= one_pc;
      cout << f[r%one_pc] + 1 << endl;
    } else {
      int r = zero_mod;
      r += zero_pow2_mod[i];
      r %= zero_pc;
      cout << f[r%zero_pc] + 1 << endl;      
    }
  }

  return 0;
}

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

typedef pair<int, int> P;
const int IINF = INT_MAX;
#define REP(i, n) for (int i = 0; i < n; i++)

int n, ma, mb, a[45], b[45], c[45];

void build(int bg, int en, map<P, int> &mp) {
    int _n = en - bg;
    REP(i, (1 << _n)) {
        int at = 0, bt = 0, ct = 0;
        REP(j, _n) {
            if ((i >> j) & 1) {
                at += a[j + bg];
                bt += b[j + bg];
                ct += c[j + bg];
            }
        }
        if (!mp.count({at, bt}) || mp[{at, bt}] > ct) {
            mp[{at, bt}] = ct;
        }
    }
}

int main() {
    map<P, int> mp1, mp2;
    cin >> n >> ma >> mb;
    REP(i, n) cin >> a[i] >> b[i] >> c[i];
    build(0, n / 2, mp1);
    build(n / 2, n, mp2);
    int ans = IINF;
    for (auto it1 : mp1) {
        for (auto it2 : mp2) {
            int as, bs;
            as = it1.first.first + it2.first.first;
            bs = it1.first.second + it2.first.second;
            if (as * bs > 0 && as * mb == bs * ma) {
                ans = min(ans, it1.second + it2.second);
            }
        }
    }
    cout << (ans != IINF ? ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 896
main = do
    n <- getInt
    mapM printThree [1..n]   
    putStrLn ""

printThree :: Int -> IO ()
printThree n 
    | isThree n = putStr $ " " ++ (show n)
    | otherwise = return ()

isThree :: Int -> Bool
isThree n 
    | n `mod` 3  == 0 = True
    | hasThree n      = True
    | otherwise       = False

hasThree :: Int -> Bool
hasThree n = any (\c -> c == '3') (show n)
--hasThree 0 = False
--hasThree 3 = True
--hasThree n = hasThree $ n `div` 10
    
getInt :: IO (Int)
getInt = do
    str <- getLine
    return $ read str


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

int main(){
    int x;
    cin >> x;
    int y = x;

    for (int k = 0; k<x; k++){
        for (int i = 0; i < x; i++){
            int j = i+2;
            int a = j*j;
            while (a <= y){
                if (y == a){
                    cout << y << endl;
                    return 0;
                }
                a *= j;
            }       
        }
        y--;
    }

    cout << 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mo=998244353;
map<string,int> dp;
string s;
int calc(string s){
	if (dp.find(s)!=dp.end()) return dp[s];
	int n=s.size(),f[105],i,j,k,l;
	string subs,pres=s; s="0"+s;
	for (int i=f[0]=1;i<=n;i++){
		f[i]=1ll*f[i-1]*(s[i]-'0'+1)%mo;
		for (int j=1;j*2<=i;j++){
			subs.clear();
			for (int k=1;k<=j;k++) subs+=s[i-j+k];
			for (int k=2;j*k<=i;k++){
				for (int l=1;l<=j;l++)
					if (s[i-j*k+l]=='0') subs[l-1]='0';
					f[i]=(f[i]+1ll*f[i-j*k]*calc(subs))%mo;
			}
		}
	}
	return dp[pres]=f[n];
}
int main(){
	cin>>s;
	dp["0"]=1; dp["1"]=2;
	printf("%d\n",calc(s));
}

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

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;
int cnt[3];
int main(){
	int n;
	cin>>n;
	int tmp=n;
	rep(i,n){
		int x;
		cin>>x;
		if(x%4==0)cnt[0]++;
		else if(x%2==0)cnt[1]++;
	}
	tmp-=(cnt[1]/2)*2+2*cnt[0]+(cnt[0]!=0);
	if(tmp>0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int main() {
	ll x;
	cin >> n;
	cin >> x;
	vector<ll> a(n);
	rep(i, n) {
		ll k;
		cin >> k;
		a[i] = abs(x - k);
	}
	ll res=a[0];
	rep(i, n-1) {
		res = gcd(a[i], a[i + 1]);
		a[i + 1] = res;
	}
	cout << res << endl;
}

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

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;

    auto initial = vector<int>(2*N-1);
    for (auto& x : initial)
    {
        cin >> x;
        x--;
    }

    const auto works = [&](const int cutoff)
    {
        auto classes = vector<int>(2*N-1);
        for (auto i = 0; i < 2*N-1; i++)
            classes[i] = initial[i] >= cutoff;

        const auto middle = N-1;
        for (auto i = middle, j = middle, expected = classes[middle]; i >= 0; i--, j++, expected = !expected)
        {
            if (classes[i] != expected) return classes[i];
            if (classes[j] != expected) return classes[j];
        }
        return classes[0];
    };

    auto lower = 0, upper = 2*N-2;
    while (lower < upper)
    {
        const auto guess = (lower + upper + 1) / 2;
        if (works(guess)) lower = guess;
        else upper = guess-1;
    }

    cout << lower+1 << endl;
}


Measured memory_bytes: 1808
N, Q = [int(s) for s in input().split()]
S = input()

t = [0 for i in range(N+1)]
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
    l, r = [int(s) for s in input().split()]
    print(t[r-1] - t[l-1])


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

int main() {
string S;
  cin >>S;
  int n =0;
  for(int i =0;i<4;i++){
    if(S.at(i)=='+'){
      n++;
    }
    else if(S.at(i)=='-'){
      n--;
    }
  }
  cout<<n;

}


Measured memory_bytes: 256
open Batteries

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_array n m e conv =
  let arr = Array.make_matrix n m e in
  Enum.Labels.iter (0 --^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);
  arr

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let dbg x = Printf.printf "%s\n" @@ dump x; x

let n = scan "%d" identity

let aux n =
  Enum.Labels.map (1 -- n)
    ~f:(fun i -> if n mod i = 0 then 1 else 0 )
  |> Enum.sum
  |> (=) 8

let () =
  Enum.Labels.map (1 -- n)
    ~f:(fun i -> if i mod 2 = 1 && aux i then 1 else 0)
  |> Enum.sum
  |> Printf.printf "%d\n"


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using tll = tuple<ll,ll,ll>;
using vtll = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

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

ll dp[1001001][2];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  
  dp[0][0]=1;
  rep(i,n) rep(j,2){
    if(j==0){
      if(s[i]=='0'){
        // s[i]==0 ... a==0,b==0 の1通り
        (dp[i+1][j]+=dp[i][j])%=MOD;
      }else{
        // s[i]==1 ... (1,0) ならj==0のまま、(0,0)ならj==1に遷移
        (dp[i+1][j]+=dp[i][j]*2)%=MOD;
        (dp[i+1][1]+=dp[i][j])%=MOD;
      }
    }else{
      // 0 or 1どちらでも
      (dp[i+1][j]+=dp[i][j]*3)%=MOD;
    }
  }
  ll ans=(dp[n][0]+dp[n][1])%MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 2000
#include <stdio.h>

int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (x>=r && x+r<=W && y>=r && y+r<=H) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2104
n,A,B,C=map(int,input().split())
L=[0]*n
for i in range(n):
  L[i]=int(input())
ans=10**10
for i in range(2**n):
  S=format(i,"10b")
  K=[]
  for j in range(n):
    if S[-1-j]=="1":
      K.append(j)
  k=len(K)
  if len(K)<3:
    continue
  for j in range(2**k):
    SS=format(j,"10b")
    AA=[]
    for l in range(k):
      if SS[-1-l]=="1":
        AA.append(K[l])
    a=len(AA)
    if a<1 or k-2<a:
      continue
    KK=sorted(list(set(K)-set(AA)))
    kk=k-a
    for l in range(2**kk):
      SSS=format(l,"10b")
      BB=[]
      for m in range(kk):
        if SSS[-1-m]=="1":
          BB.append(KK[m])
      b=len(BB)
      if b<1 or kk-1<b:
        continue
      CC=sorted(list(set(KK)-set(BB)))
      c=len(CC)
      AAA=sum(L[AA[x]] for x in range(a))
      BBB=sum(L[BB[x]] for x in range(b))
      CCC=sum(L[CC[x]] for x in range(c))
      aans=(a+b+c-3)*10+abs(AAA-A)+abs(BBB-B)+abs(CCC-C)
      if aans<ans:
        ans=aans
print(ans)

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

int main() {
  long long int N, X; cin >> N >> X;
  
  long long int ans = 0;
  vector<long long int> A(N);
  for(int i=0; i<N; i++) {
   	cin >> A[i];
    if(i == 0) {
      ans += max(0LL, A[i] - X);
      A[i] -= max(0LL, A[i] - X);
    }
    else {
      ans += max(0LL, A[i-1] + A[i] - X);
      A[i] -= max(0LL, A[i-1] + A[i] - X);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s;cin>>s;
    string res="";
    for(int i=0;i<(int)s.length();i+=2){
        res += s[i];
    }
    cout<<res<<endl;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383



int main (){
    fast;
    int n;
    cin>>n;
    if(n >= 30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}











Measured memory_bytes: 3608
package main

import "fmt"

func main() {
	var n, a int
	fmt.Scan(&n, &a)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	// i番目までからk回選んで, 合計値がsになる組み合わせ
	var dp [60][60][3000]int
	// 初期値
	dp[0][0][0] = 1

	for i := 0; i < n; i++ {
		for k := 0; k < n; k++ {
			for s := 0; s < 2500; s++ {
				dp[i+1][k][s] += dp[i][k][s]
				dp[i+1][k+1][s+nums[i]] += dp[i][k][s]
			}
		}
	}

	ans := 0
	for i := 1; i <= n; i++ {
		ans += dp[n][i][a*i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 75264
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
		
	void doIt() {
		int a = sc.nextInt();
		int p = sc.nextInt();
		System.out.println((3 * a + p) / 2);
	}

	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

int main()
{
    int n,a[105];
    int cnt=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i=i+2)
    {
        if(a[i]%2==1)
        {
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S;
    cin >> S;

    int red = 0;
    REP(i, S.length()) {
        if (S[i] == '0') {
            red++;
        }
    }
    int blue = S.length() - red;

    int ans = 2*min(red, blue);
    print(ans);
}

signed main() {
    solve();
}


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

typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define int ll

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

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

int n, m, a, b, c, d;
char g[1007][1007];
int vis[1007][1007];

int dr[4] = { -1, 1, 0, 0};
int dc[4] = { 0, 0, -1, 1};
int dm[5] = { -2, -1, 0, 1, 2};
bool check(int x, int y) {
	return x >= 0 && x < n && y >= 0 && y < m && g[x][y] == '.';
}

void solve() {
	cin >> n >> m >> a >> b >> c >> d;
	a--; b--; c--; d--;
	F0R(i, n) F0R(j, m) cin >> g[i][j], vis[i][j] = 0;

	deque<pair<pii, int>> q;

	q.push_front({{a, b}, 0});

	while (!q.empty()) {
		pair<pii, int> p = q.front();
		q.pop_front();
		int row = p.F.F;
		int col = p.F.S;
		int dist = p.S;

		if (vis[row][col]) continue;
		vis[row][col] = 1;

		if (row == c && col == d) {
			cout << dist;
			return;
		}

		F0R(i, 4) {

			int curr = row + dr[i];
			int curc = col + dc[i];
			if (check(curr, curc) && !vis[curr][curc]) {
				q.push_front({{curr, curc}, dist});
				// vis[curr][curc] = 1;
			}

		}

		FOR(i, -2, 3) {
			FOR(j, -2, 3) {
				int curr = row + i;
				int curc = col + j;

				if (check(curr, curc) && !vis[curr][curc]) {
					q.push_back({{curr, curc}, dist + 1});
					// vis[curr][curc] = 1;
				}
			}
		}
	}
	// F0R(i, n) {F0R(j, m) cerr << vis[i][j] << ' '; cerr << '\n';}
	cout << -1;

}

int32_t main() {
	_

#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
	solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}


Measured memory_bytes: 13868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define psi pair<string,int>

bool func(psi a, psi b){
  if(a.first!=b.first) return a.first<b.first;
  else return a.second>b.second;
}

int main(){
  int N; cin>>N;
  psi p[N];
  string si;
  int pi;
  map<int,int> mp_idx;
  REP(i,N){
    cin >>si>>pi;
    p[i] = make_pair(si,pi);
    mp_idx[pi] = i+1;
  }
  sort(p,p+N,func);
  REP(i,N){
    cout << mp_idx[p[i].second]<< "\n";
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=0;
    while(s[l]!='\0'){
        l++;
    }
    if(l%2==0){
        cout<<"No"<<endl;

        return 0;
    }
    else{
        int sum=0;
        for(int i=0,j=l-1;i<l-1,j>=0;i+=1,j-=1){
            if(s[i]==s[j]){
                sum++;
            }
        }
        ///cout<<sum<<endl;
        if(sum!=l){
           cout<<"No"<<endl;

           return 0;
        }
        int x = (l-1)/2,sum1=0;
        for(int i=0,j=x-1;i<x-1,j>=0;i+=1,j-=1){
            if(s[i]==s[j]){
               sum1++;
            }
        }
        if(sum1!=x){
            cout<<"No"<<endl;

            return 0;
        }
        int y = (l+3)/2,sum2=0,z = (l+1)-y;
        for(int i=y-1,j=l-1;i<l,j>=y-1;i+=1,j-=1){
            if(s[i]==s[j]){
               sum2++;
            }
        }
        if(sum2!=z){
            cout<<"No"<<endl;

            return 0;
        }
        else{
            cout<<"Yes"<<endl;

            return 0;
        }
    }


    return 0;
}


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

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

void join(map<int, int> &a, map<int, int> &b) {
	if (a.size() < b.size()) swap(a, b);
	for (auto t : b) {
		a[t.first] += t.second;
	}
	b.clear();
}

const int N = 2e5 + 7;

int sz[N];
vector<int> g[N];
map<int, int> v[N];
int ans[N];
int color[N];

void dfs(int cur, int p) {
	sz[cur] = 1;
	for (auto t : g[cur]) {
		if (t != p) {
			dfs(t, cur);
			int rs = sz[t] - v[t][color[cur]];
			ans[color[cur]] -= rs * (rs + 1) / 2;
			sz[cur] += sz[t];
			join(v[cur], v[t]);
		}
	}
	v[cur][color[cur]] = sz[cur];
}

int cc[N];

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

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> color[i];
		color[i]--;
		cc[color[i]]++;
	}	
	for (int i = 0; i + 1 < n; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < n; i++) {
		ans[i] = (n * (n + 1)) / 2;
	}
	dfs(0, -1);
	for (auto [clr, cnt] : v[0]) {
		int rs = n - cnt;
		ans[clr] -= rs * (rs + 1) / 2;
	}
	for (int i = 0; i < n; i++) {
		if (!cc[i]) ans[i] = 0;
		cout << ans[i] << ' ';
	}
	cout << '\n';
}


Measured memory_bytes: 54684
#include<bits/stdc++.h>
using namespace std;
signed main()
{
    int test=1;
    //cin>>test;
    while(test--){
      int n;
      cin>>n;
      int a[n];
      int x=0;
      for(int i=0;i<n;i++) {
        cin>>a[i];
        x^=a[i];
      }
      for(int i=0;i<n;i++){
        cout<<(x^a[i])<<" ";
      }

      
    }
    

    return 0;
}


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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}

LL a[N], b[N];

void Solve() {
	LL sum = 0;

	rep (i, 1, 3) cin >> a[i], sum += a[i];

	int times = 0;
	while (times <= 1000) {
		int ok = 0;
		rep (i, 1, 3) if (a[i] & 1) { ok = 1; break; }
		if (ok) break;

		times++;

		rep (i, 1, 3) b[i] = (sum - a[i]) / 2;
		rep (i, 1, 3) a[i] = b[i];

	}

	if (times > 1000) cout << -1 << endl;
	else cout << times << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


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

int main() {
  int N, i;
  cin >> N;
  vector<int> A(N);
  for (i = 0; i < N; i++) {
    cin >> A[i];
  }
  bool can = true;
  sort(A.begin(), A.end());
  for (i = 0; i < N; i++) {
    if (A[i] == A[i+1]) {
      can = false;
      break;
    }
  }
  if (can == true) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 1024
a=int(input())
b=list(map(int,input().split()))
cc=1
d=[0 for i in range(a)]
d[0]=sum(b[0::2])-sum(b[1::2])
print(str(d[0]), end="")
for i in range(1,a):
  d[i]=b[i-1]*2-d[i-1]
  print(" "+str(d[i]), end="")


Measured memory_bytes: 14092
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


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

  int n, c;
  cin >> n >> c;
  vector<vector<int>> costs(vector<vector<int>>(c, vector<int>(c)));
  rep(i, c) rep(j, c) cin >> costs[i][j];

  vector<vector<int>> grids(vector<vector<int>>(n, vector<int>(n)));
  rep(i, n) rep(j, n) {
    cin >> grids[i][j];
    grids[i][j]--;
  }

  vector<int> c1(c, 0), c2(c, 0), c3(c, 0);

  rep(i, c) {
    rep(h, n) rep(w, n) {
      if ((h + w) % 3 == 0) c1[i] += costs[grids[h][w]][i];
      if ((h + w) % 3 == 1) c2[i] += costs[grids[h][w]][i];
      if ((h + w) % 3 == 2) c3[i] += costs[grids[h][w]][i];
    }
  }

  int ans = INF;
  for (int i = 0; i < c; i++) {
    for (int j = 0; j < c; j++) {
      if (i == j) continue;
      for (int k = 0; k < c; k++) {
        if (i == k || j == k) continue;
        chmin(ans, c1[i] + c2[j] + c3[k]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;



long long int n,m,cou=0,res=0,h[200000];
string s,t;                
int main() {
	cout << fixed << setprecision(10);
	cin>>n;
	cout<<n*(n-1)/2<<endl;
} 


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


using namespace std;

int N, M;
int switches[10];
int ans = 0;
vector<int> states;
vector<vector<int>> lamps;


//全探索
void DFS(int k) {
	if (k < 0) {
		//すべての電球が点灯するか
		int add = 1;
		for (int i = 0; i < M; i++)
		{
			int count = 0;
			for (auto j : lamps[i]) {
				count += switches[j - 1];
			}
			if (count % 2 != states[i]) {
				add = 0;
				break;
			}
		}
		ans += add;
		return;
	}
	else {
		switches[k] = 0;
		DFS(k - 1);
		switches[k] = 1;
		DFS(k - 1);
		return;
	}
}

int main() {

	cin >> N >> M;

	lamps.resize(M);

	for (int i = 0; i < M; i++)
	{
		int k;
		cin >> k;
		for (int j = 0; j < k; j++)
		{
			int s;
			cin >> s;
			lamps[i].push_back(s);
		}
	}

	for (int i = 0; i < M; i++) {
		int p;
		cin >> p;
		states.push_back(p);
	}

	DFS(N - 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int h,w,i,j;
    scanf("%d %d",&h,&w);
    while(h!=0&&w!=0){
    	for(i=0;i<h;i++){
    		for(j=0;j<w;j++){
    			printf("#");
    		}
    		printf("\n");
    	}
    	printf("\n");
    	scanf("%d %d",&h,&w);
    }
    return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<int> X(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> X[i];
	}
	sort(X.begin(), X.end());

	auto minSum = INT_MAX;
	for (auto i = X[0]; i <= X[N - 1]; ++i)
	{
		auto sum = 0;
		for (auto j : X)
		{
			sum += (i - j) * (i - j);
		}

		minSum = min(minSum, sum);
	}
	cout << minSum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  int N;

  cin >> N;
  vector<int> a(N);

  rep(i, N) cin >> a[i];

  int count;
  rep(i, N) {
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import fractions

inp = [int(i) for i in input().split()]
c1 = (inp[0]-1) // inp[2]
c2 = inp[1] // inp[2]
c = c2 - c1

d1 = (inp[0]-1) // inp[3]
d2 = inp[1] // inp[3]
d = d2 -d1

e1 = (inp[0]-1) // int(inp[3] * inp[2]/fractions.gcd(inp[3],inp[2]))
e2 = inp[1] // int(inp[3] * inp[2]/fractions.gcd(inp[3],inp[2]))
e = e2 - e1

print(int(inp[1]-inp[0]+1-(c+d-e)))

Measured memory_bytes: 5076
N, A, B = map(int,input().split(" "))
ans = 0
diff = abs(A-B)

if diff % 2 == 0:
    ans = diff // 2
else:
    edge = min(A-1, N-B) + 1
    edge += (B-A-1)//2
    ans = edge

print(ans)



Measured memory_bytes: 2940
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INF=(1<<21);
static const int WHI=0;
static const int GRA=1;
static const int BLA=2;
int n,m[MAX][MAX];
int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];
  for(int i=0;i<n;++i){
    d[i]=INF;
    p[i]=-1;
    color[i]=WHI;
  }
  d[0]=0;
  while(114514){
    minv=INF;
    u=-1;
    for(int i=0;i<n;++i){
      if(minv>d[i] && color[i]!=BLA){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLA;
    for(int v=0;v<n;++v){
      if(color[v]!=BLA && m[u][v]!=INF){
	if(d[v]>m[u][v]){
	  d[v]=m[u][v];
	  p[v]=u;
	  color[v]=GRA;
	}
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;++i){
    if(p[i]!=-1) sum+=m[i][p[i]];
  }
  return sum;
}

int main(){
  cin>>n;
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      int e;
      cin>>e;
      m[i][j]=(e==-1)?INF:e;
    }
  }
  cout<<prim()<<endl;
  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int a[110], b[110];
Int c[110], d[110];

vector<P> edge2[55 * 2500];

vector<Int> dijkstra(int s, vector<P> *edge){
    priority_queue<P, vector<P>, greater<P>> pq;
    vector<Int> dist(55*2500, LINF);
    dist[s] = 0;
    pq.push(P(dist[s], s));
    while(!pq.empty()){
        auto tmp = pq.top();pq.pop();
        int from = tmp.second;
        int d = tmp.first;
        if(dist[from] < d)continue;
        for(auto p: edge[from]){
            int to = p.first;
            int d = p.second;
            if(dist[to] > dist[from] + d){
                dist[to] = dist[from] + d;
                pq.push(P(dist[to], to));
            }
        }
    }
    return dist;
}

int value(int v, int s){
    return v*2500 + s;
}

vector<P> edge[55];

int main(){
    int n, m ,s, u, v;
    cin >> n >> m >> s;
    for(int i = 0;i < m;i++){
        cin >> u >> v >> a[i] >> b[i];u--,v--;
        edge[u].emplace_back(v, i);
        edge[v].emplace_back(u, i);
    }
    for(int i = 0;i < n;i++){
        cin >> c[i] >> d[i];
    }

    for(int i = 0;i < n;i++){
        for(int j = 0;j <= 2499;j++){
            int to = min(j + c[i], 2499ll);
            edge2[value(i,j)].emplace_back(value(i,to), d[i]);
            for(auto p: edge[i]){
                int to = p.first;
                int edge_ind = p.second;
                if(j < a[edge_ind])continue;
                edge2[value(i,j)].emplace_back(value(to, j- a[edge_ind]), b[edge_ind]);
            }
        }
    }
    s = min(s, 2499);
    auto dist = dijkstra(value(0,s), edge2);

    for(int i = 1;i < n;i++){
        Int ans = LINF;
        for(int j = 0;j < 2500;j++){
            ans = min(ans, dist[value(i, j)]);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 24052
using System;

namespace ABC139_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            var ans = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == T[i])
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int n;
int a[1 << 18];

int winnerkode(int l, int r)
{
	// l, l+1, l+2, ... rのうちの勝者の硬度を求める
	if(r - l == 1){
		if(a[l] == a[r]) return a[l];
		else return max(a[l], a[r]) - min(a[l], a[r]);
	}
	int tmp1 = winnerkode(l, (l + r) / 2);
	int tmp2 = winnerkode((l + r) / 2 + 1, r);
	if(tmp1 == tmp2) return tmp1;
	else return max(tmp1, tmp2) - min(tmp1, tmp2);
}

int main()
{
	cin >> n;
	for(int i = 0; i < (1 << n); i++){
		cin >> a[i];
	}
	cout << winnerkode(0, (1 << n) - 1) << endl;
	return 0;
}

Measured memory_bytes: 1280
import itertools
import math

N = int(input())
XY = [list(map(int,input().split(' '))) for _ in range(N)]
All_combination = list(itertools.permutations(XY))
All_distances = []
for each_list in All_combination:
    distance = 0
    for i in range(1,N):
        distance += math.sqrt((each_list[i-1][0] - each_list[i][0])**2 + (each_list[i-1][1] - each_list[i][1])**2) 
    All_distances.append(distance)
print(sum(All_distances)/len(All_distances))


Measured memory_bytes: 46064
n,k=map(int, input().split())
h=[]
for i in range(n):

    hi = int(input())
    h.append(hi)

h.sort()
tmp = 1000000000
for i in range(0, n-k+1):
    tmp = min(tmp, abs(h[i]-h[i+k-1]))
print(tmp)


Measured memory_bytes: 7440
# -*- coding: utf-8 -*-

n = int(input())
s = ["" for _ in range(n)]

for i in range(n):
    s[i] = input()

nAC = s.count("AC")
nWA = s.count("WA")
nTLE = s.count("TLE")
nRE = s.count("RE")

print("AC x", nAC)
print("WA x", nWA)
print("TLE x", nTLE)
print("RE x", nRE)


Measured memory_bytes: 16300
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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(){
    int n; cin >> n;
    vector<vector<int>> grid(2, vector<int>(n));
    rep(i, 2){
        rep(j, n){
            cin >> grid[i][j];
        }
    }
    vector<vector<int>> dp(2, vector<int>(n, 0));
    dp[0][0] = grid[0][0];
    rep(i, 2){
        rep(j, n){
            if(j < n-1) chmax(dp[i][j+1], dp[i][j] + grid[i][j+1]);
            if(i == 0) chmax(dp[i+1][j], dp[i][j] + grid[i+1][j]);
        }
    }
    cout << dp[1][n-1] << ln;
}


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

int main(){
 int n,m=0;
 cin>>n;
 for(int i=1;i<10;i++){
  for(int j=0;j<10;j++){
    if(n==i*j)m=1;
  }
 }
  if(m==0)cout<<"No"<<endl;
  else if(m==1)cout<<"Yes"<<endl;
  
 return 0;
}
    

Measured memory_bytes: 256