akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; 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;
    }
}

// 二項係数計算
ll nCk(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;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    ll g = gcd(N,M);
    if(g == 1){
        cout << "1\n";
        return 0;
    }
    ll n = g;
    ll ans = 0;
    //vector<ll> yakusu;
    for(ll i = 2;i * i <= g;i++){/*
        if(g % i == 0){
            yakusu.push_back(i);
            if(i * i != g)yakusu.push_back(g / i);
        }*/
        if(n % i == 0){
            while(n % i == 0){
                n /= i;
            }
            ans++;
        }
    }
    if(isp(n))ans++;
    cout << ans + 1 << endl;
    /*
    ll s = yakusu.size();
    sort(all(yakusu));
    ll high = yakusu[s - 1];
    vector<bool> ok(high + 1,true);
    rep(i,s){
        if(ok[yakusu[i]] == true){
            for(ll j = yakusu[i] * 2;j <= high;j += yakusu[i]){
                ok[j] = false;
            }
        }
    }
    ll ans = 0;
    rep(i,s){
        if(ok[yakusu[i]] == true){
            ans++;
            //cout << yakusu[i] << "\n";
        }
    }
    //rep(i,s)cout << yakusu[i] << "\n";
    cout << ans + 1 << endl;*/
}

Measured memory_bytes: 3620
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define endl "\n"

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

void solve() {
	int n;
	cin >> n;

	vi a(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	int left, right, ans;
	if ((n & 1)) {
		left = a[n / 2];
		right = b[n / 2];
		ans = right - left + 1;
	} else {
		left = (a[n / 2] + a[n / 2 - 1]);
		right = (b[n / 2] + b[n / 2 - 1]);
		ans = right - left + 1;
	}

	cout << ans << endl;
}

signed main() {
	crap;

	solve();


	return 0;
}

Measured memory_bytes: 6328
// Example program
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;
vector<int>a;
int main()
{
  char s[100000];
  int a[28],d=0;
  cin>>s;
  int n=strlen(s);
  for(int i=0;i<n;i++){
      if(a[s[i]-'a']==1){
          d=1;
      }
      a[s[i]-'a']=1;
      
  }
  if(d==0){
      cout<<"yes";
  }
  else{
   cout<<"no";   
  }
}

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;
    if(A>=13){
        cout<<B<<endl;
    }else if(A>=6){
        cout<<B/2<<endl;
    }else{
        cout<<0<<endl;
    }
}

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

#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)

using ll = long long;
#define INF 1e9

int N;
vector<int> x, y, h;

