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

/**
 * Created by wild on 16/09/26.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String one = scan.next();
        String two = scan.next();
        String three = scan.next();

        boolean ok = true;
        char turn = 'a';
        char winner = 'a';

        while (ok) {
            switch (turn) {
                case 'a':
                    if (one.equals(" ")){
                        winner = 'A';
                        ok = false;
                    }else {
                        turn = one.charAt(0);
                        one = ret(one);
                    }
                    break;
                case 'b':
                    if (two.equals(" ")){
                        winner = 'B';
                        ok = false;
                    }else {
                        turn = two.charAt(0);
                        two = ret(two);
                    }
                    break;
                case 'c':
                    if (three.equals(" ")){
                        winner = 'C';
                        ok = false;
                    }else {
                        turn = three.charAt(0);
                        three = ret(three);
                    }
                    break;
            }

        }
        System.out.println(winner);
    }

    public static String ret(String str) {
        if (str.length() != 1) {
            return str.substring(1);
        } else {
            return " ";
        }
    }
}

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

using namespace std;
deque<int> q;
int main()
{
    int a;
    cin >> a;q.push_back(a);
    cin >> a;q.push_back(a);
    cin >> a;q.push_back(a);
    sort(q.begin(), q.end());
    puts(q[0]==5&&q[1]==5&&q[2]==7?"YES":"NO");
}



Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int rowNum = sc.nextInt();
		int colNum = sc.nextInt();
		String line = sc.nextLine();
		List<String> map = new ArrayList<>();
		for(int i = 0; i < rowNum; i++) {
			line = sc.nextLine();
			if(line.contains("#")) {
				map.add(line);
			} else {
				rowNum--;
				i--;
			}
		}
		for(int i = 0; i < colNum; i++) {
			boolean empty = true;
			for(String str : map) {
				if(str.charAt(i) == '#') {
					empty = false;
					break;
				}
			}
			if(empty) {
				for(int j = 0; j < rowNum; j++) {
					String str;
					if(i+1 >= colNum) {
						str = map.get(j).substring(0, i);
					}else {
						str = map.get(j).substring(0, i) + map.get(j).substring(i + 1);
					}
					map.set(j, str);
				}
				i--;
				colNum--;
			}
		}

		for(String str : map) {
			System.out.println(str);
		}
	}
}




Measured memory_bytes: 24404
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    string s, t;
    cin >> s >> t;
    bool flg = false;
    int slen = s.length(); int tlen = t.length();
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    for(int i = 0; i < slen; ++i) {
        bool flg2 = true;
        for(int j = 0; j < tlen; ++j) {
            if(i+j < slen && s.at(i+j) == '?') {

            }else {
                if(i+j < slen && s.at(i+j) == t.at(j)) {
                    
                }else {
                    flg2 = false; break;
                }
            }
        }
        if(flg2) {
            flg = true;
            for(int j = 0; j < tlen; ++j) {
                s.at(i+j) = t.at(j);
            }
            break;
        }
    }
    if(!flg) cout << "UNRESTORABLE" << endl;
    else {
        for(int i = 0; i < slen; ++i) {
            if(s.at(i) == '?') s.at(i) = 'a';
        }
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A[15], x[15][15], y[15][15];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d", &A[i]);
        for(int j=0;j<A[i];j++){
            scanf("%d%d", &x[i][j], &y[i][j]);
            x[i][j]--;
        }
    }
    int ans = 0;
    for(int i=0;i<(1<<n);i++){
        bool ok = 1;
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                for(int k=0;k<A[j];k++){
                    if(y[j][k] == ((i>>x[j][k])&1)) continue;
                    ok = 0;
                    break;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000000
#define MOD 1000000007
#define MAX 3000000
using Graph=vector<vector<int>>;

void dfs(Graph &G,int v,vector<bool> &can_reach){
  can_reach.at(v)=true;
  for(auto nv:G.at(v)){
    if(can_reach.at(nv)){
      continue;
    }
    dfs(G,nv,can_reach);
  }
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<vector<pair<int,ll>>> G(N);
  Graph Gr(N);
  for(int i=0;i<M;i++){
    int a,b;
    int c;
    cin>>a>>b>>c;
    a--;b--;
    G.at(a).push_back(make_pair(b,c));
    Gr.at(b).push_back(a);
  }

  vector<ll> score(N,-INF);
  score.at(0)=0;
  for(int k=0;k<N+1;k++){
    for(int i=0;i<N;i++){
      if(score.at(i)==-INF){
        continue;
      }
      for(auto e:G.at(i)){
        int nv=e.first;
        ll s=e.second;
        if(score.at(nv)<score.at(i)+s){
          score.at(nv)=score.at(i)+s;
        }
      }
    }
  }

  bool loop=false;
  vector<int> A;
  for(int i=0;i<N;i++){
    if(score.at(i)==-INF){
      continue;
    }
    for(auto e:G.at(i)){
      int nv=e.first;
      ll s=e.second;
      if(score.at(nv)<score.at(i)+s){
        loop=true;
        A.push_back(i);
        break;
      }
    }
  }

  if(loop){
    vector<bool> can_reach(N,false);
    dfs(Gr,N-1,can_reach);
    bool flag=false;
    for(auto v:A){
      flag=flag|can_reach.at(v);
    }
    if(flag){
      cout<<"inf"<<endl;
    }else{
      cout<<score.at(N-1)<<endl;
    }
  }else{
    cout<<score.at(N-1)<<endl;
  }

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long K) {
  double ans = 0;
  for (int i = 1; i <= N; i++) {
    LL cur = i;
    double prob = 1;
    while (cur <= K - 1) {
      cur *= 2;
      prob /= 2.0;
    }
    ans += prob / (double)N;
  }
  cout << ans << endl;
}

int main() {
  cout << setprecision(15);
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  solve(N, K);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int llint;
llint v[1000005],dp[1000005],n;
int x[25][25];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			cin >> x[i][j];
		}
	}
	for(int i=0;i<(1 << n);i++) {
		for(int j=0;j<n;j++) {
			for(int k=j+1;k<n;k++) {
				v[i]+=((i & (1 << j)) && (i & (1 << k)))*x[j][k];
			}
		}
	}
	for(int i=0;i<(1 << n);i++) {
		dp[i]=max(dp[i],v[i]);
		for(int j=i;j>0;j=(j-1) & i) {
			dp[i]=max(dp[i],dp[j]+dp[i ^ j]);
		}
	}
	cout << dp[(1 << n)-1];
	return 0;
}


Measured memory_bytes: 4692
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int cnt = 0;
    vector<int> a, b, c;
    for(int i = 1; i <= n; ++i){
        int x; cin >> x;
        if(x % 4 == 0)a.push_back(x);
        else if(x % 2 == 0)b.push_back(x);
        else c.push_back(x);
    }
    if(b.size() == 0){
        if(c.size() > a.size() + 1)cout << "No" << endl;
        else cout << "Yes" << endl;
    }else if(c.size() > a.size())cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define F first
#define S second

typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e12;
const ll mlnf = -1e12;

// Graph problem
using Graph = vector<vector<int>>;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

// solve

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }
    int ans = max(N - accumulate(all(A), 0), -1);
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int>H(N);
  for(int i=0; i<N; i++) cin >> H.at(i);
  
  int64_t Max=0;
  int64_t count=0;
  
  for(int i=0; i<N-1; i++){
    if(H.at(i)>=H.at(i+1)){
      count++;
      Max=max(Max,count);
    }
    else count=0;
  }  
  cout << Max << endl;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long int li;

int main(void){
    ll ans=0;
    int n,a,b;
    cin >> n >> a >> b;
    int p[n+1];
    for(int i=1;i<=n;i++)cin >> p[i];
    ll num1=0;
    ll num2=0;
    ll num3=0;
    for(int i=1;i<=n;i++){
        if(p[i]<=a)num1++;
        if(p[i]>=a+1&&p[i]<=b)num2++;
        if(p[i]>=b+1)num3++;
    }
    ans = min(num1,num2);
    ans = min(ans,num3);
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> par;
vector<int> rnk;
void init (int n) {
	par.resize(n + 1);
	rnk.resize(n + 1);
	for (int i = 1; i <= n; i++)
		par[i] = i, rnk[i] = 1;
}
int p(int x) {
	return par[x] = ((par[x] == x) ? x : p(par[x]));
}
void u(int a, int b) {
	a = p(a), b = p(b);
	if (a == b) return;
	if(rnk[a] > rnk[b])
		par[b] = a;
	else if(rnk[a] < rnk[b])
		par[a] = b;
	else
		par[a] = b, rnk[b]++;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> cnt(n + 1);
	init(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		cnt[a]++, cnt[b]++;
		u(a, b);
	}
	vector<int> sz(n + 1), ans(n + 1);
	for (int i = 1; i <= n; i++)
		sz[p(i)]++;
	for (int i = 1; i <= n; i++)
		ans[i] = sz[p(i)] - 1 - cnt[i];
	for (int j = 0; j < k; j++) {
		int c, d;
		cin >> c >> d;
		if (p(c) == p(d))
			ans[c]--, ans[d]--;
	}
	for (int i = 1; i <= n; i++)
		cout << ans[i] << " \n"[i == n];
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>

using namespace std;

int N,K;
string S;
int main(){
  cin >> N >> K;
  cin >> S;
  for(int i=0;i<N;i++){
    if(i==K-1){
      if(S[i]=='A') cout << 'a';
      if(S[i]=='B') cout << 'b';
      if(S[i]=='C') cout << 'c';
    }else cout << S[i];
  }
  cout << endl;
  return 0;
}


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

#define pb push_back

using namespace std;

const int MOD = 2;

int n, x = 0;
string s;
vector<int> v, f;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    f.assign(1e6 + 5, 0);
    for(int i = 1; i < 1e6 + 5; ++i){
        f[i] = i/2 + f[i/2];
        // cout << f[i] << " ";
    }
    for(int i = 0; i < n; ++i){
        v.pb(s[i] - 1 - '0');
    }
    for(int i = 0; i < n; ++i){
        if(v[i] == 1){
            x ^= ((f[n - 1] - f[n - 1 - i] - f[i]) == 0);
        }
    }
    if(x){
        cout << 1;
        return 0;
    }
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        if(v[i] == 1) cnt++;
    }
    if(cnt){
        cout << 0;
        return 0;
    }
    for(int i = 0; i < n; ++i){
        v[i] /= 2;
    }
    x = 0;
    for(int i = 0; i < n; ++i){
        if(v[i] == 1){
            x ^= ((f[n - 1] - f[n - 1 - i] - f[i]) == 0);
        }
    }
    cout << (x ? 2 : 0);
    return 0;
}

Measured memory_bytes: 12312
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
ll d[200010];
 
int main() {
	vector<pair<ll,ll> > v;
	clr(d,0);
	ll h,w,n;
	cin>>h>>w>>n;
  	swap(h,w);
	map<pair<ll,ll>,ll> ma;
	rep(i,0,n){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		v.pb(mp(x,y));
		ma[mp(x,y)]=1;
	}
	ll y = 0;
	ll x = 0;
	rep(i,1,w){
		if(ma[mp(x+1,y+1)]!=1){
			x++;
			y++;
		}
		else{
			x++;
		}
		d[i]=min(y,h-1);
	}
	ll mn = w-1;
	rep(i,0,v.sz){
		{
			ll x1 = v[i].fi-1;
			ll y1 = v[i].se;
			if(x1>=0){
				ll x2 = x1;
				ll y2 = y1;
				if(ma[mp(x2,y2)]!=1){
					if(y2<=d[x2]){
						mn = min(mn,x2);
					}
				}
			}
		}
	}
	cout << mn+1 << endl;
	return 0;
}

Measured memory_bytes: 38892
/*
 * 
 * Author: Pranav Bansal
 * 
*/
#include<bits/stdc++.h>

