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


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		boolean bass = false;
		if(!S.substring(0, 1).equals( S.substring(1, 2))) bass = true;
		if(!S.substring(2, 3).equals(S.substring(1, 2))) bass = true;


		if(bass) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22868
#include<stdio.h>
int main(void){
 
    int m,n,g,l,work,a,b;
 
    while(scanf("%d%d",&m,&n)!=EOF){
 
        a=m;
        b=n;
 
        if(m<n){
            work=m;
            m=n;
            n=work;
        }
 
        while(n!=0){
            work=m%n;
            m=n;
            n=work;
        }
 
        g=m;
        l=a/g;
        l*=b;
 
        printf("%d %d\n",g,l);
 
    }
    return 0;
}


Measured memory_bytes: 2032
n=int(input())
a_s=list(map(int,input().split()))
color_list=[0]*8
god=0
point_split=[1,400,800,1200,1600,2000,2400,2800,3200]
for a in a_s:
    for i in range(8):
        if point_split[i]<=a<point_split[i+1]:
            color_list[i]+=1
    if a >=3200:
        god+=1

ans=0
for color in color_list:
    if color:
        ans+=1
max=ans+god
if ans==0:
    min=1
else:
    min=ans

print(min,max)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int H, N;
    int total = 0;
    scanf("%d %d", &H, &N);
    for(int i = 0; i < N; i++){
        int a;
        scanf("%d", &a);
        total += a;
    }
    printf(total < H ? "No" : "Yes");    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long a, b, z, a1, b2, lcm, temp;

	while(scanf("%ld %ld", &a, &b)!=EOF){
		a1=a+1;
		b2=b+1;
		while((z = a % b)!= 0){
			a = b;
			b = z;
			}
		printf("%ld ", b);
		temp=(b2-1)/b;
		lcm=(a1-1)*temp;
		printf("%ld\n", lcm);
	}
	return 0;
}

Measured memory_bytes: 592
def sgn(x):
    if x>0:
        return 1
    elif x<0:
        return -1
    else:
        return 0
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
mod=10**9+7
if K==N:
    ans=1
    for i in range(N):
        ans=ans*A[i]
        ans%=mod
    print(ans)
    exit()
if max(A)<0 and K%2==1:
    ans=1
    A.sort()
    for i in range(K):
        ans=ans*A[-i-1]
        ans%=mod
    print(ans)
    exit()
A.sort(key=lambda x:abs(x),reverse=True)
P=1
Pfugou=1
for i in range(K):
    P=P*A[i]
    P%=mod
    Pfugou=Pfugou*sgn(A[i])
if Pfugou!=-1:
    print(P)
    exit()
X=[]
Y=[]
for i in range(N):
    if A[i]>=0:
        X.append(A[i])
    else:
        Y.append(-A[i])
X.sort()
Y.sort()
S=[]
while(len(S)<K):
    if len(S)==K-1:
        S.append(X[-1])
        X.pop()
    elif len(X)<=1 and len(Y)<=1:
        #選んでないのが2個以下
        #len(S)<K<=N-1
        #len(S)=N-len(X)-len(Y)>=N-2
        #よってlen(S)=N-2,K=N-1
        #前述で処理済み
        #なのでここでやることはない
        pass
    elif len(X)<=1:
        S.append(Y[-1])
        S.append(Y[-2])
        Y.pop()
        Y.pop()
    elif len(Y)<=1:
        S.append(X[-1])
        S.append(X[-2])
        X.pop()
        X.pop()
    else:
        if X[-1]*X[-2]>Y[-1]*Y[-2]:
            S.append(X[-1])
            X.pop()
        else:
            S.append(Y[-1])
            S.append(Y[-2])
            Y.pop()
            Y.pop()
ans=1
for i in S:
    ans=ans*i
    ans%=mod
print(ans)

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

using namespace std;

int main() {
	int x[5], k;
	bool ok = 0;
	cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4] >> k;
	for (int i = 0; i < 5; ++i)
		for (int j = i + 1; j < 5; ++j)
			if (abs(x[i] - x[j]) > k)
				ok = 1;
	if (ok)
		cout << ":(";
	else 
		cout << "Yay!";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

using namespace std;

