akhauriyash/Code-Regression huggingface dataset:
#O(nm) = O(60n)で解けるはず・・・！
n = int(input())
l = list(map(int,input().split()))
#2進数の桁の出現数をカウントする。
lone = [0]*60
for i in range(n):
  s = bin(l[i])[2:]
  for j in range(len(s)):
    lone[j] += int(s[-j-1])
ans = 0
for i in range(60):
  ans += (2**i*lone[i]*(n-lone[i]))%(10**9+7)
print(ans%(10**9+7))


Measured memory_bytes: 122808
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, L;
    cin >> N >> L;
    vector <string> vals(N);
    for(int i = 0; i < N; i++){
        string cur;
        cin >> cur;
        vals[i] = cur;
    }
    sort(vals.begin(), vals.end());
    string ans = "";
    for(int i = 0; i < N; i++){
        ans+=vals[i];
    }
    cout << ans << "\n";
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}

::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> primeFactors(::std::int64_t x) {
    ::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> res;
    for (::std::int64_t i = 2; i*i <= x; ++i) {
        if (x % i == 0) {
            res.emplace_back(i, 1);
            x /= i;
            while (x % i == 0) x /= i, res.back().second++;
        }
    }
    if (x != 1) res.emplace_back(x, 1);
    return res;
}


int main(void) {
    int64 N, M;
    cin >> N >> M;
    vector<int64> a(M), b(M), c(M, 0);
    REP(i, M) {
        cin >> a[i] >> b[i];
        REP(j, b[i]) {
            int64 cc;
            cin >> cc; cc--;
            c[i] |= (1 << cc);
        }
    }
    auto dp = make_v<int64>(M+1, 1 << N);
    fill_v<int64>(dp, INF_LL);
    dp[0][0] = 0;
    REP(i, M) {
        REP(j, 1 << N) {
            chmin(dp[i+1][j | c[i]], dp[i][j] + a[i]);
            chmin(dp[i+1][j], dp[i][j]);
        }
    }
    if (dp[M][(1 << N)-1] == INF_LL) {
        cout << -1 << endl;
    } else {
        cout << dp[M][(1 << N) - 1] << endl;
    }
}


Measured memory_bytes: 32384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);
    private static boolean[] checked;
    private static List<List<Integer>> neighbor;

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	neighbor = new ArrayList<List<Integer>>(N);
	for (int i = 0; i < N; i++) {
	    neighbor.add(new ArrayList<Integer>());
	}

	for (int i = 0; i < N-1; i++) {
	    int a = Integer.parseInt(scan.next()) - 1;
	    int b = Integer.parseInt(scan.next()) - 1;
	    neighbor.get(a).add(b);
	    neighbor.get(b).add(a);
	}

	checked = new boolean[N];
	checked[0] = true;
	int[] dist1 = new int[N];
	dfs(0, dist1);

	checked = new boolean[N];
	checked[N-1] = true;
	int[] distN = new int[N];
	dfs(N-1, distN);

	int black = 0;
	int white = 0;
	for (int i = 0; i < N; i++) {
	    if(dist1[i] <= distN[i]) black++;
	    else white++;
	}
	
	System.out.println(black > white ? "Fennec" : "Snuke");
	scan.close();
    }

    private static void dfs(int node, int[] dist) {
	for(int p: neighbor.get(node)) {
	    if(!checked[p]) {
		checked[p] = true;
		dist[p] = dist[node] + 1;
		dfs(p, dist);
	    }
	}
    }
}


Measured memory_bytes: 81952
import heapq
import sys
from collections import defaultdict
readline = sys.stdin.readline

n, m, s = map(int, input().split())

ls = [[] for _ in range(n)]
ms = []
for _ in range(m):
    u, v, a, b = map(int, input().split())
    ls[u - 1].append((v - 1, a, b))
    ls[v - 1].append((u - 1, a, b))
for _ in range(n):
    c, d = map(int, input().split())
    ms.append((c, d))

