akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll x,t;cin>>x>>t;
  cout<<max(x-t,buf)<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#ifndef M_PI
#define M_PI (3.14159265358979323846)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

//#define INF (1e10)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x) { cout << x << endl; }
template<class T, class... A> void print(const T& first, const A& ... rest) { cout << first << " "; prll(rest...); }
struct PreMain { PreMain() { cin.tie(0); ios::sync_with_stdio(false); } } premain;


void calcTheta(
	double cx,	//円の中心(X座標)
	double cy,	//円の中心(Y座標)
	double r,	//円の半径
	double px,	//点のX座標
	double py,	//点のY座標
	double &theta0,
	double &theta1
) {
	double d = sqrt(cx * cx + cy * cy);
	double q = atan2(cy, cx);
	if (q < -M_PI / 2) q += M_PI * 2;
	double v = asin((double)r / d);
	theta0 = max(0.0, min(M_PI, q - v));
	theta1 = min(M_PI, max(0.0, q + v));
}

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

	vector<pair<double, double>> thetas(N);
	REP(i, N) {
		double x, y, r;
		cin >> x >> y >> r;
		double theta0, theta1;
		calcTheta(x, y, r, 0.0, 0.0, theta0, theta1);
		thetas[i] = make_pair(theta0, theta1);
	}

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

	vector<pair<double, double>> thetas2(N);

	/* 含まれてしまうものは除く */
	int sz = 0;
	REP(i, N) {
		bool isIinJ = false;
		REP(j, N) {
			if (i == j) continue;
			if ((thetas[j].first < thetas[i].first) && (thetas[i].second < thetas[j].second)) {
				isIinJ = true;
			}
		}
		if (!isIinJ) {
			thetas2[sz++] = thetas[i];
		}
	}

	vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0.0));
	double ans = 0.0;
	for (int i = 1; i <= K; i++) {
		double tmp = 0;
		int at = 0;
		for (int j = 0; j < sz; j++) {
			while (thetas2[at].second < thetas2[j].first) {
				tmp = max(tmp, dp[i - 1][at]); at++; 
			}
			dp[i][j] = max(tmp + thetas2[j].second - thetas2[j].first, dp[i - 1][at] + thetas2[j].second - thetas2[at].second);
			ans = max(ans, dp[i][j]);
		}

	}
	ans /= M_PI;

	print(ans);

	return 0;
}