int main(){
  cin >> N;
  x.resize(N), y.resize(N), h.resize(N);
  REP(i, N){
    cin >> x[i] >> y[i] >> h[i];
  }

  REP(i, 101){
    REP(j, 101){
      int dis = 300, idx = -1;
      REP(k, N){
        int d = abs(x[k]-i)+abs(y[k]-j);
        if(d < dis && h[k]!= 0){
          dis = d;
          idx = k;
        }
      }
      if(idx == -1) break;
      int H = h[idx] + abs(x[idx]-i)+abs(y[idx]-j);

      bool flag = true;
      REP(k, N){
        if(h[k] != max(H-abs(x[k]-i)-abs(y[k]-j),0)){
          flag = false;
          break;
        }
      }
      if(flag){
        cout << i << " " << j << " " << H << endl;
        return 0;
      }
    }
  }
  

  return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

int w,h;
string s[1000];
int n;
int x[1000],y[1000];
bool wall[1000];

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

#define IN(x,y) (0<=x && x<w && 0<=y && y<h)
int vis[1000][1000];
bool check(int q)
{
    rep(i,q) s[y[i]][x[i]]='.';
    memset(vis,0,sizeof(vis));

    bool ret=false;

    queue<pi> que;
    que.push(pi(0,0));
    vis[0][0]=true;
    while(!que.empty())
    {
        pi now=que.front();
        que.pop();

        if(s[now.fi][now.se]=='t')
        {
            ret=true;
            break;
        }

        rep(i,4)
        {
            int nx=now.se+dx[i], ny=now.fi+dy[i];
            if(IN(nx,ny) && s[ny][nx]!='#' && !vis[ny][nx])
            {
                vis[ny][nx]=1;
                que.push(pi(ny,nx));
            }
        }
    }

    rep(i,q) if(wall[i]) s[y[i]][x[i]]='#';
    return ret;
}

int main()
{
    while(cin >>w >>h)
    {
        rep(i,h) cin >>s[i];
        cin >>n;
        rep(i,n)
        {
            cin >>x[i] >>y[i];
            wall[i]=(s[y[i]][x[i]]=='#');
        }

        if(check(0))
        {
            printf("0\n");
            continue;
        }

        int l=0, r=n+1;
        while(r-l>1)
        {
            int m=(l+r)/2;

            if(check(m)) r=m;
            else l=m;
        }

        if(r==n+1) r=-1;
        printf("%d\n", r);
    }
    return 0;
}

Measured memory_bytes: 8104
#include <cstdio>
#include <algorithm>

#define ll long long
#define maxn 200000

int main() {
    int n, st, dr, l = 0;
    scanf("%d", &n);
    ll a[maxn + 1];
    int i = n / 2 + 1;
    st = i - 1;
    dr = i + 1;
    scanf("%lld", &a[i]);
    if (n % 2 != 0)
        l = 1;
    for (int j = 2; j <= n; j++) {
        if (l == 0) {
            scanf("%lld", &a[st]);
            st--;
        }
        else {
            scanf("%lld", &a[dr]);
            dr++;
        }
        l = 1 - l;

    }


    for (int i = 1; i <= n; i++)
        printf("%lld ", a[i]);
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#define INF 10e10

using namespace std;

//  #define y cout << "yes"<< endl
  #define Y cout << "YES" << endl
  #define y cout << "Yes" << endl
//  #define n cout << "no"<< endl
  #define N cout << "NO" << endl
  #define n cout << "No" << endl
  #define pu(q) cout << q ;
  #define put(q) cout << q << " ";
  #define puts(q) cout << q << endl;
  
  
	int a,b,c,d,e,f,g,h,ans,res;
//	char a,b,c,d,e,f,g,h,ans,res;
//	string a,b,c,d,e,f,g,h,ans,res;
//	double a,b,c,d,e,f,g,h,ans,res;
	
void take(int x);
  
int main(void){
	take(1);//数

puts(pow(a,3));	
	return 0;
}
void take(int x){
	if(x==1)
		cin >> a;
	else if(x==2)
		cin >> a >> b;
	else if(x==3)
		cin >> a >> b >> c;
	else if(x==4)
		cin >> a >> b >> c >> d;
	else if(x==5)
		cin >> a >> b >> c >> d >> e;
	else if(x==6)
		cin >> a >> b >> c >> d >> e >> f;
	else if(x==7)
		cin >> a >> b >> c >> d >> e >> f >> g;
	else if(x==8)
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
	return ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
string s;
  cin>>s;
  int p = 0;
  for(int i=0; i<s.size(); i++)
  {
    if(s[i]=='+')
      p++;
    else
      p--;
  }
  cout<<p<<endl;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
ai = list(map(int, input().split()))

ais = list(map(lambda x: x*(-1), ai))

heapq.heapify(ais)

for i in range(m):
    j = heapq.heappop(ais)
    heapq.heappush(ais, -(-j//2))
    #print(ais)

print(-sum(ais))

Measured memory_bytes: 14180
#include <stdio.h>
#include <algorithm>

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

	int* a = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	int* b = new int[M];
	int* c = new int[M];
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &b[i], &c[i]);
	}
	int* max = new int[N];

	std::pair<int, int>* ac = new std::pair<int, int>[N + M];
	for (int i = 0; i < N; i++) {
		ac[i] = std::pair<int, int>(a[i], 1);
	}
	for (int i = N; i < N + M; i++) {
		ac[i] = std::pair<int, int>(c[i - N], b[i - N]);
	}
	sort(ac, ac + N + M);
	long long res = 0;
	int cnt = 0;
	for (int i = N + M - 1; i >= 0; i--) {
		for (int j = 0; j < ac[i].second; j++) {
			res += ac[i].first;
			cnt++;
			if (cnt == N) {
				printf("%lld", res);
				//Sleep(10000);
				return 0;
			}
		}
	}
}

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

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	
	char x;
	int in = 1, out = 1;
	for(int i = 0; i < n; i++){
		cin >> x;
		if(x == 'a' && in+out-2 < a+b){
			cout << "Yes" << endl;
			in++;
		}else if(x == 'b' && in+out-2 < a+b && out <= b){
			cout << "Yes" << endl;
			out++;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int[] A = new int[H];
		for (int i = 0; i < H; i++) {
			A[i] = in.nextInt();
		}
		buildMaxHeap(A);
		for (int i : A) {
			System.out.print(" " + i);
		}
		System.out.println();
	}

	public static void buildMaxHeap(int[] A) {
		int H = A.length;
		for (int i = H / 2; i >= 0; i--) {
			maxHeapify(A, i);
		}
	}

	public static void maxHeapify(int[] A, int i) {
		int H = A.length;
		int l = 2 * i + 1;
		int r = 2 * i + 2;
		int largest;
		if (l < H && A[l] > A[i]) {
			largest = l;
		} else {
			largest = i;
		}
		if (r < H && A[r] > A[largest]) {
			largest = r;
		}

		if (largest != i) {
			int tmp = A[i];
			A[i] = A[largest];
			A[largest] = tmp;
			maxHeapify(A, largest);
		}
	}
}


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i%k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3648
// author: @Vitalosa

#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

template <typename T>
ostream& operator<< (ostream &f, const vector<T> &a){
    for(int i = 0; i < a.size()-1; ++i){ f << a[i] << ' '; }
    f << *(a.end()-1);
    return f;
}

template <typename T>
ostream& operator<< (ostream &f, const vector< vector<T> > &a){
    for(int i = 0; i < a.size()-1; ++i){ f << a[i] << endl; }
    f << *(a.end()-1);
    return f;
}

template <typename T>
istream& operator>> (istream &f, vector<T> &a){
    for(auto &el : a){ f >> el; }
    return f;
}

#define maxN 500500

#define int long long

char arr[maxN];

int cnt[maxN];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,p;
    cin>>n>>p;
    for (int i=1; i<=n; ++i){
        cin>>arr[i];
    }
    int st=1;
    int sum=0;
    int ans=0;
    if (p==2 || p==5){
        for(int i=1; i<=n; ++i){
            if ((arr[i]-'0')%p==0) ans+=i;
        }
    }else{
        for (int i=n; i>0; --i){
            sum+=st*(arr[i]-'0');
            st*=10;
            st%=p;
            sum%=p;
            ans+=cnt[sum];
            if (sum%p==0) ++ans;
            cnt[sum]++;
        }
    }
    cout<<ans<<"\n";
}

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

//#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int n,i,sum=0,j,m,count=0;
	cin >> n >> m;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
		sum+=v[i];
	}
	int x=4*m;
	//int ax = sum/x;
	//cout << ax << '\n';
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		//cout << v[i] << '\n';
		if(v[i]>=ceil(sum/(4.0*m)))
			count++;
	}
	if(count>=m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len=s.length();
    for(int i=0;i<len;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<len;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes\n";
                    return 0;
                }
            }
        }
    }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int r;
    cin >> r;
    double pi = acos(-1);
    cout << 2*pi*r << endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define ll long long int