visited = defaultdict(int)
ans = [-1] * n
count = 0

q = [(0, 0, s)]
while q:
    t, i, s = heapq.heappop(q)
    if visited[(i, s)]:
        continue
    visited[(i, s)] = 1
    if ans[i] == -1:
        ans[i] = t
        count += 1
        if count == n:
            break

    if s <= 2500:
        tc, td = ms[i]
        heapq.heappush(q, (t + td, i, s + tc))
    for ni, a, b in ls[i]:
        if not visited[(ni, s - a)] and s >= a:
            heapq.heappush(q, (t + b, ni, s - a))

for v in ans[1:]:
    print(v)


Measured memory_bytes: 158480
// VSCF.cpp : Defines the entry point for the console application.
//
#include <cmath>
#include <list>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define FOR(v,p,k) for(int v=p;v<=k;++v)
#define FORD(v,p,k) for(int v=p;v>=k;--v)
#define REP(i,n) for(int i=0;i<(n);++i)
#define VAR(v,i) __typeof(i) v=(i)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define PB push_back
#define ST first
#define ND second
#define SIZE(x) (int)x.size()
#define ALL(c) c.begin(),c.end()
#define int long long
#define MAXN 1000010
typedef long double LD;

#undef int
int main() {
#define int long long
	int n;
	cin >> n;
	vector<int> inp(n);
	REP(i, n) {
		cin >> inp[i];
	}
	int idxCustomer = 1;
	int val = 2;
	int res = inp[0] - 1;
	while (idxCustomer != n) {
		if (inp[idxCustomer] == val) {
			val++;
			idxCustomer++;
		} else
		if (inp[idxCustomer] < val) {
			idxCustomer++;
		} else {
			inp[idxCustomer] -= 1 + val;
			res += inp[idxCustomer] / val + 1;
			idxCustomer++;
		}
	}
	cout << res;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }
        int[] hi = new int[N];
        int status = 0;//0:none 1:start 2:end
        int result = 0;
        boolean judged = false;
        while ( !equal(hi, h)) {
            for (int i = 0; i < N; i++) {
                if (status == 0 && hi[i] < h[i] && !judged) {
                    status = 1;
                    result++;
                    hi[i]++;
                    //System.out.println(i + " a");
                    judged = true;
                }
                if (status == 1 && hi[i] < h[i] && !judged) {
                    hi[i]++;
                    //System.out.println(i + "b");
                    judged = true;
                }
                if (status == 1 && hi[i] >= h[i] && !judged) {
                    status = 2;
                    //System.out.println(i + "c");
                    judged = true;
                }
                judged = false;
                //System.out.println(result);
            }
            status = 0;
            //System.out.println(result);
        }
        System.out.println(result);
    }

    static boolean equal(int[] a, int[] b) {
        boolean result = true;
        for (int i = 0; i < a.length; i++) {
            if (a[i] != b[i]) {
                result = false;
                break;
            }
            //System.out.print(a[i] + " ");
        }
        //System.out.println(result);
        return result;
    }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */
const int MOD = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MAX = 3003;
ll dp[MAX][MAX];
ll a[MAX];
bool visited[MAX][MAX];

ll rec(int l, int r){
  if(visited[l][r]) return dp[l][r];
  ll ret;
  if(r == l){
    ret = a[r];
  }else{
    ret = max(a[r] - rec(l,r-1), a[l] - rec(l+1, r));
  }
  visited[l][r] = true;
  return dp[l][r] = ret;
}

int main() {
  int N;  cin >> N;
  REP(i, N) cin >> a[i];

  cout << rec(0, N-1) << endl;
}


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

