akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

template<class T>
struct SegTree {
  using FX = function<T(T, T)>;
  int n;
  FX fx;
  const T ex;
  vector<T> dat;
  SegTree(int n_, FX fx_, T ex_):fx(fx_), ex(ex_), n(1) {
    while(n < n_) n <<= 1;
    dat.assign((n<<1)-1, ex);
  }
  inline int chld(int k) {return (k<<1)+1;}
  inline int chrd(int k) {return (k<<1)+2;}
  void update(int i, T x) {
    i += n-1;
    dat[i] = x;
    while(i) {
      i = (i-1)>>1;
      dat[i] = fx(dat[chld(i)], dat[chrd(i)]);
    }
  }
  inline T query(int a, int b) {return query(a, b, 0, 0, n);}
  T query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return ex;
    if(a <= l && r <= b) return dat[k];
    T vl = query(a, b, chld(k), l, (l+r)>>1);
    T vr = query(a, b, chrd(k), (l+r)>>1, r);
    return fx(vl, vr);
  }
  const T &operator[](int idx) const {return dat[idx+n-1];}
};

const int N = 2e5+10;

//head

int n;
int h[N];
int a[N];
SegTree<ll> seg(N, [](ll i, ll j)->ll{return max(i, j);}, 0);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) cin >> h[i];
  rep(i, n) cin >> a[i];
  rep(i, n) {
    ll ma = seg.query(0, h[i]);
    seg.update(h[i]-1, ma+a[i]);
  }

  cout << seg.query(0, n) << endl;
}

Measured memory_bytes: 9020
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

ll a,b,ab;
ll x,y;
/// abピザをk枚買うと
//aを max(0,x-k)枚、bをmax(0,y-k)枚

