akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var s = cin.ReadLine;

            WriteLine(s.Substring(0, 4) + " " + s.Substring(4));
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair

int ans=0, x, y, b[101010];
bool vis[202020];
vector<pi> v;

int main(){
int n, m;

rep(i, 1, 101010){
b[i]=1;
}
vis[1]=true;
cin >> n >> m;
rep(i, 1, m){
cin >> x >> y;
v.pb({x,y});
}

rep(i, 0, m-1){

        int x = v[i].f;
        int y = v[i].s;
        if(vis[x]){
            vis[y]=true;
        }
        b[x]--;
        b[y]++;
        if(b[x]<=0)vis[x]=false;

}





rep(i, 1, n){
if(vis[i])ans++;
}

cout << ans << endl;

return 0;}


Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
typedef int LL;
const LL maxn=3e6+9,mod=1e9+7;
#define pb push_back
#define opt operator
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0'|| c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}
	return x*f;
}
LL Pow(LL base,LL b){ LL ret(1); while(b){ if(b&1) ret=1ll*ret*base%mod; base=1ll*base*base%mod; b>>=1; } return ret; }
LL n,m,T,v2;
LL a[maxn];
struct node{
	LL to,nxt;
}dis[maxn];
LL ans;
LL head[maxn],num,size[maxn],fac[maxn],fac2[maxn];
void Add(LL u,LL v){
	dis[++num]=(node){v,head[u]}; head[u]=num;
}
void Dfs(LL u,LL fa){
	size[u]=1;
	LL sz(0);
	for(LL i=head[u];i;i=dis[i].nxt){
		LL v(dis[i].to);
		if(v==fa){
		}else{
		    Dfs(v,u); size[u]+=size[v];
	    }
		sz++;
	}
	LL ret(0);
	for(LL i=head[u];i;i=dis[i].nxt){
		LL v(dis[i].to);
		if(v==fa) ret=(1ll*ret+1ll*fac[size[u]]*(1ll-fac[n-size[u]]+mod)%mod)%mod;
		else ret=(1ll*ret+1ll*fac[n-size[v]]*(1ll-fac[size[v]]+mod)%mod)%mod;
	}
	ret=(1ll*ret+fac[n])%mod;
	ret=(1ll*ret+v2)%mod;
	ret=(1ll-ret+mod)%mod;
	ans=(1ll*ans+ret)%mod;
}
LL A[maxn],B[maxn];
int main(){
	LL xx(7ll*Pow(16,mod-2)%mod);
//	printf("%d\n",xx);
    n=Read();
    v2=(Pow(2,mod-2));
    fac[0]=1; for(LL i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*v2%mod;
//    printf("    %d\n",fac[2]);
    fac2[0]=1; for(LL i=1;i<=n;++i) fac2[i]=1ll*fac2[i-1]*2%mod;
    for(LL i=1;i<n;++i){
    	LL u(Read()),v(Read()); Add(u,v); Add(v,u);
	}
    Dfs(1,0);
    printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 21760
/*
 * 2566.cc: Restore Calculation
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

typedef long long ll;
const ll MOD = 1000000007;

/* typedef */

/* global variables */

int as[MAX_N], bs[MAX_N], cs[MAX_N];
ll dp[MAX_N + 1][2];

/* subroutines */

/* main */

int main() {
  for (;;) {
    string sa, sb, sc;
    cin >> sa;
    if (sa == "0") break;
    cin >> sb >> sc;

    int n = sa.size();
    for (int i = 0, j = n - 1; i < n; i++, j--) {
      as[j] = (sa[i] == '?') ? -1 : sa[i] - '0';
      bs[j] = (sb[i] == '?') ? -1 : sb[i] - '0';
      cs[j] = (sc[i] == '?') ? -1 : sc[i] - '0';
    }
    //for (int i = 0; i < n; i++) printf("%d", as[i]); putchar('\n');
    //for (int i = 0; i < n; i++) printf("%d", bs[i]); putchar('\n');
    //for (int i = 0; i < n; i++) printf("%d", cs[i]); putchar('\n');

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int i = 0; i < n; i++)
      for (int j = 0; j < 2; j++)
	if (dp[i][j] > 0) {
	  int mina = (i == n - 1) ? 1 : 0;
	  for (int a = mina; a <= 9; a++)
	    if (as[i] < 0 || as[i] == a) {
	      int minb = (i == n - 1) ? 1 : 0;
	      for (int b = minb; b <= 9; b++) 
		if (bs[i] < 0 || bs[i] == b) {
		  int c = a + b + j;
		  int cr = c / 10;
		  c %= 10;
		  if ((cs[i] < 0 || cs[i] == c) && (i < n - 1 || c != 0)) {
		    dp[i + 1][cr] = (dp[i + 1][cr] + dp[i][j]) % MOD;
		    //printf("[%d] %d+%d+(%d)=(%d)%d (%d,%d,%d)\n",
		    //i, a, b, j, cr, c, as[i], bs[i], cs[i]);
		  }
		}
	    }
	}

    printf("%lld\n", dp[n][0]);
  }

  return 0;
}

Measured memory_bytes: 1196
import bisect
N=int(input())
L=map(int,input().split())
l=list(L)
l.sort()

result=0
for i in range(0,N):
  for j in range(i+1,N):
    result += bisect.bisect_left(l,l[i]+l[j])-1-j

print(result)

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

int main() 
{ 
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    int count=0,sum=0;
    
     for(int i=0;i<n;i++){
        if(a[i]%2==0){
            count++;}}
            
    for(int i=0;i<n;i++){
        if(a[i]%2==0){
            if(a[i]%3==0 or a[i]%5==0){
                sum++;
            }}}
           
if(sum==count){
    cout<<"APPROVED"<<endl;
}
else{
     cout<<"DENIED"<<endl;
    }}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  string s, t;
  cin >> s >> t;
  for (int i = n; i >= 0; --i) {
    if (t.substr(0,i) == s.substr(n-i)) {
      cout<<n*2-i<<endl;
      return 0;
    }
  }
  return 0;
}