int main(void){
    int x, a, b, n;
    cin >> x >> a >> b >> n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(s == "nobiro"){
            x = max(0, x+a);
        }
        else if(s == "tidime"){
            x = max(0, x+b);
        }
        else{
            x = 0;
        }
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3208
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
int H, n;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> H >> n;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        H -= x;
    }
    if (H <= 0) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

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

    set<ll> div;
    for (int i = 1; i * i < sum; i++) {
        if (sum % i == 0) {
            div.insert(i);
            div.insert(sum / i);
        }
    }

    ll ans = 1;
    for (ll g : div) {
        ll A = 0, B = 0, cnt = 1e18;
        vector<int> r(n);
        for (int i = 0; i < n; i++) {
            r[i] = a[i] % g;
            B += g - r[i];
        }
        sort(r.begin(), r.end());
        for (int i = 0; i < n; i++) {
            A += r[i];
            B -= (g - r[i]);
            cnt = min(cnt, max(A, B));
        }
        if (cnt <= k) ans = max(ans, g);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    string s; cin >> s;
    int ans = 0;
    if (s == "RRR") ans = 3;
    if (s == "RRS") ans = 2;
    if (s == "RSR") ans = 1;
    if (s == "RSS") ans = 1;
    if (s == "SRR") ans = 2;
    if (s == "SRS") ans = 1;
    if (s == "SSR") ans = 1;
    if (s == "SSS") ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005
/* The judge is never wrong! Your code is buggy ??
   Look for:
 * * an easier and alternate approach
 * * if concept is corret and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
 */




int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        int r;
        cin >> r;
        double x=6.28318530717958623200;
        double ans=x*r;
        cout << fixed << setprecision(12) << ans << '\n';

}


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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

struct data{
    int v,c,d;
    data(int v,int c,int d):v(v),c(c),d(d){}
    bool operator<(const data &d)const{
        return c>d.c;
    }
};

const int SIZE=200000;
const int INF=1001001001001001001LL;
int W,H,K;
int X[SIZE],Y[SIZE];

vpint row[SIZE],col[SIZE];

int to[SIZE][4];
int cost[SIZE][4];

int dist[SIZE][2];


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

    cin>>W>>H>>K;
    rep(i,K){
        cin>>X[i]>>Y[i];
        X[i]--;Y[i]--;
        row[Y[i]].pb(pint(X[i],i));
        col[X[i]].pb(pint(Y[i],i));
    }

    rep(i,H)sort(all(row[i]));
    rep(i,W)sort(all(col[i]));

    memset(to,-1,sizeof(to));

    rep(i,H){
        rep(j,(int)row[i].size()-1){
            pint &v=row[i][j],&u=row[i][j+1];
            to[v.se][1]=u.se;cost[v.se][1]=u.fi-v.fi;
            to[u.se][3]=v.se;cost[u.se][3]=u.fi-v.fi;
        }
    }
    rep(i,W){
        rep(j,(int)col[i].size()-1){
            pint &v=col[i][j],&u=col[i][j+1];
            to[v.se][2]=u.se;cost[v.se][2]=u.fi-v.fi;
            to[u.se][0]=v.se;cost[u.se][0]=u.fi-v.fi;
        }
    }

    if(col[0].size()==0){
        cout<<-1<<endl;
        return 0;
    }

    pint start=col[0][0];
    fill_n(*dist,SIZE*2,INF);
    dist[start.se][0]=start.fi;
    priority_queue<data>que;
    que.push(data(start.se,start.fi,0));

    while(que.size()){
        data d=que.top();que.pop();
        if(dist[d.v][d.d]<d.c)continue;
        if(dist[d.v][1-d.d]>d.c+1){
            dist[d.v][1-d.d]=d.c+1;
            que.push(data(d.v,d.c+1,1-d.d));
        }

        rep(i,4){
            if(i%2!=d.d)continue;
            int t=to[d.v][i],c=cost[d.v][i];
            if(t==-1)continue;
            if(dist[t][d.d]<=d.c+c)continue;
            dist[t][d.d]=d.c+c;
            que.push(data(t,d.c+c,d.d));
        }
    }
    int mi=INF;

    rep(i,K){
        if(X[i]==W-1){
            chmin(mi,dist[i][0]+H-1-Y[i]);
        }
        if(Y[i]==H-1){
            chmin(mi,dist[i][1]+W-1-X[i]);
        }
    }
    
    if(mi==INF)cout<<-1<<endl;
    else cout<<mi<<endl;
    return 0;
}

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