int main(){

  cin>>a>>b>>ab>>x>>y;
  ll ans=1000000000;
  for(ll i=0;i<=max(x,y);i++){
    ll cost=ab*2*i + max(0LL,x-i)*a + max(0LL,y-i)*b;
    ans=min(ans,cost);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> a(n);
    for (int &x : a) {
        cin >> x;
    }
    int res = 0;
    for (int i = 1; i < n - 1; i++) {
        vector<int> b = {a[i - 1], a[i], a[i + 1]};
        sort(b.begin(), b.end());
        res += (b[1] == a[i]);
    }
    cout << res << "\n";
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  string T = "", U = "";
  for (int i = 0; i < S.size(); ++i) {
    if (i < S.size() / 2)
      T += S[i];
    else
      U += S[i];
  }
  //cout << T <<" " << U << endl;
  if (T == U)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
 int A[1000], v;
 int i, j, n;
 scanf("%d", &n);
 for(i=0; i<n; i++) scanf("%d", A+i);
 for(i=0; i<n; i++){
  v = A[i];
  j=i-1;
  while(j>=0 && v<A[j]){
   A[j+1] = A[j];
   j--;
  }
  A[j+1] = v;
  printf("%d", A[0]);
  for(j=1; j<n; j++){
   printf(" %d", A[j]);
  }
  puts("");
 }
 return(0);
}

Measured memory_bytes: 616
/*
#include<rabbit>;
using blueHulkStress;
using AceOfSpades;
*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};

int main(int argc, char const *argv[])
{
	
	ll l, r, ans = LLONG_MAX;cin>>l>>r;

	if ((l - 1 ) / 2019 != r / 2019)
	{
		ans = 0;
	}

	r = min(r,l + 2019);

	for (int i = l; i < r; ++i)
	{
		for (int j = i + 1; j <= r; ++j)
		{
			ans = min(ans, ((i % 2019LL) * (j % 2019LL)) % 2019LL);
		}
	}
	cout<<ans;
}	

Measured memory_bytes: 256
s = STDIN.gets.chomp

splits = s.scan(/.{1,2}/)

yy_mm = true
mm_yy = true

if splits[0].to_i > 12
  mm_yy = false
elsif splits[0].to_i == 0
  mm_yy = false
end

if splits[1].to_i  > 12
  yy_mm = false
elsif splits[1].to_i == 0
  yy_mm = false
end


result = if yy_mm
           if mm_yy
             "AMBIGUOUS"
           else
             "YYMM"
           end

         else
           if mm_yy
             "MMYY"
           else
             "NA"
           end
         end

puts result

Measured memory_bytes: 1788
#include<iostream>
#include<math.h>
#include <iomanip>

using namespace std;

int next_idx(int max_n, int cor, int dice){
    int output;
    if(cor+dice <= max_n){
         output = cor+dice;
     } else {
         output = max_n - (cor+dice-max_n);
     }
     return output;
}

int main(){
    while(1){
        int N, T, L, B;
        int MAX_N = 100, MAX_T = 100;

        int l[MAX_N];
        int b[MAX_N];

        float dp[MAX_T+1][MAX_N+1];
        int map[MAX_N+1];

        cin >> N >> T >> L >> B;

        if (N==0) break;

        for(int i=0; i<L; ++i){
            cin >> l[i];
        }
        for(int i=0; i<B; ++i){
            cin >> b[i];
        }

        for(int i=0; i<=MAX_N; ++i){
            map[i] = 0;
        }
        for(int i=0; i<L; ++i){
            map[l[i]] = 1;
        }
        for(int i=0; i<B; ++i){
            map[b[i]] = 2;
        }

        for(int i=0; i<=MAX_T; ++i){
            for(int j=0; j<=MAX_N; ++j){
                dp[i][j] = 0;
            }
        }
        
        dp[0][0] = 1;
        for(int i=0; i<T; ++i){
            dp[i+1][N] += dp[i][N];
            for(int j=0; j<N; ++j){
                for(int k=1; k<=6; ++k){
                    int next = next_idx(N, j, k);
                    if(map[next] == 1 && i+2<=T){
                        dp[i+2][next] += dp[i][j]/6;
                    } else if(map[next] == 1 && i+1==T) {
                        dp[i+1][next] += dp[i][j]/6;
                    } else if(map[next]==2) {
                        dp[i+1][0] += dp[i][j]/6;
                    } else {
                        dp[i+1][next] += dp[i][j]/6;
                    }
                }
            }
        }

        cout << fixed << setprecision(6) << dp[T][N] << endl;
    }
}

Measured memory_bytes: 3300
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

	mp::cpp_int a, b, c;
	cin >> a >> b >> c;
    if(a+b>=c)
    {
        cout<<"No"<<endl;
        ret;
    }
    
	c -= a + b;
	c *= c;
	a = (a * b * 4);

	if (a<c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int x, a, b, c;
	cin >> x;
	cin >> a;
	cin >> b;
	x = x - a;
	for (int i = 1; i < 10000; i++){
		x = x - b;
		if (x < b){
			cout << x;
			return 0;
		}
}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int n = scan.nextInt();
	    int d = scan.nextInt();
	    int x = scan.nextInt();
	    int a[]=new int[n];
	    for(int i=0;i<n;i++) {
	    	a[i]=scan.nextInt();
	    }
	    scan.close();
	    int sum=0;
	    for(int i=0;i<n;i++) {
	    	for(int j=0;a[i]*j+1<=d;j++) {
		    	sum+=1;
		    }
	    }
	    System.out.println(sum+x);
	}

}


Measured memory_bytes: 21588
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String text = sc.next();
        int count = 0;
        while (sc.hasNext()) {
            String str = sc.next();
            if (str.equals("END_OF_TEXT")){
                break;
            }
            if (str.compareToIgnoreCase(text) == 0){
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26276
<?php
while(true) {
  $k = trim(fgets(STDIN));
  if ($k == 0) {
    break;
  }

  $year = trim(fgets(STDIN));

  $motoris = array();
  for ($i =0; $i < $k; ++$i) {
    $a = explode(' ', fgets(STDIN));
    if ($a[2] == 1) {
      $motoris[$a[0]] = (1 + $year * ($a[1] / 100));
    } else {
      $motoris[$a[0]] = pow(1 + ($a[1] / 100), $year);
    }
  }

  arsort($motoris);
  $b = array_keys($motoris);
  echo $b[0] . PHP_EOL;

}

Measured memory_bytes: 15720
let readInt () = Scanf.scanf " %d" (fun x -> x)

let solve n a =
  let b = Array.make n (-1) in
  let rec go i =
    if i < 1 then ()
    else
    let rec sumPrev s j =
      if j > n then s else sumPrev (s + b.(j-1)) (j + i)
    in
    let tot = sumPrev 0 (2*i) mod 2 in
    (*Printf.printf "%d %d %d\n" i tot a.(i-1);*)
    b.(i-1) <- if tot = a.(i-1) then 0 else 1;
    go (i-1)
  in go n;
  let rec go (k, acc) i =
    if i < 1 then (k, acc)
    else go (if b.(i-1) = 1 then (k+1, i :: acc) else (k, acc)) (i-1)
  in go (0, []) n

let main () =
  let n = readInt () in
  let a = Array.init n (fun _ -> readInt ()) in
  let (k, ans) = solve n a in
  Printf.printf "%d\n" k;
  ans |> List.iter (fun x -> Printf.printf "%d " x);
  print_endline ""

let () = main ()


Measured memory_bytes: 9344
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int N = Integer.parseInt(in.next());
		int K = Integer.parseInt(in.next());
		int ans = 1;
		for(int i = 0; i < N; i++){
			if(ans + K < ans * 2)ans += K;
			else ans += ans;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22868
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        r: i32,
        g: i32
    }
    let ans = 2 * g - r;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	long long N, A, B;
	cin >> N >> A >> B;

	if ((B - A) % 2 == 0) {
		cout << (B - A) / 2 << endl;
	}
	else {
		long long ans1 = A + (B - A - 1) / 2;
		long long ansN = (N - B + 1) + (B - A - 1) / 2;
		cout << min(ans1, ansN) << endl;
	}
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

int main(){
    const ll MX=1000000;
    ll n;
    cin>>n;
    vector<ll> a(n);
    map<ll,ll> M;
    for(auto &I:a){
        cin>>I;
        ll k=1;
        for(ll i=2;i*i*i<=I;i++){
            while(I%(i*i*i)==0){I/=i*i*i;}
        }
        M[I]++;
    }
    ll ans=0;
    for(auto I=M.begin();I!=M.end();++I){
        if(I->second==0){continue;}
        if(I->first==1){ans+=min(1LL,I->second); I->second=0;}
        else{
            ll k=I->first;
            ll o=1;
            ll d=1;
            for(ll i=2;i*i*i<=k;i++){
                if(k%(i*i)==0){d*=i; k/=i*i;}
                if(k%i==0){o*=i; k/=i;}
            }
            if(k!=1){
                ll s=sqrt(k);
                for(ll i=max(2LL,s-100);i<=s+100;i++){
                    if(k%(i*i)==0){k/=(i*i); d*=i;}
                }
            }
            o*=k;
            if(o>=MX){
                ans+=I->second;
                I->second=0;
            }
            else{
                if(M.count(o*o*d)){
                    auto T=M.find(o*o*d);
                    ans+=max(I->second,T->second);
                    I->second=0; T->second=0;
                }
                else{
                    ans+=I->second;
                    I->second=0;
                }
            }
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 7332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, max;

			var word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);


			max = a + b;
			if (max < a - b)
				max = a - b;

			if (max < a * b)
				max = a * b;

			Console.WriteLine(max);

			Console.ReadKey();

		}
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

int main() {
  int h, w, n; cin >> h >> w >> n;
  vector<int> a(n); REP(i,n) cin >> a[i];
  vector<vector<int>> c(h, vector<int>(w));
  int x = 0, y = 0;
  REP(i,n) {
    REP(j,a[i]) {
      c[x][y] = i+1;
      
      if (x%2==0) {
        if (y == w-1) x++;
        else y++;
      } else {
        if (y == 0) x++;
        else y--;
      }
    }
  }
  REP(i,h) {
    REP(j,w) {
      cout << c[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
from sys import stdin
R, G, B, N = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(3001):
  for j in range(3001):
    tmp = i*R+j*G
    if N >= tmp and (N-tmp)%B == 0:
      ans += 1
print(ans)


Measured memory_bytes: 32364
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


vector<vector<int>> change;
vector<int> cost(10, MOD);

void setting(){
  // changeの情報を元に各々の数字を1を変えるのに必要なコストcostをセットする
  set<int> yet;
  for (int i=0; i<10; i++) yet.insert(i);
  set<int> s;
  while (!yet.empty()){
    // 1.setに入ってないもので最も値の小さい物をsetに入れる
    int costmin = MOD, mindex = 10;
    for (auto value : yet){
      if (cost.at(value) < costmin){
        costmin = cost.at(value); mindex = value;
      }
    }
    yet.erase(mindex);
    s.insert(mindex);
    // 2.setに入っていないものから入っているものを介してより小さな値にできるかチェック
    for (auto vyet : yet){
      for (auto vs : s){
        chmin(cost.at(vyet), cost.at(vs) + change.at(vyet).at(vs));
      }
    }

  }

}

int main() {
  int h,w; cin >>h >>w;
  change.assign(10, vector<int>(10, 0));
  rep(i, 10) rep(j, 10) cin >>change.at(i).at(j);
  vector<int> a(10);
  rep(i, h){
    rep(j, w){
      int buf; cin >>buf;
      if (buf == -1) continue;
      a.at(buf)++;
    }
  }

  for (int i=0; i<10; i++) cost.at(i) = change.at(i).at(1);
  setting();

  ll ans = 0;
  for (int i=0; i<10; i++){
    ans += a.at(i) * cost.at(i);
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>


using namespace std;

void Solution()
{
    int c1, c2, c3;
    
    while(cin>>c1>>c2>>c3)
    {
        int cardUse[10] = {0};
        int sumCheck = 20;
        
        double cardAdd = 0;
        
        sumCheck -= c1 + c2;
        
        cardUse[c1 - 1] = 1;
        cardUse[c2 - 1] = 1;
        cardUse[c3 - 1] = 1;
        
        for(int i = 0; i < 10; i++)
        {
            if(cardUse[i] == 0)
            {
                if(i >= sumCheck)
                {
                    cardAdd++;
                }
            }
        }
        
        if(cardAdd / (10 - 3) <= 0.5) // cardAdd/n is probability
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
}

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

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

int main(){
  int X;
  cin >> X;
  for(int i = -1000; i < 500000; i++){
    for(int j = -10000; j < i; j++){
      if((i*i*i*i*i - j*j*j*j*j) == X){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  int ans = 10000;
  vector<int> p(n);
  
  rep(i,n){
  cin >> p[i];
    int cnt = 0;
    rep(j,30){
      if(p[i]%2==0) {
      cnt++;
      p[i]/=2;
      }
      else break;
    }
  ans = min(ans,cnt);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

int main(){
    int n, m;
    map<string, int> card;

    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        map<string, int>::iterator it = card.find(s);
        if (it == card.end()){
            card.insert(make_pair(s, 1));
        }
        else{
            it->second++;
        }
    }
    scanf("%d", &m);
    for(int i = 0; i < m; i++){
        string s;
        cin >> s;
        map<string, int>::iterator it = card.find(s);
        if (it == card.end()){
            card.insert(make_pair(s, -1));
        }
        else{
            it->second--;
        }
    }

    int ans = 0;
    for(map<string, int>::iterator it = card.begin(); it != card.end(); it++){
            ans = max(ans, it->second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# 入力
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

INF = 10 ** 9


def dfs(cursor, a, b, c):  # cursor:カーソル a,b,c:現在の竹の長さ
    if cursor == N:  # cursorが最後まで行ったら終了する。
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    # abs(a - A) + abs(b - B) + abs(c - C) - 30 でなぜ30を減じているのかというと、
    # dfs(0,0,0)
    # dfs(0,0,0,0)で始まる以上、最初に選ばれるa,b,cを決定する際にもコストが10増加してしまうからである。
    # また、全探索を行う中で、a,b,cの初期値が0,0,0である以上、a,b,cのどれかが0のまま終了する場合が存在する。
    # この場合はa,b,cに竹が対応してないと言えるため、解にはならない、そこで三項演算子を利用して
    # その場合についてコストをINFとしている

    # 以下は4**Nで展開される再起処理となる。
    # カーソルの当たっている竹に対して、(A or B or Cに合成する) or (合成しない)の場合に分ける
    no_compound_pattern = dfs(cursor+1, a, b, c)
    compound_a_pattern = dfs(cursor+1, a + L[cursor], b, c)+10
    compound_b_pattern = dfs(cursor+1, a, b + L[cursor], c)+10
    compound_c_pattern = dfs(cursor+1, a, b, c + L[cursor])+10

    # 結果的に以下の値が返るのはそれぞれのパターンのコストが決定されてからなので
    # 以下のコードは最終的なコストの最小値
    return min(no_compound_pattern, compound_a_pattern, compound_b_pattern, compound_c_pattern)


print(dfs(0, 0, 0, 0))


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll a,b,c,d,x,y;
	cin >>a >>b >>c >>x >>y;
	ll ans = a * x + b * y;
	rep(i, max(x,y)*2+1){
		ll na=max(0LL, x-i/2), nb=max(0LL, y-i/2);
		ll cnd = c*i;
		cnd += a*na + b*nb;
		ans = min(ans, cnd);
	}
	cout << ans <<"\n";
	return 0;
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int a ;

int main() {
  cin >> a ;
  if( a / 100 == a % 10 ){
    cout << "Yes\n" ;
  } else cout << "No\n" ;
}


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

constexpr int MOD = 998'244'353;

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(long long e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e & 1) {a = (a * p) % mod; e--;}
            else {p = (p * p) % mod; e /= 2;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

int main() {
	int n, s;
	cin >> n >> s;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	ModInt<MOD> dp[n + 1][s + 1];
	dp[0][0] = 2;
	dp[0][0] = dp[0][0].pow(n);
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= s; j++) {
			dp[i + 1][j] += dp[i][j];
		}
		for (int j = 0; j <= s; j++) {
			if (j + a[i] <= s) {
				dp[i + 1][j + a[i]] += dp[i][j] / 2;
			}
		}
	}
	
	cout << dp[n][s] << '\n';
	
	return 0;
}
	

Measured memory_bytes: 38780
N, M = [int(x) for x in input().split()]

XYZ = []

p1 = []
p2 = []
p3 = []
p4 = []
p5 = []
p6 = []
p7 = []
p8 = []
for i in range(N):
    x, y, z = [int(x) for x in input().split()]
    p1.append(x + y + z)
    p2.append(x - y + z)
    p3.append(-x + y + z)
    p4.append(-x - y + z)
    p5.append(x + y - z)
    p6.append(x - y - z)
    p7.append(-x + y - z)
    p8.append(-x - y - z)

p1.sort(reverse=True)
p2.sort(reverse=True)
p3.sort(reverse=True)
p4.sort(reverse=True)
p5.sort(reverse=True)
p6.sort(reverse=True)
p7.sort(reverse=True)
p8.sort(reverse=True)

v1 = sum(p1[:M])
v2 = sum(p2[:M])
v3 = sum(p3[:M])
v4 = sum(p4[:M])
v5 = sum(p5[:M])
v6 = sum(p6[:M])
v7 = sum(p7[:M])
v8 = sum(p8[:M])

print(max(v1, v2, v3, v4, v5, v6, v7, v8))



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

int main(){
    int n; cin >> n;
    vector<int> arr(n);
    rep(i,n) cin >> arr[i];
    sort(arr.begin(),arr.end());
    cout << arr[n-1] - arr[0] << endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N+1-x):
        if 10000*x + 5000*y + 1000*(N - x - y) == Y:
            print(x, y, N - x - y)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 40684
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

ll arr[200005];
int main(){
    IOS
    //freopen("output.txt","w",stdout);

    int n;
    cin>>n;



    unordered_map<ll,ll>left,right;

    for(int i=1;i<=n;i++){
        cin>>arr[i];
        left[arr[i]+i]++;
        right[i-arr[i]]++;
    }
    ll ans = 0;
    for(auto it=left.begin();it!=left.end();it++){
        ans+=(*it).second*right[(*it).first];
        //cout<<(*it).first<<" "<<(*it).second<<"\n";
    }

    cout<<ans<<"\n";
}


Measured memory_bytes: 27756
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for i in range(n+1):
    for j in range(n+1):
        if i + j <= k and i + j <= n:
            g = v[:i] + v[n-j:]
            g.sort()
            for l in range(min(k-i-j, i+j)+1):
                ans = max(ans, sum(g[l:]))

print(ans)


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
int T,A;
char S[101010];
int i,a;
int main(){
    scanf("%d%d%s", &T, &A,S);
    S[A - 1] = S[A - 1] + 32;
    printf("%s",S);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
	int n,m;
	while(cin>>n>>m,n){
        vi code(m);
        rep(i,m)cin>>code[i];
        vvi dp(n+1,vi(256,INF));
        dp[0][128]=0;
        range(i,1,n+1){
            int num; cin>>num;
            rep(j,256){
                rep(k,m){
                    int next=min(max(j+code[k],0),255);
                    int diff=num-next;
                    dp[i][next]=min(dp[i][next],dp[i-1][j]+diff*diff);
                }
            }
        }
        cout<<*min_element(all(dp[n]))<<endl;
	}
	return 0;
}

Measured memory_bytes: 23712
#include<stdio.h>
int main(){
  int W, H, x, y, r;
  scanf("%d %d %d %d %d\n", &W, &H, &x, &y, &r);
  if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;
typedef long long LL;

// import here

int main(){
    LL x, y;
    cin >> x >> y;
    if(x % y == 0){
        cout << -1 << endl;
        return 0;
    }
    cout << x << endl;
    return 0;
}

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

int main(void) {
	int N;
	scanf("%d", &N);
	int a[200100];
	int ans = 0;
	int target = 1;
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		if (a[i] != target) {
			ans++;
		} else {
			target++;
		}
	}
	if (ans == N) printf("-1\n");
	else printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 4564
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	a--;b--;c--;d--;
	string s;
	vector<int> v(n+5,0);
	cin>>s;
	FOR(i,n,n+5)s+='#';
	int r=-1;
	cerr<<"test"<<endl;
	FOR(i,a,n){
		int cnt=0;
		if(s[i]=='#'&&s[i+1]=='#'&&r==-1)r=i;
		if(s[i]=='#')continue;
		FOR(j,0,4){
			int k=i+j;
			if(s[k]=='#')break;
			cnt++;
		}
		v[i]=cnt;
	}
	if(r==-1)r=mod;
	if(c<d){
		if(0){
		}else{
			int f=1;
			FOR(i,a+1,c){
				if(s[i]=='#'&&s[i+1]=='#'){
					f=0;
				}
			}
			FOR(i,b+1,d){
				if(s[i]=='#'&&s[i+1]=='#'){
					f=0;
				}
			}
			if(f){
				cout<<"Yes";
			}else{
				cout<<"No";
			}
			return 0;
		}
		return -1;
	}
	int f=0;
	FOR(i,b-1,d){
		if(v[i]>=3)f=1;
	}
	FOR(i,a+1,c){
		if(s[i]=='#'&&s[i+1]=='#'){
			f=0;
		}
	}
	FOR(i,b+1,d){
		if(s[i]=='#'&&s[i+1]=='#'){
			f=0;
		}
	}
	if(f){
		cout<<"Yes";
	}else{
		cout<<"No";
	}


	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(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 ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    double v[n];
    rep(i, n) cin >> v[i];
    sort(v, v + n);
    double ans = v[0];
    for(int i = 1; i < n; i ++){
        ans = (ans + v[i]) / 2;
    }
    cout <<setprecision(10)  <<  ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(s) for s in input().split()]

sum1 = 0
count = 0
total_length = sum(a)

for i in range(len(a)):
    sum1 += a[i]
    if sum1 >= total_length / 2:
        count1 = abs(sum1 - sum(a[i + 1:]))
        count2 = abs(sum1 - a[i] - sum(a[i:]))
        if count1 <= count2:
            count = count1
        else:
            count = count2
        break
print(count)


Measured memory_bytes: 31400
S = input()
n = len(S)
ans = 0
p = 0
q = 0
m = 1
s = ['>']
for i in range(n):
    s.append(S[i])
s.append('<')
for i in range(1,n+2):
    if s[i] == '<':
        if s[i-1] == '>':
            if p > 0:
                ans += (1-m)*(q-1)
            else:
                ans += (1-m)*q
            p = 0
            q = 0
            m = 1
        else:
            p += 1
            ans += p
    else:
        if s[i-1] == '<':
            p += 1
            q += 1
        else:
            p += -1
            q += 1
        m = p
        ans += p
    
print(ans)

Measured memory_bytes: 8220
import java.util.*;
import java.io.*;

public class Main {
    
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in1 = br.readLine().split(" ");
        int N = Integer.parseInt(in1[0]);
        int M = Integer.parseInt(in1[1]);
        
        int[] x = new int[M];
        int[] y = new int[M];
        for(int i = 0; i < M; i++){
            in1 = br.readLine().split(" ");
            x[i] = Integer.parseInt(in1[0]);
            y[i] = Integer.parseInt(in1[1]);
            x[i]--; y[i]--;
        }

        br.close();

        int[] ball_number = new int[N];
        boolean[] red_exist = new boolean[N];

        Arrays.fill(ball_number, 1);
        red_exist[0] = true;

        for(int i = 0; i < M; i++){
            ball_number[x[i]]--;
            ball_number[y[i]]++;

            if(red_exist[x[i]]) red_exist[y[i]] = true;
            if(ball_number[x[i]] == 0) red_exist[x[i]] = false;
        }

        int ans = 0;
        for(int i = 0; i < N; i++){
            if(red_exist[i]) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 46132
import itertools


def main():
    N = int(input())
    L = len(str(N))
    cnt = 0
    for length in range(3, L + 1):
        for semi_753 in itertools.product(['3', '5', '7'], repeat=length):
            n_str = ''.join(semi_753)
            if '3' in n_str and '5' in n_str and '7' in n_str:
                n = int(n_str)
                if n <= N:
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

class Main {

    static final long mjd_base = Fliegel( 2012, 12, 21 );
    static final long[] maya_unit = {13, 20, 20, 18, 20};
    static final long maya_cycle = 13*20*20*18*20;

    static long Fliegel( long y, long m, long d ) {//グレゴリオ暦を修正ユリウス通日に換算
	if ( m <= 2 ) {
	    m += 12;
	    --y;
	}
	return (long)(Math.floor(365.25*y) + Math.floor(y/400.0) - Math.floor(y/100.0)
		      + Math.floor(30.59*(m-2)) + d - 678912.0);
    }
    
    void solve(){

	Scanner sc = new Scanner(System.in);

	while ( true ) {

	    String s = sc.next().trim();
	    if ( s.charAt(0) == '#' ) break;

	    String[] t = s.split("\\.");

	    long[] g = new long[3];
	    long[] m = new long[5];

	    if ( t.length == 3 ) {

		for ( int i=0; i<t.length; ++i ) g[i] = Long.parseLong(t[i]);

		long mjd = (Fliegel(g[0], g[1], g[2]) - mjd_base)%maya_cycle;
		
		for ( int i=maya_unit.length-1; i>=0; --i ) {
		    m[i] = mjd%maya_unit[i];
		    mjd /= maya_unit[i];
		}

		System.out.printf("%d.%d.%d.%d.%d\n", m[0], m[1], m[2], m[3], m[4]);
	    }
	    else {

		for ( int i=0; i<t.length; ++i ) m[i] = Long.parseLong(t[i]);

		//マヤ暦をユリウス通日に換算
		long mjd = m[0];
		for ( int i=1; i<maya_unit.length; ++i ) {
		    mjd *= maya_unit[i];
		    mjd += m[i];
		}
		mjd += mjd_base;

		//ユリウス通日をグレゴリオ暦に換算
		mjd += 678881;
		long a = 4*mjd + 3 + (long)(4*Math.floor(3.0*Math.floor(1.0 + 4.0*(mjd+1)/146097.0)/4.0));
		long b = 2 + 5*(long)Math.floor( (a%1461)/4.0 );

		g[0] = (long)Math.floor(a/1461.0);
		g[1] = 3 + (long)Math.floor(b/153.0);
		g[2] = 1 + (long)Math.floor( (b%153)/5.0 );
		if ( g[1] > 12 ) {
		    g[1] -= 12;
		    ++g[0];
		}
	    
		System.out.printf("%d.%d.%d\n", g[0], g[1], g[2]);
	    }
	}

    }

    public static void main(String[] a) { new Main().solve(); }
}



Measured memory_bytes: 34640
N=int(input())

n=len(str(N))//2
full=0
for i in range(n):
    full+=int('9'+'0'*i*2)

if len(str(N))%2==0:
    b=0
else:
    times=len(str(N))-1
    if times==0:
        nines=0
    else:
        nines=int('9'*times)
    b=N-nines
ans=full+b
print(ans)

Measured memory_bytes: 3064
///   BISMILLAHIR RAHMANIR RAHEEM
///   ALLAH IS WATCHING ME
///   ALLAH save us from COVID-19.Amin.

///   █▀█─█──█──█▀█─█─█
///   █▄█─█──█──█▄█─█▄█
///   █─█─█▄─█▄─█─█─█─█

///   كُلُّ نَفْسٍ ذَآئِقَةُ الْمَوْت
///   Every soul shall taste death.



#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

///  order_of_key return number of elements less than x.
///  find_by_order return index.

using namespace std;
using namespace __gnu_pbds;


#define MOHAMMAD  ios::sync_with_stdio(0);cin.tie(0);
#define all(x)    (x).begin(), (x).end()
#define AE        cout << fixed << setprecision(10);

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

//***********************************************  The END **********************************************************************************************************************************




int main()
{

    // MOHAMMAD
  int n , sum = 0;
  cin >> n;
  int arr[n];
  for( int i = 0 ; i<n ; ++i ) cin >> arr[i];

  for ( int i = 0 ; i<n ; ++i ){
                sum^=arr[i];
  }
  for ( int i = 0 ; i<n ; ++i ){
       cout << (sum^arr[i]) << " ";
  }

}

/*





  Alhamdulillah
*/



Measured memory_bytes: 4396
def mlist(n, *args, **keys):
    if len(args) == 0:
        return [keys.get('default')] * n
    else:
        return [mlist(*args, **keys) for i in range(n)]


def f(n, sm):
            if n == 0:
                return int(sm == 0)
            if memo[n][sm] is not None:
                return memo[n][sm]
            memo[n][sm] = 0
            for i in range(min(10, sm + 1)):
                memo[n][sm] += f(n - 1, sm - i)
            return memo[n][sm]

try:
    memo = mlist(5, 51)
    while True:
        print f(4, int(raw_input()))
except EOFError:
    pass

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
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...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	string s; cin >> s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}








	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  string s, t, u; cin >> s >> t >> u;
  string ans = "";
  ans += s[0]-32; ans += t[0]-32; ans += u[0]-32;
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 504
n, a, b = map(int, input().split())
s = input()