Measured memory_bytes: 256
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

/* オリジナル関数を追加 */
void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2112
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var s = o.a(1);
  var ans = 9e9;
  var w = xArray(0,n+1);
  var b = xArray(0,n+1);
  for(var i = 0; i < n; i++){
    w[i+1] = w[i];
    if(s[i] === "#")w[i+1]++;
  }
  for(var i = i-1; i >= 0; i--){
    b[i] = b[i+1];
    if(s[i] === ".")b[i]++;
  }
  for(var i = 0; i <= n; i++){
    var t = w[i] + b[i];
    if(t < ans)ans = t;
  }
  return ans;
}


Measured memory_bytes: 10800
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <cmath>
#include<map>
#include<string.h>
#include <algorithm>
#include <bits/stdc++.h> 
#include<vector>

using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define replb(i,a,b) for(ll i=a;i>=b;i--)
#define repl(i,a,b) for(ll i=a;i<b;i++)
#define repit(arr)  for(auto it=arr.begin();it!=arr.end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define seti set <int>
#define setl set <ll>
#define dseti set <int, greater <int> >
#define dsetl set <ll, greater <ll> >
#define mseti multiset <int>
#define msetl multiset <ll>
#define dmseti multiset <int, greater <int> >
#define dmsetl multiset <ll, greater <ll> >
#define sortA(arr)   sort(arr.begin(),arr.end())
#define ssort(arr) stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
int gcd(int a,int b){
    if (a < b) swap(a, b);
    if (b == 0) return a;
    else return gcd(b, a % b);
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t,n;
    cin>>n;
    cout<<n+n*n+n*n*n;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

class UnionFind{
public:
	vector<int>T;
	vector<int>p;
	UnionFind(int n){
		T.resize(n);
		p.resize(n);
		for(int i=0;i<n;i++){
			p[i]=i;
		}
	}
	
	int getParent(int n){
		if(p[n]==n)return n;
		return getParent(p[n]);
	}
	bool isSame(int n,int m){
		return getParent(n)==getParent(m);
	}
	void unite(int n,int m){
		int rx=getParent(n);
		int ry=getParent(m);
		p[rx]=ry;
	}
};
	
int main(){
	init();
	ll H,W;cin>>H>>W;
	string flame;
	for(int i=0;i<W+2;i++)flame.push_back('#');
	cout<<flame<<endl;
	for(int i=0;i<H;i++){
		string s;cin>>s;
		s="#"+s+"#";
		cout<<s<<endl;
	}
	cout<<flame<<endl;
}


Measured memory_bytes: 256
A,B,C,X,Y=list(map(int,input().split()))

ret=10**10

for i in range(max(2*X,2*Y)+1):
    cx=X-i//2
    cy=Y-i//2

    price=max(0,cx)*A+max(0,cy)*B+i*C
    ret=min(ret,price)

print(ret)

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

const int k_mod = 1e9 + 7;

ll* cost_array;

void dfs( vector <vector <pair <int, ll> > >& tree_matrix, int x, ll cost ){
	cost_array[ x ] = cost;
	if (cost == k_mod)
		cost = 0;
	for(auto p: tree_matrix[ x ]){
		if (cost_array[ p.first ] == 0)
			dfs( tree_matrix, p.first, cost + p.second );
	}
}

int main( void ){
	int N;
	cin >> N;
	vector <vector <pair <int, ll> > > tree_matrix( N + 2 );
	cost_array = new ll[ N + 2 ]();
	rep( i, 0, N - 1 ){
		int a, b, c;
		cin >> a >> b >> c;
		tree_matrix[ a - 1 ].push_back( make_pair( b - 1, c ));
		tree_matrix[ b - 1 ].push_back( make_pair( a - 1, c ));
	}
	int Q, K;
	cin >> Q >> K;
	dfs( tree_matrix,  K - 1, k_mod );
	rep( i, 0, Q ){
		int x, y;
		cin >> x >> y;
		cout << cost_array[ x - 1 ] + cost_array[ y - 1 ] << endl;
	}
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
#define OUTP(x) cout << x.first << ' ' << x.second << endl;

using namespace std;

map<string, int> nm;

int main()
{
    int n; cin >> n;
    int a[n];
    FOR(i, n, 0)
    {
        string s; cin >> s >> a[i];
        nm[s] = i;
    }
    string now ; cin >> now;
    int ind = nm[now] + 1;
    ll ans = 0;
    FOR(i, n, ind)ans += a[i];
    cout << ans << endl;
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = max(a+b, max(a-b, a*b));
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

vector<vector<vector<int>>> dp(90, vector<vector<int>>(90, vector<int>(25700)));
vector<vector<int>> A(90, vector<int>(90));
vector<vector<int>> B(90, vector<int>(90));


int main() {
    int h, w;
    cin >> h >> w;
    rp(i, 0, h) {
        rp(j, 0, w) {
            cin >> A.at(i+1).at(j+1);
        }
    }
    rp(i, 0, h) {
        rp(j, 0, w) {
            cin >> B.at(i+1).at(j+1);
        }
    }
    dp[0][1][12850] = 1;
    dp[1][0][12850] = 1;
    rp(i, 1, h+1) {
        rp(j, 1, w+1) {
            int s = A[i][j] - B[i][j];
            rp(k, 0, 25700) {
                if(dp[i][j-1][k] == 1 or dp[i-1][j][k] == 1) {
                    dp[i][j][k + s] = 1;
                    dp[i][j][k - s] = 1;
                }                
            }
        }
    }
    int res = INT_MAX;
    rp(k, 0, 25700) {
        if(dp[h][w][k] == 1) chmin(res, abs(k-12850));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 825692
n = int(input())
arr = list(map(int, input().strip().split()))

dp = [0] * (n)
dp[1] = abs(arr[1] - arr[0])

for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(arr[i-1] - arr[i]), dp[i-2] + abs(arr[i-2] - arr[i]))

print(dp[-1])

Measured memory_bytes: 13980
macro_rules! input {
    // ?
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };

    // stdinの生成 値の読み込み開始
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    // ?
    ($next:expr) => {};
    // ?
    ($next:expr, ) => {};

    // 変数名:型の読み込みの繰り返し
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    // 値を読み込むベース 型,の繰り返し
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    // 配列の読み込み
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    // 文字列Vec<char>の読み込み
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    // usize1?の読み込み
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // 指定した型で読み込み
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        nums : [u64;n],
    };


    println!("{}", solve(nums));
}

fn solve(mut nums: Vec<u64>) -> usize {
    let mut counter: usize = 0;
    while nums.iter().all(|x| x % 2 == 0) {
        counter = counter + 1;
        nums = nums.into_iter().map(|x| x / 2).collect()
    }
    return counter;
}

macro_rules! tests {
    ($($name:ident:[$( $args:expr ),*] => $output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output,super::solve($($args),*));
                }
            )*
        }
    }
}