#define inf 3e18+1
#define all(v) (v).begin(),(v).end() 
#define N 200005
#define F first 
#define S second 
using namespace std;
ll mod=1e9+7;
// ll parent[N];  
// ll size[N]; 
// ll find(ll i){
//     if(parent[i]!=i) {
//         parent[i]=find(parent[i]);
//     }
//     return parent[i];
// }
// void Union(ll x,ll y){
//     ll a=find(x);
//     ll b=find(y);
//     if(a==b) return;
//     parent[a]=parent[b];
// }
int main()
{
    // added the two lines below 
    ios_base::sync_with_stdio (false); 
    cin.tie(NULL);
    cout.tie(0);    
    ll test=1;//cin>>test;
    while(test--){
        ll n,k;
        cin>>n>>k;
        vector<ll>v(n);
        for(int i=0;i<n;i++){
            cin>>v[i];
        }
        ll dp[n];
        dp[0]=0;
        dp[1]=abs(v[0]-v[1]);
        for(int i=2;i<n;i++){
            dp[i]=INT_MAX;
            for(int j=i-1;j>=max((ll)0,i-k);j--){
                dp[i]=min(dp[j]+abs(v[i]-v[j]),dp[i]);
            }
            
        }
        cout<<dp[n-1];

    }
    return 0;
    
}




Measured memory_bytes: 4748
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> x(N),y(N);
  for(int i = 0; i < N; ++i){
    cin >> x[i];
    y[i] = x[i];
  }
  sort(x.begin(), x.end());
  int c1 = x[N/2-1];
  int c2 = x[N/2];
  for(int i = 0; i < N; ++i){
    if(y[i] <= c1) cout << c2 << endl;
    else cout << c1 << endl;
  }

}


Measured memory_bytes: 3712
public class Main {

	public static void main(String[] args) {
		String input = new java.util.Scanner(System.in).nextLine(); 
		String[] inputAry = input.split(" ");
		int a = Integer.parseInt(inputAry[0]);
		int b = Integer.parseInt(inputAry[1]);
		int mennseki = a * b;
		int nagasa = (a + b) * 2;
		System.out.println(mennseki + " " + nagasa);
	}
}

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

using namespace std;

int main() {
	int n, a, b;
	while ( cin >> n >> a >> b, n || a || b ) {
		vector<bool> f(n+1, false); f[0] = true;
		int x[2] = {a, b};
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < n+1; ++j) {
				if (f[j] && j+x[i] < n+1) {
					f[j+x[i]] = true;
				}
			}
		}

		int ans = 0;
		for (int i = 1; i < f.size(); ++i) {
			if (f[i]) ++ans;
		}
		cout << n-ans << endl;
	}
}

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

template<typename Mono>
class SegmentTree {
private:
	using F = std::function<Mono(Mono, Mono)>;
	std::vector<Mono> Node;
	long long Size;
	const F f;
	const Mono Unit;

public:
	SegmentTree(long long N, const F f, const Mono& M) : f(f), Unit(M) {
		Size = 1;
		while (Size < N) Size <<= 1;
		Node.assign(Size * 2, Unit);
	}

	void Set(long long N, long long X) {
		Node[N + Size] = X;
	}