#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define V(x) vector<x>
#define P(x,y) pair<x,y>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
#define endl "\n"
#define coutd(n) cout << fixed << setprecision(n)
#define watch(x) cout<<#x<<" = "<<x<<endl;
typedef double db;
typedef long double ld;	
const int mod = 1000000007;

using namespace std;

int32_t main(){
    fast
    	
	//int t;
	//cin>>t;
	//rep(_,0,t){
		
	//}
	int a,b;
	cin>>a>>b;
	cout<<a*b;	
	
    return 0;
}


Measured memory_bytes: 3692
N = int(input())
points = [list(map(int, input().split())) for _ in range(N)]
INF = 10**10
xmax = -INF
xmin = INF
ymax = -INF
ymin = INF
for x, y in points:
  minus = x-y
  plus = x+y
  xmax = max(xmax, minus)
  xmin = min(xmin, minus)
  ymax = max(ymax, plus)
  ymin = min(ymin, plus)
print(max(xmax-xmin, ymax-ymin))

Measured memory_bytes: 102488
import sys, math
from collections import deque

readline = sys.stdin.readline

M, D = map(int, readline().split())

count = 0
for m in range(1, M + 1):
    for d in range(2, D + 1):
        dstr = str(d)
        if len(dstr) != 2:
            continue
        d1 = int(dstr[1])
        d2 = int(dstr[0])
        if d1 < 2 or d2 < 2:
            continue
        if d1 * d2 == m:
            count += 1


