akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

class FFrogJump {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> S(N);
        REP(i, N) cin >> S[i];

        int res = 0;
        FOR(c, 1, N - 1) {
            int sum = 0;
            int l = 0;
            int r = N - 1;
            while (l + c < N) {
                if ((N - 1) % c == 0 && l >= r) break;
                sum += S[l] + S[r];
                res = max(sum, res);
                l += c;
                r -= c;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FFrogJump solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<algorithm>
using namespace std;

#define ran 222

int n;
int a[ran];
int p[ran];
vector<pair<int, int> > v;

int q(int x, int y) {
	char s[ran];
	for(int i=0;i<n;i++)
		s[i] = (i==x || i==y) ? '1' : '0';
	s[n] = 0;
	printf("? %s\n", s);
	fflush(stdout);
	
	int res = 0;
	scanf("%d", &res);
	return res;
}

int get_p(int x) {
	return p[x] == -1 ? x : p[x] = get_p(p[x]);
}

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) a[i] = i;
	srand(time(0));
	random_shuffle(a,a+n);
	//for(int i=0;i<n;i++) printf("%d ", a[i]);
	//puts("");
	memset(p, -1, sizeof p);
	v.clear();
	int todo = n-1;
	for(int i=0;i<n && todo;i++)
		for(int j=i+1;j<n && todo;j++) {
			//printf("-- %d %d\n", a[i], a[j]);
			int x = get_p(a[i]), y = get_p(a[j]);
			if(x!=y) {
				int ret = q(a[i], a[j]);
				if(ret) {
					p[x] = y;
					v.push_back(make_pair(a[i], a[j]));
					todo --;
				}
			}
		}
	printf("!");
	for(int i=0;i<v.size();i++)
		printf(" (%d,%d)", v[i].first, v[i].second);
	puts("");
	fflush(stdout);
	
	return 0;
}

Measured memory_bytes: 852
{-# OPTIONS_GHC -O2 #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Data.Array.Unboxed
import Data.Array.ST
import Data.STRef 
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Monad.ST
import Data.List
import Data.Char
import qualified Data.Map.Strict as M

convert :: Int -> Int -> VU.Vector (Int,Int) -> V.Vector [Int]
convert n e graph = V.create $ do
    v <- VM.replicate n []
    forM_ [0..e-1] $ \i -> do
        let (x,y) = graph VU.! i
        VM.modify v (y-1:) (x-1)
        VM.modify v (x-1:) (y-1)
    return v

bipartite :: Int -> V.Vector [Int] -> Maybe (VU.Vector Int)
bipartite n graph = runST $ do
    vec <- VUM.replicate n (-1)
    VUM.write vec 0 0
    go [0] vec
    where go :: [Int] -> VUM.MVector s Int -> ST s (Maybe (VU.Vector Int))
          go [] vec = do
              vv <- VU.freeze vec
              return $ Just vv
          go (n:ns) vec = do
              now <- VUM.read vec n
              ls <- newSTRef ns
              flag <- newSTRef False
              forM_ (graph V.! n) $ \i -> do
                  b <- VUM.read vec i
                  when (b == -1) $ VUM.write vec i (1-now) >> modifySTRef ls (i:)
                  when (b == now) $ writeSTRef flag True
              ln <- readSTRef ls
              ff <- readSTRef flag
              if ff then return Nothing else go ln vec


main :: IO ()
main = do
    [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    graph <- convert n m <$> (VU.replicateM m $ (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine)
    print $ case bipartite n graph of
        Nothing -> (n*(n-1))`div`2-m
        Just vec -> let len = VU.sum vec in len*(n-len) - m

Measured memory_bytes: 17916
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> A(n);
    vector<int> B(m);
    rep(i, n) cin >> A[i];
    rep(i, m) cin >> B[i];
    long long t = 0;
    rep(i,m) t += B[i];

    int j = m;
    int ans=0;
    rep(i,n+1){
        while(j > 0 && t > k){
            --j;
            t -= B[j];
        }
        if(t > k)break;
        ans = max(ans,i+j);
        if(i == n)break;
        t += A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
template<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1;}
    return 0;
}
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1;}
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans = 0;
    REP(i,SZ(S)/2){
        if(S[i] != S[SZ(S)-1-i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 1010;

int n;
char a[maxn][maxn];

int main(int argc, char *argv[]) {
#ifdef DEBUG
	freopen(argv[1], "r", stdin);
	freopen(argv[2], "w", stdout);
#endif
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", a[i] + 1);
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			a[i + n][j] = a[i][j];
			a[i][j + n] = a[i][j];
			a[i + n][j + n] = a[i][j];
		}
	}
	int ans = 0;
	for (int j = 1; j <= n; ++j) {
		bool ok = 1;
		for (int x = 1; x <= n; ++x) {
			for (int y = 1; y <= n; ++y) {
				if(a[x][y + j - 1] != a[y][x + j - 1]) {
					ok = 0;
					break;
				}
			}
		}
		if(ok) {
			ans += n;
		}
	}
	printf("%d\n", ans);
	return 0;
}



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

int main()
{
	int n,m;
	cin>>n>>m;
	string s;
	char map[100][100],tem[100][100];
	for(int i=0; i<100; i++) {
		for(int j=0; j<100; j++)map[i][j]=tem[i][j]='w';
	}
	for(int i=0; i<n; i++){
		cin>>s;
		for(int j=0; j<n; j++) map[i][j]=s[j];
	}
	for(int i=0; i<m; i++){
		cin>>s;
		for(int j=0; j<m; j++) tem[i][j]=s[j];
	}
	int ans=0;
	for(int i=0; i<=n-m; i++){
		for(int j=0; j<=n-m; j++){
			int c=0;
			for(int p=0; p<m; p++){
				for(int q=0; q<m; q++){
					if(map[i+p][j+q]==tem[p][q])c++;
				}
			}
			if(c==m*m)ans=1;
		}
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
  int parent;
  int left;
  int right;
} Tree;
Tree tree[10000];

#define NIL -1
int getheight(int);
int main()
{
  int i,id,j,n,k,depth=0,num,l,r,degree=0,height=0;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    tree[i].parent=NIL;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    tree[id].left=l;
    tree[id].right=r;
    if(l!=NIL && r!=NIL){
      tree[l].parent=id;
      tree[r].parent=id;
    }
    else if(l!=NIL && r==NIL){
      tree[l].parent=id;
    }
    else if(l==NIL && r!=NIL){
      tree[r].parent=id;
    }
  }
   
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,tree[i].parent);
    if(tree[i].parent==NIL){
      printf("sibling = -1, ");
    }
    else if(tree[tree[i].parent].left==i){
      printf("sibling = %d, ",tree[tree[i].parent].right);
    }
    else{
      printf("sibling = %d, ",tree[tree[i].parent].left);
    }
    printf("degree = ");
    if(tree[i].left!=NIL && tree[i].right!=NIL){
      printf("2, ");
    }
    else if(tree[i].left==NIL && tree[i].right==NIL){
      printf("0, ");
    }
    else printf("1, ");
 
    num=i;
    while(tree[num].parent!=NIL){
      depth++;
      num=tree[num].parent;
    }
    printf("depth = %d, ",depth);
    depth=0;
 
    printf("height = ");
    height=getheight(i);
    printf("%d,",height);
    //s=0;t=0;
     
    if(tree[i].parent==NIL){
      printf(" root\n");
    }
    else if(tree[i].left==NIL && tree[i].right==NIL){
      printf(" leaf\n");
    }
    else {
      printf(" internal node\n");
      }
  }
  return 0;
}

int getheight(int i)
{
  int s=0,t=0;
  if(tree[i].left==NIL && tree[i].right==NIL)return 0;

  if(tree[i].left!=NIL){
  s=getheight(tree[i].left)+1;
  }
  if(tree[i].right!=NIL){
  t=getheight(tree[i].right)+1;
  }
  if(s>t){
    
    return s;
  }
  else{
    return t;
  }
}



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

int MOD = int(1e9 + 7);
LL qpow(int xx, int y) {
    LL res = 1;
    LL x = 1LL * xx;
    while (y) {
        if (y & 1) res = res * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}

LL cnt[100005];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    int MOD = int(1e9 + 7);

    LL res = 0;
    for (int i = K; i >= 1; i--) {
        int num = K / i;
        if (num == 1) {
            cnt[i] = 1;
            res = (res + i) % MOD;
        } else {
            LL ccnt = qpow(num, N);
            for (int j = i; j <= K; j += i) ccnt = (ccnt - cnt[j] + MOD) % MOD;
            // res = (res + ccnt * i) % MOD;
            cnt[i] = ccnt;
            res = (res + i * ccnt) % MOD;
        }
        // cout << i << " " << cnt[i] << " "  << res << '\n';
    }
    res %= MOD;
    cout << res << '\n';


    return 0;
}


Measured memory_bytes: 4416
n,m=[int(i) for i in input().split()]
a=[]
b=[]
c=[]
d=[]
e=[]
f=[]
g=[]
h=[]
for i in range(n):
    x,y,z=[int(i) for i in input().split()]
    a.append(x+y+z)
    b.append(x+y-z)
    c.append(x-y+z)
    d.append(x-y-z)
    e.append(-x+y+z)
    f.append(-x+y-z)
    g.append(-x-y+z)
    h.append(-x-y-z)

a.sort()
b.sort()
c.sort()
d.sort()
e.sort()
f.sort()
g.sort()
h.sort()

nn=n-m
print(max(sum(a[nn:]),sum(b[nn:]),sum(c[nn:]),sum(d[nn:]),sum(e[nn:]),sum(f[nn:]),sum(g[nn:]),sum(h[nn:])))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
vector<int> a, b, c, d;
int N, M, Q;
int ans = 0;
void dfs(vector<int>A){
    if (A.size() == N + 1) {
        int now = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]]  == c[i]) {
                now += d[i];
            }
        }
        ans = max(now, ans);
        return;
    }
    A.push_back(A.back());
    while (A.back() <= M) {
        dfs(A);
        A.back()++;
    }
}
int main() {
    cin >> N >> M >> Q;
    a = b = c = d = vector<int>(Q);
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;

}


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