tests! {
    //テスト名:[引数]=>expected
    test1: [vec![8, 12, 40]] => 2,
    test2: [vec![5, 6, 8, 10]] => 0,
    test3: [vec![382253568, 723152896, 37802240, 379425024, 404894720, 471526144]]=> 8,
}


Measured memory_bytes: 4352
N, M = gets.split.map(&:to_i)
LRs = readlines.map{|l| l.split.map(&:to_i)}

puts LRs.each_with_object(Array.new(N + 2, 0)){|(l, r), a| a[l] += 1; a[r + 1] -= 1}.inject([]){|b, a| b << (b.last || 0) + a}.count(M)

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

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


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 1000000000000000000LL //2e18
#define SIZE 210

ll dp[10000][SIZE];

bool solve(){
  int n, m, r;
  ll dist[2][SIZE][SIZE];
  
  scanf("%d%d", &n, &m);

  if(n == 0) return false;

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      dist[0][i][j] = dist[1][i][j] = LLINF;
    
  for(int i=0;i<n;i++)
    dist[0][i][i] = dist[1][i][i] = 0;
  
  for(int i=0;i<m;i++){
    int x, y, t, cn;
    char c;

    scanf("%d%d%d %c", &x, &y, &t, &c);
    x--; y--;
    cn = c == 'S';

    dist[cn][x][y] = dist[cn][y][x] = t;
  }

  
  for(int p=0;p<2;p++)
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
          dist[p][i][j] = min(dist[p][i][j], dist[p][i][k] + dist[p][k][j]);
  
  int prev_z, z;
  
  scanf("%d%d", &r, &prev_z);
  prev_z--;
  
  for(int i=0;i<=r;i++)
    for(int j=0;j<n;j++)
      dp[i][j] = LLINF;

  dp[0][prev_z] = 0;
  
  for(int i=0;i<r-1;i++){
    scanf("%d", &z);
    z--;
    
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        dp[i+1][j] = min(dp[i+1][j], dp[i][k] + dist[0][prev_z][k] + dist[1][k][j] + dist[0][j][z]);
      }
      dp[i+1][j] = min(dp[i+1][j], dp[i][j] + dist[0][prev_z][z]);
    }
    
    prev_z = z;
  }
  
  ll ans = LLINF;
  
  for(int i=0;i<n;i++){
    ans = min(ans, dp[r-1][i]);
  }
  
  printf("%lld\n", ans);
  
  
  return true;
}