	void Set(std::vector<Mono> V) {
		for (int i = 0; i < V.size(); i++) {
			Set(i, V[i]);
		}
		for (int i = Size - 1; i > 0; i--) Node[i] = f(Node[i * 2], Node[i * 2 + 1]);
	}

	void Set(Mono V[], long long S) {
		for (int i = 0; i < S; i++) {
			Set(i, V[i]);
		}
		for (int i = Size - 1; i > 0; i--) Node[i] = f(Node[i * 2], Node[i * 2 + 1]);
	}

	void update(long long K, long long X) {
		K += Size;
		Node[K] = X;
		while (K >>= 1) Node[K] = f(Node[K * 2], Node[K * 2 + 1]);
	}

	Mono query(long long A, long long B, long long K = 1, long long L = 0, long long R = -1) {
		if (R < 0) R = Size;
		if (B <= L || R <= A) return Unit;
		if (A <= L && R <= B) return Node[K];
		return f(query(A, B, K * 2, L, (L + R) / 2), query(A, B, K * 2 + 1, (L + R) / 2, R));
	}

	Mono operator[](const long long K) const { return Node[K + Size]; };

	long long size() { return Size; };

	void put() {
		std::cout << Size << '\n';
		for (int i = 1; i < Size * 2; i++) std::cout << Node[i] << ' ';
		std::cout << '\n';
	}
};

int main() {
	long long N, Q;
	std::cin >> N >> Q;
	SegmentTree<long long> Seg(N, [](long long A, long long B) {return std::min(A, B); }, INT_MAX);
	for (int i = 0; i < Q; i++) {
		long long Mode, A, B;
		std::cin >> Mode >> A >> B;
		if (Mode == 0) {
			Seg.update(A, B);
		}
		if (Mode == 1) {
			std::cout << Seg.query(A, B + 1) << '\n';
		}
	}
}


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

using namespace std;

int n,k;
int a[15];
int b[15];
int answer;

int main(){
    int i,x,poz=0,val,ok,aux,j;

    cin>>n>>k;

    for(i=1;i<=k;i++){
        cin>>x;
        a[x]++;
    }

    aux=n;

    while(n){
        poz++;
        b[poz]=n%10;
        n/=10;
    }

    ok=0;

    for(i=poz;i>0;i--){
        if(!ok){
            for(j=9;j>=b[i];j--)
                if(a[j]==0)
                    val=j;

            answer=answer*10+val;

            if(val>b[i])
                ok=1;
        }
        else{
            for(j=9;j>=0;j--)
                if(a[j]==0)
                    val=j;

            answer=answer*10+val;
        }
    }

    if(answer<aux){
        for(j=9;j>=1;j--)
            if(a[j]==0)
                val=j;

        cout<<val;

        if(a[0]==0)
            val=0;

        for(i=1;i<=poz;i++)
            cout<<val;
    }
    else
        cout<<answer;


    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);

		int n = 0;
		int m = 0;
		String conv[] = new String[124];
		String nextchar = "";
		while (true){
			n = Integer.parseInt(std.next());
			if (n==0){break;}

			Arrays.fill(conv, "");
			for(int i=0; i<2*n; i+=2){
				conv[i] = std.next();
				conv[i+1] = std.next();
			}

			m = Integer.parseInt(std.next());
			nextchar = "";
			for(int j=0; j<m; j++){
				nextchar = std.next();
				for (int i=0; i<2*n; i+=2){
					if (nextchar.equals(conv[i])){
						nextchar = conv[i+1];
						break;
					}
				}
				System.out.print(nextchar);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 68780
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ans=1
cnt=abs(a-(t-h[0]*0.006))
for i in range(1,n):
    if abs(a-(t-h[i]*0.006))<=cnt:
        cnt=abs(a-(t-h[i]*0.006))
        ans=i+1
    else:
        pass
print(ans)

Measured memory_bytes: 9200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var P = ReadLine().Replace(" ", "");
        var Q = ReadLine().Replace(" ", "");

        IEnumerable<string> GetPermutation(int n)
        {
            var stack = new Stack<string>();
            stack.Push("");
            while (0 < stack.Count)
            {
                var s = stack.Pop();

                if (s.Length == n)
                {
                    yield return s;
                    continue;
                }

                for (char c = '1'; c <= ('0' + n); c++)
                {
                    if (s.Contains(c))
                        continue;

                    stack.Push(s + c);
                }
            }
        }

        var permutations = GetPermutation(N).OrderBy(s => s).ToList();
        var ans = Math.Abs(permutations.IndexOf(P) - permutations.IndexOf(Q));

        WriteLine(ans);
    }
}


Measured memory_bytes: 37052
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
int m;
cin>>m;
cout<<48-m<<endl;
}

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