Measured memory_bytes: 21100
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define mpi map<int,int>
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
int main() {
	string s;
	cin>>s;
	rep(i,0,s.size())
		if(s[i]=='7'){
			cout<<"Yes";
			return 0;
		}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  vector<int> r(n, 0), g(n, 0), b(n, 0);
  for (int i = n - 1; 0 <= i; --i) {
    if (i != n - 1) {
      r[i] = r[i + 1];
      g[i] = g[i + 1];
      b[i] = b[i + 1];
    }
    switch (s[i]) {
    case ('R'):
      ++r[i];
      break;
    case ('G'):
      ++g[i];
      break;
    case ('B'):
      ++b[i];
      break;
    }
  }

  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (s[i] == s[j])
        continue;

      long long tmp = 0;
      if (s[i] != 'R' && s[j] != 'R') {
        tmp = r[j];
        if (j + (j - i) < n && s[j + (j - i)] == 'R')
          --tmp;
      } else if (s[i] != 'G' && s[j] != 'G') {
        tmp = g[j];
        if (j + (j - i) < n && s[j + (j - i)] == 'G')
          --tmp;
      } else if (s[i] != 'B' && s[j] != 'B') {
        tmp = b[j];
        if (j + (j - i) < n && s[j + (j - i)] == 'B')
          --tmp;
      }

      ans += tmp;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3568
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<string>
#include<math.h>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;
const int INF=100000000;
int main(){
  int n,m,t;
  cin>>n>>m>>t;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int tloss=0;
  tloss+=2*m;
  for(int i=0;i<n-1;i++){
    if(a[i+1]-a[i]>2*m){
      tloss+=2*m;
    }
    else{
      tloss+=(a[i+1]-a[i]);
    }
  }
  if(a[n-1]+m>t){
    tloss-=(a[n-1]+m-t);
  }
  cout<<t-tloss<<endl;
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxx=2e5+10;
int num[maxx];
int vis[maxx];
int ro[maxx];
unsigned long long k,len=0,h,sir=0,st;
int main() {
	int n;
	memset(vis,0,sizeof(vis));
	scanf("%d%lld",&n,&k);
	rep(i,1,n+1){
		scanf("%d",&num[i]);
	}
	int t=1;
	while( k>0 ){
		k--;
		vis[t]=1;
		ro[len++]=t;
		t=num[t];
		if(vis[t])break;
	}
	if(k<=0)printf("%d",t);
	else{
		per(i,0,len){
			sir++;
			if(ro[i]==t)break;
		}
		st=len-sir;
		h=k%sir+st;
		printf("%d",ro[h]);
		
		
	}
} 

Measured memory_bytes: 5872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std ;
using namespace __gnu_pbds ;

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

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	long long arr[n*3] ;
	for(int i = 0 ; i < n*3 ; ++i)
		cin>>arr[i] ;
	ordered_set s ;
	long long sum = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		sum += arr[i] ;
		s.insert({arr[i] , i}) ;
	}
	long long dp[n+1] , dp2[n+1];
	dp[0] = sum ;
	pair<int , int>p ;
	int idx = 0 ;
	for(int i = n ; i < n * 2 ; ++i)
	{
		p = (*s.find_by_order(idx)) ;
		if(arr[i] > p.first)
			sum -= p.first , sum += arr[i] ;
		s.insert({arr[i] , i}) ;
		idx++ ;
		dp[idx] = sum ;
	}
	reverse(arr , arr + n * 3) ;
	ordered_set s2 ;
	sum = 0ll ;
	for(int i = 0 ; i < n ; ++i)
	{
		sum += arr[i] ;
		s2.insert({arr[i] , i}) ;
	}
	dp2[0] = sum ;
	idx = 0 ;
	for(int i = n ; i < n * 2 ; ++i)
	{
		p = (*s2.find_by_order(n-1)) ;
		if(arr[i] < p.first)
			sum -= p.first , sum += arr[i] ;
		s2.insert({arr[i] , i}) ;
		idx++ ;
		dp2[idx] = sum ;
	}
	long long ans = -1e18 ;
	for(int i = 0 ; i <= n ; ++i)
		ans = max(ans , dp[i] - dp2[n-i]) ;
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 29184
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
total = 0

curr = -2
for i in a:
    total += b[i - 1]
    if i == curr + 1:
        total += c[i - 2]
    curr = i

print(total)


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  
  string t1 = s.substr(0, n), t2 = s.substr(n);
  reverse(t2.begin(), t2.end());
  
  map<pair<string, string>, ll> mp;
  for(int bit = 0; bit < (1 << n); bit++){
    string keep1, keep2;
    for(int i = 0; i < n; i++){
      if(bit & (1 << i)) keep1 = keep1 + t1.at(i);
      else keep2 = keep2 + t1.at(i);
    }
    mp[make_pair(keep1, keep2)]++;
  }
  
  ll ans = 0;
  for(int bit = 0; bit < (1 << n); bit++){
    string keep1, keep2;
    for(int i = 0; i < n; i++){
      if(bit & (1 << i)) keep1 = keep1 + t2.at(i);
      else keep2 = keep2 + t2.at(i);
    }
    ans += mp[make_pair(keep1, keep2)];
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 87808
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;

int main(){
	LL n, a, b;
	cin >> n >> a >> b;
	LL s[n];
	for(int i = 0; i < n; i++) cin >> s[i];
	LL ans[n+1];
	LL ans1[n+1];
	LL ans2[n+1];
	for(int i = 0; i <= n; i++) ans[i] = ans1[i] = ans2[i] = 0;
	ans[n] = 1;
	int ta = n-1;
	int tb = n-1;
	int bada[n+1], badb[n+1];
	for(int i = 0; i < n; i++){
		bada[i+1] = badb[i+1] = 0;
		if(s[i+1] - s[i] < a){
			bada[i+1] = 1;
		}
		if(s[i+1] - s[i] < b){
			badb[i+1] = 1;
		}
	}
	bada[0] = badb[0] = 0;
	for(int i = 1; i <= n; i++){
		bada[i] += bada[i-1];
		badb[i] += badb[i-1];
	}
	for(int i = n-1; i >= 0; i--){
		while(s[ta] >= a + s[i]) ta--;
		while(s[tb] >= b + s[i]) tb--;
		if(ta == i){
			ans1[i] += ans[i+1];
		} else {
			if(badb[ta]-badb[i+1] == 0) ans1[i] += ans2[ta];
		}
		if(tb == i){
			ans2[i] += ans[i+1];
		} else {
			if(bada[tb]-bada[i+1] == 0)  ans2[i] += ans1[tb];
		}
		ans[i] = ans1[i] + ans2[i];
		ans1[i] %= MOD;	
		ans2[i] %= MOD;
		ans[i] %= MOD;
	}
	cout << ans[0] << endl;
}


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

public class Main{

     public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        int a= scanner.nextInt();
         int b= scanner.nextInt();
          int c= scanner.nextInt();
           int d= scanner.nextInt();
         int sum=0;
         for(int i=0;i<a;i++)
         {
             if(i<b)
             sum=sum+c;
             else
             sum=sum+d;
             
         }
         
         System.out.println(sum);
         
        
        
        
        
        //for(int i=0;i<n;i++)
        
        //System.out.println();
     }
}

Measured memory_bytes: 35424
x, n = map(int, input().strip().split())
ps = list(map(int, input().strip().split()))

min_m = -1
min_diff = 1e9
for m in range(102):
    diff = abs(m - x)
    if diff < min_diff and m not in ps:
        min_m = m
        min_diff = diff

print(min_m)


Measured memory_bytes: 9200
N=int(input())
H=list(map(int, input().split()))
for i in range(N-1):
  if H[N-i-2]-H[N-i-1]==1:
    H[N-i-2]-=1
  elif H[N-i-2]-H[N-i-1]>1:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 14396
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int cnt[] = new int[n+1];
		for(int i=0; i<n-1; i++) {
			int v = sc.nextInt();
			cnt[v]++;
		}
		for(int i=1; i<=n; i++) {
			System.out.println(cnt[i]);
		}
		sc.close();
	}


}