print(count)

Measured memory_bytes: 39280
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void precomp()
{
}

void solve()
{
    int a;
    cin>>a;
    cout<<a + a*a + a*a*a<<endl;
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    precomp();
    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	void solve() {
		IOS;
		int n;
		cin >> n;
		double res = (double)n * 2 * 3.141926535;
		cout << setprecision(20) << res << endl;
	}

} // namespace idaten

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


Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 2*100005
#define se second
#define fi first
#define be begin()
#define en end()
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define mod 1000000007
#define Endl "\n"
#define cy cout<<"YES"<<endl;
#define cn cout<<"NO"<<endl;
using namespace std;
	
	
	
int main()
{
	fast;
	ll n;
	cin>>n;
	ll a[n];

	ll i;
	ll x=0;
	rep(i,n)
	{
		cin>>a[i];
		x=(a[i]^x);
	}
	
	for(i=0;i<n;i++)
	{
		ll p=a[i]^x;
		cout<<p<<" ";
	}
	cout<<endl;
	return 0;
	
}

Measured memory_bytes: 5100
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N-2):
    if max(p[i],p[i+1],p[i+2]) != p[i+1] and min(p[i],p[i+1],p[i+2]) != p[i+1]:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#!/usr/bin/env python3


def digit(k,c=0):
    if k == 0:
        return c
    else:
        return digit(k//10,c+1)

def solve(n):
    l = []
    for i in range(round(n**(1/2))):
        a = i+1
        if n % a != 0:
            continue
        b = n // a
        l.append(max(digit(a),digit(b)))
    return min(l)



def main():
    N = int(input())
    print(solve(N))

if __name__ == '__main__':
    main()

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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define int long long
#define ll unsigned long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
	std::ios::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);

