akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
bool check(int length)
{
    map<string, int> m;
    for(int i = 1; i + length <= n+1; i++)
    {
        string tmp = s.substr(i-1, length);
        if(m[tmp])
        {
            if(i-m[tmp]>=length) return true;
        }
        else
        {
            m[tmp] = i;
        }
    }
    return false;
}

int main()
{
    cin >> n;
    cin >> s;
    int l = 0, r = n;
    while(l <= r)
    {
        int mid = (l+r)>>1;
        if(check(mid)) l = mid+1;
        else r = mid-1;
    }
    cout << r << endl;
}


Measured memory_bytes: 6660
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  int n;cin>>n;
  string s;cin>>s;
  for(auto& e: s){
  	int num = int(e-'A');
    cout<<char('A'+(num+n)%26);
  }
  cout<<endl;
}


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

typedef vector<int> vi;

vi v;
int n;
  
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    while(cin >> n)
    {
        v = vi(n);
        for(int i = 0; i < n; i++)
            cin >> v[i];
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        cout << v.size() << '\n';
    }
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c[10][10];
int a[10];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
    cin>>c[i][j];
    for(int k=0;k<10;k++)
    for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
    c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
    int x;
    for(int i=0;i<n;i++)
    for(int i=0;i<m;i++)
    {
        cin>>x;
        if(x>=0)a[x]++;
    }
    int ans=0;
    for(int i=0;i<10;i++)ans+=c[i][1]*a[i];
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
using ll=long long;