Measured memory_bytes: 70628
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


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

  pr((a+b)%24);


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mt make_tuple
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

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

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
bool cmp(tuple<string,ll,ll>&a,tuple<string,ll,ll>&b)
{
    if(get<0>(a)== get<0>(b))
    {
        return get<1>(a) > get<1>(b);
    }
    return get<0>(a) < get<0>(b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    string a;
    ll b;
    vector<tuple<string,ll,ll>>v;
    go(i,0,n)
    {
        cin>>a>>b;
        v.pb(mt(a,b,i));
    }
    sort(v.begin(),v.end(),cmp);
    go(i,0,n)
    {
        show(get<2>(v[i])+1);
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
-- end of templete

f left x right [] = reverse left ++ [x] ++ right
f left x [] ('-':'>':c:ss) = f (x:left) c [] ss
f left x (y:nr) ('-':'>':c:ss) = f (x:left) y nr ss
f [] x right ('<':'-':c:ss) = f [] c (x:right) ss
f (y:nl) x right ('<':'-':c:ss) = f nl y (x:right) ss

main = do
    n <- getInt
    replicateM n $ do
        getLine >>= \(c:cs) -> putStrLn $ f [] c [] cs
    return ()


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a[5];
    rep(i,5) cin>>a[i];
    int max=9, n=0;
    rep(i,5){
        if(max%10>a[i]%10 && a[i]%10!=0){
            max=a[i];
            n=i;
        }
    }
    rep(i,5){
        if(i!=n){
            a[i]+=9;
            a[i]/=10;
            a[i]*=10;
        }
    }
    int ans=0;
    rep(i,5) ans+=a[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int check(long a,long b,long c);

int main(void){
	int a,b,c,f,n,i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf(" %d %d %d",&a,&b,&c);
		f=check(a,b,c);
		if(f==0)
		printf("YES\n");
		else
		printf("NO\n");
	}
	
	
	return 0;
}

int check(long a,long b,long c){
	int t;
	if(c<a){
		t=a;
		a=c;
		c=t;
	}
	if(c<b){
		t=b;
		b=c;
		c=t;
	}
	if(a*a+b*b==c*c)return 0;
	else return 1;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b)
{
  return *(int*)b-*(int*)a;
}

int main(void)
{
  int heights[10];
  int i;
  for(i=0; i<10; ++i) {
    scanf("%d", &heights[i]);
  }
  qsort(heights, 10, sizeof(int), compare);
  printf("%d\n", heights[0]);
  printf("%d\n", heights[1]);
  printf("%d\n", heights[2]);

  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#include <queue>


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

  int64_t N, M;
  cin >> N >> M; 

priority_queue<int64_t> A; 

  for (int64_t i = 0; i < N; i++) {
    int64_t tmp; 
    cin >> tmp; 
    A.push(tmp);  
  }


  for (int64_t i = 0; i < M; i++) {
    auto tmp =  A.top(); 
    A.pop(); 
    A.push(tmp/2); 
  }

  int64_t sum = 0;
  for (int64_t i = 0; i < N; i++) {
    sum += A.top(); 
    A.pop(); 
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 4268
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(void)
{
    vector<long long> numbers;
    map<int, long long> number_counts;
    int number_count;

    cin >> number_count;

    for(int i = 0; i < number_count; i++){
        int n;
        cin >> n;
        numbers.push_back(n);

        if(number_counts.find(n) == number_counts.end()){
            number_counts[n] = 1;
        }else{
            number_counts[n] += 1;
        }
    }

    long long complete_sum = 0;
    for(auto itr = number_counts.begin(); itr != number_counts.end(); itr++){
        complete_sum += itr->second * (itr->second - 1) / 2;
    }


    for(int k = 0; k < number_count; k++){
        cout << complete_sum + 1 - number_counts[numbers[k]] << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll comb[53][53];
ll combsum[53][53];
void make_table(){
  for(ll i=0;i<=51;i++){
    comb[i][0]=1;
    comb[i][i]=1;
  }
  for(ll i=1;i<=51;i++)for(ll j=1;j<i;j++){
    comb[i][j]=(comb[i-1][j-1]+comb[i-1][j]);
  }
}

ll cnt0[(1<<18)];
ll cnt1[(1<<18)];
ll pcnt[(1<<18)],sgn[(1<<18)];

ll bitv(ll a, ll n){
  return (a>>n)&1LL;
}

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

  make_table();
  rep(i,52){
    rep(j,52){
      combsum[i][j+1]=combsum[i][j]+comb[i][j];
    }
  }

  const ll B=18;
  rep(i,1<<B){
    pcnt[i]=bcnt(i);
    if(pcnt[i]%2==1) sgn[i]=-1;
    else sgn[i]=+1;
  }

  ll N,K,S,T;
  cin>>N>>K>>S>>T;
  vector<ll> A(N);
  rep(i,N)cin>>A[i];
  vector<ll> tmp;
  ll mask=(1<<B)-1;
  rep(j,B){
    if(bitv(S,j)==1&&bitv(T,j)==0){
      cout<<0<<endl;
      return 0;
    }
  }
  rep(j,B){
    if(bitv(S,j)==1||bitv(T,j)==0){
      mask^=(1LL<<j);
    }
  }
  //dbg(mask);
  rep(i,N){
    bool ok=true;
    rep(j,B){
      if(bitv(S,j)==1&&bitv(A[i],j)==0){
        ok=false;
      }
      if(bitv(T,j)==0&&bitv(A[i],j)==1){
        ok=false;
      }
    }
    if(ok){
      tmp.push_back(A[i]);
    }
  }
  A=tmp;
  N=A.size();
  //dbg(N);

  rep(i,N)A[i]=(A[i]&mask);


  ll res=0;
  rep(U,1<<B){
    if((U|mask)!=mask)continue;
    map<ll,ll> cnt;
    rep(i,N){
      ll s=(U&A[i]);
      cnt[s]++;
    }
    for(P p : cnt){
      res+=(combsum[p.se][K+1]-1)*sgn[U];
    }
  }
  cout<<res<<endl;

  return 0;
}


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

int N, L;
vector<string> sl;

void solve(){
  sort(sl.begin(), sl.end());
  for(int i = 0; i < N; ++i){
    cout << sl[i];
  }
  cout << endl;
  return ;
}


int main(){
  cin >> N >> L;
  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    sl.push_back(s);
  }
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
int main(){
	string s,t;cin>>s>>t;
	rep(i,s.size()){
		string k;
		rep(j,s.size()){
			k+=s[(j+i)%s.size()];
		}
		if(k==t){
			puts("Yes");return 0;
		}
	}
	puts("No");
   return 0;
}

Measured memory_bytes: 256
// Contest: AtCoder Beginner Contest 178 (https://atcoder.jp/contests/abc178)
// Problem: A: Not (https://atcoder.jp/contests/abc178/tasks/abc178_a)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

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

    int x; cin >> x;
    cout << (1 - x) << '\n';

    return 0;
}


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

public class Main {
    //    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        String ans = main.solve();
        System.out.println(ans);
    }
    String solve() throws IOException{
        int n = sc.nextInt();
        // ascending of Ai
        PriorityQueue<Pair> front = new PriorityQueue<>(100,(o1,o2)->(o1.A-o2.A));
        // descending of Bi
        PriorityQueue<Pair> back = new PriorityQueue<>(100,(o1,o2)->(o2.B-o1.B));
        int perfect = 0;
        for(int i=0;i<n;i++){
            String s = sc.next();
            int[] temp = helper(s);
            if(temp[0]==0&&temp[1]==0) {
                perfect ++;
                continue;
            }
            Pair p = new Pair(temp[0],temp[1]);
            if(temp[0]==0||p.B>=p.A) front.add(p);
            else back.add(p);
        }
        if(perfect>0&&front.size()==0) {
            perfect--;
            front.add(new Pair(0,0));
        }
        while(perfect-->0) back.add(new Pair(0,0));
        ArrayList<Pair> list = new ArrayList<>();
        while(front.size()>0) list.add(front.poll());
        while(back.size()>0) list.add(back.poll());
        int left = 0, right = 0;
        for(int i=0;i<list.size();i++){
            Pair p = list.get(i);
            if(left-p.A<0) return "No";
            left += p.B-p.A;
        }
        for(int i=list.size()-1; i>=0; i--){
            Pair p = list.get(i);
            if(right-p.B<0) return "No";
            right += p.A-p.B;
        }
        if(left==0&&right==0) return "Yes";
        else return "No";

    }
    int[] helper(String s){
        int[] ans = new int[2];
        char[] arr = s.toCharArray();
        int mini = 100, left = 0, right = 0;
        for(char c:arr){
            if(c=='(') left++;
            else left--;
            mini = Math.min(mini,left);
        }
        ans[0] = Math.abs(Math.min(mini,0));
        mini = 100;
        for(int i=arr.length-1;i>=0;i--){
            if(arr[i]==')') right++;
            else right--;
            mini = Math.min(mini, right);
        }
        ans[1] = Math.abs(Math.min(mini,0));
        return ans;
    }
    class Pair{
        int A, B;
        // means ")"*A + "("*B
        public Pair(int _A, int _B){A=_A;B=_B;}
    }
}

Measured memory_bytes: 101352
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b==15)
	{
		cout<<"+";
		return 0;
	}
	if(a*b==15)
	{
		cout<<"*";
		return 0;
	}
	cout<<"x";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD 998244353
long long binaryPowerMethod(long long z,long long n, long long mod){
  long long ans = 1;
  while(n != 0){
    if(n%2){
      ans*=z;
      if(mod)ans%=mod;
    }
    n/=2;
    z*=z;
    if(mod)z%=mod;
  }
  return ans;
}

long long len[100001];
int main(){
  long long n;cin>>n;
  vector<long long> a(n);
  long long mx = 0;
  for(int i = 0; n > i; i++){
    cin>>a[i];
    mx = max(a[i],mx);
    len[a[i]]++;
  }
  for(int i = 0; mx >= i; i++){
    if(!len[i]){
      cout << 0 << endl;
      return 0;
    }
  }
  if(len[0] != 1){
    cout << 0 << endl;
    return 0;
  }
  if(a[0] != 0){
    cout << 0 << endl;
    return 0;
  }
  long long ans = 1;
  for(int i = 1; mx >= i; i++){
    ans = (ans * binaryPowerMethod(len[i-1],len[i],MOD))%MOD;
  }
  cout << ans << endl;
}

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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> c(13);
    c[0]++;
    for (int i = 0; i < n; i++) {
        ll t;
        std::cin >> t;
        c[t]++;
        if(c[t]==3){
            std::cout << 0 << std::endl;
            return 0;
        }
        if( c[t]==2 && (t == 0 || t == 12) ){
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    vector<bool> have(24,false);
    
    vector<ll> ones;
    have[12] = true;
    if(c[12] == 1){
        have[0] = true;
    }
    for (int i = 1; i <= 11; i++) {
        if(c[i]==2){
            have[12+i] = true;
            have[12-i] = true;
        }else if(c[i] == 1){
            ones.push_back(i);
        }
    }
    ll minv = 0;
    
    for (int i = 0; i < ( 1<<ones.size() ); i++) {
        
        vector<bool> now_have(24,false);
        
        for (int j = 0; j < 24; j++) {
            now_have[j] = have[j];
        }
        
        for (int j = 0; j < ones.size(); j++) {
            if( i & (1<<j) ){
                now_have[12+ones[j]] = true;
            }else{
                now_have[12-ones[j]] = true;
            }
        }
        
        // for (int j = 0; j < 24; j++) {
        //     if(now_have[j]){
        //         std::cout << "1";
        //     }else{
        //         std::cout << "0";
        //     }
        // }
        ll kou = 25;
        
        // for (int j = 0; j < 24; j++) {
        //     if(now_have[j]){
        //         std::cout << "0";
        //     }else{
        //         std::cout << "1";
        //     }
        // }
        // std::cout << std::endl;

        for (int j = 0; j < 24; j++) {
            if(!now_have[j])continue;
            ll dif = 1;
            while(true){
                if( now_have[(j+dif)%24] ){
                    // std::cout << kou << std::endl;
                    kou = min(kou,min(dif,24-dif));
                    break;
                }else{
                    dif++;
                }
            }
        }
        minv = max(minv,kou);
    }
    
    std::cout << minv << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010,P=1e9+7;
int n,x,y,eg,hd[MAXN],ver[2*MAXN],nx[2*MAXN],siz[MAXN],f[MAXN];
void add_edge (int x,int y) {
    ver[++eg]=y;
    nx[eg]=hd[x];
    hd[x]=eg;
    return;
}
int qpow (int a,int b) {
    int res=1;
    while (b) {
        if (b&1) {res=(1ll*res*a)%P;}
        a=(1ll*a*a)%P,b>>=1; 
    }
    return res;
}
void dfs1 (int x,int fa) {
    siz[x]=1;
    for (int i=hd[x];i;i=nx[i]) {
        if (ver[i]==fa) {continue;}
        dfs1(ver[i],x);
        siz[x]+=siz[ver[i]];
    }
    f[1]=(1ll*f[1]*siz[x])%P;
    return;
}
void dfs2 (int x,int fa) {
    for (int i=hd[x];i;i=nx[i]) {
        if (ver[i]==fa) {continue;}
        f[ver[i]]=(1ll*f[x]*((1ll*(n-siz[ver[i]])*qpow(siz[ver[i]],P-2))%P))%P; 
        dfs2(ver[i],x);
    }
    return;
}
int main () {
    scanf("%d",&n);
    f[1]=1;
    for (int i=1;i<=n-1;i++) {
        scanf("%d%d",&x,&y);
        add_edge(x,y),add_edge(y,x);
    }
    dfs1(1,0);
    dfs2(1,0);
    int tmp=1;
    for (int i=1;i<=n;i++) {tmp=(1ll*tmp*i)%P;}
    for (int i=1;i<=n;i++) {printf("%d\n",(1ll*tmp*qpow(f[i],P-2))%P);}
    return 0;
}

Measured memory_bytes: 7808
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ.Volume1
{
    public class SportMeet
    {
        public static int Main()
        {
            while (true)
            {
                int team = int.Parse(Console.ReadLine());
                if (team == 0) { break; }

                // チーム数が5の場合→0,1,2,3,4なので
                // ブービー賞は3
                int booby = team - 2;

                var score = new List<KeyValuePair<int, int>>();
                for (int i = 0; i < team; i++)
                {
                    var input = Console.ReadLine().Split(' ');
                    int id = int.Parse(input[0]);
                    int time = int.Parse(input[1]) * 60 + int.Parse(input[2]) +
                        int.Parse(input[3]) * 60 + int.Parse(input[4]) +
                        int.Parse(input[5]) * 60 + int.Parse(input[6]) +
                        int.Parse(input[7]) * 60 + int.Parse(input[8]);
                    var kvp = new KeyValuePair<int, int>(id, time);
                    score.Add(kvp);
                }

                int counter = 0;
                foreach (var s in score.OrderBy(x => x.Value))
                {
                    if (counter == 0 || counter == 1 || counter == booby)
                    {
                        Console.WriteLine(s.Key);
                    }
                    counter++;
                }
            }
            return 0;
        }
    }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


int main()
{
    ll N, M;
    cin >> N >> M;
    vec a(N), b(N), c(M), d(M);
    REP(i,0,N) cin >> a[i] >> b[i];
    REP(i,0,M) cin >> c[i] >> d[i];

    REP(i,0,N) {
        ll D = INF, k = 0;
        REP(j,0,M) {
            if(D > abs(a[i]-c[j]) + abs(b[i]-d[j])) {
                D = abs(a[i]-c[j]) + abs(b[i]-d[j]);
                k = j + 1;
            }
        }
        PR(k);
    }


    return 0;
}

/*



*/

Measured memory_bytes: 3620
//
//  main.swift
//  AtCoderSwift
//
//  Created by burita083 on 2020/08/25.
//  Copyright © 2020 burita083. All rights reserved.
//

import Foundation
func readInt() -> Int {
    return Int(readLine()!)!
}
 
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
 
func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func abc080_b() {
    let N = readLine()!
    let sum = N.map { Int(String($0))! }.reduce(0, +)
    print(Int(N)! % sum == 0 ? "Yes" : "No")
}

//abc080_b()

func abc078_b() {
    let input = readInts()
    var X = input[0]
    let Y = input[1]
    let Z = input[2]
    var ans = 0
    X -= Y+Z*2
    ans += 1
    ans += X/(Y+Z)
    
    print(ans)
}

abc078_b()


Measured memory_bytes: 13592
num=gets.to_i
max=-1000000
min=1000000
sum=0
array=gets.split(" ")
num.times do |x|
    i=array[x].to_i
    sum+=i
    if max<i
        max=i
    end
    if min>i
        min=i
    end
end
print(min," ",max," ",sum,"\n")

Measured memory_bytes: 8952
_n = STDIN.gets
a = STDIN.gets.split.map(&:to_i)

nn = a.inject({}) {|acc, n|
  acc[n - 1] ||= 0
  acc[n] ||= 0
  acc[n + 1] ||= 0

  acc[n - 1] += 1
  acc[n] += 1
  acc[n + 1] += 1
  acc
}


puts nn.values.max


Measured memory_bytes: 14980
// jha4032

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int 
#define mp make_pair
#define M 1000000007
#define N 1000006
void fast()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

ll power(ll a, ll b)
{
  if (b == 0)
    return 1;
  ll tmp = power(a, b / 2)%M;
  tmp = (tmp * tmp )%M ;
  if (b & 1)
    return (tmp * a )%M ;
  return tmp;
}
ll fact[N], invfact[N];
ll ans=0;
void pre1()
{
  fact[0] = 1;
  invfact[0] = power(fact[0], M - 2);
  for (int i = 1; i < N; i++)
  {
    fact[i] = (i * fact[i - 1]) % M;
    invfact[i] = power(fact[i], M - 2);
  }
}


ll n;
ll a[100005];	
ll dp[100005];



int main(){
memset(dp,-1,sizeof dp);
//dp[0]=0;
cin>>n;
for(int i=0;i<n;i++){
	 cin>>a[i];
}
dp[0]=0;dp[1]=abs(a[0]-a[1]);
for(int i=2;i<n;i++){
   dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i-2]-a[i]));
}
cout<<dp[n-1]<<endl;

}

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

string S;
int N;

bool ok(int k) {
    if (2*k >= N) {
        char a = S[N - k + 1 - 1];
        for (int i = N - k + 1; i <= k; i ++) {
            if (S[i - 1] != a) return false;
        }
        return true;
    } else {
        return true;
    }
}

// [h, t) を検索
int bsearch(int h, int t) {
    if (t - h <= 1)     return h;
    int mid = (h + t) / 2;
    if (ok(mid)) {
        return bsearch(mid, t);
    } else {
        return bsearch(h, mid);
    }
}

signed main() {
    getline(cin, S);
    N = S.size();
    cout << bsearch(0, N + 1) << endl;
    return 0;
}

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



int main()
{
    string s1;
    string s2;
    cin>>s1>>s2;

    int n1=s1.length();
    int n2=s2.length();


    vector<vector<int>> dp(n1+1,vector<int>(n2+1));

    for(int x=0;x<n1+1;x++)
    {
        dp[x][0]=0;
    }

    for(int x=0;x<n2+1;x++)
    {
        dp[0][x]=0;
    }


    for(int x=1;x<n1+1;x++)
    {
        for(int y=1;y<n2+1;y++)
        {
            if(s1[x-1]==s2[y-1])
            {
                dp[x][y]=1+dp[x-1][y-1];

            }
            else
            {
                dp[x][y]=max(dp[x][y-1],dp[x-1][y]);
            }
        }
    }


    // for(int x=1;x<n1+1;x++)
    // {
    //     for(int y=1;y<n2+1;y++)
    //     {
    //         cout<<dp[x][y]<<" ";
    //     }
    //     cout<<endl;
    // }

    string ans="";
    int len=-1;
    int i=n1;
    int j=n2;
    while(len!=0)
    {
        int a,b;
        if(s1[i-1]==s2[j-1])
        {
            ans=s1[i-1]+ans;
            a=i-1;
            b=j-1;
        }
        else
        {
            
            if(dp[i-1][j]>dp[i][j-1])
            {
                a=i-1;
                b=j;

            }
            else
            {
                a=i;
                b=j-1;
            }
        }
        // cout<<"hi"<<a<<" "<<b<<endl;
        i=a;j=b;
        len=dp[a][b];
        
    }

    cout<<ans<<endl;



    // cout<<dp[n1][n2];
}

Measured memory_bytes: 35584
import std.stdio;
import std.string;
import std.array;

int[] dx = [0, -1, 0, 1, 0];
int[] dy = [-1, 0, 0, 0, 1];
string str;
string[10] s;
char[10][10] ch;
int[10][10] ans;

void main(){
	int n;
	readf("%d\n", &n);
	for (int i = 0; i < n; i++) {
		foreach (j; 0..10) s[j] = replace(chomp(readln()), " ", "");
		// try all patterns in 1st line
		for (int j = 0; j  < 2^^10 ; j++) {
			str = format("%010b", j);
			foreach (k; 0..10) {
				ch[k] = s[k];
				ans[k] = 0;
			}
			if (solve()) break;
		}
		// print
		foreach (y; 0..10) {
			write(ans[y][0]);
			foreach (x; 1..10) {
				write(" ", ans[y][x]);
			}
			writeln();
		}
	}
}

void toggle(int px, int py){
	int x, y;
	foreach (i; 0..5) {
		x = dx[i]+px;
		y = dy[i]+py;
		if (x < 0 || x > 9 || y < 0 || y > 9) continue;

		if(ch[y][x] == '0') ch[y][x] = '1';
		else ch[y][x] = '0';
	}
}

bool solve(){
	foreach (y; 0..10) {
		foreach (x; 0..10) {
			if ((y == 0 && str[x] == '1') || (y > 0 && ch[y-1][x] == '1')) {
				toggle(x, y);
				ans[y][x] = 1;
			}
		}
	}
	// check
	foreach (y; 0..10)
		foreach (x; 0..10)
		if (ch[y][x] == '1') return false;
	return true;
}

Measured memory_bytes: 1044
from collections import defaultdict
dic = defaultdict(int)
N,M = map(int,input().split())
A = list(map(int,input().split()))
for x in A:
  dic[x] += 1
for i in range(M):
  a,b = map(int,input().split())
  dic[b] += a

#print(dic)
L =list(dic.keys())
L.sort(reverse = True)

cnt = 0
ans = 0
for i in range(len(L)):
  val = L[i]
  #print(cnt,val,dic[val])
  if cnt + dic[val] <= N:
    cnt += dic[val]
    ans += val*dic[val]
  else:
    ans += val*(N-cnt)
    break
print(ans)


Measured memory_bytes: 109040
using System;


namespace Csharp
{
    class Program
    {

        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            
            string target = "RRR";
            string target2 = "RR";
            string target3 = "R";
            if (S.Contains(target))
            {
                Console.WriteLine(3);
            }else if (S.Contains(target2))
            {
                Console.WriteLine(2);
            }else if (S.Contains(target3))
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }


            
        }
        
    }
}


Measured memory_bytes: 25720
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
vector<int>adj[100001];
bool vis[100001]={false};
int col[100001];
//int tot=0;
int components[100001];
vector<int>v;
void dfs(int x,int y)
{
    vis[x]=true;
    v.pb(x);
    col[x]=y;
    for(auto z:adj[x])
    {
        if(!vis[z])
        {
            dfs(z,y);
        }
    }
    //components[x]=tot;
}
signed main()
{
int n,m,k;
cin>>n>>m>>k;
int x,y;
for(int i=0;i<m;i++)
{
    cin>>x>>y;
    adj[x].pb(y);
    adj[y].pb(x);
}
int c=1;
for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i,c);
            c++;
            for(auto k:v)
            {
                components[k]=v.size();
            }
            v.clear();
        }

    }