const int Maxn = 100001;
const ld pi = acos(-1);
const int mod = 998244353;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A)
{
	for (auto x : A)
		out << x << " ";
	return out;
}



int32_t main(){IOS
	int n,d,a,bombs=0;	cin>>n>>d>>a;
	vector<ipr> A(n);	fr(i,0,n)	cin>>A[i].ff>>A[i].ss;
	sort(all(A));
	vector<int>x(n), h(n), pre(n);
	fr(i,0,n){
		x[i] = A[i].ff;
		h[i] = A[i].ss;
	}
	pre[0] = 0;
	fr(i,0,n){
		h[i] -= pre[i] * a;
		h[i] = max((int)0, h[i]);
		int pos = x[i] + 2 * d, r = upper_bound(all(x), pos) - x.begin() - 1;
		int temp = ceil((double)h[i] / a);
		pre[i] += temp;
		if (r + 1 < n)
			pre[r + 1] -= temp;
		if(i+1<n)
			pre[i+1] += pre[i];
		bombs += temp;
	}
	cout << bombs << endl;
	return 0;
}


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

int main()
{
    long long i,j,a,b,c=0,l=0,t,x,y,n;
    cin>>n;
    long long A[n];
    for(i=0;i<n;i++)
    cin>>A[i];
    for(i=0;i<n-1;i++)
    {
      if(A[i]>A[i+1])
      {
          c+=(A[i]-A[i+1]);
          A[i+1]=A[i];
      }
    }

cout<<c<<endl;
 return 0;
}