int main() {
	// your code goes here
int m,f,r;

   while(1){
   	cin>>m;
   	cin>>f;
   	cin>>r;
   	  	if(m==-1&&f==-1&&r==-1){break;}
   	  if(m==-1||f==-1){
   	  cout<<"F"<<endl;
   	  continue;
   	  }  
	     if(m+f>=80){
	     	cout<<"A"<<endl;
	     }
	         if(65<=m+f&&m+f<80){
	         	cout<<"B"<<endl;
	         }
	             if(50<=m+f&&m+f<65){
	             	cout<<"C"<<endl;
	             }
	             if(30<=m+f&&m+f<50){
	             	if(50<=r){
	                	cout<<"C"<<endl;
	                }
	                   if(50>r){
	                   	  cout<<"D"<<endl;
	                   }
	             }
	             
	                   	     if(m+f<30){
	                   	     	 cout<<"F"<<endl;
	                   	     }
   	}    
	return 0;
	}

Measured memory_bytes: 3116
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

int N;
int a[MAX];

signed main() {
	cin >> N;
	rep(i, N) {
		cin >> a[i];
		a[i]--;
	}
	int cnt = 0;
	rep(i, N) {
		if (a[a[i]] == i) cnt++;
	}
	cout << cnt / 2 << endl;
	return 0;
}


Measured memory_bytes: 640
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    int64_t ans = 0;

    size_t L = S.size();

    for (uint64_t op = 0; op < (1 << L-1); ++op) {

        int64_t val = 0;
        int64_t tmp = 0;
        for (size_t i = 0; i < L; ++i) {
            tmp *= 10;
            tmp += int(S[i] - '0');
            if (op&(1<<i)) {
                // +
                val += tmp;
                tmp = 0;
            }
        }
        ans += tmp;
        ans += val;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    cin >> a;
    forn (i, k, n) {
        if (a[i] > a[i - k])
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}

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

using namespace std;
int n,a,b,c,p;
vector <int> t[100][100];
int u[100][100];
int no[100],in[100];
int in2[100][100];
int INF = (1<<24);

int change(int x){
  for(int i=0;i<n;i++)if(no[i]==x)return i;
}
vector<int> x,z;


int main(){
  for(int i=0;i<100;i++)
    for(int j=0;j<100;j++){
      u[i][j]=(i==j?0: INF );
      if(i==j)continue;
      t[i][j].push_back(i);
      t[i][j].push_back(j);
    }
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>no[i];
    cin>>in[i];
    for(int j=0;j<in[i];j++){
      cin>>in2[i][j];
    }
  }
  
  
  for(int i=0;i<n;i++){
    for(int j=0;j<in[i];j++){
     u[i][change(in2[i][j])]=1;
    }
  }

  


  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(u[i][k]+u[k][j]<u[i][j]){
	  u[i][j]=u[i][k]+u[k][j];

	  /*
	  t[i][j].clear();
	  x=t[i][k];
	  z=t[k][j];
	  for(int l=0;l<(int)x.size();l++)t[i][j].push_back(x[l]);
	  t[i][j].push_back(no[j]);
	  for(int l=0;l<(int)z.size();l++)t[i][j].push_back(z[l]);
	  */
	}
      }
    }
  }
  cin>>p;
  while(p--){
    cin>>a>>b>>c;
    if(u[change(a)][change(b)]+1>c)cout<<"NA"<<endl;
    else{
      cout<<u[change(a)][change(b)]+1<<endl;
      /*cout<<t[change(a)][change(b)].size()<<endl;
      
      for(int i=0;i<(int)t[change(a)][change(b)].size();i++){
	if(i)cout<<' ';
	cout<<t[change(a)][change(b)][i];
      }
      cout<<endl;
      */
    }
  }
  return 0;
}