int main(){
    int X,Y,Z;
    cin>>X>>Y>>Z;

    int ans;
    if(X%(Y+Z)>=Z)ans=X/(Y+Z);
    else ans=X/(Y+Z)-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
//constexpr ll P = 1e9 + 7;
//constexpr ll P = 998244353;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

vector<vector<ll>> adj;
vector<ll> dp;

ll dfs(ll prev, ll now) {
	if (dp[now] >= 0) return dp[now];
	ll ret = -1;
	for (auto i : adj[now]) {
		if (i == prev) continue;
		ret = max(ret, dfs(now, i));
	}
	return dp[now] = ret + 1;
}

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

	ll n, m;
	cin >> n >> m;
	adj.resize(n);
	vector<ll> cnt(n, 0);
	while (m--) {
		ll x, y;
		cin >> x >> y;
		adj[x - 1].push_back(y - 1);
		cnt[y - 1]++;
	}

	dp.resize(n, -1);
	for (ll i = 0; i < n; i++) {
		if (cnt[i] == 0) dfs(-1, i);
	}

	ll ans = 0;
	for (ll i = 0; i < n; i++) ans = max(ans, dp[i]);
	cout << ans << endl;
}

Measured memory_bytes: 16284
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
vi adj[N];int p[N];
vi v;map<int,int>mp;
bool vis[N]={false};
int dfs(int x)
{
    vis[x]=true;
    v.pb(x);mp[p[x]]=1;
    for(auto y:adj[x])
    {
        if(!vis[y])
            dfs(y);
    }
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   rep(i,1,n+1)cin>>p[i];
   rep(i,0,m)
   {
       int u,v;
       cin>>u>>v;
       adj[u].pb(v);
       adj[v].pb(u);
   }
   int cnt=0;
   for(int i=1;i<=n;i++)
   {
       if(!vis[i])
       {
           v.clear();mp.clear();
           dfs(i);
           for(auto x:v)
           {
               if(mp[x])cnt++;
           }
       }
   }
   cout<<cnt<<endl;

}



Measured memory_bytes: 18676
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        Array.Sort(A);
        Array.Reverse(A);
        long ans = 1;
        long mod = 1000000007;

        for (int i = 0; i < N; i++)
        {
            if (A[i] != (N - 1) - (i / 2 * 2))
            {
                Console.WriteLine(0);
                return;
            }
            if (i % 2 == 1)
            {
                ans *= 2;
                ans %= mod;
            }
        }
        Console.WriteLine(ans);
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 16864
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a, b, c, d;
	cin >> a >> b >> c;
	d = b + c - a;
	if (d < 0)
	{
		d = 0;
	}
	cout << d << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

struct BIT {
private:
	vector<ll>Bit;
	ll N;
public:
	void init(ll n) {
		N = n;
		Bit.resize(n);
	}
	void add(ll a, ll w) {
		for (int x = a; x < N; x += x & -x) Bit[x] += w;
	}
	ll SUM(ll a) {
		ll ret = 0;
		for (int x = a; x > 0; x -= x & -x) ret += Bit[x];
		return ret;
	}
};

ll n, l, r, mid, m;
vector<int>a, b;

int main() {
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> m;
		a.eb(m);
		b.eb(m);
	}
	sort(ALL(b));
	b.erase(unique(ALL(b)), b.end());
	l = -1, r = b.size() - 1;
	while (r - l > 1) {
		mid = (r + l) / 2;
		ll sum = 0;
		BIT bit;
		bit.init(300010);
		int c = n + 1;
		int cnt = 0;
		bit.add(c, 1);
		for (int i = 0;i < n;i++) {
			if (a[i] <= b[mid])cnt++;
			else cnt--;
			sum += bit.SUM(c + cnt - 1);
			bit.add(c + cnt, 1);
		}
		if (sum < (n + 1)*n / 2 / 2 + 1)l = mid;
		else r = mid;
	}
	cout << b[r] << endl;
	return 0;
}

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

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 1000000;
int const modulo = 998244353;
int const modulo2 = 1000000007;
int const base = 26;
int pow[2][1 + nmax];

void precompute() {
  pow[0][0] = pow[1][0] = 1;
  for(int i = 1;i <= nmax; i++) {
    pow[0][i] = 1LL * pow[0][i - 1] * base % modulo;
    pow[1][i] = 1LL * pow[1][i - 1] * base % modulo2;
  }
}

class Hash {
public:
  int l;
  int number, number2;
  Hash(char ch = -1) {
    if(ch == -1) {
      l = number = number2 = 0;
    } else {
      l = 1;
      number = number2 = ch - 'a';
    }
  }
  
  Hash operator + (Hash a) const {
    Hash result;
    result.l = l + a.l;
    result.number = (1LL * number * pow[0][a.l] + a.number) % modulo;
    result.number2 = (1LL * number2 * pow[1][a.l] + a.number2) % modulo2;
    return result;
  }
  bool operator == (Hash a) const {
    return l == a.l && number == a.number && number2 == a.number2;
  }
  bool operator < (Hash a) const {
    if(l != a.l)
      return l < a.l;
    else if(number != a.number)
      return number < a.number;
    else
      return number2 < a.number2;
  }
};
std::string v[1 + nmax];
int id[1 + nmax];