Measured memory_bytes: 5196
n = int(raw_input())

print "",

for i in xrange(3,n+1):
	x = i
	if x % 3 == 0:
		print i,
		continue
	while x:
		if x % 10 == 3:
			print i,
			break

		elif x / 10 != 0:
			x = x / 10
			continue
		else:
			break

Measured memory_bytes: 4200
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	long long int a, b, x;
	cin >> a >> b >> x;

	if(a != 0) cout << b/x - (a-1)/x << endl;
	else cout << b/x + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<climits>
using namespace std;
int main()
{
	unsigned long n;
	string ans;

	cin >> n;
	while (n > 0) {
		if (n % 26 == 0) {
			ans += 'z';
			n -= 1;
		}
		else {
			ans += (n % 26) + 'a' - 1;
		}
		n = n/26;
	}

	int i;
	for (i = ans.length() - 1; i >= 0;i--) {
		cout << ans[i];
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}    


signed main()
{
    showoff;
   	int n;
   	cin >>n;
   	if(n&1){cout << 0;return 0;}
   	int c1 = 0,x = 5;
   	while((n/x) > 1){
   		c1 += (n/x)/2;
   		x *= 5;
   	}
   	cout << c1;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 

Measured memory_bytes: 256
n, m = map(int, input().split())
xs = list(map(int, input().split(' ')))
xs.sort()

if n == 1:
  print(xs[-1] - xs[0])
  exit()

diff = [(i, b-a) for i, (a, b) in enumerate(zip(xs, xs[1:]))]
diff.sort(key=lambda x: x[1])

start_indexes = [0] + list(map(lambda x:x[0] + 1, diff[-n+1:]))
start_indexes.sort()

steps = 0
for i_start, i_end in zip(start_indexes, start_indexes[1:] + [m]):
    steps += xs[i_end - 1] - xs[i_start]
print(steps)


Measured memory_bytes: 22720
import java.util.*;

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

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		long a[] = new long[N+1];
		for(int i=0;i<N+1;i++) a[i]=scanner.nextInt();
		long b[] = new long[N];
		for(int i=0;i<N;i++) b[i]=scanner.nextInt();

		long defeated=0;



		for(int i=0;i<N;i++) {
			long tmp1 = b[i];
			long tmp2 = a[i];
			b[i]-= a[i];
			a[i]-= tmp1;
			if(b[i] >= 0) {
				defeated += tmp2;
				long tmp3=b[i];
				long tmp4=a[i+1];
				b[i] -= a[i+1];
				if(b[i] >= 0) {
					defeated += tmp4;
					a[i+1]=0;

				}else {
					a[i+1] -= tmp3;
					defeated += tmp3;
				}

			}else defeated +=tmp1;

//			System.out.println("defeated[" + i + "]=" + defeated);
		}

		System.out.println(defeated);

		scanner.close();
	}
}


Measured memory_bytes: 64932
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    int a,b,c;cin>>a>>b>>c;
    if(c<=a+b+1)cout<<b+c<<endl;
    else {
        int num=a+b+1;
        cout<<num+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int dp[n+2];
 // memset(dp,INT_MAX,sizeof dp);
  for (int i=0;i<n;i++) dp[i]=INT_MAX;
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++){
    for(int j=1;j<=k&&i-j>=0;j++) 
   	 dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
   // cout<<dp[i]<<"  ";
  }
  cout<<endl;
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,W; cin>>N>>W;
  vector<ll> w(N),v(N); rep(i,N) cin>>w[i]>>v[i];
  
  //dp
  vector<vector<ll>> table(N,vector<ll>(W+1,-INF));
  
  function<ll(ll,ll)> dp=[&](ll i,ll j){
    if(i<0||j<=0) return 0LL;
    if(table[i][j]>-INF) return table[i][j];
    
    ll ret=0;
    chmax(ret,dp(i-1,j));
    if(j-w[i]>=0) chmax(ret,dp(i-1,j-w[i])+v[i]);
    
    return table[i][j]=ret;
  };
  
  cout<<dp(N-1,W)<<endl;
  /*
  rep(i,N){
    rep(j,W+1){
      if(j!=0) cout<<" ";
      cout<<dp(i,j);
    }
    cout<<endl;
  }
  */
  
  return 0;
}

