akhauriyash/Code-Regression huggingface dataset:
use std::borrow::Borrow;
#[allow(unused_imports)]
use std::fs::File;
#[allow(unused_imports)]
use std::io::{stdout, BufWriter, Read, Write};
#[allow(unused_imports)]
use std::thread;

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    let stdin = std::io::stdin();
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}

fn run() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let input = read_input();
    let mut input = input.split_whitespace();

    let in_n: i64 = input.next().unwrap().parse().unwrap();
    let in_a: Vec<i64> = input.map(|s| s.parse().unwrap()).collect();

    // 2で割り切れる数
    let mut cnt2: Vec<i64> = in_a
        .iter()
        .map(|&a| {
            let mut a = a;
            let mut cnt = 0;
            while a % 2 == 0 {
                a /= 2;
                cnt += 1;
            }
            cnt
        })
        .collect();
    cnt2.sort();

    let mut counts: Vec<i64> = vec![];
    let mut left: usize = 0;
    let mut right: usize = cnt2.len() - 1;
    while left <= right {
        counts.push(cnt2[left]);
        left += 1;
        if left <= right {
            counts.push(cnt2[right]);
            right -= 1;
        }
    }
    let ok = counts.windows(2).all(|ab| ab[0] + ab[1] >= 2);
    if ok {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

const int MAX_N = 3005;
int n, m;
ll arr[MAX_N][MAX_N];
ll dp[MAX_N][MAX_N][4];

int main() { FAST
    int k;
    cin >> n >> m >> k;
    M00(i, k) {
        int x, y; ll v;
        cin >> x >> y >> v;
        x--; y--;
        arr[x][y] = v;
    }
    dp[0][0][0] = 0;
    dp[0][0][1] = arr[0][0];
    M00(i, n) {
        M00(j, m) {
            if(i == 0 && j == 0) continue;
            M00(cnt, 4) {
                if(cnt-1 >= 0) {
                    if(j-1 >= 0) ckmax(dp[i][j][cnt], dp[i][j-1][cnt-1] + arr[i][j]);
                    if(i-1 >= 0 && cnt == 1) M00(kk, 4) ckmax(dp[i][j][cnt], dp[i-1][j][kk] + arr[i][j]);
                }
                if(j-1 >= 0) ckmax(dp[i][j][cnt], dp[i][j-1][cnt]);
                if(i-1 >= 0 && cnt == 0) M00(kk, 4) ckmax(dp[i][j][cnt], dp[i-1][j][kk]);
            }
        }
    }
    ll res = 0;
    M00(kk, 4) ckmax(res, dp[n-1][m-1][kk]);
    finish(res);
}



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

int main(void){
  long long N;
  cin >> N;
  for(long long i = 1; i <= 3501; i++){
   for(long long j = 1; j <= 3501; j++){
     long long up = N * i * j;
     long long down = (long long) 4 * i * j - N * i - N * j;
     if(down == 0)continue;
     if(up % down != 0) continue; 
     if(up / down > 0 && up / down < 3501){
       cout << i << " " << j << " " << up / down;
       return 0;
     }
   }
    
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 1ll << 60;

vector<LL> S, T;

int main() {
   int A, B, Q;
   LL s, t, p;
   scanf("%d %d %d", &A, &B, &Q);
   S.push_back(-INF);
   for (int i = 0; i < A; i++) {
      scanf("%lld", &s);
      S.push_back(s);
   }//for
   S.push_back(INF);
   T.push_back(-INF);
   for (int i = 0; i < B; i++) {
      scanf("%lld", &t);
      T.push_back(t);
   }//for
   T.push_back(INF);
   while (Q--) {
      scanf("%lld", &p);
      LL best = INF;
      auto it1 = lower_bound(S.begin(), S.end(), p);
      auto it2 = lower_bound(T.begin(), T.end(), p);
      auto it1prv = it1;
      it1prv--;
      auto it2prv = it2;
      it2prv--;
      LL d1 = *it1;
      LL d2 = *it2;
      LL d1prv = *it1prv;
      LL d2prv = *it2prv;
      printf("%lld\n", min({max(d1,d2)-p, p-min(d1prv, d2prv), 2*(d1-p)+p-d2prv, 2*(d2-p)+p-d1prv, d1-p+2*(p-d2prv), d2-p+2*(p-d1prv)}));
   }//while
   return 0;
}//main


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

int main() {
    int L;

    while (cin >> L, L) {
        int month = 0, savings = 0, M, N;
        for (int i = 0; i < 12; i++) {
            cin >> M >> N;
            savings += M - N;
            if (month == 0 && L <= savings) month = i + 1;
        }
        if (month > 0) {
            cout << month << endl;
        }
        else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <vector>
#include <map>
#include <cstring>
#include <iostream>
#include <string>

const int MAX_V = 41;

int V, E;//V:????????°, E: ????????°

using namespace std;

const string INIT = "#";

const int MAX_L = 401 * 6;

//============================================================

const int INF = 0x3f3f3f3f;

struct Edge{
	int from, to;
	std::string cost;
	Edge(int from_, int to_, std::string cost_) :from(from_), to(to_), cost(cost_){}
};

std::vector<Edge> es;
std::string d[MAX_V];// ???????????¢

void AddEdge(int from, int to, std::string cost){
	es.push_back(Edge(from, to, cost));
}

void ClearEdge(){
	es.clear();
}

bool BellmanFord(int s, int g){
	std::fill(d, d + MAX_V, INIT);
	d[s] = "";
	bool isUpdate = false;

	while (1){
		for (int j = 0; j < E; ++j){
			for (Edge e : es){

				if (d[e.to].size() > MAX_L) continue; //??????????????°??\????????´??°????°???°

				if (d[e.from] != INIT && (d[e.to] == INIT || d[e.to] > e.cost + d[e.from])){
					d[e.to] = e.cost + d[e.from];
					isUpdate = true;
				}
			}
		}
		if (!isUpdate) break;
		isUpdate = false;
	}
	if (d[g] == INIT || d[g].size() > MAX_L) return true;
	return false;
}

//============================================================

int main(void)
{
	while (1){
		int s, g;
		cin >> V >> E >> s >> g;
		if (V == 0) return 0;
		for (int i = 0; i < E; ++i){
			int x, y;
			std::string lab;
			cin >> x >> y >> lab;
			AddEdge(y, x, lab);
		}
		if (BellmanFord(g, s))
			std::cout << "NO" << std::endl;
		else
			std::cout << d[s] << std::endl;
		ClearEdge();
	}
}

Measured memory_bytes: 1360
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
//****************************************
// Graph template
//****************************************

// status of node
template <typename X>
struct Node{ 
  int idx;
  int in;
  int depth;
  
  Node() = default;

  Node(int idx, int in, int depth) : idx(idx), in(in), depth(depth) {}

  void Show() {
    cout << idx  << ":" << in << ":" << depth << "\n";
  }
  
};

// status of edge
template <typename X>
struct Edge{
  int from;
  int to;
  X cost;

  Edge() = default;

  Edge(int from, int to, X cost) : from(from), to(to), cost(cost) {}
};

template <typename X>
class Graph{
private:
  int n; // number of node
  int m; // number of edge
  vector<vector<Edge<X>>> edge; // edge
  vector<Node<X>> node; 
  vector<Node<X>> tsort;
  
public:
  explicit Graph(int n) : n(n) {
    edge.resize(n);
  }

  Graph(int n, int m, vector<int> from, vector<int> to) : n(n), m(m) {
    edge.resize(n);
    rep(i,m) {
      add_edge(from[i], to[i]);
      //      add_edge(to[i], from[i]);      
    }
  }
  
  Graph(int n, int m, vector<int> from, vector<int> to, vector<X> cost) : n(n), m(m) {
    edge.resize(n);
    rep(i,m) {
      add_edge(from[i], to[i], cost[i]);
      //      add_edge(to[i], from[i], cost[i]);      
    }
  }

  void add_edge(int from, int to, X cost = 1) {
    edge[from].emplace_back(from, to, cost);
  }

  void Init_node() {
    rep(i,n) {
      node.emplace_back(i, 0, 0);
    }
  }

  void Tsort() {
    Init_node();

    rep(i,n) for(auto next: edge[i]) node[next.to].in++;

    queue<Node<X>> q;
    rep(i,n) if(node[i].in == 0) {
      q.emplace(i, 0, 0);
    }

    while( !q.empty() ) {
      Node<X> now = q.front(); q.pop();
      int v = now.idx;
      int depth = now.depth;
      tsort.push_back(node[v]);
      for(auto next: edge[v]) {
	int w = next.to;
	node[w].in--;
	node[w].depth = depth + 1;
	if(node[w].in == 0) {
	  q.emplace(w, 0, depth + 1);
	}
      }
    }
  }

  void Show() {
    // rep(i,n) {
    //   tsort[i].Show();
    // }
    rep(i,n) cout << tsort[i].idx << "\n";
  }
  
};

int main()
{
  int n,m;cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i,m) {
    cin >> a[i] >> b[i];
  }

  Graph<int> gp(n, m, a, b);
  gp.Tsort();
  gp.Show();
  
  return 0;
}



Measured memory_bytes: 4728
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

using P = pair<int, int>;

int main() {
  int H, W, N;
  while (cin >> H >> W >> N) {
    map<int, int> leftMostHole;
    for (int i = 0; i < N; i++) {
      int y, x;
      cin >> y >> x;
      --y;
      --x;
      if (y == 0) continue;
      if (leftMostHole.count(y)) {
        leftMostHole[y] = min(leftMostHole[y], x);
      } else {
        leftMostHole[y] = x;
      }
    }
    leftMostHole[H] = 0;
    int res;
    int wide = 1, preY = 0;
    for (auto& ps : leftMostHole) {
      int y = ps.fst;
      int x = ps.snd;
      wide = min(wide + y - preY - 1, W);
      if (x < wide) {
        res = y;
        break;
      }
      wide = min(wide + 1, x);
      preY = y;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    ll n, k;
    cin >> n >> k;
    n %= k;
    ll N = n - k;
    cout << min(n, -N) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }

int main() {
	ll N, M;

	cin >> N >> M;

	ll Lans, Rans;

	Lans = 1, Rans = N;
	rep(i, M) {
		ll L, R;

		cin >> L >> R;

		Rans = min(R, Rans);
		Lans = max(Lans, L);

	}

	cout << max(Rans - Lans + 1, 0) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;
const double PI=3.14159265359;




int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,a,b;
    
    cin>>n>>a>>b;
    
    int c1=0,c2=0,c3=0;
    
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        if(x<=a) c1++;
        else if(x<=b) c2++;
        else c3++;
    }
    cout<<(min(min(c1,c2),c3));
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char s[3];
	int i;
	for(i=0;i<3;i++)
	{
		scanf("%c",&s[i]);
	}
	if((s[0] == 'A' && s[1] == 'A' && s[2] == 'A') || (s[0] == 'B' && s[1] == 'B' && s[2] == 'B'))
	{
		printf("No");
	 }
	 else
	 {
	 	printf("Yes");
	  } 
 } 

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

char s[MAXN];

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	scanf("%s", s);
	n = strlen(s);
	n -= 8;
	s[n] = 0;
	printf("%s\n", s);
}

void printans(){

}

int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> value(N);
  for(int i=0; i<N; i++){
    cin >> value.at(i);
  }
  vector<int> cost(N);
  for(int j=0; j<N; j++){
    cin >> cost.at(j);
  }
  vector<int> benefit(N);
  for(int k=0; k<N; k++){
    benefit.at(k) = value.at(k) - cost.at(k);
  }
  int ans = 0;
  for(int l=0; l<N; l++){
    if(benefit.at(l) > 0){
      ans = ans + benefit.at(l);
    }
  }
  cout << ans << endl;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define reps(i, n) for (int i = 1; i <= (int) n; i++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << x << endl
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) { return b < a && (a = b, true); }
struct SetUp { SetUp() { cout << fixed << setprecision(20); }; } setUp;

int N;
int A[110000];
signed main() {
    cin >> N;
    int k = 0;
    rep(i, N) {
        cin >> A[i];
        k ^= A[i];
    }
    rep(i, N) { A[i] &= ~k; }
    int x = 0;
    for (int i = 60; i >= 0; i--) {
        int idx = -1;
        rep(j, N) { if (A[j] & bit(i)) { idx = j; }}
        if (idx == -1) { continue; }
        int tmp = A[idx];
        if (~x & bit(i)) { x ^= tmp; }
        rep(j, N) { if (A[j] & bit(i)) { A[j] ^= tmp; }}
    }
    cout << (k ^ x) + x << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//#define int long long
int main(){
  int h,w,f[1000]={},cnt=0,cnt2=0,cnt3=0;
  string a;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    cin>>a;
    for(int j=0;j<w;j++){
      int t=(int)a[j];
      f[t]++;
    }
  }
  
  for(int i=(int)'a';i<1000;i++){
    if(f[i]%2!=0){
      cnt++;
      if((f[i]-1)%4!=0)cnt3++;
    }else if(f[i]%4!=0)cnt2++;
    if(f[i]==h*w){
      cout<<"Yes";
      return 0;
    }
  }
  
  if(h%2==0&&w%2==0){
    if(cnt2||cnt)cout<<"No";
    else cout<<"Yes";
  }else if(h%2==0){
    if(cnt)cout<<"No";
    else if(cnt2<=h/2)cout<<"Yes";
    else cout<<"No";
  }else if(w%2==0){
    if(cnt)cout<<"No";
    else if(cnt2<=w/2)cout<<"Yes";
    else cout<<"No";
  }else{
    if(cnt<=1&&cnt2+cnt3<=w/2+h/2)cout<<"Yes";
    else cout<<"No";
  }
  return 0;
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;
typedef long double ld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	ll a, b;
	cin>>a>>b;
	ll ans = max(a+a-1, max(b+b-1, a+b));
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

        double ans = 0;
        for (int i = 1; i <= n; i++) {
            int count = (int) Math.max(Math.ceil(Math.log10((double) k / i) / Math.log10(2)), 0);
            double val = Math.pow(0.5, count) / n;
            ans += val;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a, b, c, ans;
    cin >> a >> b >> c;
    ans = b + c - a;
    if(ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

ans = 0
K, N = map(int, input().split())
if N == 100:
    ans = 100**(K+1)+100**K
else:
    ans = 100**K*N
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    bool flg=false;
    int cnt=0;

    vector<int> v(n);
    rep(i, n) cin >> v[i];

    while(true){
        for(int i=0; i<n; i++){
            if(v[i] % 2 != 0) {
                flg=false;
                break;   
            }
            else flg=true; 
        }
        if(flg){
            for(int i=0; i<n; i++){
                v[i] /= 2;
            }
            cnt++;
        }
        else break;
    }
    out(cnt);

}

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

int main(){
      string s, t;
      cin >> s >> t;
      bool judge = false;
      int count = 0;
      if(t.size() == s.size() + 1){
            for (size_t i = 0; i < s.size(); i++) {
                  if(s[i] != t[i]) break;
                  count++;
            }
      }

      if(count == s.size()) judge = true;

      if(judge) cout << "Yes" <<endl;
      else cout << "No" <<endl;
}


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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto a = load<int>();
	auto b = load<int>();
	cout << max(a+b, max(a-b, a*b)) << '\n';	
}


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

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

	int ans = str.size();
	for (int i = 1; i < str.size() + 1; ++i)
		if (str[i] != str[i - 1])
			ans = std::min(ans, std::max(i, static_cast<int>(str.size()) - i));

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

Measured memory_bytes: 512
package main

import (
	"fmt"
	"math"
)

var s string
var ans, res int
var mod int = pow(10, 9) + 7

func main() {
	fmt.Scan(&s)
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "," {
			fmt.Printf("%s", " ")
		} else {
			fmt.Printf("%s", string(s[i]))
		}
	}
}

/*  ----------------------------------------  */
func lcm(x, y uint64) uint64 {
	return (x / gcd(x, y)) * y
}

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


Measured memory_bytes: 512
(defun solve (s1 s2)
  (with-output-to-string (*standard-output*)
    (loop for ch1 across s1
          for ch2 across s2
          do (write-char ch1)
             (write-char ch2))))

#-swank
(let ((n (read))
      (str (read-line)))
  (declare (ignore n))
  (let ((pos (position #\Space str)))
    (format t "~A~%" (solve (subseq str 0 pos) (subseq str (1+ pos))))))


Measured memory_bytes: 15844
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
# スペース区切りの整数の入力
l = map(int, raw_input().split())

c = 1
for a in l:
	c=c*a

ret= sum([(c-1)%a for a in l])
print ret


Measured memory_bytes: 2820
N = int(input())
F = [tuple(map(int, input().split())) for _ in range(N)]

DP = [0] * 3

for f in F:
    D = [0] * 3
    S = {0, 1, 2}
    for i in range(3):
        S.remove(i)
        for s in S:
            D[i] = max(D[i], f[i] + DP[s])
        S.add(i)
    DP = D

print(max(DP))

Measured memory_bytes: 91100
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

from functools import lru_cache
#@lru_cache(maxsize = None)

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#a = [x for x in map(int, input().split())]
a, p = map(int, input().split())
#print(n, q, file=sys.stderr)

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()


def doit(n, s):
  if n < 2:
    return
  print(s, file=sys.stderr)

  last = n - 1
  for x in range(last):
    if qa(s[x], s[last]):
      swap = s[x]
      s[x] = s[last]
      s[last] = swap
  doit(last, s)

try:
  print ((a * 3 + p) // 2)
#  doit(n, s)
except Exception as e:
  print(e, file=sys.stderr)
  print(s)


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

double myRound(double x){
  int y = (int)round(x * 1000);
  return y / 1000.0;
}

int main(){
  double a, b, p, c, d, q;

  while(cin >> a >> b >> p >> c >> d >> q){
    double tmp = a * d - b * c;
    double x = (d * p - b * q) / tmp;
    double y = (a * q - c * p) / tmp;

    printf("%.3f %.3f\n", myRound(x), myRound(y));
  }
}

Measured memory_bytes: 1252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int []a=new int[n];
		int []b=new int[n];
		int []c=new int[n-1];
		for(int i=0;i<n;i++) {
			a[i]=scn.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=scn.nextInt();
		}
		for(int i=0;i<n-1;i++) {
			c[i]=scn.nextInt();
		}
		int sum=0;
		for(int i=0;i<n;i++) {
				sum+=b[a[i]-1];
				//System.out.println(b[a[i]-1]);
			if(i>0) {
				if(a[i]==a[i-1]+1) {
					sum+=c[a[i]-2];
					//System.out.println(c[a[i]-2]);
				}
			}
		}
		System.out.println(sum);
	}

}


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

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    int amin = 9999999, bmin = 9999999;
    for (int i = 0; i < A; i++) {
        cin >> a[i];
        amin = min(a[i], amin);
    }
    for (int i = 0; i < B; i++) {
        cin >> b[i];
        bmin = min(b[i], bmin);
    }
    int ans = amin + bmin;
    for (int i = 0; i < M; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, a[x-1]+b[y-1]-c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

void init(int n, vector<int>& v){
  v.resize(n);
  for(int i = 0; i < n; i++){
    v[i] = i;
  }
}

int root(int a, vector<int>& v){
  if(v[a] == a) return a;
  return (v[a] = root(v[a], v));
}

bool same(int a, int b, vector<int>& v){
  return root(a,v) == root(b,v);
}

void unite(int a, int b, vector<int>& v){
  v[root(a,v)] = root(b,v);
}


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

  vector<int> cost, src, dst;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(a[i][j] > -1){
        cost.push_back(a[i][j]);
        src.push_back(i);
        dst.push_back(j);
      }
    }
  }
  vector<pair<int, int> > edges(cost.size());

  for(int i = 0; i < cost.size(); i++){
    // cout << "cost" << cost[i] << endl;
    // cout << "i" << i << endl;
    edges[i] = make_pair(cost[i], i);
    // cout << edges[i].first << " : " << edges[i].second << endl;
  }

  sort(edges.begin(),edges.end());

  // for(int i = 0; i < cost.size(); i++)
    // cout << edges[i].first << " : " << edges[i].second << endl;

  int sum = 0;
  vector<int> units;
  init(n, units);
  for(int i = 0; i < edges.size(); i++){
    int idx = edges[i].second;
    int s = src[idx], d = dst[idx];
    // cout << s << "," << d << endl;
    if(same(s, d, units))
      continue;
    unite(s, d, units);

    sum += cost[idx];
  }

  cout << sum << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1}; //00右,01下,10左,11上

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int h,w,k,mask,memo[50][50][4][1<<12];
char fld[50][50];

bool Check(int y,int x){
	return 0<=y&&y<h&&0<=x&&x<w&&fld[y][x]!='#';
}

int Max(int y,int x,int c,int bit){
	int &res=memo[y][x][c][bit];
	if(res!=-1) return res;
	if(y==h-1&&x==w-1&&c==0) return res=0;

	bool done=false;
	int py=y,px=x;
	rep(i,0,2*k){
		py-=dy[(bit>>(i*2))&3];
		px-=dx[(bit>>(i*2))&3];
		if(y==py&&x==px){
			done=true;
			break;
		}
	}
	int gift=0;
	if(!done&&fld[y][x]!='.') gift=fld[y][x]-'0';

	res=-INF;
	rep(i,0,4){
		int ny=y+dy[i],nx=x+dx[i];
		if(!Check(ny,nx)) continue;
		if(i<2){
			res=max(res,Max(ny,nx,c,((bit<<2)|i)&mask)+gift);
		}else if(c>=1){
			res=max(res,Max(ny,nx,c-1,((bit<<2)|i)&mask)+gift);
		}
	}

	return res;
}

void Solve(){
	fill_n((int*)memo,50*50*4*(1<<12),-1);
	cin >> h >> w >> k;
	mask=(1<<(4*k))-1;
	rep(i,0,h) rep(j,0,w) cin >> fld[i][j];

	cout << Max(0,0,k,0) << endl;
}

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

Measured memory_bytes: 161196
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

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

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,K;
  cin>>K>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  int ma(0);
  sort(A.begin(),A.end());
  for(int i(1);i<N;i++){
    ma = max(ma,A[i] - A[i-1]);
  }
  ma = max(ma,(K-A[N-1])+A[0]);
  cout << K - ma << endl;
  return 0;
}



Measured memory_bytes: 1024
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
using namespace std;
 
typedef long long ll;

int main(){
	double l;
    cin >> l;
    cout <<fixed << setprecision(8)<<l*l*l/27 << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
    fastio
    ll N;
    cin>>N;
    vector<vector<ll>> V(N,vector<ll>(3));

    for(int i=0;i<N;i++){
        cin>>V[i][0]>>V[i][1]>>V[i][2];
    }
    vector<vector<ll>> dp(N,vector<ll>(3));
    dp[0][0]=V[0][0];
    dp[0][1]=V[0][1];
    dp[0][2]=V[0][2];
    for(int i=1;i<N;i++){
        dp[i][0]=V[i][0] + max({dp[i-1][1],dp[i-1][2]});
        dp[i][1]=V[i][1] + max({dp[i-1][0],dp[i-1][2]});
        dp[i][2]=V[i][2] + max({dp[i-1][0],dp[i-1][1]});
    }
    cout<<*max_element(dp[N-1].begin(),dp[N-1].end())<<"\n";
    return 0;
}

Measured memory_bytes: 14220
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

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



int main(){
    ll n,c=0,d=0,e=1;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) {
        cin>>a[i];
        if(a[i]==1) d++;
    }
    if(d==0){
        cout<<-1<<endl;
        return 0;
    }
    
    ll now = 1;
    ll ans = 0;
    rep(i, n) {
        if (a[i] == now) now++;
        else ans++;
    }
    if (now == 1) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N, M, Q = inpl()

imos2d = [[0]*(N+2) for _ in range(N+2)]
S = [[0]*(N+2) for _ in range(N+2)]
S2 = [[0]*(N+2) for _ in range(N+2)]

for _ in range(M):
    L, R = inpl()
    imos2d[0][R] += 1
    imos2d[L+1][R] -= 1


for i in range(N+2):
    S[i][0] = imos2d[i][0]
    for j in range(N+1):
        S[i][j+1] = S[i][j] + imos2d[i][j+1]

S2[0] = [s for s in S[0]]
for i in range(N+1):
    for j in range(N+2):
        S2[i+1][j] = S2[i][j] + S[i+1][j]

for _ in range(Q):
    p, q = inpl()
    print(S2[p][q])

Measured memory_bytes: 17456
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    int count=0;
    for(int i = 0;i<3;i++){
        if(S.at(i) == '1'){
            count++;
        }
        else{
            continue;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

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

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX  410

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> Q;
	int n, m;
	int a, b, c;
	int count[MAX] = {}, dis[MAX] = {};
	vector<pair<int,int>> G[MAX];
	
	cin>>n>>m;
	
	for(int i = 0; i < m; i++){
		cin>>a>>b>>c;
		G[a].push_back(make_pair(b,c));
		count[b]++;
	}
	
	Q.push(make_pair(0,0));
	
	while(!Q.empty()){
		pair<int,int> P = Q.top(); Q.pop();
		
		if(count[P.first]) continue;
		
		for(int i = 0; i < G[P.first].size(); i++){
			dis[G[P.first][i].first] = max(dis[P.first] + G[P.first][i].second, dis[G[P.first][i].first]);
			count[G[P.first][i].first]--;
			if(!count[G[P.first][i].first]) Q.push(make_pair(G[P.first][i].first,0));
		}
	}
	
	cout<<dis[n-1]<<endl;
	
	return 0;
}


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

int main(){
  bool is_prime[1000000];
  for(int i=0;i<1000000;i++){
    is_prime[i] = true;
  }
  is_prime[0] = false;
  is_prime[1] = false;
  
  for(int i=2;i<1000000;i++){
    if(is_prime[i]){
      for(int j=2*i;j<1000000;j += i){
	is_prime[j] = false;
      }
    }
  }
 
 int n,counter;
 while(cin >> n){
 counter = 0;
 
 for (int k = 1; k <= n; k++)
   if(is_prime[k]){
     counter++;
   }

 cout << counter << endl;
 }
 
 return 0;
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

int main(){
    fcin;

    int a, b, c;
    cin >> a >> b >> c;

    int s = a + b + c;
    if(s >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}



Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int a,b;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  cin >> a >> b;
  if(a>=13){
    cout << b << endl;
  }
  else if(a>=6){
    cout << b/2 << endl;
  }
  else cout << 0 << endl;




return 0;
}
///....


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

typedef long long ll;
const int MAXN = 500010;

struct Node
{
	ll mn, add;
	int l, r;
}t[MAXN * 30];
int cnt, rt;

inline int newnode(int l, int r)
{
	t[++cnt] = (Node){l, 0, 0, 0};
	return cnt;
}

inline void pushup(int o, int l, int r)
{
	int mid = (l + r) >> 1;
	if(!t[o].l) t[o].l = newnode(l, mid);
	if(!t[o].r) t[o].r = newnode(mid + 1, r);
	t[o].mn = min(t[t[o].l].mn, t[t[o].r].mn);
}

inline void pushdown(int o, int l, int r)
{
	if(t[o].add)
	{
		int mid = (l + r) >> 1;
		if(!t[o].l) t[o].l = newnode(l, mid);
		if(!t[o].r) t[o].r = newnode(mid + 1, r);
		t[t[o].l].add += t[o].add, t[t[o].l].mn += t[o].add;
		t[t[o].r].add += t[o].add, t[t[o].r].mn += t[o].add;
		t[o].add = 0;
	}
}

ll ask(int &o, int l, int r, int L, int R)
{
	if(!o) o = newnode(l, r);
	if(l == L && r == R) return t[o].mn;
	int mid = (l + r) >> 1;
	pushdown(o, l, r);
	if(R <= mid) return ask(t[o].l, l, mid, L, R);
	else if(L > mid) return ask(t[o].r, mid + 1, r, L, R);
	else return min(ask(t[o].l, l, mid, L, mid), ask(t[o].r, mid + 1, r, mid + 1, R));
}

void add(int &o, int l, int r, int L, int R, ll res)
{
	if(!o) o = newnode(l, r);
	if(l == L && r == R)
	{
		t[o].add += res, t[o].mn += res;
		return;
	}
	int mid = (l + r) >> 1;
	pushdown(o, l, r);
	if(R <= mid) add(t[o].l, l, mid, L, R, res);
	else if(L > mid) add(t[o].r, mid + 1, r, L, R, res);
	else
	{
		add(t[o].l, l, mid, L, mid, res);
		add(t[o].r, mid + 1, r, mid + 1, R, res);
	}
	pushup(o, l, r);
}

int n; ll ans;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		int x; scanf("%d", &x);
		ans += ask(rt, 0, 1e9, x, 1e9) - x;
		add(rt, 0, 1e9, 0, x - 1, 1);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 108800
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(L[n-1])

Measured memory_bytes: 38256
#include <iostream>

long long int dp[100][100000];
int main() {
	int N;
	int W;
	int w[100];
	long long int v[100];
	std::cin >> N >> W;
	for (int i = 0; i < N; i++) {
		std::cin >> w[i] >> v[i];
	}

	for (int i = w[0]-1; i < W; i++) {
		dp[0][i] = v[0];
	}

	for (int i = 1; i < N; i++) {
		for (int j = 0; j < w[i]; j++) {
			dp[i][j] = dp[i - 1][j];
		}
		for (int j = w[i]; j < W; j++) {
			if (dp[i - 1][j] < dp[i - 1][j - w[i]] + v[i]) {
				dp[i][j] = dp[i - 1][j - w[i]] + v[i];//j=5 w[i]=4 i=1 
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	std::cout << dp[N - 1][W - 1] << std::endl;
	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j < W; j++) {
			std::cout << dp[i][j] << " ";
		}
		std::cout << std::endl;
	}*/
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int qpow(int x,int k)
{
    int r=1;
    while(k)
    {
        if(k&1)r=1ll*r*x%mod;
        k>>=1;x=1ll*x*x%mod;
    }
    return r;
}
int n,X,Y;
struct Ball{
    int c,w;
}b[200200];
int mi[200200];
int ami,amc;
int cmi;
bool av[200200];
int tot;
int cnt[200200];
int fac[200200],ifac[200200];
int main()
{
    scanf("%d%d%d",&n,&X,&Y);
    memset(mi,0x3f,sizeof(mi));
    ami=mi[0];
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d",&b[i].c,&b[i].w);
        mi[b[i].c]=min(mi[b[i].c],b[i].w);
        if(mi[b[i].c]<ami)
            ami=mi[b[i].c],amc=b[i].c;
    }
    cmi=mi[0];
    for(int i=1;i<=n;++i)
        if(b[i].c!=amc)cmi=min(cmi,b[i].w);
    for(int i=1;i<=n;++i)
        if(mi[i]+ami<=Y)av[i]=1;
    av[amc]=1;
    for(int i=1;i<=n;++i)
    {
        if(!av[b[i].c])continue;
        cnt[b[i].c]++;tot++;
        if(b[i].w+mi[b[i].c]<=X||b[i].w==mi[b[i].c])
            continue;
        if(b[i].c!=amc&&b[i].w+ami<=Y)continue;
        if(b[i].c==amc&&b[i].w+cmi<=Y)continue;
        cnt[b[i].c]--;tot--;
    }
    fac[0]=1;
    for(int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpow(fac[n],mod-2);
    for(int i=n-1;i>=0;--i)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
    int ans=fac[tot];
    for(int i=1;i<=n;++i)
        ans=1ll*ans*ifac[cnt[i]]%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
 

    class Program
    {
        static void Main(string[] args)
        {
            int s = int.Parse(Console.ReadLine());
            int h = s / 3600;
            int m = (s % 3600) / 60;
            int b = (s % 60);
            Console.WriteLine("{0}:{1}:{2}",h,m,b);
        }
        
    }
}

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

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

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





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


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int n; long long d;
    scanf("%d%lld",&n,&d);
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        long long x,y;
        scanf("%lld%lld",&x,&y);
        if(x*x+y*y<=d*d) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 1736
import math
a,b,C = map(float,input().split())
S = 0.5 * a * b * math.sin(math.radians(C))
c = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(C)))
L = a+ b+c
x = (a**2+b**2-c**2)/(2*a)
h = math.sqrt(b**2-x**2)
print(round(S,8))
print(round(L,8))
print(round(h,8))



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

int main(void) {
  long long X, Y;
  cin >> X >> Y;

  long long now = X;
  int cnt = 0;
  while (now <= Y) {
    cnt++;
    now *= 2;
  }
  cout << cnt << endl;
  return 0;
}

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

using namespace std;

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int main() {
  int elaps=0,c;
  int i,q;
  P u;
  cin>>n>>q;
  for(i=1;i<=n;i++){
    scanf("%s %d",Q[i].name,&Q[i].t);
  }
  head=1;tail=n+1;
  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0) enqueue(u);
    else cout<<u.name<<" "<<elaps<<endl;
  }
}



Measured memory_bytes: 13196
using System;

namespace AtCoder_ABC_B
{
    class Program
    {
        static void Main(string[] args)
        {
            Boolean ans = false;
            String inputLine = Console.ReadLine();

            if (inputLine[0] == inputLine[1] && inputLine[2] == inputLine[3] && inputLine[0] != inputLine[2]) 
            {
                ans = true;
            }else if (inputLine[0] == inputLine[2] && inputLine[1] == inputLine[3] && inputLine[0] != inputLine[3])
            {
                ans = true;
            }else if (inputLine[0] == inputLine[3] && inputLine[1] == inputLine[2] && inputLine[0] != inputLine[1])
            {
                ans = true;
            }

                if (ans == true)
            {
                Console.WriteLine("Yes");
            }else {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092