bool compare(int x, int y) {
  return v[x].size() < v[y].size();
}
std::map<Hash, int> mp;

int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  int n;
  std::cin >> n;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  for(int i = 1;i <= n; i++)
    id[i] = i;
  std::sort(id + 1, id + n + 1, compare);
  ll result = 0;
  precompute();

  for(int i = 1;i <= n; i++) {
    int first[base] = {0};
    std::string &aux = v[id[i]];

    for(int j = 0; j < base; j++)
      first[j] = aux.size();
    Hash suff;
    
    for(int j = aux.size() - 1; 0 <= j; j--)
      first[aux[j] - 'a'] = j;

    for(int j = aux.size() - 1; 0 <= j; j--) {
      for(int h = 0; h < base; h++) {
        if(first[h] <= j) {
          Hash new_hash = Hash(h + 'a') + suff;
          if(mp.find(new_hash) != mp.end())
            result += mp[new_hash];
        }
      }
      suff = (Hash(aux[j]) + suff);
    }
    mp[suff]++;
  }
  std::cout << result;
  return 0;
}



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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


int main(){
    int n;
    cin>>n;
    vector<str> s(n);
    vector<ll> co(5,0);


    for(int i=0;i<n;i++){
        cin>>s.at(i);
        switch(s.at(i).at(0)){
            case 'M':
                co.at(0)++;
                break;
            case 'A':
                co.at(1)++;
                break;
                case 'R':
                co.at(2)++;
                break;
                case 'C':
                co.at(3)++;
                break;
                case 'H':
                co.at(4)++;
                break;
        }
    }

    ll ans=0;
    for(int i=0;i<5;i++){
        for(int j=(i+1);j<5;j++){
            for(int k=(j+1);k<5;k++){
                ans += co.at(i)*co.at(j)*co.at(k);
            }
        }
    }

    cout<<ans;



}

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

typedef long long ll;
const int N=3005;
int a[N],n;
ll f[N][N];

ll dp(int l,int r) {
	if(l>r) return 0;
	if(f[l][r]!=-4557430888798830400ll) return f[l][r];
	if(((l+r)&1)==((n+1)&1)) {
		f[l][r]=max(dp(l,r-1)+a[r],dp(l+1,r)+a[l]);
	}
	else {
		f[l][r]=min(dp(l,r-1)-a[r],dp(l+1,r)-a[l]);
	}
	return f[l][r];
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	memset(f,192,sizeof(f));
	printf("%lld\n",dp(1,n));
	
	return 0;
}


Measured memory_bytes: 71040
#include <iostream>
#include <set>
#include <list>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std; 