Measured memory_bytes: 82200
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,x,y;
    scanf("%d",&n);
    if(n==1)
    {
        printf("Hello World\n");
        return 0;
    }
    scanf("%d%d",&x,&y);
    printf("%d\n",x+y);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

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

Measured memory_bytes: 256
from collections import deque

section = input( )
area = 0
depthPosArr = deque( )
depthPosPoolArr = deque( )

for ipos, ground in enumerate( section ):
	if "\\" == ground:
		depthPosArr.append( ipos )
	elif "/" == ground:
		if len( depthPosArr ):
			jpos = depthPosArr.pop( )
			pool =  ipos - jpos
			area += pool

			while len( depthPosPoolArr ):
				preJPos, prePool = depthPosPoolArr.pop( )
				if jpos <= preJPos:
					pool += prePool
				else:
					depthPosPoolArr.append( ( preJPos, prePool ) )
					break
			depthPosPoolArr.append( ( jpos, pool ) )

print( area )
output = deque( )
output.append( len( depthPosPoolArr ) )
for arr in depthPosPoolArr:
	output.append( arr[1] )
print( " ".join( map( str, output ) ) )

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c);
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000
#define PI acos(-1.0)

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

#define scan(x)      do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;
ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    //scan(n);
    cin>>n;
    cout<<(n*(n-1))/2<<endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> v(n, 0);
    
    bool inc = false, dec = false;

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

    int ans = 1;

    for(int i = 0; i + 1 < n; ++i) {
        if(v[i + 1] > v[i] and dec) {
            ans++;
            inc = false;
            dec = false;
        } else if(v[i + 1] < v[i] and inc) {
            ans++;
            inc = false;
            dec = false;
        } else if(v[i + 1] > v[i]) {
            inc = true;
        } else if(v[i + 1] < v[i]) {
            dec = true;
        }
    }

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

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int n,m; cin>>n>>m;
	cout<<(m*(m-1)+n*(n-1))/2;
	
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int n;
    s(n);

    int prizes[n][3] = {0};
//    fill_n(prizes, n*3, (int)-1);
//    vector<vector<int>> prizes(n, vector<int>(3, 0));
    f(i, 0, n){
        f(j, 0, 3){
            s(prizes[i][j]);
        }
    }
//    vector<vector<int>> dp(n + 1, vector<int>(3, 0));
    int dp[n+1][3] = {0};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            int idx1 = (j + 1) % 3;
            int idx2 = (j + 2) % 3;
            dp[i + 1][j] = max(dp[i][idx1] + prizes[i][idx1], dp[i][idx2] + prizes[i][idx2]);
        }
    }
    int maxx = *max_element(dp[n], dp[n]+3);
    p(maxx);
    return;
}

class CVacation {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CVacation solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 8304
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
const int Max_N = 100000;
ll N,M;
vector<vector<ll> > A(Max_N);
priority_queue<int> que;

int main(){
  cin >> N >> M;
  for(int i=0;i<N;i++){
    ll n,m;
    cin>>n>>m;
    A[n].push_back(m);
  }
  ll sum =0;
  for(int j=1;j<M+1;j++){
    for(auto i:A[j]){
	que.push(i);
    }
    if(!que.empty()){
      sum += que.top();
      que.pop();
    }
  }
  cout << sum << endl;
  
}



Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

double p[8];
double q[8];
double A[8];
double B[8];
const double EPS = 1e-10;

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  rep(i, 6) {
    cin >> p[i];
    p[i] /= 100.0;
  }

  using Pair = pair<double, int>;
  vector<Pair> ps;
  rep(i, 6) {
    cin >> q[i];
    q[i] /= 100.0;
    if (p[i]+q[i] > EPS) ps.eb(Pair(q[i]/(p[i]+q[i]), i));
    else ps.eb(Pair(0, i));
  }
  ps.eb(Pair(1+EPS, 6));
  sort(all(ps));