int main(){

	int a;
	cin >> a;
	cout << a+a*a+a*a*a << '\n';

	return 0;
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

unsigned long long gcd(unsigned long long a, unsigned long long b) {
    if (a < b) {
        return gcd(b, a);
    }
    unsigned long long c;
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    int N;
    cin >> N;

    unsigned long long current_lcm = 1;
    for (int i = 0; i < N; i++) {
        unsigned long long t;
        cin >> t;
        current_lcm = t / gcd(t, current_lcm) * current_lcm;
    }

    cout << current_lcm << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <map>

typedef long long ll;
using namespace std;
map<ll,int> paper;

int main(){
	int N;
	scanf("%d",&N);	
	ll t;
	for(int i = 0; i < N; i++){
		scanf("%lld",&t);	
		paper[t] += 1;
	}
	int ans = 0;
	map<ll,int>::iterator i;
	for(i = paper.begin(); i != paper.end(); i++){
		ans += (*i).second % 2;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int B[21];
int main()
{
	int N, M, C;
	cin >> N >> M >> C;
	for (int i = 0; i < M; i++) cin >> B[i];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < M; j++) {
			int A;
			cin >> A;
			sum += A * B[j];
		}
		if (sum + C > 0) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3556
#include <iostream>
using namespace std;
#define MAX 2000000

int gHeap[MAX + 1],gSize;

void maxHeapify(int i){
    int left,right,largest;
    left = 2 * i;
    right = 2 * i + 1;
    
    // 左の子、自分、右の子で値が最大のノードを選択
    if(left <= gSize && gHeap[left] > gHeap[i]){
        largest = left;
    }
    else{
        largest = i;
    }
    // 右の子と比較
    if(right <= gSize && gHeap[right] > gHeap[largest]) largest = right;
    
    if(largest != i){
        swap(gHeap[i],gHeap[largest]);
        maxHeapify(largest);
    }
}

int main(){
    cin >> gSize;
    
    for(int i = 1;i <= gSize;++i) cin >> gHeap[i];
    // buildMaxHeap
    for(int i = gSize / 2;i >= 1;--i)maxHeapify(i);
    
    for(int i = 1;i <= gSize;++i){
        cout << " " << gHeap[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 4960
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(void){
int N,M;
cin >> N >> M;
const int nmmax=50;
char A[nmmax][nmmax],B[nmmax][nmmax];

for(int y=0;y<N;++y){
    for(int x=0;x<N;++x){
    cin >> A[y][x];
     }
 }

 for(int y=0;y<M;++y){
     for(int x=0;x<M;++x){
     cin >> B[y][x];
 }
 }

 bool exist=false;

 for(int ly=0;ly<N;++ly){
     for(int lx=0;lx<N;++lx){
    if(ly+M-1>=N or lx+M-1>=N) continue;

bool match=true;
for(int y=0;y<M;++y){
    for(int x=0;x<M;++x){
    if(A[ly+y][lx+x]!=B[y][x]) match=false;
 }
 }
    if(match) exist=true;
 }
 }

 if(exist)
    cout << "Yes" << endl;
 else
    cout << "No" << endl;

 return 0;
 }

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]

r_bit = 1 << H
w_bit = 1 << W

# print(r_bit, w_bit)

ans = 0
for r in range(r_bit):
    n_row = []
    for i in range(H):
        if r & 1:
            n_row.append(i)
        r >>= 1

    for c in range(w_bit):
        # 使えない行、列

        n_col = []

        for j in range(W):
            if c & 1:
                n_col.append(j)
            c >>= 1

        cnt = 0
        for i in range(H):
            for j in range(W):
                if i in n_row or j in n_col:
                    continue
                if C[i][j] == "#":
                    cnt += 1

        if cnt == K:
            ans += 1

print(ans)



Measured memory_bytes: 9228
#include<iostream>
using namespace std;
const int N = 8;
int st[N][N]={};
int rc[N]={},cc[N]={};
int sc[N*2]={},dc[N*2]={};
int cnt=0;
void print(){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++)
      cout<<(st[i][j]?"Q":".");
    cout<<endl;
  }
  exit(0);
}

void dfs(int y,int x){
  if(y==N){
    if(cnt==N) print();
    return;
  }
  int ny=y+(x+1)/N,nx=(x+1)%N;
  if(st[y][x]==2){
    dfs(ny,nx);
    return;
  }
  
  dfs(ny,nx);
  if(!rc[y]&&!cc[x]&&!sc[y+x]&&!dc[N+y-x]){
    rc[y]++;
    cc[x]++;
    sc[y+x]++;
    dc[N+y-x]++;

    st[y][x]=1;
    cnt++;
    dfs(ny,nx);
    cnt--;
    st[y][x]=0;
    
    rc[y]--;
    cc[x]--;
    sc[y+x]--;
    dc[N+y-x]--;
  }  
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int r,c;
    cin>>r>>c;
    st[r][c]=2;
    rc[r]++;
    cc[c]++;
    sc[r+c]++;
    dc[N+r-c]++;
    cnt++;
  }  
  dfs(0,0);
  return 0;
}



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

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

const long long MOD = 1000000007;

int main(){
  string s;
  cin>>s;
  bool ans=false;
  rep(i,3){
    if(s.at(i)=='7') ans=true;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main(){
    int q;
    cin >> q;
    map<string, int> mp;
    for(int i=0; i<q; i++){
        int a;
        string key;
        cin >> a >> key;
        if(a == 0){
            int x;
            cin >> x;
            mp[key] = x;
        }else{
            cout << mp[key] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 27852
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int compare_int(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int main() {
	int N; 
	int n,remove = 0;
	int a[100000];
	cin >> N;
	for (n = 0; n < N; n++) {
		cin >> a[n];
	}
	map <int, int> mp;

	for (n = 0; n < N; n++) {
		mp[a[n]]++;
	}
	
	for (auto m = mp.begin(); m != mp.end(); m++) {
		if (m->first < m->second) {
			remove += (m->second- m->first);
		}
		else if (m->first > m->second) {
			remove += m->second;
		}
	}
	cout << remove << endl;
	
	return 0;
}

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

vector<int> divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> ans;
  ans = divisor(m);
  rep(i,ans.size()){
    // cout << ans[i] << endl;
    if(ans[i]>=n){
      cout << m/ans[i] << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        char[] ch = String.valueOf(n).toCharArray();
        long sum = 0;
        for (int i = 0; i < ch.length; i++) {
            sum += ch[i] - '0';
        }
        System.out.println(Math.max((ch.length - 1) * 9 + (ch[0] - '0') - 1, sum));
    }

}


Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0 -1};

ll N;

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

  cin >> N;

  cout << N * (N-1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>
const ll BIG = 1000000000;

int main() {
    int n, k;
    cin>>n>>k;
    mcf_graph<int, ll> g(2*n + 2);
    int s = 2 * n, t = 2 * n + 1;
    g.add_edge(s, t, n * k, BIG);
    REP(i, 0, n){
        g.add_edge(s, i, k, 0);
        g.add_edge(n + i, t, k, 0);
    }
    REP(i, 0, n){
        REP(j, 0, n){
            ll a;
            cin >> a;
            g.add_edge(i, n + j, 1, BIG - a);
        }
    }
    auto result = g.flow(s, t, n * k);
    cout << 1LL * n * k * BIG - result.second << endl;
    vector<string> grid(n, string(n, '.'));
    auto edges = g.edges();
    for(auto e: edges){
        if(e.from == s || e.to == t || e.flow == 0) continue;
        grid[e.from][e.to - n] = 'X';
    }
    REP(i, 0, n) cout << grid[i] << endl;
}

Measured memory_bytes: 3964
use std::io;


fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    let nums = read_nums();
    let a = nums[0];
    let b = nums[1];
    let t = nums[2];

    let ret = t/a*b;
    



    print!("{}", ret);
}   

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

vector<ll> zAlgorithm(const string& s)
{
	ll N = (ll)s.size();
	vector<ll> res(N);

	for (ll i = 1, j = 0; i < N;)
	{
		while (i + j < N && s[j] == s[i+j]) ++j;
		res[i] = j;
		if (j == 0) {++i; continue;}
		ll k{1};
		while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
		i += k;
		j -= k;
	}

	res[0] = N;
	return res;
}


int main(int argc, char **argv)
{
	ll N; cin >> N;
	string S; cin >> S;

	ll res{0};
	
	REP(i, N)
	{
		vector<ll> z = zAlgorithm(S.substr(i, N-i));
		ll sz = z.size();
		for (ll j = 1; j < sz; ++j)
			if (j >= z[j]) res = max(res, z[j]);
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int d,m1=0,m2=0,m3=0,i;
	for(i=0;i<10;i++){
		scanf("%d",&d);
		if(d>m1){
			m3=m2;
			m2=m1;
			m1=d;
		}else if(d>m2){
			m3=m2;
			m2=d;
		}else if(d>m3){
			m3=d;
		}
	}
	printf("%d\n",m1);
	printf("%d\n",m2);
	printf("%d\n",m3);
	return 0;
}

Measured memory_bytes: 600
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def f(x):
    res = 0
    while x % 2 == 0:
        res += 1
        x /= 2
    return res

n, m = map(int, input().split())
A = list(map(int, input().split()))

l = lcm(*[a // 2 for a in A])
ans = math.floor((m + l) / (2*l))
if len(set([f(a) for a in A])) != 1:
    print(0)
else:
    print(ans)

Measured memory_bytes: 16308
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, kmin;
    cin >> n >> kmin;
    vector<ll> x(n), y(n);
    vector<pair<ll, ll>> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        p[i] = make_pair(x[i], y[i]);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    ll ans = infl * 4LL;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = i + 1; k < n; ++k) {
                for (int l = j + 1; l < n; ++l) {
                    int cnt = 0;
                    ll xmin = x[i], xmax = x[k], ymin = y[j], ymax = y[l];
                    for (int m = 0; m < n; ++m) {
                        cnt += (int)(xmin <= p[m].first && p[m].first <= xmax && ymin <= p[m].second && p[m].second <= ymax);
                    }

                    if (cnt >= kmin)
                        ans = min(ans, (xmax - xmin) * (ymax - ymin));
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}

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

class B
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(string.Join("\n", new int[h[0]].Select(_ => Console.ReadLine()).Select(x => $"{x}\n{x}")));
	}
}


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

int main() {
  
  int i, N;
  cin >> N;
  
  for (i = 0; i < N; i++) {
    string op;
    cin >> op;
    
    if (op == "Y") {
      break;
    }
  }
  
  if (i == N) {
    cout << "Three" << endl;
  }
  
  else {
    cout << "Four" << endl;
  }
  
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define rep2(i, a, b) for(int i=a; i<=(int)(b); ++i)
#define all(v) v.begin(),v.end()
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  set<int> s;
  rep(i, k) {
    int x;
    cin >> x;
    rep(j, x) {
      int y;
      cin >> y;
      s.insert(y);
    }
  }
  cout << (n-s.size()) << endl;
}

Measured memory_bytes: 3656
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
main(int argc, char **argv)
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		int count = 0;
		while (n != 1)
		{
			if (n % 2 == 0)
				n /= 2;
			else
				n = 3 * n + 1;

			count++;
		}

		printf("%d\n", count);
	}

	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main(){
    ll x, y, i = 1;
    cin >> x >> y;
    while(x * 2 <= y){
        x *= 2;
        i++;
    }
    cout << i << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);

    if(a==1&&b==2||a==2&&b==1)
    {
        printf("3");
    }
    else if(a==1&&b==3||a==3&&b==1)
    {
        printf("2");
    }
    else if(a==2&&b==3||a==3&&b==2)
    {
        printf("1");
    }
    return 0;
}


Measured memory_bytes: 128
#define  _CRT_SECURE_NO_WARNINGS

#pragma comment(linker, "/STACK:256000000")

#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <deque>
#include <queue>
#include <iomanip>
#include <fstream>
#include <string>

#define ll long long 
#define ld long double 
#define fi(n) for(int i = 0; i < (n); i++)
#define FOR(i, k, n) for(int i = (k); i < (n); i++)

//const int INF = 2147483647;
const int INF = 1e9;
const long long lINF = 9223372036854775807;

using namespace std;

//#define cin in
//#define cout out

ifstream in;
ofstream out;

vector<ll> primes;
vector<ll> par;
vector<ll> rang;

void findePrimes(ll n)
{
	primes.push_back(2);
	par[2] = 2;
	for (ll i = 3; i < n; i += 2)
	{
		bool pr = true;
		for (auto e : primes)
			if (i % e == 0)
			{
				pr = false;
				break;
			}
		if (pr)
		{
			primes.push_back(i);
			par[i] = i;
		}
	}
}

ll findPar(ll k)
{
	if (par[k] == k)
		return k;
	par[k] = findPar(par[k]);
	return par[k];
}

int main()
{
	in.open("input.txt");
	out.open("output.txt");
	ll a, b;
	cin >> a >> b;
	cout << (a + b) % 24;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 5;
string a;
bool flag;
int i;
vector<char> v(N);
void solve(int s,int i)
{
    if(i == 4 and (!flag)){
        if(s == 7){
            flag = true;
            rep(i,0,4){
                cout<<a[i];
                if(i != 3) cout<<v[i+1];
            }
            cout<<"=7";
        }
        return;
    }
    if(not flag) v[i] = '+',  solve(s + (a[i] - '0'),i + 1);
    if(not flag) v[i] = '-',  solve(s - (a[i] - '0'),i + 1);
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a;
    solve(0,0);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

int array[200001];

void swap(int n1, int n2);
int partition(int left, int right);
void quicksort(int left, int right);

void swap(int n1, int n2)
{
    int temp = array[n1];
    array[n1] = array[n2];
    array[n2] = temp;
}

int partition(int left, int right)
{
    int pivot = array[right], i=left-1;
    for(int j=left; j<=right-1; j++){
        if(array[j] >= pivot){
            i++;
            swap(i, j);
        }
    }
    i++;
    swap(i, right);

    return i;
}

void quicksort(int left, int right)
{
    int j;
    if(left<right){
        j = partition(left, right);
        quicksort(left, j-1);
        quicksort(j+1, right);
    }
}

int compare(const void *a, const void *b)
{
	return *(int*)b - *(int*)a;
}


int main(){
	int n, k;
	long sum;
	scanf("%d%d", &n, &k);
	for(int i=0; i<n; i++){
		scanf("%d", &array[i]);
	}

	if(n<=k) printf("0\n");
	else{
		//quicksort(0, n-1);
		qsort(array, n, sizeof(int), compare);

		/*
		for(int i=0; i<n; i++){
			printf("%d\n", array[i]);
		}
		*/

		sum = 0;
		for(int i=k; i<n; i++){
			sum += array[i];
		}
		printf("%ld\n", sum);
	}

	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll N;cin>>N;
    rep1(h,3500){
        rep1(n,3500){
            ll a=N*n*h, b=4*h*n-N*(n+h);
            if(b>0&&a%b==0){
                ll res=a/b;
                cout<<h<<" "<<n<<" "<<res<<endl;
                return 0;
            }
        }
    }
}


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

    int n;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    int c=0;int f=0;
    for(int i=0;i<n;i++)
    {

   // sort(p,p+i);
    if(p[f]>=p[i])
       {
         f=i; c++;
       }
    }
    cout<<c;

}


Measured memory_bytes: 1024
N,M = map(int,input().split())
*A, = map(int,input().split())
import heapq
B = sorted(-a for a in A)
heapq.heapify(B)
for _ in [0]*M:
    b = -((-heapq.heappop(B))//2)
    heapq.heappush(B,b)
print(-sum(B))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin>>n>>x;
  vector<int> arr;
  int temp;
  for(int i=0; i<n; i++) {
  	cin>>temp;
  	arr.push_back(temp);
  }
  for(int i=0; i<n-1; i++)
  	arr[i+1] = arr[i]+ arr[i+1];
  std::vector<int>::iterator upper;
  upper = std::upper_bound(arr.begin(),arr.end(),x);
  cout<<upper-arr.begin()+1;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int field[14][14];
void bomb(int x, int y);
int main(){
  int n,x,y;
  cin >>n;
  for(int c=1; c<=n; c++){
    for(int i=0; i<8; i++) for(int j=0; j<8; j++) scanf("%1d",&field[j+3][i+3]);
    cin >>x>>y;
    bomb(x+2,y+2);
    cout <<"Data "<<c<<":"<<endl;
    for(int i=0; i<8; i++){
      for(int j=0; j<8; j++){
	cout <<field[j+3][i+3];
      }
      cout <<endl;
    }
  }
  return 0;
}
void bomb(int x, int y){
  field[x][y] = 0;
  if(field[x+1][y] == 1) bomb(x+1,y);
  if(field[x+2][y] == 1) bomb(x+2,y);
  if(field[x+3][y] == 1) bomb(x+3,y);
  if(field[x-1][y] == 1) bomb(x-1,y);
  if(field[x-2][y] == 1) bomb(x-2,y);
  if(field[x-3][y] == 1) bomb(x-3,y);
  if(field[x][y+1] == 1) bomb(x,y+1);
  if(field[x][y+2] == 1) bomb(x,y+2);
  if(field[x][y+3] == 1) bomb(x,y+3);
  if(field[x][y-1] == 1) bomb(x,y-1);
  if(field[x][y-2] == 1) bomb(x,y-2);
  if(field[x][y-3] == 1) bomb(x,y-3);
}

Measured memory_bytes: 1248
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

typedef long long LL;

int n, k;

int main()
{
    scanf("%d%d", &n, &k);
    
    if(!k)
    {
        printf("%lld\n", (LL)n * n);
        return 0;
    }
    
    LL res = 0;
    for(int b = k + 1; b <= n; b ++)
    {
        res += n / b * (b - k);
        if(n % b >= k)  res += n % b - k + 1;
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<uint32> a(n), b(n);
	for (uint32 i = 0;i < n;++i) {
		std::cin >> a[i];
	}
	for (uint32 i = 0;i < n;++i) {
		std::cin >> b[i];
	}
	std::vector<int64> c(n);
	int64 count=0;
	for (uint32 i = 0;i < n;++i) {
		c[i] = (int64)a[i] - (int64)b[i];
		if (c[i] < 0 && (-c[i]) % 2 == 1) {
			++c[i];
		}
		count += c[i];
	}
	count = -count;
	if (count < 0) {
		std::cout << "No\n";return 0;
	}
	uint32 c2 = 0, c1 = 0;
	for (uint32 i = 0;i < n;++i) {
		if (c[i] < 0) {
			c2 += (-c[i]) / 2;
		}
		else {
			c1 += c[i];
		}
	}
	if (count < c2 || count < c1) {
		std::cout << "No\n";
	}
	else {
		std::cout << "Yes\n";
	}
	return 0;
}

Measured memory_bytes: 512
N, M = map(int, input().split())
ls = []
dp = [float('inf')]*(1<<N)
for i in range(M):
  a, b = map(int, input().split())
  c = ['0']*N
  inf = [int(i)-1 for i in input().split()]
  for i in range(b):
    x = inf[i]
    c[x] = '1'
  m = ''.join(c)
  m = int(m,2)
  ls += [(a,m)]
  dp[m] = min(a,dp[m])
dp[0] = 0
for i in range(1<<N):
  for j in range(1<<N):
    dp[i|j] = min(dp[i|j], dp[i]+dp[j])
ans = dp[-1] if dp[-1]!=float('inf') else -1
print(ans)


Measured memory_bytes: 48728
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100000;

int n;

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

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

  if (n == 2) {
    int m = max(A[1], A[2]);
    cout << m << endl;
    return 0;
  }

  vector<int> L(n + 1);
  vector<int> R(n + 1);

  for (int i = 0; i < n; i++) {
    L[i + 1] = gcd(L[i], A[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    R[i] = gcd(R[i + 1], A[i]);
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    res = max(res, gcd(L[i], R[i + 1]));
  }

  cout << res << endl;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main{
    public static int M = 1046527;
    public static char H[][] = new char[M][14];
    public static char x[] = new char[14];
    public static void main(String...args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        String cmd, s;
        for(int i = 0; i < N; i++){
            char[] str = new char[14];
            cmd = scan.next();
            s = scan.next();
            for(int j = 0; j < s.length(); j++){
                str[j] = s.charAt(j);
            }
            if(cmd.charAt(0) == 'i') {
                insert(str);
            } else {
                if(find(str) == 1) {
                    System.out.println("yes");
                } else {
                    System.out.println("no");
                }
            }
        }
        scan.close();
    }
    
    public static int getChar(char ch) {
        if(ch == 'A') return 1;
        else if(ch == 'C') return 2;
        else if(ch == 'G') return 3;
        else if(ch == 'T') return 4;
        else return 0;
    }
    
    public static long getKey(char[] str) {
        long sum = 0;
        long p = 1;
        for(int i = 0; i < 14; i++){
            sum += p * (getChar(str[i]));
            p *= 5;
        }
        return sum;
    }

    public static int find(char[] str) {
        long key = getKey(str);
        int h;
        for(int i = 0;; i++) {
            h = (h1(key) + i * h2(key)) % M;
            if(isCheck(H[h], str)){
                return 1;
            } 
            else if(H[h][0] == x[0]) {
                return 0;
            }
        }
    }

    public static boolean isCheck(char[] c1, char[] c2) {
        for(int i = 0; i < 14; i++){
            if(c1[i] != c2[i]) {
                return false;
            }
        }
        return true;
    }
   
    public static void strcpy(char[] c1, char[]c2) {
        for(int i = 0; i < 14; i++) {
            c1[i] = c2[i];
        }
    }

    public static int insert(char str[]) {
        long key = getKey(str);
        int h;
        for(int i = 0;; i++){
            h = (h1(key) + i * h2(key)) % M;
            if(isCheck(H[h], str)) return 1;
            else if(H[h][0] == x[0]) {
                strcpy(H[h], str);
                return 0;
            }
        }
    }

    public static int h1(long key) {
        return (int)(key % M);
    }
    public static int h2(long key) {
        return (int)(key % (M - 1));
    }
}




Measured memory_bytes: 375656
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

    set<char> cs;
    for(int i = 0; i < 4; i++) cs.insert(S[i]);
    
    if(cs.size() != 2){
        cout << "No" << endl;
        return 0;
    }

    char top = S[0];
    int cnt = 0;

    for(int i = 1; i < 4; i++){
        if(S[i] == top) cnt++;
    }
    
    if(cnt != 1){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    ll a, b, x;
    cin >> a >> b >> x;
    a += (x - a % x) % x;
    b -= b % x;
    cout << (b - a) / x + 1 << endl;
    return 0;
}


Measured memory_bytes: 764
# s を一文字ずつ ord で文字コードに変換して n 分足し chr で文字列に元に戻し出力
# A..Z(65..90)

n = gets.to_i
s = gets.chomp.chars
ans = []

s.each do |i|
  if (i.ord + n) >= 91
    ans << (i.ord + n - 26).chr
  else
    ans << (i.ord + n).chr
  end
end

puts ans.join

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
const int MOD=1e9+7;
const int INF=1e18;
void io(string s="file"){freopen((s + ".in").c_str(), "r", stdin);freopen((s + ".out").c_str(), "w", stdout);}


signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    vii v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
    
    for(int i=0;i<n;i++){
        if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}



Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int n;
long long w[20],ans;
vector<pair<long long,long long> >dp[20][20];
pair<long long,long long>st[35357700];
int tp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&w[i]);
	for(int i=1;i<=n;++i)dp[i][i-1].emplace_back(make_pair(0,0));
	for(int len=1;len<=n-2;++len)
		for(int i=2,j=i+len-1;j<=n-1;++i,++j)
		{
			tp=0;
			for(int k=i;k<=j;++k)
				for(auto a:dp[i][k-1])
					for(auto b:dp[k+1][j])
						st[++tp]=make_pair(a.first+a.second+b.first+w[k],b.second+a.second+b.first+w[k]);
			sort(st+1,st+1+tp);
			long long mi=0x3f3f3f3f3f3f3f3f;
			for(int k=1;k<=tp;++k)if(st[k].second<mi)dp[i][j].emplace_back(st[k]),mi=st[k].second;
		}
//	int sum=0;
//	for(int i=1;i<=n;++i)
//		for(int j=i;j<=n;++j)
//			printf("%d %d %d\n",i,j,dp[i][j].size()),sum+=dp[i][j].size();
	ans=0x3f3f3f3f3f3f3f3f;
	for(auto a:dp[2][n-1])ans=min(ans,a.first+a.second);
	printf("%lld",ans+w[1]+w[n]);
//	printf("\n%d",sum);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;

    vector<string> S(N);

    int ans = 0;
    int num_a = 0;
    int num_b = 0;
    int ab = 0;
    REP(i, N)
    {
        int a = 0, b = 0;
        cin >> S.at(i);
        REP(j, S.at(i).size() - 1)
        {
            if (S.at(i).at(j) == 'A' && S.at(i).at(j + 1) == 'B')
                ans++;
        }

        if (S.at(i).at(S.at(i).size() - 1) == 'A' && S.at(i).at(0) == 'B')
        {
            num_a++;
            num_b++;
            ab++;
        }
        else if (S.at(i).at(0) == 'B')
            num_a += 1;
        else if (S.at(i).at(S.at(i).size() - 1) == 'A')
            num_b += 1;
    }

    if (num_a == num_b && num_a == ab)
        ans += max(min(num_a, num_b) - 1, 0);
    else
        ans += min(num_a, num_b);
    cout << ans;
}

Measured memory_bytes: 768
/******************************************************************************

рассвет.

*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int>
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s)
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i];
using namespace std;

const lli MOD=1e9+7;
const lli MAXN=5e4+1;
const ld PI=acos(-1);

int main(){
    rapgame
    //freopen("bridges.in", "r", stdin);
    //freopen("bridges.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
         ld w,h,x,y;
         cin >> w >> h >> x >> y;
         ld ans=w*h/2.0;
         cout << fixed << setprecision(30) << ans;
         if(x*2.0==w && y*2.0==h) cout << " 1";
         else cout << " 0";
    }
    return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define pb push_back
#define inf 0x3f3f3f3f
#define all(v) (v).begin() , (v).end()
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef long long   ll;

int dx[] = {0 , 0 , 1 , -1 , 1 , 1 , -1 , -1};
int dy[] = {1 ,-1 , 0 , 0 , -1 , 1 ,  1 , -1};



int main()
{
    int n , l;
    cin>> n >> l;
    string a[n];
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;++i){
        cout<<a[i];
    }
    cout<<endl;
    return 0;
}


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

using namespace std;

void solve()
{
	map<int, int> Map;
	for(int i = 1; i < 31; ++i)
	{
		Map[i] = 0;
	}
	for(int i = 0; i < 28; ++i)
	{
		int Num;
		cin >> Num;
		Map[Num]++;
	}
	for(int i = 1; i < 31; ++i)
	{
		if(Map[i] == 0)
		{
			cout << i << endl;
		}
	}
}

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

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

typedef long long ll;
const int MAX_N = 100000;

int main() {
	int N;
	ll a[MAX_N];

	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		std::cin >> a[i];
	}
	std::sort(a, a + N);

	int ans = 0, cnt = 0;
	ll last = a[0];
	for(int i = 0; i < N; ++i) {
		if(a[i] == last) ++cnt;
		else {
			if(cnt % 2 != 0) ++ans;
			cnt = 1;
			last = a[i];
		}
	}
	if(cnt % 2 != 0) ++ans;

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll n,k;
	cin>>n>>k;
	string ans="";
	while(n>0)
	{
		ans+=(n%k)+'0';
		n/=k;
	}
	cout<<(ll)ans.size();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
    int n ; cin >> n ;
    vector < int > a(n) ;
    for( int i = 0 ;i  < n ; i++) cin >> a[i] ;
    int element = 0 ;
    vector < int > answer ;
    while(element<=n){
        for( int i = n - 1 - element ; i >= 0 ; i--){
            if(a[i]-1 == i){
                answer.PB(a[i]);
                for( int j = i ; j < n-1 ; j++){
                        a[j] = a[j+1];
                }
                break ;
            }
        }
        element++;
    }
    if(answer.size()!=n){
        cout << -1 ;
        return ;
    }
    for( int i = answer.size() - 1 ; i >= 0 ; i--) cout << answer[i] << "\n" ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


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

const int MOD = 1000000000 + 7;

int main() {
	int n; cin >> n;
	vector<bitset<60>> b(n);
	for (int i = 0; i < n; i++) {
		long long a; cin >> a;
		b.at(i) = a;
	}
	long long ans = 0;
	long long p = 1;
	for (int i = 0; i < 60; i++) {
		int num1 = 0, num0 = 0;
		for (int j = 0; j < n; j++) {
			if (b.at(j).test(i)) num1++;
			else num0++;
		}
		ans += p * num1 % MOD * num0; ans %= MOD;
		p *= 2; p %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!T;r.popFront;}}

void main()
{
  int n; readV(n);
  int[] p; readA(n, p);

  auto r = 0;
  foreach (i; 0..n-1)
    if (p[i] == i+1) {
      ++r;
      swap(p[i], p[i+1]);
    }

  if (p[n-1] == n)
    ++r;

  writeln(r);
}


Measured memory_bytes: 3708
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val s = sc.next()
    var left = 0
    var right = s.substring(1 until n).count { it == 'E' }
    val first = left + right
    println((1 until n).map {
        if (s[it - 1] == 'W') left++
        if (s[it] == 'E') right--
        left + right
    }.plus(first).min())
}


Measured memory_bytes: 45400
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int ord[n];
    rep(i, n) ord[i] = i+1;
    rep(i, m){
        int a;
        scanf("%d", &a);
        --a;
        ord[a] = -i;
    }
    int idx[n];
    rep(i, n) idx[i] = i;
    sort(idx, idx+n, [&](const int &a, const int &b){return ord[a] < ord[b];});
    rep(i, n) printf("%d\n", idx[i]+1);
}


Measured memory_bytes: 4824
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

MB = 50

bits = [0] * (MB + 1)

for i in range(MB):
    for a in A:
        if a & (1 << i):
            bits[i] += 1

#print(bits)

def calc(k):
    r = 0
    for j in range(0, MB):
        if k & (1 << j):
            r += max(bits[j], N - bits[j]) << j
        else:
            r += bits[j] << j
    return r

result = calc(K)

for i in range(0, MB):
    m = 1 << i
    if K & m:
        k = K ^ m | (m - 1)
        r = calc(k)
        # print(k, r)
        result = max(result, r)

print(result)



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

long long N;

void rec(long long d, int use, long long &cnt) {
  if (d > N) return;
  if (use == 0b111) cnt++;

  rec(d * 10 + 7, use | 0b001, cnt);
  rec(d * 10 + 5, use | 0b010, cnt);
  rec(d * 10 + 3, use | 0b100, cnt);
}

int main() {
  cin >> N;
  long long res = 0;
  rec(0, 0, res); 
  cout << res << endl;
}

Measured memory_bytes: 256