int main(){
    int n;cin>>n;
    ll a,b;cin>>a>>b;
    ll x[100010];
    for(int i=0;i<n;++i){
        cin>>x[i];
    }
    ll ans=0;
    for(int i=0;i<n-1;++i){
        ans+=min(a*(x[i+1]-x[i]),b);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
/*author* Priyanshu Shrivastav
*from*(IIT Palakkad)
 *_ __ ___  _ ______ ___  _ ____   ___  ___| |_
 | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __|
 | | | | | | | | (_| (_) | | | \ V /| | (__| |_
 |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__|
 When I wrote this, only God and I understood what I was doing
 * Now, only God knows*/

#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sqr(x) ((x)*(x))
#define mod(x) ((x)%N)
#define INF (N-7)
#define EPS (double)1e-9

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

const ui N = 1000000007;

int main() {
#ifdef CONVICTION
	FILE* fp_in = freopen ("in", "r", stdin);
	FILE* fp_err = freopen ("err", "w", stderr);
	int start_s=clock();
	cerr.precision (3); cerr << fixed;
#endif
	ios_base::sync_with_stdio(false);
	cin.tie (NULL); cout.precision (10); cout << fixed;


	/*solution starts here...*/
	int n;
	cin >> n;
	for (int i = 0; i <= ceil (n/7); i++)
		for (int j = 0; j <= ceil (n/4); j++)
			if (7*i + 4*j == n && (i || j)) {
				cout << "Yes\n";
				return 0;
			}
	cout << "No\n";

#ifdef CONVICTION
	cerr << "\ntime taken: " <<
		((int)clock()-start_s)/double(CLOCKS_PER_SEC)*1000 << " s\n";
#endif
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

ll D = 1e9;

int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> b(n);
    rep(i,n) b[i] = a[i] * D + 0.5;
    map<P, ll> mp;
    rep(i, n){
        int x = 0, y = 0;
        ll bi = b[i];
        while(bi % 2 == 0 && x <19){
            x++;
            bi /= 2;
        }
        bi = b[i];
        while(bi % 5 == 0 && y < 19){
            y++;
            bi /= 5;
        }
        mp[P(x,y)]++;
    }

    ll ans = 0;
    for(auto m1: mp){
        for(auto m2: mp){
            P p1 = m1.first, p2 = m2.first;
            if (p1.first + p2.first < 18 || p1.second + p2.second < 18) continue;
            if (m1 == m2){
                ans += m1.second * (m2.second-1);
            }else{
                ans += m1.second * m2.second;
            }
        }
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

void maxHeapify(int A[],int i,int H){
  int l = left(i);
  int r = right(i);
  int largest;
  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;
  if(largest != i){
    swap(A[i],A[largest]);
    maxHeapify(A,largest,H);
  }
}


int main(){
  int H;
  cin >> H;
  int A[H+1];
  for(int i = 1;i<H+1;i++){
    cin >> A[i];
  }
  for(int i = H/2;i>=1;i--){
    maxHeapify(A,i,H);
  }
  for(int i = 1;i<H+1;i++){
    cout << " "<< A[i];
  }
  cout << endl;
}



Measured memory_bytes: 5012
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  if(n%2==1){
    cout<<0<<endl;
  }else{
    n/=10;
    long long res = n;
    while(n>0){
      n /= 5;
      res += n;
    }
    
    cout<<res<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
module M = Map.Make(struct type t = int * int let compare = compare end)
let inc k m = try M.add k (1 + M.find k m) m with Not_found -> M.add k 1 m

let init n = Array.make n (-1)
let rec find x p =
  if p.(x) < 0 then x
  else let x' = find p.(x) p in p.(x) <- x'; x'
let unite x y p =
  let x', y' = find x p, find y p in
  if x' = y' then () else begin
    if p.(x') < p.(y') then begin
      p.(x') <- p.(x') + p.(y'); p.(y') <- x';
    end else begin
      p.(y') <- p.(x') + p.(y'); p.(x') <- y';
    end
  end
let size x p = - p.(find x p)

let () =
  Scanf.scanf "%d %d %d" @@ fun n k l ->
  let e0 = Array.init k (fun _ -> Scanf.scanf " %d %d" (fun x y -> x-1, y-1)) in
  let e1 = Array.init l (fun _ -> Scanf.scanf " %d %d" (fun x y -> x-1, y-1)) in
  let uf0, uf1, uf2  = init n, init n, init n in
  e0 |> Array.iter (fun (u, v) -> unite u v uf0);
  e1 |> Array.iter (fun (u, v) -> unite u v uf1);
  let g = Array.init n (fun i -> (find i uf0, find i uf1)) in
  let m = Array.fold_left (fun m (i, j) -> inc (i, j) m) M.empty g in
  g |> Array.iter (fun p -> M.find p m |> Printf.printf "%d ");
  print_newline ()


Measured memory_bytes: 23964
#include <iostream>
using namespace std;
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  long long int H[N];
  for(int i = 0; i < N; ++i) cin >> H[i];
  long long int ng = 0, ok = 1000000000;
  while(ok > ng + 1){
    long long int m = (ok + ng) / 2, t = m;
    for(int i = 0; i < N; ++i){
      if(H[i]-t*B > 0){
	m -= (H[i]-t*B+A-B-1)/(A-B);
      }
      //cout << m << endl;
      if(m < 0) break;
    }
    if(m < 0) ng = t;
    else ok = t;
  }
  cout << ng + 1 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int mod = 924844033;
const int MAX = 2020;

inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }

inline int sub(int a, int b) { return a >= b ? a - b : a - b + mod; }

inline int mul(int a, int b) { return llint(a) * b % mod; }

int f[MAX][MAX][2];

vector<int> solve(vector<int>& a, int N, int K) {
  if (a.size() == 0) {
    return {1};
  }

  int n = a.size();
  REP(i, n + 1) REP(j, n + 1) REP(k, 2) f[i][j][k] = 0;

  if (a[0] >= K) {
    f[0][0][0] = 1;
  } else {
    f[0][0][1] = 1;
  }

  REP(i, n) REP(j, i + 1) REP(k, 2) {
    f[i + 1][j][0] = add(f[i + 1][j][0], f[i][j][k]);
    if (k == 0) {
      f[i + 1][j + 1][0] = add(f[i + 1][j + 1][0], f[i][j][k]);
    }
    f[i + 1][j + 1][1] = add(f[i + 1][j + 1][1], f[i][j][k]);
  }

  vector<int> ret;
  REP(i, n + 1) {
    if (a[n - 1] + K < N) {
      ret.push_back(add(f[n][i][0], f[n][i][1]));
    } else {
      ret.push_back(f[n][i][0]);
    }
  }
  return ret;
}

int main(void) {
  ios_base::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;

  vector<vector<int>> buckets(2 * K);
  REP(i, N) buckets[i % (2 * K)].push_back(i);

  vector<int> f = {1};

  for (auto& x : buckets) {
    vector<int> g = solve(x, N, K);
    vector<int> nf(f.size() + g.size() - 1);

    REP(i, (int)f.size()) REP(j, (int)g.size()) {
      nf[i + j] = add(nf[i + j], mul(f[i], g[j]));
    }
    f = move(nf);
  }

  int ret = 0;
  assert((int)f.size() == N + 1);
  int rem_ways = 1;
  for (int i = N; i >= 0; --i) {
    if (i % 2 == 0) {
      ret = add(ret, mul(rem_ways, f[i]));
    } else {
      ret = sub(ret, mul(rem_ways, f[i]));
    }
    rem_ways = mul(rem_ways, N - i + 1);
  }

  cout << ret << "\n";
  return 0;
}


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

int main()
{
    unsigned long long N;
    long long ans = 0;
    cin >> N;
    vector<vector<unsigned long long>> input;
    input.resize(N);
    for (unsigned long long i = 0; i < N; i++)
    {
        input[i].resize(N);
    }

    for (unsigned long long i = 0; i < N; i++)
    {
        for (unsigned long long j = 0; j < N; j++)
        {
            cin >> input[i][j];
        }
    }

    vector<vector<unsigned long long>> way = input;

    for (unsigned long long i = 0; i < N; i++)
    {
        for (unsigned long long j = 0; j < N; j++)
        {
            for (unsigned long long k = 0; k < N; k++)
            {
                if (input[i][j] > input[i][k] + input[k][j])
                {
                    ans = -1;
                    break;
                }
                else if (input[i][j] == input[i][k] + input[k][j] && i != k && k != j && j != i)
                {
                    way[i][j] = 0;
                }
            }
            if (ans == -1)
                break;
        }
        if (ans == -1)
            break;
    }

    if (ans != -1)
    {
        for (unsigned long long i = 0; i < N; i++)
        {
            for (unsigned long long j = 0; j < i; j++)
            {
                ans += way[i][j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1664
import collections
def main(input_s):
    c = collections.Counter(input_s)
    c_sort = c.most_common(1)
    max_count = c_sort[0][1]
    out_result = []
    for key, value in c.items():
        if value==max_count:
            out_result.append(key)
    return out_result

if __name__ == '__main__':
    N = int(input()) #1行目のNを取得する
    s = [input() for i in range(N)] #複数行の数値の入力を取得
    huga = main(s)
    huga = sorted(huga)
    for i in huga:
        print(i)

Measured memory_bytes: 104400
n = int(input())

cnt = 0
flag = False
for i in range(n):
    d1, d2 = list(map(int, input().split()))
    if (d1 == d2):
        cnt += 1
    else:
        cnt = 0
    
    if (cnt >=3):
        flag = True

if (flag):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9168
#include <iostream>

typedef unsigned long long ull;
ull a[55];
ull p[55];

ull func(ull n, ull x){
    if(!n) return 1;
    if(x==1) return 0;
    if(1<x&&x<=(1+a[n-1])){
        return func(n-1, x-1);
    }
    if(x==(2+a[n-1])) return p[n-1]+1;
    if(2+a[n-1]<x&&x<=a[n]-1){
        return (p[n-1]+1+func(n-1, x-2-a[n-1]));
    }
    return 2*p[n-1]+1;
}


int main(){
    ull n, x;
    std::cin >> n >> x;
    a[0] = 1;
    p[0] = 1;
    for(int i = 1; i <= n; i++){
        a[i] = a[i-1]*2+3;
        p[i] = p[i-1]*2+1;
    }
    std::cout << func(n, x) << std::endl;
}


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

int main() {

  int N;
  cin >> N;
  string ans = "APPROVED";

  for (int i = 0; i < N; i++)
  {
    int num;
    cin >> num;

    if(num%2 == 0) {
      if(num%3 != 0 && num%5 != 0){
        ans ="DENIED";
      }
    }
  }

  cout << ans << endl;
}

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

using namespace std;

int main(){
  string A, B;
  cin >> A >> B;

  if (A.size() > B.size()){
    printf("GREATER\n");
  }else if (A.size() < B.size()){
    printf("LESS\n");
  }else{
    int flg = 0;
    for (int i = 0; i < A.size(); i++){
      if(A[i] > B[i]){
        flg = 1;
        break;
      }else if(A[i] < B[i]){
        flg = 2;
        break;
      }
    }
    if (flg == 1){
      printf("GREATER\n");
    }else if(flg == 2){
      printf("LESS\n");
    }else{
      printf("EQUAL\n");
    }
  }
}


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

int main(){
	int a,b,c,x,count=0;
  	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;++i){
    	for(int j=0;j<=b;++j){
        	for(int k=0;k<=c;++k){
            	if(500*i+100*j+50*k==x)++count;
            }
        }
    }cout<<count<<endl;
  	return 0;
}

Measured memory_bytes: 256
n, y = gets.split.map(&:to_i)

a = b = c = -1
valid = false

0.upto(n) do |i|
  break if valid

  0.upto(n - i) do |j|
    k = n - i - j
    valid = 10_000 * i + 5_000 * j + 1_000 * k == y

    if valid
      a, b, c = [i, j, k]
      break
    end
  end
end

puts [a, b, c].join(" ")


Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll A,B,Q;
  cin>>A>>B>>Q;
  vector<ll> S(A),T(B),X(Q);
  FORi(A){
    cin>>S[i];
  }
  FORi(B){
    cin>>T[i]; 
  }
  //S.sort();
  //T.sort();
  FORi(Q){
    cin>>X[i];
  }
  FORi(Q){
    auto Sitr =lower_bound(S.begin(),S.end(),X[i]);
    auto Titr =lower_bound(T.begin(),T.end(),X[i]);
    ll kyori=LLONG_MAX;
    if(Sitr!=S.begin()&&Titr!=T.begin()){
      kyori=max(X[i]-*(Sitr-1),X[i]-*(Titr-1));
    }
    if(Sitr!=S.end()&&Titr!=T.end()){
      ll tmp=max(*Sitr-X[i],*Titr-X[i]);
      kyori=min(tmp,kyori);
    }
    if(Sitr!=S.begin()&&Titr!=T.end()){
      ll tmp=*Titr - *(Sitr-1)+min(X[i]-*(Sitr-1),*Titr-X[i]);
      kyori=min(tmp,kyori);
    }
    if(Sitr!=S.end()&&Titr!=T.begin()){
      ll tmp=*Sitr - *(Titr-1)+min(X[i]-*(Titr-1),*Sitr-X[i]);
      kyori=min(tmp,kyori);
    }
    cout<<kyori<<endl;
    //cout<<endl;
  }
  //cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>

 

 

 

using namespace std;

 

 

 

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


Measured memory_bytes: 3116
# coding: utf-8
# Your code here!
import math
a, b, x = map(int, input().split())

if x <= (1 / 2) * (a**2 * b):
    
    n = ((b**2) * a)/(2 * x)
    print(math.degrees(math.atan(n)))
else:
    n = 2 * ((a**2) * b - x) / a**3
    print(math.degrees(math.atan(n)))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, k; std::cin >> n >> k;
  int radix = 10;
  std::vector< int > a(radix, false);
  loop(k) {
    int x; std::cin >> x;
    a.at(x) = true;
  }
  auto check = [&] (int x) {
    while (x) {
      if (a.at(x % radix)) return false;
      x /= 10;
    }
    return true;
  };
  rep(i,n,radix*n) {
    if (check(i)) {
      std::cout << i << std::endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>

using namespace std;


int main(){
    int A;
    int B;
    int C;
    cin >> A >> B >> C;
    
    cout << max(10 * A + B + C,max(A + 10 * B + C, 10 * C + A + B)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(a>0 && c>0){
    c-=b;
    if(c<=0){
      cout << "Yes" << endl;
      break;
    }
    a-=d;
    if(a<=0){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/
 
 
int main(){
	int n;
	cin >> n;
	cout << n*n*n << "\n";
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstring>
using namespace std;
char S[15];
int main()
{
    cin >> S;
    if(strlen(S) % 2 != 0){
        cout << "No\n";
        return 0;
    }
    for(int i = 0; i < strlen(S); i += 2)
    if(!(S[i] == 'h' && S[i + 1] == 'i')){
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ALDS1_2_B{
	class Sample{
		static void Main(string[] args){
			int exchange=0;
			int N = int.Parse(Console.ReadLine());
			int[] nums = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
			
			for(int i=0; i<=N-1; i++){
				int minj = i;
				for(int j=i; j<=N-1; j++){
					if(nums[j] < nums[minj]){
						minj = j;
					}
				}
				if(minj != i){
					int x = nums[minj];
					nums[minj] = nums[i];
					nums[i] = x;
					exchange++;
				}
			}
			int cnt=0;
			foreach(int s in nums){
				Console.Write(s);
				if(cnt == nums.Length-1){
					Console.WriteLine();
				} else {
					Console.Write(" ");
				}
				cnt++;
			}
			Console.WriteLine(exchange);
		}
	}
}


Measured memory_bytes: 18340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pli pair<ll, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pq priority_queue;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int k;
	string s;
	cin>>k;
	cin>>s;
	if(s.length()<=k)
		cout<<s<<"\n";
	else
	{
		lp(i,0,k)
			cout<<s[i];
		cout<<"...\n";
	}
	return 0;
}

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

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

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <ll> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  
    int T=1;
    //cin >> T;
    while(T--){
        int n,m,x;
        cin>>n>>m>>x;
        ll c[n], a[n][m];
        rep(i,n){
            cin>>c[i];
            rep(j,m) cin>>a[i][j];
        }
        ll s[m]={0};
        ll mn=mod, f=0, tmp, f1;
        for(ll mask=1; mask<(1<<n);mask++){
            tmp=0;
            rep(j,n){
                if((1<<j) & mask){
                    tmp+=c[j];
                    rep(k,m) s[k]+=a[j][k];
                }
            }
            f1=1;
            rep(j,m) {
                if(s[j]<x) f1=0;
                s[j]=0;
            }
            if(f1){
                f=1;
                mn=min(mn,tmp);
            }
        }
        if(!f) cout<<-1<<el;
        else cout<<mn<<el; 
    }

    return 0;
}

Measured memory_bytes: 3652
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(int i=0; i<(n); i++)
#define jloop(n) for(int j=0; j<(n); j++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
const ll N = 2e5+9;
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
#define endl '\n'
ll po(ll,ll);


















int main() {
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif // ONLINE_JUDGE*/
  ios::sync_with_stdio(0);
  cin.tie(0);
  char c; cin >> c;
  c++;
  cout << c;
  R 0;
}
/*

*/



































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
const ll mod = 1000000007;
int main(){
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
for(int i=0;i<n-1;i++){
    if(a.at(i)<a.at(i+1))a.at(i+1)--;
}
bool check=true;
int now=-1;
for(int i=0;i<n;i++){
    if(now>a.at(i))check=false;
    now=a.at(i);
}
if(check)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}



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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];


long long dp[100010];

int main() {
    int N; cin >> N;
    vector<long long> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];
    
    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;
    
    // 初期条件
    dp[0] = 0;
    
    // ループ
    for (int i = 0; i < N; ++i) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    
    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector <int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];

  int ans = 0;
  for (int i = 0; i < n-2; i++) {
    vector <int> tmp = {p[i], p[i+1], p[i+2]};
    sort(tmp.begin(), tmp.end());
    if (tmp[1]==p[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
struct UnionFind {
	vector<int>par;
	UnionFind(int n) :par(n,-1) {}
	void init(int n) { par.assign(n, -1); }
	
	int root(int x) {
		if (par[x] < 0)return x;
		return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (par[x] > par[y])swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
int main() {
	ll N, M; cin >> N >> M;
	vector<int>A(M), B(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i];
		--A[i], --B[i];
	}
	UnionFind uf(N);
	ll cur = N * (N - 1) / 2;
	vector<ll>res;
	for (int i = 0; i < M; ++i) {
		res.push_back(cur);
		int a = A[M-1-i], b = B[M-1-i];
		if (uf.same(a, b))continue;
		ll sa = uf.size(a), sb = uf.size(b);
		cur -= sa * sb;
		uf.merge(a, b);
	}
	reverse(res.begin(), res.end());
	for (int i = 0; i < res.size(); ++i) {
		cout << res[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var str = ReadLine();
        WriteLine(str.Length>3&&str.Substring(0, 4) == "YAKI" ? "Yes" : "No");
    }
    
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define out(x) cerr << #x << " = " << x << "\n"
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar();bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
// Sub the Seq. and then Add Edge
// Note How Palind. Works
const int N = 3e5 + 10, mod = 26;
char s[N];
int pre[N], a[N], n, Q, sum[N];

inline int find(int u) {
  return pre[u] == u ? u : pre[u] = find(pre[u]);
}

inline void Merge(int x, int y);
inline void init() {
  for(int i = 1; i <= n; i ++) s[i] -= 'a';
  for(int i = 1; i <= n + 1; i ++) {
    a[i] = (s[i] - s[i - 1]) % mod;
    sum[i] = a[i];
    pre[i] = i;
  }
  for(int i = 1; i <= n + 1; i ++) {
    Merge(i, n + 1 - i + 1);
  }
}

inline void Merge(int x, int y) {
  int u = find(x), v = find(y);
  if(u == v) return ;
  (sum[u] += sum[v]) %= mod; sum[v] = 0;
  pre[v] = u;
}

main() {
  scanf("%s", s + 1); n = strlen(s + 1);
  init();
  read(Q);
  for(int i = 1; i <= Q; i ++) {
    int x, y;
    read(x), read(y); ++ y;
    Merge(x, y);
  }
  // for(int i = 1; i <= n + 1; i ++) cout << a[i] << ' '; putchar('\n');
  // for(int i = 1; i <= n + 1; i ++) cout << sum[i] << ' '; putchar('\n');

  for(int i = 1; i <= n + 1; i ++) if(pre[i] == i) {
      if(sum[i]) return cout << "NO\n", 0;
    }
  cout << "YES\n";
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdbool.h>



int a[100026];

bool binary(int n,int key){
  int right,left = 0,mid = 0;
  right = n;

  while(1){
    // printf("right = %d,left = %d,mid = %d\n",right,left,mid);
    mid = (right + left) / 2;
    //   printf("a[mid] = %d,mid = %d\n",a[mid],mid);
    if(a[mid] == key) return true;
    else if(right == left) return false;
    else if(a[mid] > key){
      right = mid;
      continue;
    }
    else{
      left = mid + 1;
      continue;
    }
  }
}

int main(){
  int n,q,i,j,key,sum = 0;
  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&a[i]);

  scanf("%d",&q);
  for(j = 0;j < q;j++){
    scanf("%d",&key);
    if(binary(n,key) == true) sum++;
    //  printf("finish,sum = %d\n",sum);
  }

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

  

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
    return 0;
}


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

using namespace std;
void solve();
int main()
{
    long long int n,x,sum=0;
    cin >> n;
    x=n;
    while(x>0)
    {
        sum+=(x%10);
        x/=10;
    }
    if(n%sum==0)
        cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3580
//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123; 
const int mod=1e9+7;
using namespace std;
int n;
string s;
int dp[200011], nx[200011][27];
int main(){
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  	srand(FOR);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> s;
	n = (int)s.len();
	for(int i = 0; i < 26; i ++)
		nx[n][i] = inf;
	for(int i = n - 1; i >= 0; i --){
		dp[i] = inf;
		for(int j = 0; j < 26; j ++){
			nx[i][j] = nx[i + 1][j];
			if(nx[i][j] == inf){
				dp[i] = 2;
			}else
				dp[i] = min(dp[i], dp[nx[i][j]] + 1);
		}
		nx[i][s[i] - 'a'] = i;
	}
	string ans = "";
	int pos = 0, len = inf;
	for(int i = 0; i < 26; i ++){
		if(nx[0][i] == inf){
			cout << char(i + 'a');         
			return 0;
		}
		if(dp[nx[0][i]] < len){ 
		//	cout << nx[0][i] << " " << dp[nx[0][i]] << endl;
			len = dp[nx[0][i]];
			pos = nx[0][i];
		}
	}
//	cout << pos << " " << len << endl;
	for(int i = pos; i < n; i += 0){
		ans += s[i];
		int to = 0;
		for(int j = 0; j < 26; j ++){	
			if(nx[i + 1][j] == inf){
				to = -1;
				ans += char(j + 'a');
				break;
			}
			if(dp[nx[i + 1][j]] == dp[i] - 1){
				to = nx[i + 1][j];
				break;
			}
		}
		if(to == -1)
			break;
		i = to;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 22420
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
set<int> edge[10000];
int score[10000];
int ans[10000];
int p;

void DFS(int a){
  ans[a]=score[p];
  p++;
  while(!edge[a].empty()){
    auto b=*edge[a].begin();
    edge[a].erase(b);
    edge[b].erase(a);
    DFS(b);
  }
  return;
}

int main(void){
  int N;
  cin >> N;
  rep(i,N-1){
    int x,y;
    cin >> x >> y;
    x--,y--;
    edge[x].insert(y);
    edge[y].insert(x);
  }
  rep(i,N) cin >> score[i];
  cout << accumulate(score,score+N,0)-*max_element(score,score+N) << endl;
  sort(score,score+N,greater<int>());
  DFS(0);
  rep(i,N) cout << ans[i] << " ";
}

Measured memory_bytes: 1920
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it before "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    int n;
    scanf("%d",&n);
    ll s = 0;
    for (int i = 1;i <= n;i ++) {
        if (i % 3 == 0 && i % 5 == 0) continue;
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        s += i;
    }
    printf("%lld\n",s);
    return 0;
}

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v)
{
    for (auto& e : v) {
        is >> e;
    }
    return is;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;


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

    int N, P;
    cin >> N >> P;
    ll W = 0;
    vector<ll> w(N);
    vector<ll> b(N);
    vector<ll> c(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> b[i];
        W += w[i];
        c[i] = (100 - P) * w[i] + P * b[i];
    }
    W *= (100 - P);
    sort(c.begin(), c.end());
    int num = 0;
    for (num = 0; num < N; num++) {
        W -= c[num];
        if (W < 0) {
            break;
        }
    }
    cout << N - num << endl;


    return 0;
}


Measured memory_bytes: 2560
#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 = 1000000000LL;
#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 func(int n){
  int cnt = 0;
  while(n % 2 == 0){
    n /= 2;
    cnt++;
  }
  return cnt;
}

int main(){
    int n;
    cin >> n;
    int mx = -1, res;
    for(int i=1; i<= n; i++){
      int num = func(i);
      if(mx < num){
        mx = num;
        res = i;
      }
    }
    cout << res << ln;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
	int xa,xb,ya,yb;
	cin >> xa >> ya >> xb >> yb;
	cout << xb - (yb-ya) << " " << yb + (xb-xa) << " ";
	cout << xa - (yb-ya) << " " << ya + (xb-xa);
			
	return 0;
}


Measured memory_bytes: 256
n=int(input())
dist=[[] for i in range(n)]
for i in range(n-1):
  a,b,c=map(int,input().split())
  dist[a-1].append([b-1,c])
  dist[b-1].append([a-1,c])  

Q,K=map(int,input().split())

INF=10**9+1
distFromK=[-1 for i in range(n)]

# start from K
stack=[]
stack.append([K-1,0,-1])
while stack:
  node=stack.pop()
  v=node[0]
  d=node[1]
  parent=node[2]
  if distFromK[v]==-1:
    distFromK[v]=d
  else:
    distFromK[v]=min(distFromK[v],d)
  targets=dist[v]
  for child in targets:
    if child[0]==parent or child[0]==v:
      continue
    stack.append([child[0],d+child[1],v])

for i in range(Q):
  x,y=map(int,input().split())
  print(distFromK[x-1]+distFromK[y-1])


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

#define PI 3.14159265359
#define MODULO 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
//large array has to be declared outside main, allocated statically
// if stored inside main, this variable lives in stack, caused overflow

int cnt[1000001];
int divi[1000001];
 
int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n; cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    cnt[a[i]]++;
  }

  // find the divisor of each number by
  // number smaller or equal to itself
  // or  in this case find multiples of i
  // if i exists in input, count of multiples increase
  for(int i=1;i<=1000000;i++)

  {
    for(int j=i;j<=1000000;j+=i)
    {
      divi[j]+=cnt[i];
    }
  }
  int ans=0;
  for(int i=0;i<n;i++)
  {
    if(divi[a[i]]==1) ans++;
  }
  cout<<ans<<'\n';

}
// Method from editorial

Measured memory_bytes: 12068
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int n,m;
    cin>>n>>m;
    map<int,int>mp;
    mp[0]=1;
    ll sum=0,ans=0;
    rep(i,n){
        int a;
        cin>>a;
        sum+=a;
        ans+=mp[sum%m];
        mp[sum%m]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int[] par = new int[2];
		for(int i=0;i<N;i++){
			int p = Math.Abs((int)(X[i] + Y[i]) % 2);
			par[p]++;
		}
		
		if(par[0] > 0 && par[1] > 0){
			Console.WriteLine(-1);
			return;
		}
		
		List<long> L = new List<long>();
		for(int i = 0;i < 36;i++){
			L.Add(1L << i);
		}
		if(par[0] > 0) L.Add(1);
		L.Sort();
		L.Reverse();
		
		var sb = new StringBuilder();
		sb.AppendLine(String.Format("{0}",L.Count));
		sb.AppendLine(String.Format("{0}",String.Join(" ",L)));
		
		String S = "RULD";
		for(int i=0;i<N;i++){
			long x0 = 0;
			long y0 = 0;
			var cmd = new List<char>();
			foreach(var l in L){
				long[] dy = new long[]{0,l,0,-l};
				long[] dx = new long[]{l,0,-l,0};
				
				long min = (long) 1e18;
				int idx = -1;
				for(int t=0;t<4;t++){
					long nx = x0 + dx[t];
					long ny = y0 + dy[t];
					if(Math.Abs(nx - X[i]) + Math.Abs(ny - Y[i]) < min){
						min = Math.Abs(nx - X[i]) + Math.Abs(ny - Y[i]);
						idx = t;
					}
				}
				
				x0 += dx[idx];
				y0 += dy[idx];
				cmd.Add(S[idx]);
			}
Debug.Assert(x0 == X[i] && y0 == Y[i]);
			sb.AppendLine(new String(cmd.ToArray()));
		}
		
		Console.Write(sb.ToString());
		
	}
	int N;
	long[] X,Y;
	public Sol(){
		N = ri();
		X = new long[N];
		Y = new long[N];
		for(int i=0;i<N;i++){
			var d = rla();
			X[i] = d[0]; Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17580
N = int(input())
A = sorted([int(x) for x in input().split()], reverse=True)

from collections import Counter
c = Counter(A)

A = sorted([(l,c) for l, c in c.items() if c >= 2], reverse=True)

if len(A) == 0:
    print(0)
elif A[0][1] >= 4:
    print(A[0][0]**2)
else:
    print(A[0][0]*A[1][0])






Measured memory_bytes: 18188
// ABC C
// DeP
#include <cstdio>

const int MAXN = 1e5+5;

int n, ans;
char S[MAXN];

int main() {
    scanf("%d%s", &n, S);
    char last = S[0];
    ans = 1;
    for (int i = 1; i < n; ++i) {
        if (last == S[i]) continue;
        else last = S[i];
        ++ans;
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    int a, b;
    cin >> a >> b;
    cout << ((a - 1) * (b - 1));
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
//using
using namespace std;
/*using vi = vector <int>;
using vs = vector <string>;
using vc = vector <char>;*/
//vector<vector<int> > hyou(N, vector<int>(N));
//define
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
//グローバル変数宣言
int c=0,e=0,n=0,k=0;


signed main(){
   cin>>n;
   vector<int>a(n),b(n);
   rep(i,n)cin>>a[i];
   rep(i,n)b[a[i]-1]=i+1;
   rep(i,n)print(b[i]);
}


Measured memory_bytes: 4836
mod = 10**9 + 7
X, Y = map(int, input().split())

if (X+Y) % 3 != 0:
    print(0)
    exit()

a = (2*Y-X)//3
b = (2*X-Y)//3
if a < 0 or b < 0:
    print(0)
    exit()

m = min(a, b)

ifact = 1
for i in range(2, m+1):
    ifact = (ifact * i) % mod
ifact = pow(ifact, mod-2, mod)
fact = 1
for i in range(a+b, a+b-m, -1):
    fact = (fact * i) % mod

print(fact*ifact % mod)


Measured memory_bytes: 9076