int main() {
    int n; scanf("%d", &n);

    int res = 0;
    int before = 0;
    for (int i=1; i<=n; i++) {
        int a; scanf("%d", &a);

        if (i == a) {
            before += 1;
        } else {
            res += (before + 1) / 2;
            before = 0;
        }
    }
    res += (before + 1) / 2;

    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n, *p = map(int, open(0).read().split())
c = 0
for i in range(n):
    if p[i] == -~i:
        if i == ~-n:
            p[i], p[i-1] = p[i-1], p[i]
        else:
            p[i], p[i+1] = p[i+1], p[i]
        c += 1
print(c)

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

using namespace std;

long long n, x, y, ans;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> x >> y;
	ans = (n / (x + y)) * x;
	n %= (x + y);
	ans += min (x, n);
	cout << ans;
}


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

const int N = 2e6;

int u[N];

int main() {
	clog << "Ready\n";
	
	int n, m;
	cin >> n >> m;
	
	int ans = 0;
	
	for (int i = 1; i <= n; ++ i) {
		int k;
		cin >> k;
		for (int j = 1; j <= k; ++ j) {
			int x;
			cin >> x;
			++u[x];
		}
	}
	
	for (int i = 1; i <= m; ++ i)
		ans += (u[i] == n);
	
	cout << ans;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll a,b;
  cin>>a>>b;
  a--;
  b--;
  cout<<(a+b-1)/(a)<<endl;
}

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

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