Measured memory_bytes: 1836
/**
*    author:  boutarou
*    created: 28.09.2020 18:15:31
**/

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

int main() {
    int n, m;
    cin >> n >> m;
    dsu uf(n);
    int ans = n - 1;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (!uf.same(a, b)) {
            uf.merge(a, b);
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
using std::cout;
using std::cin;
using std::endl;

void getCombinations(int m, int sum)
{
	int i, j, k, total = 0;
	for (i = 1; i <= m; i++)
	{
		for (j = i + 1; j <= m; j++)
		{
			for (k = j + 1; k <= m; k++)
			{
				if (i + j + k == sum) total++;
			}
		}
	}
	cout << total << endl;
}

int main()
{
	int m, sum;
	while (true)
	{
		cin >> m >> sum;
		if (m == 0 && sum == 0) break;
		getCombinations(m, sum);
	}
	return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

void solve() {
	int N, Q; cin >> N >> Q;
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	vector<int>odd(N + 1), even(N + 1),cum(N+1);
	REP(i, N) {
		odd[i + 1] += odd[i];
		even[i + 1] += even[i];
		cum[i + 1] = cum[i] + A[i];
		if (i & 1)odd[i + 1] += A[i];
		else even[i + 1] += A[i];
	}
	vector<int>X(Q);
	REP(i, Q)cin >> X[i];
	REP(_, Q) {
		int x = X[_];
		int ok = 1, ng = N;
		while (abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			int id = N - 2 * mid + 1;
			if (id < 0) {
				ng = mid; continue;
			}
			if (abs(A[N - mid] - x) >= abs(A[id] - x))ok = mid;
			else ng = mid;
		}
		ll sum = cum[N] - cum[N - ok];
		if (N - 2 * ok >= 0) {
			if ((N - 2 * ok) & 1)sum += even[N - 2 * ok];
			else sum += odd[N - 2 * ok];
		}
		print(sum);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define ll long long
#define eb emplace_back
#define all(c) (c).begin(), (c).end()
#define vi vector<int>
#define N 500010
#define MOD 998244353


struct S {
	ll a;
	ll size;
};

struct F {
	ll a, b;
};

S op(S l, S r) { return S{ (l.a + r.a) % MOD, l.size + r.size }; }

S e() { return S{ 0, 0 }; }

S mapping(F l, S r) { return S{ ((r.a * l.a) + (r.size * l.b)) % MOD, r.size }; }

F composition(F l, F r) { return F{ (r.a * l.a) % MOD, ((r.b * l.a) + l.b) % MOD }; }

F id() { return F{ 1, 0 }; }

int main() {
	int n, q;
	cin >> n >> q;
	ll ans;
	vector<S> a(n);
	rep(i,n) {
		ll x;
		cin >> x;
		a[i] = S{ x, 1 };
	}

	lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

	rep(i,q) {
		int t;
		scanf("%d", &t);
		if (t == 0) {
			int l, r;
			ll c, d;
			cin >> l >> r >> c >> d;
			seg.apply(l, r, F{ c, d });
		}
		else {
			int l, r;
			cin >> l >> r;
			ans = seg.prod(l, r).a;
			cout << ans << endl;
		}
	}
}


Measured memory_bytes: 35664
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	A, _ := strconv.Atoi(read())
	B, _ := strconv.Atoi(read())
	C, _ := strconv.Atoi(read())
	var ans int
	if C-A+B > 0 {
		ans = C - A + B
	} else {
		ans = 0
	}
	fmt.Printf("%v\n", ans)
}


Measured memory_bytes: 640
list_W = []
list_K = []

for i in range(10) :
    list_W.append(int(input()))
for i in range(10) :
    list_K.append(int(input()))

list_W.sort(reverse = True)
list_K.sort(reverse = True)

sum_W = sum(list_W[0:3])
sum_K = sum(list_K[0:3])

print(sum_W, sum_K)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a,b,m;
    cin >> a >> b >> m;
    vector<int> va(a),vb(b);
    rep(i,0,a-1)cin >> va[i];
    rep(i,0,b-1)cin >> vb[i];
    int ans = INF,ansa=INF,ansb=INF;
    rep(i,0,a-1)ansa = min(ansa,va[i]);
    rep(i,0,b-1)ansb = min(ansb,vb[i]);
    ans = ansa + ansb;
    rep(i,1,m){
        int x,y,c;
        cin >> x >> y >> c;
        x--;y--;
        ans = min(ans,va[x]+vb[y]-c);
    }

    cout << ans << endl;
//  printf("%.10f\n",as);

    return 0;
}

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

struct UnionFind{
  int n;
  vector<int> ran,p,cnt;
  UnionFind(){}
  UnionFind(int sz):n(sz),ran(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(ran[x]<ran[y]) swap(x,y);
    ran[x]+=ran[y];
    p[y]=x;
  }
  int sum(int x){
    return ran[find(x)];
  }
};

int n,m,a,b,ans;

signed main(){
  while(cin>>n>>m,n){
    ans=1;
    UnionFind U(n);
    r(i,m){
      cin>>a>>b;
      a--;b--;
      U.unite(a,b);
    }
    r(i,n)if(U.find(i)==i)ans=(ans*2)%1000000007;
    if(m)ans=(ans+1)%1000000007;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3492
n = gets.to_i
pp = gets.split.map &:to_i
qq = gets.split.map &:to_i

i = 1
a = nil
b = nil
(1..n).to_a.permutation do |x|
  a = i if pp == x  
  b = i if qq == x
  i += 1
end
puts (a-b).abs


Measured memory_bytes: 2172
import sys
input = sys.stdin.readline
import itertools
import numpy as np
from scipy.sparse.csgraph import connected_components

H,W = map(int,input().split())
words = np.array([list(input().rstrip()) for _ in range(H)], dtype='U1')

def gen_pair_pattern_even(rest):
    # 偶数個を仮定
    if len(rest) == 0:
        yield []
        return
    if len(rest) == 1:
        x = rest.pop()
        yield [(x,x)]
        return
    li = list(rest)
    x = li[0]
    for y in li[1:]:
        se = rest.copy()
        se.remove(x)
        se.remove(y)
        for p in gen_pair_pattern_even(se):
            yield p + [(x,y)]    

def gen_pair_pattern(N):
    if N & 1:
        for n in range(N):
            se = set(x for x in range(N) if x != n)
            for p in gen_pair_pattern_even(se):
                yield p + [(n,n)]
    else:
        for p in gen_pair_pattern_even(set(range(N))):
            yield p

def test(row_pairs):
    graph = np.ones((W,W), dtype = np.bool)
    for r1,r2 in row_pairs:
        graph &= (words[r1][:,None] == words[r2][None,:])
    graph &= graph.T
    se = set(range(W))
    while se:
        removed = False
        for i,j in itertools.combinations(se,2):
            if graph[i,j]:
                se.remove(i)
                se.remove(j)
                removed = True
                break
        if not removed:
            break
    if len(se) > 1:
        return False
    return True

bl = False
for p in gen_pair_pattern(H):
    if test(p):
        bl = True
        break

answer = 'YES' if bl else 'NO'
print(answer)

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

int main(){
  string S;
  cin >> S;
  int R = 0;
  int streak = 0;
  for(int i=0; i<3; ++i){
  	if(S[i]=='R'){
      ++R;
      if(R>streak){streak = R;}
    }
    else{R=0;}
  }
  cout << streak << endl;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n; cin >> n;
    map <int, int> s;
    ll cur = n - 1, ans = 0;
    FOR(i, 1, n) {
        int tt; cin >> tt;
        auto e = s.find(tt + cur);
        if (e != s.end()) ans += e->se;
        s[n - tt - i]++;
        cur--;
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    string s;
    cin>>s;
    replace(all(s),',',' ');
    cout<<s<<endl;
    return 0;
}

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

int main(){
    int A,B;   
    cin>>A>>B;
    
    cout<<((max(A,B)<=8)?"Yay!":":(")<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	int nw;
	int old = 0;
	int cnt = 0;
	REP(i, N) {
		cin >> nw;
		if (old < nw) {
			cnt += (nw - old);
		}
		old = nw;
	}
	print(cnt);


	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll X;
    cin >> X;

    if(X >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n,ans=0; cin>>n;
  int l[n];
  rep(i,n){
    cin>>l[i];
  }
  sort(l,l+n);
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]!=l[j] && l[j]!=l[k] && l[i]+l[j]>l[k]){
          ans++;
        }
      }
    }
  }
  cout<<ans;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, X, ans = 0, a, b;
  std::cin >> N >> X;
  ans = N, a = X, b = N-X;
  while(true){
    if(a>b) swap(a, b);
    ans += 2*a*(b/a);
    //std::cout << a << " " << b << " " << ans << '\n';
    b = b % a;
    if(b==0) {
      ans -= a;
      break;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main() {
	long long a, b, idx=1; cin>>a>>b;
	
	if(a<b){
		long long i=b;
		b=a; a=i;
	}
	
	while(b*idx%a!=0){
		idx++;
	}
	
	cout<<b*idx;
	
	return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

    int N;
    cin >> N;
    vector<int> a(N+1);
    rep(i,N) cin>>a[i+1];
    
    int c=1;
    int cnt=0;
    rep(i,N){
        c = a[c];
        cnt++;
        if(c==2) {cout<<cnt<<endl; return 0;}
    }
    cout << -1 << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int digits(ll x) {
  int res = 1;
  while (x >= 10) {
    x /= 10;
    res++;
  }
  return res;
}

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

  ll N;
  cin >> N;

  int ans = digits(N);

  for (int i = 2; i <= (int)floor(sqrt(N)); i++) {
    // cout << N << " " << i << endl;
    if (N % i == 0) {
      int d = max(digits(i), digits(N / i));
      // cout << i << " " << d << endl;
      ans = min(ans, d);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int N=2e3+10;
int a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1);
    long long res=0;
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
    {
        int l=j,r=n;
        while(l<r)
        {
            int mid=l+r+1>>1;
            if(a[mid]<a[i]+a[j])    l=mid;
            else r=mid-1;
        }
        res+=l-j;
    }
    cout<<res;
}

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

using namespace std;

int main()
{
  int n, l;
  while(cin >> n >> l, n || l){
    l *= 2;
    int ant[20];
    for(int i = 0; i < n; i++){
      char d; int p;
      cin >> d >> p;
      if(d == 'R') ant[i] = p*2;
      else ant[i] = -p*2;
    }
    int m = n, out = -1; 
    for(int t = 0; ; t++){
      //cout << "TIME: " << t << endl;
      if(m == 0){
	cout << t/2 << " " << out + 1 << endl;
	break;
      } else {
	int now = -1;
	int tunnel[201];
	memset(tunnel, -1, sizeof(tunnel));
	for(int i = 0; i < n; i++){ 
	  if(ant[i] == 114514) continue;
	  //cout << "ANT: " << i+1 << " " << ant[i] << endl;
	  ant[i] += 1;
	  if(ant[i] == 0 || ant[i] == l){
	    m--;
	    if(now == -1 || ant[i] == 0) now = i;
	    ant[i] = 114514;
	  } else {
	    if(tunnel[abs(ant[i])] == -1) tunnel[abs(ant[i])] = i;
	    else if(abs(ant[i])%2 == 0) ant[i] *= -1, ant[tunnel[abs(ant[i])]] *= -1;
	  }
	}
	out = now;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  string s1,s2;cin>>s1>>s2;
  int a,b;cin>>a>>b;
  string u;cin>>u;
  
  if(s1==u){
    cout<<a-1<<" "<<b<<endl;
  }
  else{
    cout<<a<<" "<<b-1<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 3632
#include "iostream"
#include "vector"
using namespace std;

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

    vector<int> a(n);
    int k = -1;
    for(int i = 0 ; i < n ; ++i){
        cin >> a[i];
        if(i > 0 && a[i - 1] + a[i] >= l){
            k = i;
        }
    }

    if(k < 0){
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;
    for(int i = 1 ; i < k ; ++i){
        cout << i << endl;
    }
    for(int i = n - 1 ; i >= k ; --i){
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 1152
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  COMinit();
  ll n,m,k;cin>>n>>m>>k;
  ll ans=0;
  
  for(ll i=1;i<=n-1;i++){
    ll part=COM(n*m-2,k-2);
    part*=n-i;
    part%=MOD;
    part*=m;
    part%=MOD;
    part*=m;
    part%=MOD;
    part*=i;
    part%=MOD;
    ans+=part;
    ans%=MOD;
  }
  //cout<<ans<<endl;
  for(ll i=1;i<=m-1;i++){
    ll part=COM(n*m-2,k-2);
    part*=m-i;
    part%=MOD;
    part*=n;
    part%=MOD;
    part*=n;
    part%=MOD;
    part*=i;
    part%=MOD;
    ans+=part;
    ans%=MOD;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 12160
# from pprint import pprint

# import math
# import collections

# n = int(input())
h, w = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

a = []
for _h in range(h):
    a.append(list(input()))

mask = [[False] * w for h in range(h)]

# 行の判定
for i, row in enumerate(a):
    if all([True if c == '.' else False for c in a[i]]):
        mask[i] = [True] * w

# 列の判定
x = [True] * w
for row in a:
    for j, col in enumerate(row):
        if col == '.':
            x[j] = x[j] and True
        else:
            x[j] = x[j] and False

for i, row in enumerate(a):
    for j, _x in enumerate(x):
        if _x:
            mask[i][j] = True

for i in range(h):
    if all(mask[i]):
        continue
    p_row = ''.join([a[i][j] for j in range(w) if mask[i][j] is False])
    print(p_row)


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N,M,K;
	cin>>N>>M>>K;
    
    
    vector<set<ll>> f_set(N);
    vector<set<ll>> b_set(N);
    rep(i,M){
        ll a,b;
        cin>>a>>b;
        f_set[a-1].insert(b-1);
        f_set[b-1].insert(a-1);
    }
    rep(i,K){
        ll a,b;
        cin>>a>>b;
        b_set[a-1].insert(b-1);
        b_set[b-1].insert(a-1);
    }
    deque<ll> dq;
    ll flag[N] = {};
    ll tmp_flag = 1;
    ll ans_all[N] = {};
    rep(i,N){
        if(flag[i]==0){
            ++tmp_flag;
            ll ans = 0;
            dq.push_back(i);
            set<ll> group_set = {};
            group_set.insert(i);
            flag[i] = tmp_flag;
            while(!dq.empty()){
                ll id = dq.front();
                dq.pop_front();
                for(auto x:f_set[id]){
                    if(flag[x] == 0){
                        group_set.insert(x);
                        flag[x] = tmp_flag;
                        dq.push_back(x);
                    }
                }
            }
            for(auto x:group_set){
                ll not_f = 0;
                for(auto y:f_set[x]){
                    if(flag[y]==tmp_flag){
                        ++not_f;
                    }
                }
                for(auto y:b_set[x]){
                    if(flag[y]==tmp_flag){
                        ++not_f;
                    }
                }
                ans_all[x] = group_set.size()-1 - not_f;
            }
        }
    }
    rep(i,N-1){
        cout<<ans_all[i]<<" ";
    }
    cout<<ans_all[N-1]<<"\n";
    return 0;
}

Measured memory_bytes: 36096