  double ans = 2;
  bool high[7] = {};
  double l = 0;
  rep(i, 7) {
    double cof = 0;
    double cons = 0;
    double r = ps[i].X;
    rep(j, 6) {
      cof -= q[j];
      cons += q[j];
      if (high[j]) {
        cof += p[j]+q[j];
        cons -= q[j];
      }
    }
    MN(ans, min(cof*l+cons, cof*r+cons));
    //cout << l << ", " << ans << endl;
    //cout << r << ", " << ans << endl;
    l = r;
    high[ps[i].Y] = 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
		using namespace std;
		#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//#define ll long long int
		#define pb push_back
		#define fe first
		#define se second
		#define endl "\n"
		#define pii pair<int, int>
        #define int long long int
		#define PI 3.14159265358979323846
		const int N = 1e5 + 10;
		int n,m;
		int tot;
		int p[N],siz[N],a[N],b[N];
		vector<int> ans;
		void init() {
			   for(int i=1;i<=n;i++) {
				      p[i]=i;
				      siz[i]=1;
			   }
			}
		int findi(int x) {
			   while(x!=p[x]){
				      p[x]=p[p[x]];
				      x=p[x];
				   }
				   return x;
			}
			
			
		void uni(int  x,int  y) {
			  int yo1=findi(x);
			  int yo2=findi(y);					
			   if(yo1==yo2)
			     return ;
			     
			     if(siz[yo1]>siz[yo2])
			        swap(yo1,yo2);
			        tot-=(siz[yo1]*siz[yo2]);
			        siz[yo2]+=siz[yo1];
                    siz[yo1]=0;
			        p[yo1]=p[yo2];
			}		
		
       
		void solve() {
		      cin>>n>>m;
		      init();
		      for(int i=1;i<=m;i++) {
				  cin>>a[i]>>b[i];  
				  }
				 tot= 1LL*((n)*(n-1)/(2));
			for(int i=m;i>=1;i--) {
				   ans.pb(tot);
				   uni(a[i],b[i]);
				}
	
				reverse(ans.begin(),ans.end());
				
				for(int i=0;i<ans.size();i++) 
				    cout<<ans[i]<<endl;	
			 					
		}			
			   

		int32_t main() {
  
		  cool;
		  int t = 1;
		  while (t--)
			solve();

		  return 0;
		}


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

int main() {
   int N, K;
   cin >> N >> K;
   vector<int> p(N);
   int count = N;
   for (int i = 0; i < count; i++)
   {
       cin >> p.at(i);
   }
   sort(p.begin(), p.end());
   int ans = 0;
   for (int i = 0; i < K; i++)
   {
       ans+= p.at(i);
       /* code */
   }
   cout << ans << endl;
   
   
}

Measured memory_bytes: 3600
mod=10**9+7
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0]*(m+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0]=1
for i in range(m+1):
    dp[0][i]=1
for i in range(n):
    for j in range(m):
        #答え見たらここの添字間違えてただけ…
        #だけど、適当にダブりを引きたくなっただけなので全然方針としてだめ、要復習
        if s[i]==t[j]:
            dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1])%mod
        else:
            dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1]-dp[i][j])%mod
print(dp[n][m])

Measured memory_bytes: 98600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# 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
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



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 modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    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;
}
const ll MAX = 510000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


using graph = vector<vector<ll>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin>>n>>k;
    COMinit();
    if(n>k){
        cout<<0<<endl;
        return 0;
    }else{
        cout<<factorial(n)*COM(k,n)%mod<<endl;
    }
    return 0;
}



Measured memory_bytes: 15176
//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int m, n;
    cin >> m >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    if(m == 2){
        int x = 0, y = 0;
        rep(i, n){
            if(a[i] == 1 + i % 2) x++;
            else y++;
        }
        cout << min(x, y) << endl;
        return 0;
    }
    int ans = 0;
    int pre = -1;
    int l = 0;
    rep(i, n){
        if(a[i] != pre){
            pre = a[i];
            ans += l / 2;
            l = 1;
        }else{
            l++;
        }
    }
    ans += l / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N; cin >> N; bool can = false;
  rep(i, N){
    if((int)((i+1)*1.08) == N) {cout << i+1 << endl; can = true; break;}
  }
  if(!(can)) cout << ":(" << endl;
}

Measured memory_bytes: 256