using namespace std;

int main(){
	
	int n;
	long long int input, po, count, ans;
	map <long long int, int> mp;
	
	cin >> n;
	
	vector<long long int> s(n+1);
	s[0] = 0;
	ans = 0;
	mp[0] = 1;
	
	REP(i,n){
		cin >> input;
		s[i+1] = input + s[i];
		ans += mp[s[i+1]];
		mp[s[i+1]]++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<cmath>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

string ans;

void func(int cnt,int w,string s){
 	if(cnt>=10){
 		if(w==0){
 			ans=s;
 		}
 	}else{
 		func(cnt+1,w,s);
 		s+=cnt+'0';
 		func(cnt+1,w-pow(2,cnt),s);
 	}
 }

int main(){
	int n;
	string s;
	while(cin>>n){
		s="";
		func(0,n,s);
		rep(i,ans.size()){
			cout<<pow(2,(int)(ans[i]-'0'));
			if(i==(ans.size()-1)){
				cout<<endl;
			}else{
				cout<<" ";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1316
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  while(true){
    int num;
    cin >> num;
    if(num==0)return;
    vector<int> sum;
    sum.push_back(0);
    for(int i=1;i<=num;i++)
      sum.push_back(sum[sum.size()-1]+i);
    int ct=0;
    for(int k=1;k<=num;k++)
      for(int i=1;i<=num-k+1;i++)
        if(sum[k+i]-sum[i-1]==num)ct++;
    cout << ct << endl;
  }
}

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



Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include<vector>

using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i =0;i<n;++i)
//#define mod (ll)(1e9+7)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    bool x[101] = {false};
    x[4] = true;
    x[7] = true;
    for(int i=8;i<=100;i++){
        if(x[i-4]) x[i]=true;
        if(x[i-7]) x[i] = true;
    }
    if(x[n]) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    double a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    vector<double> water, sugar;

    rep(i, f) rep(j, f) if (100 * (a * i + b * j) <= f) water.push_back(100 * (a * i + b * j));
    rep(i, f) rep(j, f) if (c * i + d * j <= f) sugar.push_back(c * i + d * j);

    int w = 0, s = 0;
    double maxn = 0;

    for (auto x : water)
    {
        for (auto y : sugar)
        {
            if (x + y <= f && y <= (x / 100) * e && maxn <= (100 * y) / (x + y))
            {
                maxn = (100 * y) / (x + y);
                w = x;
                s = y;
            }
        }
    }

    cout << w + s << " " << s << endl;

    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll> 
#define clr(x) memset(x,0,sizeof(x))
const ll size=1e6+7;
ll arr[size];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll d,n;cin>>d>>n;
    ll st=(ll)pow(100,d);
    if(n<=99)cout<<st*n<<endl;
    else cout<<st*(n+1)<<endl;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

intmax_t f(const std::vector<intmax_t>& A, intmax_t X) {
  intmax_t res = 0;
  for (auto ai: A)
    res += ai ^ X;
  return res;
}

int main() {
  size_t N;
  intmax_t K;
  scanf("%zu %jd", &N, &K);

  std::vector<intmax_t> A(N);
  for (auto& ai: A) scanf("%jd", &ai);

  intmax_t X = 0;
  for (intmax_t k = 1L << 42; k; k >>= 1) {
    if (k > K) continue;
    if ((X^k) > K) continue;
    // if (f(A, X^k) > f(A, X)) X ^= k;
    intmax_t o = 0;
    intmax_t e = 0;
    for (auto ai: A) {
      if (ai & k) {
        ++e;
      } else {
        ++o;
      }
    }
    if (e < o) X ^= k;
  }
  printf("%jd\n", std::max(f(A, 0), f(A, X)));
}


Measured memory_bytes: 1024
n = int( input() )
d_1 = []
d_2 = []
for _ in range( n ):
    a, b = map( int, input().split() )
    d_1.append( a )
    d_2.append( b )

for i in range( n - 2 ):
    if d_1[ i ] == d_2[ i ] and d_1[ i + 1 ] == d_2[ i + 1 ] and d_1[ i + 2 ] == d_2[ i + 2 ]:
        print( "Yes" )
        break
else:
    print( "No" )

Measured memory_bytes: 9188
n,t = map(int, input().split())
li =[]
for i in range(n):
    li.append(list(map(int, input().split())))
#print(li)

a =[]
for i in range(n):
    if li[i][1] <= t:
        a.append(i)
#print(a)
b = []
for i in a:
    b.append(li[i][0])
#print(b)
if b:
    print(min(b))
else:
    print("TLE")


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

int main() {
    int N, X;
    cin >> N >> X;
    vi M(N);
    int sum = 0;
    rep(i, N) {
        cin >> M[i];
        sum += M[i];
    }

    X -= sum;

    int mmin = *min_element(M.begin(), M.end());
    cout << (N + (X / mmin)) << endl;
}

Measured memory_bytes: 3588
/**********************
 * AGC001 -B
*********************************/
#include <iostream>

using namespace std;

typedef long long ll;

ll get_length_in_parallelogram(ll a, ll b)
{
    if(a > b) return get_length_in_parallelogram(b,a);
    else if(b % a == 0) return (b / a * 2 - 1) * a;
    else return (b / a * 2) * a + get_length_in_parallelogram(a, b%a);
}

int main()
{
    ll n, x;
    cin >> n >> x;
    cout << n + get_length_in_parallelogram(x,n-x) << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        Arrays.sort(a);

        sum[0] = a[0];
        for(int i=1; i<n; i++){
            sum[i] = sum[i-1] + a[i];
        }

        int pos = -1;
        for(int i=0; i<n-1; i++){
            if(sum[i] * 2 < a[i+1]){
                pos = i;
            }
        }


        System.out.println(n - (pos+1));


    }
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string x,y;
    cin >> x >> y;
    int i,j;
    i = x.size();
    j = y.size();
    vector<char> solution;
    vector<vector<int>> dp(x.size()+1,vector<int>(y.size()+1,0));
    for (int i = 1; i <= x.size(); ++i) {
        for (int j = 1; j <= y.size(); ++j) {
            if(x[i-1] == y[j-1])
                dp[i][j] = dp[i-1][j-1]+1;
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    while(i > 0 && j > 0){
        if(x[i-1] == y[j-1])
        {
            solution.push_back(x[i-1]);
            i--;j--;

        } else
        {
            if(dp[i-1][j] > dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    for (int k = solution.size()-1; k >= 0; --k) {
        cout << solution[k];
    }
}

Measured memory_bytes: 35584
def f(h,w):
    s=h*h+w*w
    h+=1
    while 1:
        while h*h<s:
            w=h+1
            while h*h+w*w<=s:
                if h*h+w*w==s:print(h,w);return
                w+=1
            h+=1
        s+=1;h=1
while 1:
    h,w=map(int,input().split())
    if h==0:break
    f(h,w)

Measured memory_bytes: 7656
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
	
	int Number;
	cin>>Number;

	int count = 0;
    int temp1, temp2;
	for(int i = 0; i<Number; i++){
        cin>>temp1;
		cin>>temp2;
		if(temp1 == temp2){
			count++;
		}
		else count = 0;

		if(count == 3){
		cout<<"Yes";
		break;
		}
		
	}

	if(count != 3)cout<<"No";
	return 0;


}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

int main(){
  ll h,w,n;
  cin >> h >> w >> n;
  map<P,ll> mp;
  rep(i,n){
    int a,b; cin>>a>>b;
    for(int j=max(1,a-2); j<=a; j++)for(int k=max(1,b-2); k<=b; k++)if(j<=h-2 && k<=w-2){
      mp[{j,k}]++;
    }
  }
  vector<ll> ans(10,0);
  for(auto it:mp){
    ans[it.S]++;
  }
  ans[0]=(h-2)*(w-2);
  rep(i,9){ ans[0]-=ans[i+1]; }
  rep(i,10){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 56448
X = int(input())

def is_prime(n):
  factors = []
  f = 2
  while f**2 <= n:
    if n % f == 0:
      n //= f
      factors.append(f)
    else:
      f += 1
  if len(factors) == 0:
    return True
  else:
    return False

ans = 0
i = X
while True:
  if is_prime(i):
    ans = i
    break
  else:
    i += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define ll long long 
ll abs (ll x, ll y) {
  if (x > y) {
    return x - y;  
  }  
  return y - x;
}

int main () {
  ll n;
  cin >> n;
  ll sum[n];
  ll s;
  for (ll i = 0; i < n; i++) {
    cin >> s;
    if (i == 0) {
      sum[i] = s;    
    }    
    else {
      sum[i] = sum[i - 1] + s;  
    }
  }
  ll min = -1;
  for (ll i = 0; i < n - 1; i++) {
   ll left = sum[i];
   ll right= sum[n - 1] - sum[i];   
   ll sa = abs(left, right);
   if (min == -1 || sa < min) {
    min = sa;  
   }
  }
  cout << min << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
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 = 1LL << 60;

long long h[100010];
long long dp[100010];

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) cin >> h[i];

  for (int i = 0; i < 100010; i++) dp[i] = INF;
  dp[0] = 0;

  for (int i = 1; i < N; i++) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }

  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  printf("%d\n",max(max(a + b,a - b),a * b));
  return 0;
}

Measured memory_bytes: 128
def main(): 

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

    max_v = 0
    max_sv = 0

    for i in range(n):
        if a[i] > max_v:
            max_sv = max_v
            max_v = a[i]
        elif a[i] > max_sv:
            max_sv = a[i]

    for i in range(n):
        if a[i] != max_v:
            print(max_v)
        else:
            print(max_sv)




if __name__ == "__main__":
    main() 

Measured memory_bytes: 68696
#!/usr/bin/env python3

N, M = map(int, input().split())
D = {}
for i in range(1, N+1):
    D[i] = []

for i in range(M):
    a, b = map(int, input().split())
    D[a].append(b)
    D[b].append(a)

for i in range(1, N+1):
    print(len(D[i]))


Measured memory_bytes: 3060
#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
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

int main()
{
    int N, A, B;

    cin >> N >> A >> B;

    cout << min(N * A, B) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

struct edge{int to,cost;};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vector<vector<edge>> g(n);
    vector<int> color(n,-1);
    rep(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        g[u].PB(edge{v,w});
        g[v].PB(edge{u,w});
    }

    color[0]=0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(auto nv:g[v]){
            if(color[nv.to]!=-1) continue;
            if(nv.cost%2==0){
                color[nv.to]=color[v];
                que.push(nv.to);
            }else{
                color[nv.to]=color[v]^1;que.push(nv.to);
            }
        }
    }
    rep(i,n) cout<<color[i]<<endl;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

int d[50][50];

int solve(int N, int M, vi& a, vi& b){
    int cnt = 0;
    rep(br,M){
        rep(i,N) rep(j,N) d[i][j] = 1000;
        rep(i,N) d[i][i] = 0;
        rep(j,M) {
            if (j == br) continue;
            d[a[j]-1][b[j]-1] = d[b[j]-1][a[j]-1] = 1;
        }
        rep(k,N) rep(i,N) rep(j,N) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);

        bool good = true;
        for (int i=1; i<N; ++i) {
            if (d[0][i] > 50) { good = false; break; }
        }
        if (!good) ++cnt;
    }
    return cnt;
}
int main() {
    int n,m; cin >> n >> m;
    vi a(m), b(m);
    rep(i,m) cin >> a[i] >> b[i];
    cout << solve(n,m,a,b) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

lucas n = lucas' (2,1) n :: Integer
  where
    lucas' (x,_) 0 = x
    lucas' (x,y) n = lucas' (y,x+y) (n-1)

main = getInt >>= print . lucas

Measured memory_bytes: 508
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int R;

int main(void) {
    scanf("%d", &R);

    if (R < 1200) puts("ABC");
    else if (R < 2800) puts("ARC");
    else puts("AGC");

	return 0;
}


Measured memory_bytes: 256
A = []
for i in range(3):
    A.append(list(map(int,input().split())))
N = int(input())
B = []
for i in range(N):
    B.append(int(input()))
L = [[False,False,False] for i in range(3)]
for e in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == e:
                L[i][j] = True

#vertical
for i in range(3):
    if L[i][0] and L[i][1] and L[i][2]:
        print('Yes')
        exit()
#horizontal
for i in range(3):
    if L[0][i] and L[1][i] and L[2][i]:
        print('Yes')
        exit()
#diagonal
if L[0][0] and L[1][1] and L[2][2]:
    print('Yes')
    exit()
if L[2][0] and L[1][1] and L[0][2]:
    print('Yes')
    exit()
print('No')



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll num[1010];
int S;
ll mo=1000000007;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	num[1]=9;
	for(i=2;i<=10;i++) num[i]=num[i-1]*10;
	
	cin>>S;
	ll L,R=1;
	ll tot=1;
	ll NL=10,NR=10,LC=1,RC=1;
	ll ret=0;
	for(L=1;L<100000000;) {
		while(tot<S) {
			R++;
			if(R==NR) NR*=10,RC++;
			tot+=RC;
		}
		if(tot==S) ret++;
		tot-=LC;
		L++;
		if(L==NL) NL*=10,LC++;
	}
	for(i=1;i<=S;i++) {
		L=S/i;
		if(L<=8) continue;
		if(S%i) {
			ret++;
		}
		else {
			(ret+=9*modpow(10,L-1)-i+1+mo)%mo;
		}
	}
	
	cout<<ret%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
// Green bin.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5;
string arr[N];
int main()
{
	int n;
	long long ans = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		sort(arr[i].begin(), arr[i].end());
	}
	sort(arr, arr + n);

	long long count = 1;
	string prev = arr[0];

	for (int i = 1; i < n; i++)
	{
		string cur = arr[i];
		if (prev == cur)
			count++;
		else {
			ans += count * (count - 1) / 2;
			count = 1;
			prev = cur;
		}
		
	}
	ans += count * (count - 1) / 2;

	cout << ans;
}


Measured memory_bytes: 7296
n = int(input())
plist = list(map(int,input().split()))
count = 0

def niban(i,list):
    if list[i]<list[i+1]<list[i+2] or list[i+2]<list[i+1]<list[i]:
      # print(list[i+1])                                                       
       return 1
    else:
       #print(list[i+1])                                                       
       return 0


#print(n)                                                                      
for i in range(n-2):
    if niban(i,plist):
        count += 1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int K = in();
    vector<int> A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << A[K-1] << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> A(N);
    rep(n,0,N) cin>>A.at(n);

    map<int,int> mp;
    for(auto a:A) mp[a]++;

    int ans=0;
    for(auto m:mp) ans+=m.second-1;

    ans=N-ans-(ans%2);
    cout<<ans<<endl;
}

Measured memory_bytes: 5376
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        String N = "0" + sc.next();
        int l = N.length();

        // 0 おつり, 1 ぴったり, 2 多く
        long[][] dp = new long[l + 1][3];

        dp[0][0] = dp[0][2] = 1;

        for (int i = 1; i < l; i++) {
            int c = N.charAt(i) - '0';
            dp[i][0] = Math.min(dp[i - 1][0], dp[i - 1][2]) + 9 - c;
            dp[i][1] = Math.min(dp[i - 1][0] + 1, dp[i - 1][1]) + c;
            dp[i][2] = Math.min(dp[i - 1][0] + 1, dp[i - 1][1]) + c + 1;
        }
//        debug(dp);
        dp[l - 1][0] += 1;
        System.out.println(Math.min(dp[l - 1][0], Math.min(dp[l - 1][1], dp[l - 1][2])));

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

}


Measured memory_bytes: 74124
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n; cin >> n;
  if(n % 2 == 0) cout << n / 2 << endl;
  else cout << n / 2 + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
        long long int N,L,ok=-1;
    cin >> N >> L;
    vector<long long int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(L<=a[i]){
            ok = i;
        }
    }

    for(int i=1;i<N;i++){
        if(L<=a[i-1]+a[i]){
            ok = i-1;
            break;
        }
    }

    if(ok==-1){
        cout << "Impossible" << endl;
    }else{
        cout << "Possible" << endl;

        for(int i=0;i<ok;i++){
            cout << i+1 << endl;
        }

        for(int i=N-1;ok<i;i--){
            cout << i << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3992
#include<iostream>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
long long a,b,c,d,p[100000],q[100000],r[100000],i,j,k,n,f;
int main(){
	string s;
	cin>>s;
	n=s.size();
	if(s[0]==s[n-1])
		n--;
	n%=2;
	if(n==1)
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
}


Measured memory_bytes: 512
from copy import deepcopy
N,M = map(int,input().split())
s_list = []
for _ in range(M):
    s_list.append(tuple(map(int,input().split()[1:])))
plist = tuple(map(int,input().split()))

counter = 0
TF = [0]*N
TFlist = []
def make_bbb(long,number):
    b_n = bin(number)[2:]
    bbb = "0"*(long-len(b_n))+b_n
    return bbb
for _ in range(2**N):
    number = list(map(int,list(make_bbb(N,_))))
    TFlist.append(number)


for TF in TFlist:
    flg = False
    ok = 0
    for num,s in enumerate(s_list):
        sum_on = 0
        #各スイッチ
        for ele in s:
            sum_on += TF[ele-1]
        if sum_on%2 != plist[num]:
            flg = False
            break
        else:
            ok += 1
    if ok == M:
        counter += 1


print(counter)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<ll , ll>
 
#define NIL -(long long)(1e9)
#define ll long long
#define satir cout<<"\n"
#define ALL(v) (v).begin(), (v).end()
#define f first
#define s second
#define sps <<" "<<
#define sp <<" "
#define spl cout<<"\n";
#define INF 0x3f3f3f3f3f3f3f3f
#define cntout cout<<" "<<rndcntbo; ++rndcntbo;
const ll N = 1*1000+7;
ll n,n1,n2,n3,k,t,d1,d2,m,ans=-1,rndcntbo=190;
ll arr[N];
ll dp[N][N];
ll pref[N];
void max_self(int &a,int b ){
	a= min(a,b);
	return;
} 
ll dpa(int l,int r){
	// cout<<l sps r<<" aadsd ";spl;
	if(l==r) return 0; //dp[l][r]=arr[l];
	// cout<<"test1";spl;
	// if(abs(l-r)==1) return (dp[l][r]=arr[l]+arr[r]);
	if(dp[l][r] != -1) return dp[l][r];
	// cout<<"test2";spl;
	
	ll nax= INF;

	for (int i = l; i < r; ++i){
		// cout<<dpa(l,i)+dpa(i+1,r);spl;
		// cout<<"myl-myr"<<l sps r <<"calling"<<l sps i;spl;
		nax = min(nax, dpa(l,i)+dpa(i+1,r)+ pref[i] - pref[l-1] + pref[r] - pref[i]);
		
	}
	dp[l][r]=nax;
	// cout<<nax;spl;
	return nax;
}
inline void coz(){
cin>>n;
pref[0]=0;
for (ll i = 1; i <= n; ++i){
	cin>>arr[i];
	// dp[i][i]=arr[i];
	pref[i]=pref[i-1]+arr[i];
}
// cout<<"asd"<<n;spl;
cout<<dpa(1 , n);
// cout<<INF;
// cout<<"bittiaq";spl;

// cout<<dp[1][n];
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(dp,-1,sizeof(dp));

// #ifndef ONLINE_JUDGE
// 	freopen("factory.in","r",stdin);  freopen("factory.out","w",stdout);
// #endif
// cin>>t;
// while(t--)
	coz();
 
// cout<<ans<<" ";
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>

using namespace std;

int main()
{
    string S,T;
    int a=0;

    cin >> S >> T;

    for(int i=0;i < S.size();i++)
    {
        if(S[i]!=T[i]) 
        {
            a+=1;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 3576
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a=b=c=0
if h%2and w%2:
    a=h//2*(w//2)
    c=1
    b=(h*w-a*4-c)//2
elif h%2or w%2:
    a=h//2*(w//2)
    b=(h*w-a*4)//2
else:
    a=h*w//4
l=[]
for i in set(s.replace('\n','')):
    l.append(s.count(i))
for i in l:
    if i>3:
        while i>3and a:
            i-=4
            a-=1
    if i>1:
        while i>1and b:
            i-=2
            b-=1
    if i and c:
        i-=1
        c-=1
if all(not t for t in(a,b,c)):
    print('Yes')
else:
    print('No')

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	int N,M;
  cin >> N >> M;
  if(N < 10){
    cout << M + 100*(10 - N) << endl;
  }else{
   cout << M << endl; 
  }

return 0;
}

Measured memory_bytes: 3588
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,k;
    cin>>n>>k;
    vi a(n);
    rep(i,n)cin>>a[i];
    int x=0ll;
    rev(i,64){
        if(k&(1ll<<i)){
            int c=0;
            rep(j,n){
                if((a[j]&(1ll<<i))==0)c++;
            }
            if(c>n/2)x|=1ll<<i;
            else {
                rev(j,i)k|=1ll<<j;
            }
        }
    }
    // cout<<x<<endl;
    int ans=0ll;
    rep(i,n)ans+=a[i]^x;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
/* B - Go to Jail */

#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, D1, D2, cnt = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> D1 >> D2;
    if(D1 == D2){
      cnt++;
    }else{
      cnt = 0;
    }
    if(cnt >= 3){
      cout << "Yes" << endl;
      break;
    }
  }
  if(cnt < 3){
    cout << "No" << endl;
  }
}


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

char a[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0);
	vector<int> r;
	ll n; cin >> n;
	while (n > 0) {
		n--;
		r.push_back(n % 26);
		n /= 26;
	}
	reverse(r.begin(), r.end());
	for (int x : r) {
		cout << (char)('a'+x);
	} cout << "\n";
}



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

int a[200009];
int b[200009];
int compare(const void* a, const void* b)
{
	const int* x = (int*) a;
	const int* y = (int*) b;

	if (*x > *y)
		return 1;
	else if (*x < *y)
		return -1;

	return 0;
}

int main()
{
    int n;
    cin>>n;
    for (int i=0;i<n;i++)
    {cin>>a[i];b[i]=a[i];}
    qsort(a,n,sizeof(int),compare);
    int m1,m2;
    m1=a[n/2-1];
    m2=a[n/2];
    for (int i=0;i<n;i++){
        if(b[i]<m2)
        {cout<<m2<<endl;}else{cout<<m1<<endl;}
    }
    
    
    
}

Measured memory_bytes: 3820