int
main(int argc, char const *argv[])
{
    int64_t n;
    cin >> n;

    vector<uint64_t> h(n);

    for (int64_t i = 0; i < n; ++i) {
	cin >> h[i];
    }

    int64_t ans = 0;
    int64_t cur = 0;
    for (int64_t j = 1; j < n; ++j) {
	if (h[j] > h[j-1]) {
	    if (cur > ans) {
		ans = cur;
	    }
	    cur = 0;
	} else {
	    cur++;
	}
    }
    if (cur > ans) {
	ans = cur;
    }

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


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const int INF=100000000LL;
typedef pair<int,int>P;
vector<P> v;
int n;
int main() {
	cin>>n;
	int a[3][101];
	int c[3][101]={};
	for(int i=1;i<=2;++i){
		for(int j=1;j<=n;++j)cin>>a[i][j];
	}
	for(int i=1;i<=2;++i){
		for(int j=1;j<=n;++j){
			c[i][j]=max(c[i-1][j],c[i][j-1])+a[i][j];
		}
	}
	cout<<c[2][n]<<endl;
	return 0;
}


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

int main(){
    stack<int> sta;
    char s[12];
    char res[12];
    int k=0;
    scanf("%s",s);
    int len=strlen(s);
    for(int i=0;i<len;i++){
        if(s[i]=='0' || s[i]=='1'){
            sta.push(s[i]);
            //printf("把s[%d]=%C压入栈。。\n",i,s[i]);
        }

        if(s[i]=='B' && !sta.empty()){
           // printf("把%c出栈。。\n",sta.top());
             sta.pop();
        }

    }
        while(!sta.empty()){
            res[k++]=sta.top();
            sta.pop();
        }
    for(int i=k-1;i>=0;i--){
        printf("%c",res[i]);
    }cout<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys


def solve(mid):
    print(mid)
    sys.stdout.flush()
    mid_state = input()
    if mid_state == "Vacant":
        print(mid)
        exit()
    if ok % 2 == mid % 2:
        if ok_state == mid_state:
            return True, mid_state
        else:
            return False, mid_state
    else:
        if ok_state == mid_state:
            return False, mid_state
        else:
            return True, mid_state

n = int(input())

print(0)
sys.stdout.flush()
ok = 0
ok_state = input()
if ok_state == "Vacant":
    print(0)
    exit()
    
print(n-1)
sys.stdout.flush()
ng = n-1
ng_state = input()
if ng_state == "Vacant":
    print(n-1)
    exit()


while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    judge, state = solve(mid)
    if judge:
        ok = mid
        ok_state = state
    else:
        ng = mid
        ng_state = state
print(ok)
exit()

Measured memory_bytes: 38852
n=int(input())
M=[list(map(int,input().split()))for _ in[0]*n]
d=[0]+[1e4]*~-n
p=[-1]*n
b=[1]*n
while 1:
 m,u=1e4,-1
 for i in range(n):
  if m>d[i]and b[i]:m,u=d[i],i
 if u<0:break
 b[u]=0
 for v in range(n):
  if b[v]and 1+M[u][v]and d[v]>M[u][v]:
   d[v],p[v]=M[u][v],u
print(sum(M[i][p[i]]for i in range(n)if p[i]+1))


Measured memory_bytes: 5900
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string a,b;
  cin>>a>>b;
  char c[2*n];
  for(int i=0,j=0;b[j]!='\0';i++,j++)
  {
    c[i]=a[j];
    c[++i]=b[j];
  }
  c[2*n]='\0';
  for(int i=0;i<2*n;i++)
	cout<<c[i];
  return 0;	
}  

Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<utility>
#include<vector>
using namespace std;
int main(){
  int n,q,ans,l,r,h,idx;
  char now_c;
  string s;
  cin >> n >> q;
  char t[q],d[q];
  cin >> s;
  for(int i=0;i<q;i++){
    cin >> t[i]>>d[i];
  }
  ans = n;
  l = -1;
  r = n;
  while(l+1<r){
    h = (l+r)/2;
    idx = h;
    now_c = s[idx];
    for(int i=0;i<q;i++){
      if(now_c==t[i]){
        idx += (d[i]=='L')?-1:1;
        if(idx<0||idx>=n){
          break;
        }
        now_c = s[idx];
      }
    }
//    cout <<l<<" "<<r<< h<<"idxx"<<idx<<endl;
    if(idx<0){
      l = h;
    }else{
      r = h;
    }
  }
  ans -= l+1;

  l = -1;
  r = n;
  while(l+1<r){
    h = (l+r)/2;
    idx = h;
    now_c = s[idx];
    for(int i=0;i<q;i++){
      if(now_c==t[i]){
        idx += (d[i]=='L')?-1:1;
        if(idx>=n||idx<0){
          break;
        }
        now_c = s[idx];
      }
    }
    if(idx>=n){
      r = h;
    }else{
      l = h;
    }
  //  cout <<l<<" "<<r<< h<<"idx"<<idx<<endl;
  }
  ans -= n-r;
  cout << ans<<endl;
}


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

int keta( int n ){
  int ret = 0 ;
  string S = to_string(n) ;
  rep( i , S.size() ) ret += S.at(i) - '0' ;
  return ret ;
}
int main() {
  int N ;
  cin >> N ;
  int A = keta(N) ;
  if( N % A == 0 ) cout << "Yes" << endl ;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+'){
            printf("%d\n",a+b);
        }else if(op=='-'){
            printf("%d\n",a-b);
        }else if(op=='*'){
            printf("%d\n",a*b);
        }else if(op=='/'){
            printf("%d\n",a/b);
        }else if(a==0 || b==0){
            break;
        }else if(op=='?'){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2088
import math
N,K = map(int,input().split())
prob = 0
for i in range(1,N+1):
  if i >= K:
    prob += 1/N
  else:
    m = math.ceil(math.log2(K) - math.log2(i))
    prob += (1/N) * (1/(2**m))

print(prob)

Measured memory_bytes: 3060
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7


a, b = input().split()
a = int(a)
b1 = int(b[:-3])
b2 = int(b[-2:])
print(a*b1+a*b2//100)


Measured memory_bytes: 72628
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;

    int x = n % 2 == 0 ? n : n * 2;
    writeln(x);
}

Measured memory_bytes: 256
#include  <stdio.h>
#define MAX 2000001

int A[MAX],B[MAX],C[MAX];

void ShowData(int n)
{
  int i;
  for (i = 1; i <= n ; i++){
    printf("%u", B[i]);
    if(i<n)printf(" ");
  }
  printf("\n");
}

void CountingSort( int n)
{
  int i, j, k;

  for (i=0;i<=MAX;i++)
  C[i] = 0;


  for (j=1;j<=n;j++){
    scanf("%d",&A[j]);
    C[A[j]]++;

  }
  for (i=1;i<=MAX;i++) {
    C[i] += C[i-1];
  }
  for (j=n;j>0;j--) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
    }

}

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

   CountingSort(n);
   ShowData(n);
  return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;

int main() {
	ll a, b, c, d, e, f, x, y;
	vector<ll> v1;
	vector<ll> v2;
	double ans = 0;
	pair<ll, ll> p = make_pair(0, 0);

	cin >> a >> b >> c >> d >> e >> f;

	REP(i, 30) {
		REP(j, 30) {
			x = 100 * a * i + 100 * b * j;

			if (x <= f) {
				v1.push_back(x);
			}
			else {
				break;
			}
		}
	}

	REP(i, 100) {
		REP(j, 100) {
			y = c * i + d * j;

			if (y <= f) {
				v2.push_back(y);
			}
			else {
				break;
			}
		}
	}

	REP(i, v1.size()) {
		REP(j, v2.size()) {
			if (v2[j] <= v1[i] * e / 100) {
				if (v1[i] + v2[j] != 0) {
					if (v1[i] + v2[j] <= f) {
						if (100.0 * v2[j] / (v1[i] + v2[j]) > ans) {
							ans = 100.0 * v2[j] / (v1[i] + v2[j]);
							p = make_pair(v1[i] + v2[j], v2[j]);
						}
					}	
				}
			}
		}
	}

	if (ans == 0) {
		p = make_pair(100 * a, 0);
	}

	cout << p.first << " " << p.second << endl;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		ArrayList<Long> list = new ArrayList<>();

		list.add((long) 2);
		list.add((long) 1);

		for(int i = 2; i <= N; i++) {
			list.add(list.get(i - 1) + list.get(i - 2));
		}
		System.out.println(list.get(N));
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;

    ll ans = 0;
    map<ll, ll> cnt;
    for (ll x = 1; x <= 200; x++) {
        for (ll y = 1; y <= 200; y++) {
            for (ll z = 1; z <= 200; z++) {
                cnt[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }

    for (ll i = 1; i <= N; i++) {
        cout << cnt[i] << "\n";
    }
}


Measured memory_bytes: 14100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#define MOD_P 1000000007
#define ll long long
using namespace std;



int main()
{
	int n;
	cin >> n;
	vector<int> ar(n + 1);
	vector<bool> put(n + 1, false);
	int ans = 0;

	for (int i = 1; i <= n; i++) {
		cin >> ar[i];
	}

	for (int i = n; i > 0; i--) {
		int sum = 0;
		for (int j = i * 2; j <= n; j += i) {
			if (put[j])sum++;
		}
		//printf("sum(%d) = %d\n", i, sum);
		if (sum % 2 == ar[i])continue;
		put[i] = true;
		ans++;

	}

	printf("%d\n", ans);
	for (int i = 1; i <= n; i++) {
		if (put[i])printf("%d ", i);
	}


	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] S = new char[H][W];
		for (int i=0;i<H;i++) {
			String tmp = sc.next();
			for (int j=0;j<W;j++) {
				S[i][j] = tmp.charAt(j);
			}
		}
		int ans = 0;

		for (int i=0;i<H;i++) {
			for (int j=0;j<W;j++) {
				int sh = i;
				int sw = j;
				int dist = 0;
				int[] first = {sh, sw, dist};
				boolean[][] visited = new boolean[H][W];
				ArrayDeque<int[]> queue = new ArrayDeque<int[]>();
				queue.add(first);
				while (!queue.isEmpty()) {
					int[] rem = queue.poll();
					if (rem[0]<0 || H<=rem[0] || rem[1]<0 || W<=rem[1]) continue;
					if (S[rem[0]][rem[1]]=='#') continue;
					if (visited[rem[0]][rem[1]]) continue;
					visited[rem[0]][rem[1]] = true;
					ans = Math.max(ans, rem[2]);

					int[] add_1 = {rem[0]+1, rem[1], rem[2]+1};
					int[] add_2 = {rem[0]-1, rem[1], rem[2]+1};
					int[] add_3 = {rem[0], rem[1]+1, rem[2]+1};
					int[] add_4 = {rem[0], rem[1]-1, rem[2]+1};
					queue.add(add_1);
					queue.add(add_2);
					queue.add(add_3);
					queue.add(add_4);
				}
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 37520
from collections import defaultdict

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

B = [0] * N
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i - 1] + A[i]
B = [0] + B

c = defaultdict(int)
for i in range(N + 1):
    c[B[i] % M] += 1

ans = 0
for k, v in c.items():
    if v >= 2:
        ans += v * (v - 1) // 2
print(ans)

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

int cnt = 0;
long n;

void dfs(long sangona) {
  if (sangona > n) return;
  int flag3 = 0, flag5 = 0, flag7 = 0;
  string s = to_string(sangona);

  for (int i = 0; i < s.size(); i++) {
    if (flag3 && flag5 && flag7)
      break;
    else if (s[i] == '3')
      flag3 = 1;
    else if (s[i] == '5')
      flag5 = 1;
    else if (s[i] == '7')
      flag7 = 1;
  }
  if (flag3 && flag5 && flag7) cnt++;

  dfs(sangona * 10 + 3);
  dfs(sangona * 10 + 5);
  dfs(sangona * 10 + 7);
  return;
}

int main() {
  cin >> n;

  dfs(0);

  cout << cnt;

  return 0;
}

Measured memory_bytes: 256