int result[n+1];
//cout<<adj[3].size()<<endl;
for(int i=1;i<=n;i++)
{
    result[i]=components[i]-adj[i].size()-1;
}
for(int i=0;i<k;i++)
{
    cin>>x>>y;
    if(col[x]==col[y])
    {
        result[x]--;
        result[y]--;
    }
}
for(int i=1;i<=n;i++)
    cout<<result[i]<<" ";
}





Measured memory_bytes: 10480
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    auto t = readln.chomp.to!(dchar[]).sort!("a < b").group.array;
    writeln(t.length == 2 && t[0][1] == 2 && t[1][1] == 2 ? "Yes" : "No");
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = []
mx = 0
for _ in range(N):
  x, y = map(int, input().split())
  u = x + y
  v = x - y
  a.append((u, v))
  mx = max(mx, max(abs(u), abs(v)))
t = a[0][0] % 2
for u, _ in a:
  if u % 2 != t:
    print(-1)
    exit(0)
d = [pow(2, i) for i in range(mx.bit_length())]
if t == 0: d = [1] + d
print(len(d))
print(*d)
for u, v in a:
  s = [0] * len(d)
  t = [0] * len(d)
  x = 0
  y = 0
  res = []
  for i in range(len(d) - 1, -1, -1):
    z = d[i]
    if u < x:
      x -= z
      s[i] = -1
    else:
      x += z
      s[i] = 1
    if v < y:
      y -= z
      t[i] = -1
    else:
      y += z
      t[i] = 1
  for i in range(len(d)):
    if s[i] == 1 and (t[i] == 1):
      res.append("R")
    elif s[i] == -1 and (t[i] == -1):
      res.append("L")
    elif s[i] == 1 and (t[i] == -1):
      res.append("U")
    elif s[i] == -1 and (t[i] == 1):
      res.append("D")
  print("".join(res))

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

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a<=b)
	{
		for(int i=0; i<b ; i++)
		{
			cout<<(char)(48+a);
		}
		cout<<endl;
	}
	if(a>b)
	{
		for(int i=0; i<a ; i++)
		{
			cout<<(char)(48+b);
		}
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
from collections import deque

def bfs(s_l, sy, sx, h, w):
    visited = [ [-1]*w for i in range(h)]
    q = deque([[sy,sx]])
    visited[sy][sx] = 0
    last_dist = -1
    while q:
        y, x = q.popleft()
        # if [y, x] == [gy, gx]:
        #     return visited[gy][gx]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            n_y, n_x = y+j, x+k
            if n_y >= h or n_x >= w or n_y < 0 or n_x < 0:
                continue
            if s_l[n_y][n_x] == '.' and visited[n_y][n_x] == -1:
                visited[n_y][n_x] = visited[y][x] + 1
                last_dist = visited[n_y][n_x]
                q.append([n_y,n_x])
    return last_dist

def main():
    h, w = map(int, input().split()) 
    s_l = []
    all_dot_cnt = 0
    for i in range(h):
        row = list(input())
        s_l.append(row)
        all_dot_cnt += row.count('.')
    
    curr_ans = -1
    visited = [ [-1]*w for i in range(h)]
    for i in range(h):
        for j in range(w):
            if s_l[i][j] == '.':
                res = bfs(s_l, i, j, h, w)
                if res > curr_ans:
                    curr_ans = res
    print(curr_ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 43756
#include<bits/stdc++.h>
using namespace std;
int l,cnt=0,tot=0,res,tmp,first[30];
struct edge{int u,v,w,next;}e[65];
inline void add(int u,int v,int w){e[++tot].u=u,e[tot].v=v,e[tot].w=w,e[tot].next=first[u],first[u]=tot;}
int main(){
	cin>>l,tmp=l,res=l;
	while(tmp)tmp>>=1,++cnt;
	for(int i=1;i<cnt;++i)add(i,i+1,0),add(i,i+1,(1<<(i-1)));
	res-=1<<(cnt-1);
	tmp=1<<(cnt-1);
	for(int i=0;i<=20;++i)if(((res>>i)&1))add(i+1,cnt,tmp),tmp+=1<<i;
	cout<<cnt<<' '<<tot<<'\n';
	for(int i=1;i<=tot;++i)cout<<e[i].u<<' '<<e[i].v<<' '<<e[i].w<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<functional>
#include<set>
#include<unordered_map>
#define int long long
using namespace std;

int b[200005];
int BIT[200005];
void  tasu(int a) {
	while (a < 200005) {
		BIT[a]++;
		a += a&-a;
	}
}
int sum(int a) {
	int b = 0;
	while (a > 0) {
		b += BIT[a];
		a -= a&-a;
	}
	return b;
}
signed main(){
	int a; scanf("%lld", &a);
	set<int>S;
	for (int c = 0; c < a; c++) {
		scanf("%d", &b[c]);
		S.insert(b[c]);
	}
	unordered_map<int, int>U;
	int c = 1;
	for (auto d = S.begin(); d != S.end(); d++) {
		U[*d] = c;
		c++;
	}
	for (int c = 0; c < a; c++) {
		b[c] = U[b[c]];
	}
	int ans = 0;
	for (int i = 0; i < a; i++) {
		ans += i - sum(b[i]);
		tasu(b[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 23652