int main(){
  while(solve());
}



Measured memory_bytes: 5480
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static class Node {
		int idx;
		ArrayList<Node> edges = new ArrayList<>();
		public Node(int idx) {
			this.idx = idx;
		}
	}
	public static class Graph {
		int N;
		Node[] nodes;
		public Graph(int n) {
			N = n;
			nodes = new Node[N];
			for(int i=0; i<N; i++)
				nodes[i] = new Node(i);
		}
		
		public void addEdge(int a, int b) {
			nodes[a].edges.add(nodes[b]);
			nodes[b].edges.add(nodes[a]);
		}
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		int N = sc.nextInt();
		Graph g = new Graph(N);

		int M = sc.nextInt();
		for(int i=0; i<M; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			g.addEdge(a, b);
		}
		
		LinkedList<Integer> ans = new LinkedList<>();
		boolean[] visited = new boolean[N];
		int head = 0;
		int tail = g.nodes[0].edges.get(0).idx;
		visited[head] = visited[tail] = true;
		ans.add(head);
		ans.add(tail);
		
		while(true) {
			int next=-1;
			for(Node n : g.nodes[head].edges) {
				if(!visited[n.idx]) {
					next = n.idx;
					break;
				}
			}
			if(next<0)
				break;
			visited[next] = true;
			ans.push(next);
			head = next;
		}
		while(true) {
			int next=-1;
			for(Node n : g.nodes[tail].edges) {
				if(!visited[n.idx]) {
					next = n.idx;
					break;
				}
			}
			if(next<0)
				break;
			visited[next] = true;
			ans.add(next);
			tail = next;
		}
	
		pw.println(ans.size());
		Iterator<Integer> it = ans.iterator();
		while(it.hasNext())
			pw.print((it.next()+1) + (it.hasNext() ? " " : "\n"));
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 103160
fn main() {
    let (n, r) = read_tuple::<i32>();

    if n >= 10 {
        println!("{:?}", r);
    } else {
        println!("{:?}", r + 100*(10-n));
    }
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
 
ll N, M;
vector<ll> v;
 
ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
 
 
int main() {
    cin >> N >> M;
    for (ll i = 0; i < N; ++i) {
        ll a; cin >> a; v.push_back(a>>1);
        if (a&1LL) { cout << "0" << endl; return 0; }
    }
    ll lcm = v[0];
    for (int i = 1; i < N; ++i) {
        lcm = (lcm * v[i]) / gcd(lcm, v[i]);
        if (lcm > M) { cout << "0" << endl; return 0; }
    }
  	for (num : v) {
      if ((lcm/num)%2LL == 0LL) { cout << 0 << endl; return 0; }
    }
 
    ll ans = 0;
    for (ll i = lcm; i <= M; i += (lcm<<1)) ++ans;
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<vector>
using namespace std ;

const int N = 1e6 + 10;
vector <int> sum ;
void add(vector<int >&T)
{
    vector<int> C;
    int t = 0;
    for(int i = 0;i<T.size()||i<sum.size();i++)
    {
        if(i<T.size()) t+=T[i];
        if(i<sum.size()) t+=sum[i];
        C.push_back(t%10);
        t/=10;
    }
    if(t)C.push_back(1);
    sum = C;
}
int main ()
{

    int n ;
    cin >> n ;
    for(int i = 1;i<= n; i++)
    {
        if(i % 5!=0 && i%3!=0)
        {
            int t = i;
            vector<int >T;
            while(t!=0)
            {
                int x= t%10;
                T.push_back(x);
                t/=10;
            }
           // for(int j =T.size();j>=0;j--) cout<<T[j];
           // cout<<endl;
            add(T);
            
        }
        
    }
    for(int i =sum.size()-1;i>=0;i--) cout<<sum[i];
    return 0 ;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// #define ll long long
// bool isEven(ll n) {return (n%2!=0)?false:true;}

using namespace std;

//atcoder - dp
//d

int N, W;
long long weight[105], value[105];
long long memo[105][100005];

long long dp(int i, int w)
{

    if(w<0)
        return INT_MIN;
    else if(w==0&&i>=0)
        return 0;
    else if(i<0)
        return 0;

    if(memo[i][w]!=-1)
        return memo[i][w];


    memo[i][w] = max(value[i] + dp(i-1, w-weight[i]) , dp(i-1, w));

    return memo[i][w];
}

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

    for (int i = 0; i < N; ++i)
    {
        cin>>weight[i]>>value[i];
        memset(memo[i], -1, sizeof(memo[i]));
    }

    // for (int i = 0; i < N; ++i)
    // {
    //     FOR0(j, 10)
    //         cout<<memo[i][j]<<" ";
    //     cout<<endl;
    // }

    cout<<dp(N-1, W)<<endl;;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			

		
	   
int main() {
			fast
			#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
			#endif

			ll t;
			t=1;
			while(t--)
			{
				ll n,m,xxx;
				cin>>n>>m>>xxx;
				ll ans=0;

				char arr[n+1][m+1]={0};
				ll arr2[n+1][m+1]={0};
				
				for(ll i=1;i<=n;i++)
				for(ll j=1;j<=m;j++)
				{
					cin>>arr[i][j];
					if(arr[i][j]=='#')
					ans+=1;
				}

				if(ans==xxx)
				ans=1;
				else
				ans=0;
				
				for(ll i=0;i<(1<<n);i++)
				{
					for(ll j=0;j<(1<<m);j++)
					{
						
						ll check=0;
						memset(arr2,-1,sizeof(arr2));
						for(ll k=0;k<n;k++)
						{
								if(i&(1<<k))
								{
									ll xx=k+1;
									check+=1;
									
									for(ll a=1;a<=n;a++)
									for(ll b=1;b<=m;b++)
										if(a==xx)
										arr2[a][b]=0;
								}
						}
						
						for(ll k=0;k<m;k++)
						{
								if(j&(1<<k))
								{
									check+=1;
									ll xx=k+1;
									for(ll a=1;a<=n;a++)
									{
										for(ll b=1;b<=m;b++)
										{
										
										if(b==xx)
										arr2[a][b]=0;
										}
									}
								}
						}
								ll count=0;
								for(ll a=1;a<=n;a++)
								{
										for(ll b=1;b<=m;b++)
										{
										if(arr2[a][b]==-1 and arr[a][b]=='#')
										count+=1;
										}
								}
									if(count==xxx and check>0)
									ans+=1;
									
							
					}
				}
				cout<<ans<<endl;
				
			}
			return 0;
		 }	




Measured memory_bytes: 3688
N = int(input())
word_cnts = {}
curr_max = 0
for _ in range(N):
    word = input()
    if word in word_cnts:
        word_cnts[word] += 1
    else:
        word_cnts[word] = 1
    curr_max = max(curr_max, word_cnts[word])

for word in sorted(k for k in word_cnts if word_cnts[k] == curr_max):
    print(word)

Measured memory_bytes: 32156
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int main(){
    string S,T;
    cin>>S>>T;
    int ss=S.size();
    int ts=T.size();
    vector<int> len(ss);
    int cnt=0;

    for(int i=0;i<ss;i++){
        cnt=0;
        for(int j=0;j<ts;j++){
            if(i+j<ss){
                if(S[i+j]==T[j]){
                    cnt++;
                }
            }else{
                cnt=0;
                break;
            }
        }
        len[i]=cnt;
    }

    int ans=0;
    for(int i=0;i<ss;i++){
        if(ans<len[i]){
            ans=len[i];
        }
    }
    ans=ts-ans;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>
int main(void) {
	int A, B;
	scanf("%d%d", &A, &B);
	if (A + B >= A - B && A + B >= A * B) {
		printf("%d", A + B);
	}
	else if (A - B >= A + B && A - B >= A * B) {
		printf("%d", A - B);
	}
	else if(A*B>= A + B && A*B >= A -B) {
		printf("%d", A*B);
	}


	return 0;

}

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

using namespace std;
int main(){
    int in, check = 0;

    cin>>in;

    while(in > 0){
        if(in%10 == 7){
            cout<<"Yes\n";
            check = 1;
            break;
        }
        in = in/10;

    }
    if(check == 0){
        cout<<"No\n";
    }

    return 0;
}



Measured memory_bytes: 3612
import sys

while 1:
    line = sys.stdin.readline()
    if (not line):
        break
    x, y = map(int, line.split())
    if (x > y):
        gcd = x
        t = y
    else :
        gcd = y
        t = x
    while (t > 0) :
        tmp = gcd % t
        gcd = t
        t = tmp
    lcm = x * y / gcd
    print str(gcd) + " " + str(lcm)

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std; 
  
typedef long long ll; 
typedef pair<ll, ll> pll;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
 
#define MOD 1000000007  
#define f(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))  
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
#define rep(i, n) f(i, 0, n) 
#define ff first 
#define ss second  
#define pb push_back 
#define all(v) v.begin(), v.end()  
#define wh(t) while (t--) 
#define inf 1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n"; 

const ll N = 2e5 + 5;

ll binpow(ll a,ll n)
{
    ll i=1;
    while(n>0)
    {
        if(n&1)
            i=(i*a);
        a=(a*a);
        n = n>>1;
    }
    return i;
}
 
ll isprime(ll n)
{
    if(n==0||n==1)
        return n;
    if(n%2==0)
        return (ll)2;
    if(n%3==0)
        return (ll)3;
    else
    {
        for(ll i=5;i*i<=n;i+=6)
        {
            if(n%i==0)
                return i;
            if(n%(i+2)==0)
                return (i+2);
        }
        return n;
    }
}

ll ans,n,m;
vvl v;

void solve(ll i, vl req, ll val){
	if(i == n) return;
	
	solve(i+1,req,val);
	
	bool bl = false;
	for(ll j = 1;j<=m; ++j){
		req[j] = max((ll)0,req[j]-v[i][j]);
		if(req[j]) bl = true;
	}
	val+= v[i][0];
	if(bl){
		solve(i+1,req,val);
	}
	else{
		ans = min(ans, val);
	}
}

int main(){
    fast;
    ll l,r,i,j,k,a,b,c,q,x,t,y,d;
   	ans = inf;
   	cin>>n>>m>>x;
	v.resize(n,vl(m+1,0));
	rep(i,n){
		rep(j,m+1) cin>>v[i][j];
	}   	
   	vl req(m+1,x);
   	solve(0,req,0);
   	
   	if(ans == inf){
   		pp(-1);	
	}
	else pp(ans);
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
string s;
int LiangJiaJun(){
    cin>>s;
    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, c, k, i;
    cin >> a >> b >> c >> k;
    if(a >= k){
        cout << k << '\n';
        exit(0);
    }
    k -= a;
    if(b >= k){
        cout << a << '\n';
        exit(0);
    }
    k -= b;
    cout << a-k << '\n';
    return 0;
}


Measured memory_bytes: 3652
use proconio::input;

struct RGB {
    r: u64,
    g: u64,
    b: u64,
}

impl RGB {
    fn count(&mut self, c: char) {
        match c {
            'R' => {
                self.r += 1;
            }
            'G' => {
                self.g += 1;
            }
            'B' => {
                self.b += 1;
            }
            _ => {
                return ();
            }
        }
    }
    fn new() -> RGB {
        RGB { r: 0, g: 0, b: 0 }
    }
}

fn is_rgb_triple(x: char, y: char, z: char) -> bool {
    let mut rgb = RGB::new();
    rgb.count(x);
    rgb.count(y);
    rgb.count(z);

    rgb.r == 1 && rgb.g == 1 && rgb.b == 1
}

fn main() {
    input! {
        n: usize,
        s: String,
    }

    let mut rgb = RGB::new();
    for c in s.chars() {
        rgb.count(c);
    }

    let mut nr_sym = 0;
    for i in 0..n {
        for j in ((i + 2)..n).step_by(2) {
            let s_i = s.as_bytes()[i] as char;
            let s_j = s.as_bytes()[j] as char;
            let s_k = s.as_bytes()[(i + j) / 2] as char;
            if is_rgb_triple(s_i, s_j, s_k) {
                nr_sym += 1;
            }
        }
    }

    let ans = (rgb.r * rgb.g * rgb.b) - nr_sym;
    println!("{}", ans);
}

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

using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using P = pair<int, int>;
int h, w, x, y, dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}, ans;
char s[25][25];
int main() {
    scanf("%d%d", &h, &w);
    rep(i, h) scanf("\n%s", s[i]);
    rep(i, h) rep(j, w) if (s[i][j] == '.') {
                int dist[25][25] = {}, m = 0;
                queue<P> qu;
                qu.push(P{i, j});
                dist[i][j] = 1;
                while (!qu.empty()) {
                    tie(x, y) = qu.front();
                    qu.pop();
                    rep(i, 4) {
                        int nx = x + dx[i], ny = y + dy[i];
                        if (dist[nx][ny] || s[nx][ny] != '.') continue;
                        dist[nx][ny] = dist[x][y] + 1;
                        m = max(m, dist[nx][ny]);
                        qu.push(P{nx, ny});
                    }
                }
                ans = max(ans, m - 1);
            }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
int A[100000];
vector<int> G[100000];
bool used[100000], used2[100000];
P dfs(int x) {
  used[x] = true;
  P m = P(A[x], x);
  for (int t : G[x]) if (!used[t]) m = min(m, dfs(t));
  return m;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  if (N-1 == M) {
    cout << 0 << "\n";
    return 0;
  }
  int C = N-1-M;
  if (2*C > N) {
    cout << "Impossible\n";
    return 0;
  }
  vector<P> ps;
  rep(i, N) cin >> A[i], ps.pb(P(A[i], i));
  sort(all(ps));
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    G[x].pb(y);
    G[y].pb(x);
  }
  long long sum = 0;
  rep(i, N) if (!used[i]) {
    P p = dfs(i);
    sum += p._1;
    used2[p._2] = true;
  }
  int rest = C-1;
  for (P p : ps) if (!used2[p._2]) {
    if (rest == 0) break;
    rest--;
    sum += p._1;
  }
  assert(rest == 0);
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 7156
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

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

	rep(i, 0, s.size()) {
		if (i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, x, l[100], d = 0,ans =1;
	cin >> n >> x;
	rep(i, n) {
		cin >> l[i];
		d += l[i];
		if (d <= x)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

// public class A {
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double T = sc.nextInt();
        double X = sc.nextInt();

        double res = 0.0000000;
        res = T/X;
        System.out.println(res);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> A(N);
    for (int &a: A)
        cin>>a;

    priority_queue<int> Q;
    for (int a: A)
        Q.push(a);
    for (int i=0; i<M; i++)
    {
        int a = Q.top();
        Q.pop();
        Q.push(a/2);
    }
    long long ans = 0;
    for (; !Q.empty(); Q.pop())
        ans += Q.top();
    cout<<ans<<endl;
}


Measured memory_bytes: 1276
# Your code here!
a,b=gets.split
a=a.to_i
b=b.to_i
aa=gets.split("")


num=["1","2","3","4","5","6","7","8","9","0"]


i=0

(a+b+1).times{
  if i==a && aa[i]=="-"
      
    elsif i!=a && num.include?(aa[i])
    
else  puts "No"
    exit
end
   
    
  i+=1  
}

puts "Yes"

Measured memory_bytes: 1788
h,w=map(int,input().split())

c=[list(map(int,input().split())) for i in range(10)]
a=[list(map(int,input().split())) for i in range(h)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])
 
ans=0

for i in range(h):
    for j in range(w):
        if a[i][j]>=0:
            ans+=c[a[i][j]][1]
print(ans)

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

int main() {
  int A, B, ans;
  cin >> A >> B;
  ans = 0;
  
  for (int i = A; i <= B; i++) {
    if ((i / 10000 == i % 10) && (i % 10000 / 1000 == i % 100 / 10)) {
      ans += 1;
    }
  }
  
  cout << ans << endl;

}


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

using namespace std;

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

    vector<int> pointX(N);
    vector<int> pointY(N);

    for (int i = 0; i < N; i++)
    {
        cin >> pointX.at(i) >> pointY.at(i);
    }

    double sumDis = 0;
    int count = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = i; j < N; j++)
        {
            if (i == j)
            {
                continue;
            }
            
            sumDis += sqrt((pointX.at(i) - pointX.at(j)) * (pointX.at(i) - pointX.at(j)) + (pointY.at(i) - pointY.at(j)) * (pointY.at(i) - pointY.at(j)));
            count++;
            // cout << i << " " << j << " " << sumDis << endl;
        }
        
    }
    cout << setprecision(10) << sumDis * (N-1) / count << "\n";
}


Measured memory_bytes: 256
from math import floor as fl
from math import ceil as ce
a,b=map(int,input().split())
aini=ce(a/0.08)
bini=ce(b/0.1)
out=max(aini,bini)
r=-1
while fl(out*0.08)>=a and fl(out*0.1)>=b:
  if fl(out*0.08)==a and fl(out*0.1)==b:
    r=out
  out-=1
print(r)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
using namespace std;
 
int main(){
	long long n,x;
	string ans;
 
	cin >> n;
 
	if(n > 9){
		x = n % 10;
	}else{
		x = n;
	}

	if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9){
		cout << "hon" << endl;
	}else if(x == 0 || x == 1 || x == 6 || x == 8){
		cout << "pon" << endl;
	}else{
		cout << "bon" << endl;
	}

}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

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

	cout << a * b << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <math.h>
#include <algorithm>  //sort,二分探索,など
#include <array>
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <map>            //map(辞書)s
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())  // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int sum = 0;
  REP(i, m) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum <= n) {
 cout << n-sum <<endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}



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

int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    
    ll ans;
    ans=t*s;
    if(ans>=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 3592
N = int(input())
c = input()

l = 0
r = N-1
ans = 0
while(l < r):
    while(l < N and c[l] == 'R'):
        l += 1
    while(r >= 0 and c[r] == 'W'):
        r -= 1
    if l > r or l >= N or r < 0:
        break
    else:
        # print(l, r)
        if l-1 == r:
            ans += 1
            break
        else:
            l += 1
            r -= 1
            ans += 1

print(ans)


Measured memory_bytes: 9456
#include<stdio.h>
int binary(int *array,int size,int num)
{
    int first=0,last=size-1;
    while(first<=last)
    {
        int mid=(first+last)/2;
        if(array[mid]==num)
        {
            return 1;
        }
        else if(num<array[mid])
        {
            last=mid-1;
        }
        else
        {
            first=mid+1;
        }
    }
    return 0;
}
int main()
{
    int n,i,b,j,z;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&b);
    for(j=0;j<b;j++)
    {
        scanf("%d",&z);
        printf("%d\n",binary(a,n,z));
    }
}



Measured memory_bytes: 2112
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  /*
  繋がっているスイッチを奇数回押すと点灯、偶数回押すと消灯
  点灯、消灯のパターンがpと一致するスイッチの押し方を数える
  */
  int n, m;
  cin >> n >> m;
  vector<int> s(n);
  rep(i, m) {
    int k;
    cin >> k;
    rep(j, k) {
      int tmp;
      cin >> tmp;
      --tmp;
      s[tmp] |= 1<<i;
    }
  }
  int p = 0;
  rep(i, m) {
    int tmp;
    cin >> tmp;
    p |= tmp<<i;
  }
  int ans = 0;
  rep(i, 1<<n) {
    int res = 0;
    rep(j, n) {
      if (i & 1<<j)
        res ^= s[j];
    }
    if (res == p)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a,b,c,x,i,j,k,nr;
int main()
{
    cin>>a>>b>>c>>x;

    for(i=0;i<=a;++i)
     for(j=0;j<=b;++j)

         for(k=0;k<=c;++k)
            if(i*500+j*100+k*50==x)nr++;


    cout<<nr<<'\n';
    return 0;
}


Measured memory_bytes: 256
N , M , X = map(int,input().split())
C = []
A = []
for _ in range(N):
    CA = list(map(int,input().split()))
    C.append(CA[0])
    A.append(CA[1:])

ans = float('inf')
for i in range(2**N):
    Level = [0]* M
    Cost = 0
    
    for j in range(N):
        if (i>>j)&1:
            Cost += C[j]
            for k in range(M):
                Level[k] += A[j][k]
                
    if all([Level[l] >= X for l in range(M)]):
        ans = min(ans, Cost)

if ans != float('inf'):
    print(ans)
else:
    print('-1')

Measured memory_bytes: 9172
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

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

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

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

  // dp[i][j] := i 枚コインを投げた時、表 j 枚である確率
  double dp[3030][3030] = {};
  dp[0][0] = 1.0;

  rep(i, n) {
    for(int j = 0; j <= i; j++) {
      dp[i+1][j+1] += dp[i][j]*p[i];
      dp[i+1][j] += dp[i][j]*(1.0-p[i]);
    }
  }

  double ans = 0.0;
  for(int i = (n+2-1)/2; i <= n; i++) ans += dp[n][i];
  cout << fixed << setprecision(10);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 72064