passed = 0
abroad_passed = 0
for i in range(len(s)):
    if s[i] == "a":
        if passed < a + b:
            print("Yes")
            passed += 1
        else:
            print("No")
        
    elif s[i] == "b":
        if passed < a + b:
            if abroad_passed < b:
                print("Yes")
                abroad_passed += 1
                passed += 1
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")
    

Measured memory_bytes: 4040
using System;
class P{
  static void Main(){
    var kari = Console.ReadLine().Split(' ');
    int a = int.Parse(kari[0]);
    int b = int.Parse(kari[1]);
    
    int kekka = -1;
    if(a<=9&&b<=9)kekka=a*b;
    
    Console.WriteLine(kekka);
  }
}

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

using namespace std;
int f(int i,int r,int w[],int v[],map<pair<int,int>,int>& mp){
	if(i<0||r<=0)return 0;
    if(mp.find({i,r})!=mp.end())return mp[{i,r}];
	if(r>=w[i]){
		mp[{i,r}]=max(f(i-1,r-w[i],w,v,mp)+v[i],f(i-1,r,w,v,mp));
	}
	else mp[{i,r}]=f(i-1,r,w,v,mp);
	return mp[{i,r}];
}

int main() {
   int n,r;
   cin>>n>>r;
   int w[n],v[n];
   for(int i=0;i<n;++i){
   	cin>>w[i]>>v[i];
   }
   map<pair<int,int>,int> mp;
   cout<<f(n-1,r,w,v,mp);
}

Measured memory_bytes: 6272
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            else{
                for(int i = 0; i < H; i++){
                    for(int j = 0; j < W; j++){
                        if(i == 0 || i == H-1){
                            System.out.printf("#");
                        }
                        else{
                            if(j == 0 || j == W-1){
                                System.out.printf("#");
                            }
                            else{
                                System.out.printf(".");
                            }
                        }
                    }
                    System.out.println("");
                }
                System.out.println("");
            }
        }
    }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int a,b,c;
    cin >> a >> b >> c;

    int ans;
    if(a == b) ans = c;
    else if(b == c) ans = a;
    else ans = b;

    cout << ans << endl;
}


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

#define maxn 100000

int main(){
	int n = 0;   
	int fra[maxn];
	
	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> fra[i];
		
	for(int i = n - 1; i >= 0; i--){
		cout << fra[i];
		if(i > 0)
			cout << ' ';
	}
	cout << endl;
	 
	return 0;
}
	

Measured memory_bytes: 1168