akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct F {
	int64_t a;
	int64_t b;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	int t; cin >> t;

	vector<F> fs(n);
	FOR_LT(i, 0, n) {
		cin >> fs[i].a >> fs[i].b;
	}
	sort(fs.begin(), fs.end(), [](const auto& lhs, const auto& rhs) {
		return lhs.a < rhs.a;
	});

	vector<vector<int64_t>> dp(6001, vector<int64_t>(n));
	FOR_LT(i, 0, n) {
		int64_t a = fs[i].a;
		int64_t b = fs[i].b;

		FOR_LT(j, 0, t + a) {
			int64_t s = (i == 0) ? 0 : dp[j][i - 1];
			if (j < a) {
				dp[j][i] = s;
			}
			else {
				int64_t s2 = (i == 0) ? 0 : dp[j - a][i - 1];
				dp[j][i] = max(s, s2 + b);
			}
		}
	}

	int64_t ans = 0;
	FOR_LT(i, 0, 6001) {
		ans = max(ans, dp[i][n - 1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 141312
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int N = s.length();
		if(N == 1){
			System.out.println(s);
			System.exit(0);
		}
		int limit = (int) Math.pow(2, N-1);
		
		long total = 0;
		
		for(int i = 0; i<limit; i++){
			StringBuilder binary = new StringBuilder();
			binary.append(Integer.toBinaryString(i));
			while(binary.length() < N-1) binary.insert(0, '0');
			binary.append('1');
			
			long sum = 0;
			int left = 0;
			for(int j = 0; j < N; j++){
				if(binary.charAt(j) == '1'){
					sum += Long.parseLong(s.substring(left, j + 1));
					left = j+1;
				}
			}
			total += sum;
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lld long double
#define w(x) ll x;cin>>x;while(x--)
#define mod 1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
    speed;
        ll n;   cin>>n;
        vector<ll> a(n),b;    for(auto &i:a)  cin>>i;
        b=a;
        ll cnt=0;
        ll no=INT_MIN;
        for(ll i=0;i<n;i++){
            no=max(no,a[i]);
            a[i]=no;
        }
        // for(auto i:a)   cout<<i<<" ";
        ll s1=accumulate(a.begin(),a.end(),(ll)0);
        ll s2=accumulate(b.begin(),b.end(),(ll)0);
        cnt=s1-s2;
        cout<<cnt<<'\n';
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, ans = 0;
	cin >> n;

	for (int i = 0; i < 10; i++) {
		if ((1 << i) <= n) ans = (1 << i);
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
const int mod = 1000000007;
int main(){
    int N,power,count;
    long long ans = 1;
    vector<int> plist;
    bool flag;
    cin >> N;
    for(int i=2;i<=N;i++){
        flag = true;
        for(int j=0;j<plist.size() && plist[j]*plist[j] <= i;j++){
            if(i%plist[j] == 0){
                flag = false;
                break;
            }
        }
        if(flag) plist.push_back(i);
    }
    for(int i=0;i<plist.size();i++){
        power = plist[i];
        count = 0;
        while(N >= power){
            count +=  N/power;
            power *= plist[i];
        }
        ans = ans*(count+1)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;
const MOD: u64 = 1_000_000_007;
fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: u64 = itr.next().unwrap().parse().unwrap();

    let mut div = vec![0; 1010];
    for mut i in 2..n + 1 {
        let mut j = 2u64;
        while j * j <= i {
            while i % j == 0 {
                div[j as usize] += 1;
                i /= j;
            }
            j += 1;
        }
        div[i as usize] += 1;
    }

    let mut ans = 1u64;
    for i in 2..1005 {
        if div[i] > 0 {
            ans = ans * (div[i] + 1) % MOD;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,x;
    cin>>n>>m>>x;
    vector<vector<ll>> mat(n,vector<ll>(m));
    vector<ll> c(n);
    rep(i,n) {
        cin>>c[i];
        rep(j,m) {
            cin>>mat[i][j];
        }
    }
    ll res = 1LL<<60;
    rep(i,1<<n) {
        vector<ll> val(m,0);
        ll money = 0;
        rep(j,n) {
            if (i>>j&1) {
                money += c[j];
                rep(k,m) {
                    val[k] += mat[j][k];
                }
            }
        }
        // cout << i << endl;
        // rep(j,n) {
        //     cout << val[i] << " ";
        // }
        // cout << endl;
        // cout << "money " << money << endl;
        bool flg = true;
        rep(j,m) {
            flg &= val[j] >=x;
        }
        if (flg) {
            chmin(res, money);
        }
    }
    cout << ((res == (1LL<<60)) ? -1 : res) << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0;
    cin >> N;
    if(N % 2 == 0){
        cout << N << endl;
    }else{
        cout << N * 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
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.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
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
getDoubles = map readDouble . words <$> getLine
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
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)
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
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

judge [q1,b,c1,c2,q2]
  | c1 + (q1 - 1) * c2 > b = Nothing
  | otherwise = let r1 = ibsearch (\q -> q * c1 + (q1 - q) * c2 <= b) (1,1 + min q2 (b `div` c1)) in Just [r1, (b - r1 * c1) `div` c2]


main = do
    ds <- getInts
    unless (ds==[0]) $ do
        putStrLn $ maybe "NA" sjoin $ judge ds
        main


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

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

    int n,k;
    cin >> n >> k;
    vector<pair<int,int>> su(n);
    for(int i=0; i<n; i++) {
        cin >> su[i].second >> su[i].first;
    }
    sort(su.begin(),su.end(),greater<>());

    long long ans=0, crt=0;
    map<int, int> topping_count;
    for(int i=0; i<k; i++) {
        crt+=su[i].first;
        topping_count[su[i].second]++;
    }
    long long x=topping_count.size();
    ans=crt+x*x;

    int j=k-1;
    for(int i=k; i<n; i++) {
        int t=su[i].second;
        if ( topping_count.count(t) ) continue;
        while( j>=0 ) {
            int tt=su[j].second;
            if ( topping_count[tt]>1 ) {
                crt=crt-su[j].first+su[i].first;
                topping_count[t]++;
                topping_count[tt]--;
                j--;
                x++;
                ans=max(ans,crt+x*x);
                break;
            } else {
                j--;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


int main(){
    int n, p[201000];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }

    int x = INT32_MAX;
    int res = 0;
    for(int i = 0; i < n; i++){
        if(p[i] < x){
            res++;
            x = p[i];
        }
    }

    cout << res << endl;



    return 0;
}


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

int main(void) {
	using namespace std;
	int N;
	cin >> N;
	vector<int> a;
	for(int i = 0; i < N; ++i) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	int dp0 = 1; //dp0[i] : a[0],...,a[i]で作れる，a[i]との差が0の列の最大長さ
	int dp1 = 1; //dp0[i] : a[0],...,a[i]で作れる，a[i]との差が1までの列の最大長さ
	int dp2 = 1; //dp0[i] : a[0],...,a[i]で作れる，a[i]との差が2までの列の最大長さ
	int res = 1;
	for(int i = 1; i < N; ++i) {
		if(a[i] == a[i - 1]) {
			++dp0;
			++dp1;
			++dp2;
		} else if(a[i] == a[i - 1] + 1) {
			dp2 = dp1 + 1;
			dp1 = dp0 + 1;
			dp0 = 1;
		} else if(a[i] == a[i - 1] + 2) {
			dp2 = dp0 + 1;
			dp1 = 1;
			dp0 = 1;
		} else {
			dp2 = 1;
			dp1 = 1;
			dp0 = 1;
		}
		if(res < dp2) res = dp2;
	}
	cout << res << '\n';
	return 0;
}



Measured memory_bytes: 892
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	all := 1
	odd := 1
	for i := 0; i < n; i++ {
		all *= 3
		a := scanInt()
		if a%2 == 0 {
			odd *= 2
		}
	}
	fmt.Println(all - odd)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>

using namespace std;

#define all(i) i.begin(), i.end()
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	int num = 0; cin >> num;
	string dat[12] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	rep(i, num)
	{
		string str; cin >> str;
		vector<int> hit(10, 0);
		rep(j, (int)str.size())
		{
			hit[str[j] - '0'] += 1;
			if (j == 0 || str[j - 1] == '0') {}
			else if (str[j] == '0')
			{
				int tmp = str[j - 1] - '0', n = hit[tmp];
				while (1)
				{
					if (n <= (int)dat[tmp].size()) { break; }
					n -= (int)dat[tmp].size();
				}
				printf("%c", dat[tmp][n - 1]);
				rep(i, 10){ hit[i] = 0; }
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 3092
/*
 *  Created on: 29 / 8 / 2020
 *  Author:     Eslam Waheed
 */

#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO

#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

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

#define ll   long long
#define ull  unsigned ll
#define ld   long double

#define all(c)   c.begin(), c.end()
#define rall(c)  c.rbegin(), c.rend()
#define stp(n)   cout << fixed << setprecision(n);
#define iq(v)    v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)    s.size()
#define endl     '\n'

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e9 + 7;
//const ld EPS = 1e-8;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
	//stp(0)
	Eslam__Waheed;
	ll a, b, c; cin >> a >> b >> c;
	cout << ((b * c >= a) ? "Yes" : "No");
}

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

int main()
{
	long long a, b, c, n;
  	cin >> a >> b >> c >> n;
  	long long sol = min(a, n);
  	n -= min(a, n);
 	n -= min(n, b);
  	sol -= n;
  	cout << sol;

	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	vector<string> input;
	string cur;
	for (int i = 0; i < 3; i++) {
		cin >> cur;
		input.push_back(cur);
	}

	string result;
	result += input[0][0];
	result += input[1][1];
	result += input[2][2];

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

struct much
{
    int x,v;
};

vector <much> G[100001];
int f[100001],d[100001];

void dfs(int i,int k)
{
    f[i]=1;
    d[i]=k;
    for(auto it : G[i])
        if(!f[it.x])
            dfs(it.x,k+it.v);
}

int main()
{
    int i,n,x,y,u,nr,k;
    scanf("%d%d",&n,&k);
    for(i=1; i<=k; i++)
    {
        scanf("%d%d%d",&x,&y,&u);
        G[x].push_back({y,u%2});
        G[y].push_back({x,u%2});
    }
    nr=0;
    for(i=1; i<=n; i++)
        if(!f[i])
        {
            dfs(i,0);
            nr++;
        }
    printf("%d",nr);

    return 0;
}


Measured memory_bytes: 9600
p = int(input())
a = list(map(int, input().split()))

MOD = p
MAX = p + 10
fact = [1] * (MAX + 1)  # i!
finv = [1] * (MAX + 1)  # (i!)^{-1}
iinv = [1] * (MAX + 1)  # i^{-1}
for i in range(2, MAX + 1):
    fact[i] = fact[i - 1] * i % MOD
    iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * iinv[i] % MOD


def comb(n: int, k: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    return (fact[n] * finv[k] % MOD) * finv[n - k] % MOD


b = [0] * p
for j in range(p):
    if a[j] == 1:
        b[0] += 1
        for k in range(p):
            b[k] += comb(p - 1, k) * pow(j, p - 1 - k, MOD) * (-1)**(
                (p - k) % 2)
            b[k] %= MOD

print(*b)


Measured memory_bytes: 74368
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();
            System.out.println(S + ((S.charAt(S.length() - 1) == 's') ? "es" : "s"));
        }
    }

}

Measured memory_bytes: 39352
def binarySearch(A, key):
    left = 0
    right = len(A)
    while (left < right):
        mid = int((left + right) / 2)
        if(A[mid] == key):
            return mid
        elif(A[mid] > key):
            right = mid
        else:
            left = mid + 1

    return -1 #not found

ans = 0
n = int(input())
A = [int(x) for x in input().split()] 
z = int(input())
q = [int(x) for x in input().split()]
for x in q:
    tmp = binarySearch(A, x)
    if(tmp != -1):
        ans += 1

print(ans)

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

int main(){

    int X,Y;
    cin>>X>>Y;
    bool ans=false;

    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            if(2*i+4*j==Y&&i+j==X){
               ans=true;
               break;
            }
        }
    }

    if(ans==true){
        cout<<"Yes"<<endl;
    }
    if(ans==false){
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
using namespace std ;
int main()
{
    int A1,A2,A3;
    int i;
    int ans[6];
    int temp;
    while( cin>>A1>>A2>>A3 )
    {
    	for(i=0;i<6;i++)
    		ans[i]=0;
    	ans[0]=abs(A2-A1)+abs(A3-A2);  //先完成第一个任务 
    	ans[1]=abs(A3-A1)+abs(A2-A3);
    	ans[2]=abs(A1-A2)+abs(A3-A1); //第二个
		ans[3]=abs(A3-A2)+abs(A1-A3);
		ans[4]=abs(A1-A3)+abs(A2-A1);  //第三个 
		ans[5]=abs(A2-A3)+abs(A1-A2);
		temp=ans[0];
		for(i=1;i<6;i++)
		{
			if(ans[i]<=temp)
				temp=ans[i];
		}
		cout<<temp<<endl;
	}

}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
 
int main(){
	int n,k;
	scanf("%d",&n);
	scanf("%d",&k);
	k=k-1;
	char s[1000];
	scanf("%s",s);

		if(s[k]=='A'){
			s[k]='a';}
			
		else if(s[k]=='B'){
			s[k]='b';}
			
		else  if(s[k]=='C'){
		s[k]='c';}
 
printf("%s",s);
    return 0;}

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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


bool solve(int N, int M, string& s, vi& a, vi& b) {
    vvi next(N);
    vi a_side(N,0), b_side(N,0);

    rep(i,M) {
        int u = a[i], v = b[i];
        bool cu = (s[u] == 'A'), cv = (s[v] == 'A');
        if (cv) ++a_side[u];
        else    ++b_side[u];
        next[u].pb(v);

        if (u != v) {
            if (cu) ++a_side[v];
            else    ++b_side[v];
            next[v].pb(u);
        }
    }

    queue<int> q;
    vector<bool> visited(N, false);
    int alive = N;



    rep(i,N){
        if (a_side[i]==0 || b_side[i]==0) {
            q.push(i);
        }
    }
    while (!q.empty()){
        int u = q.front(); q.pop();
        if (visited[u]) continue;

        bool cu = (s[u] == 'A');

        visited[u] = true;
        --alive;

        for (int v: next[u]) {
            if (visited[v]) continue;
            if (cu) --a_side[v];
            else    --b_side[v];
            if (a_side[v]==0 || b_side[v]==0) {
                q.push(v);
            }
        }
    }
    return alive > 0;
}

int main() {
    int N, M; cin >> N >> M;
    string s; cin >> s;
    vi a(M), b(M);
    rep(i,M) { scanf("%d %d", &a[i], &b[i]); --a[i]; --b[i]; }
    cout << (solve(N,M,s,a,b) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 13700
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int a1,a2,a3; cin >> a1 >> a2 >> a3;

    if(a1+a2+a3 >=22){
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }


    return 0;
}

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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

unsigned long long arr[52], dp[52][2501];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    // bruh am i supposed to bsearch this shit
    // oh shit i am

    // get 0
    // if i do an even distance away from 0

    string beg, state;
    int n; cin >> n;

    cout << 0 << endl;
    cin >> beg;

    if(beg == "Vacant"){
        return 0;
    }

    int mid, left = 0, right = n;

    for(int i = 0; i < 20; ++i){
        mid = (left + right) >> 1;
        cout << mid << endl;
        cin >> state;
        if(state == "Vacant")
            break;
        if(mid % 2 == 0){
            if(state == beg){
                left = mid;
            } else {
                right = mid;
            }
        } else {
            if(state != beg){
                left = mid;
            } else {
                right = mid;
            }
        }
    }

    return 0;

}


Measured memory_bytes: 852
#include <stdio.h>

int main(void) {
  
   int A,B;
   scanf("%d%d", &A, &B);

   if(A % 3 == 0){
     printf("Possible");
   }
   else if(B % 3 == 0){
     printf("Possible");
   }
   else if((A+B) % 3 == 0){
     printf("Possible");
   }
   else{
     printf("Impossible");
   }
   return 0;
   }   

Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        String op = sc.next();
        int B = sc.nextInt();

        if(op.equals("+")){
            System.out.println(A + B);
        }
        else{
            System.out.println(A - B);
        }
    }
}

Measured memory_bytes: 25044
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>

using namespace std;

queue<pair<int, int> > q;
int N, X, Y, ans[2010];
bool vis[2010];

int main() {
    scanf("%d%d%d", &N, &X, &Y);
    for (int i = 1; i <= N; ++i) {
        memset(vis, 0, sizeof(vis));
        q = queue<pair<int, int> >();
        vis[i] = 1;
        q.push(make_pair(i, 0));
        while (!q.empty()) {
            pair<int, int> now = q.front();
            q.pop();
            if (now.first > 1 && !vis[now.first - 1]) {
                ++ans[now.second + 1];
                vis[now.first - 1] = 1;
                q.push(make_pair(now.first - 1, now.second + 1));
            }
            if (now.first < N && !vis[now.first + 1]) {
                ++ans[now.second + 1];
                vis[now.first + 1] = 1;
                q.push(make_pair(now.first + 1, now.second + 1));
            }
            if (now.first == X && !vis[Y]) {
                ++ans[now.second + 1];
                vis[Y] = 1;
                q.push(make_pair(Y, now.second + 1));
            }
            if (now.first == Y && !vis[X]) {
                ++ans[now.second + 1];
                vis[X] = 1;
                q.push(make_pair(X, now.second + 1));
            }
        }
    }
    for (int i = 1; i < N; ++i) {
        printf("%d\n", ans[i] / 2);
    }
    return 0;
}

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

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    for(int i=0; i<101; i++){
        S = S.back() + S;
        S.pop_back();
        if(S == T){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

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

    vector<ll> A(N);
    vector<ll> bit_num(60);
    rep(i,N){
        ll a;
        cin>>a;
        ll ind = 0;
        while(a!=0){
            if(a&1 != 0){
                ++bit_num[ind];
            }
            ++ind;
            a>>=1;
        }
    }
    ll ans =0;
    ll n = 1;
    rep(i,60){
        ans += (((N-bit_num[i])*bit_num[i])%MOD*n)%MOD;
        ans %= MOD;
        n*=2;
        n%=MOD;
    }
    // rep(i,N){
    //     cout<<bit_num[i];
    // }
    // cout<<"\n";
    cout<<ans<<"\n";


	return 0;
}

Measured memory_bytes: 2560
//#include </Users/piyush/Desktop/nodejs/first-app/CP/bits/stdc++.h>
 #include <bits/stdc++.h>
typedef long long ll;
using namespace std;


#define print(x) for(auto iuiuiuiuiui:x){ cout<<iuiuiuiuiui<<" ";}br;

#define br cout<<"\n"
const int INF=1e9+5;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);


    ll n, total_w;
    cin>>n>>total_w;


    vector<ll> weight(total_w+1,0);

    ll w,v,maxi=INT_MIN;

    for(ll i=0;i<n;i++){
        cin>>w>>v;

        for(ll j=total_w-w;j>=0;j--){
            weight[j+w]=max(weight[j+w],weight[j]+v);
            maxi=max(weight[j+w],maxi);
        }

    }

    cout<<maxi;






}

Measured memory_bytes: 1024
import Control.Monad
import Control.Applicative

qsort :: [Int] -> [Int]
qsort [] = []
qsort (p:xs) =
  let lt   = filter (< p) xs
      gteq = filter (>= p) xs
  in  qsort lt ++ [p] ++ qsort gteq


penalty :: [Int] -> Int -> Int
penalty xs n = penalty' xs n 0
  where penalty' [] _ acc = acc
        penalty' _  0 acc = acc
        penalty' (y:ys) i acc = penalty' ys (i - 1) (acc + y * i)


solver :: [String] -> [Int]
solver (n:l:xs) =
  let
    num  = read n :: Int
    line = map (read :: String -> Int) $ words l
  in
    penalty (qsort line) num : solver xs
solver [] = []

main :: IO()
main = do
  inputs <- lines <$> getContents
  mapM_ print $ solver inputs

Measured memory_bytes: 5112
#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 1000

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    stack stk1, stk2;
    char str[11];
    int i = 0;

    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk1);
    initialize_stack(&stk2);
    //文字列を受け取る
    scanf("%s", str);
    //スタックにデータを追加
    for(i = 0; i < 10; i++){
        if(str[i] == 'B'){
            if(stk1.count > 0){
                pop(&stk1);
            }
        }else if(str[i] == '0' || str[i] == '1'){ 
            push(&stk1, str[i]);
        }else{
            break;
        }
    }

    //スタック内部のデータの前後反転
    while(stk1.count > 0){
        push(&stk2, pop(&stk1));
    }

    //答えを出力
    while(stk2.count > 0){
        printf("%c", pop(&stk2));
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1624
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int n,m,l;
	cin >> n >> m >> l;
	vector< vector<int> > A(n,vector<int>(m));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> A[i][j];
		}
	}
	vector< vector<int> > B(m,vector<int>(l));
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < l; ++j) {
			cin >> B[i][j];
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < l; ++j) {
			long long res = 0;
			for (int k = 0; k < m; ++k) {
				res += A[i][k]*B[k][j];
			}
			cout << res;
			if (j < l-1) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  REP(i,n){
    int32 a;
    cin >> a;
    if(a % 2 == 0){
      if(a % 3 != 0 && a % 5 != 0){
        cout << "DENIED\n";
        return 0;
      }
    }
  }
  cout << "APPROVED\n";
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using Int = unsigned int;
using llong = long long;
using Llong = unsigned long long;
using ldouble = long double;
using intV = vector<int>;
using llongV = vector<long long>;
using llongVV = vector<vector<long long>>;
using Graph = vector<vector<long long>>;
using costGraph = vector<vector<pair<long long, long long>>>;

const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0LL; i < llong(n); i++)
#define FORS(i, a, b) for (llong i = llong(a); i < llong(b); i++)

// 0-indexed, [l, r)
class SegmentTree {
    public :
        llongV __data;
        llong __size;

        SegmentTree (llong size) {
            this->init(size);
        };

        void init (llong size) {
            // 完全二分木にする
            llong binSize = 0;
            while((1 << binSize) < size) {
                binSize++;
            }
            this->__size = (1 << binSize);

            this->__data.resize(this->__size * 2);
            for(llong i = 0; i < this->__size * 2; i++) {
                this->__data[i] = INF;
            }
        };

        /* メソッド */
        void update(llong index, llong value) {
            index += this->__size - 1;
            this->__data[index] = value;
            while(index > 0) {
                index = (index - 1) / 2;
                this->__data[index] = min(this->__data[index * 2 + 1], this->__data[index * 2 + 2]);
            }
        };

        llong __query(llong qLeft, llong qRight, llong node, llong left, llong right) {
            if(right <= qLeft || qRight <= left) return INF;
            if(qLeft <= left && right <= qRight) return this->__data[node];

            llong leftVal = this->__query(qLeft, qRight, node * 2 + 1, left, (left + right) / 2);
            llong rightVal = this->__query(qLeft, qRight, node * 2 + 2, (left + right) / 2, right);
            return min(leftVal, rightVal);
        }

        // wrapper
        llong query(llong left, llong right) {
            return this->__query(left, right, 0, 0, this->__size);
        };
};

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

    llong N, M;
    cin >> N >> M;

    SegmentTree tree(N + 1);
    tree.update(1, 0);
    vector<tuple<llong, llong, llong>> edges(M);

    FOR(i, M) cin >> get<0>(edges[i]) >> get<1>(edges[i]) >> get<2>(edges[i]);
    sort(edges.begin(), edges.end());

    FOR(i, 10) {
        for(auto a : edges) {
            llong L, R, C;
            tie(L, R, C) = a;
            llong cost = tree.query(L, R + 1) + C;
            tree.update(R, min(cost, tree.query(R, R + 1)));
        }
    }

    llong ans = tree.query(N, N + 1);
    if(ans == INF) ans = -1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4608
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
 
using namespace std;

vector<int> d[2];
vector<vector<int> > e;
const int inf=100000000;

void dfs(int pos,int cost,int idx){
	if( d[idx][pos]<=cost ) return;
	
	d[idx][pos]=cost;
	for(int i=0;i<e[pos].size();i++){
		dfs( e[pos][i], cost+1, idx );
	}
}

int main(){

	int n;
	cin>>n;

	d[0]=vector<int>(n,inf);
	d[1]=vector<int>(n,inf);

	e=vector<vector<int> >(n);
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	dfs(0,0,0);
	dfs(n-1,0,1);

	int fen=0,snu=0;
	for(int i=0;i<n;i++){
		if(d[0][i]<=d[1][i]) fen++;
		else snu++;
	}

	if(fen>snu) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;

	return 0;
}


Measured memory_bytes: 11136
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    if a == b {
        println!("Draw");
    } else if (1 < a && a < b) || b == 1 {
        println!("Bob");
    } else {
        println!("Alice");
    }
}


Measured memory_bytes: 4352
n=int(input())
w=[int(i) for i in input().split()]
t=1
x1=sum(w[1:n])
x2=w[0]
x=abs(x1-x2)
while t<n:
  a=sum(w[0:t])
  b=sum(w[t:n])
  c=abs(a-b)
  if c<x:
    x=c
  else:
    x=x
  t=t+1
print(x)

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

int mod = 1000000007;

int main()
{
    int H, W;
    int black = 0;
    int white = 0;

    cin >> H >> W;

    vector<int> dH = {1, 0, -1, 0};
    vector<int> dW = {0, 1, 0, -1};

    vector<vector<char>> map(H, vector<char>(W)); //迷路地図

    char tmp;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> tmp;
            map[i][j] = tmp;
            if (tmp == '#')
                black++;
            if (tmp == '.')
                white++;
        }
    }

    vector<vector<int>> list(H, vector<int>(W, -1)); //距離を記録
    queue<pair<int, int>> que;                       //保留用

    int Hs, Ws;
    list[0][0] = 0;            //スタート地点
    que.push(make_pair(0, 0)); //こちらも
    while (!que.empty())
    {
        pair<int, int> now = que.front();
        que.pop();

        for (int i = 0; i < 4; i++)
        {
            int Hs = now.first + dH[i];
            int Ws = now.second + dW[i];

            if (Hs == -1 || Hs == H || Ws == -1 || Ws == W) //範囲外
                continue;
            if (list[Hs][Ws] != -1 || map[Hs][Ws] == '#') //探索済み
                continue;
            list[Hs][Ws] = list[now.first][now.second] + 1;
            que.push(make_pair(Hs, Ws));
        }
    }
    if (list[H - 1][W - 1] == -1)//到達不能
        cout << -1;
    else
    {
        cout << white - list[H - 1][W - 1] - 1;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define MP make_pair
#define vii vector<pii>
#define vi vector<int>
#define ll long long
using namespace std;
const int N=1e5+5;
int n,h[N];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>h[i];
	for(int i=n-2;i>=0;i--)
	{
		if(h[i]-1>h[i+1])
		{
			cout<<"No\n";
			return 0;
		}
		else
		{
			h[i]=min(h[i+1],h[i]);
		}
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std; 
int main(){
unsigned long long int n,m,k,i,x,pk, pans=0, mx=0,mxn=0, mxm=0;	
vector<unsigned long long int> nv;
vector<unsigned long long int> mv;
cin>>n>>m>>k;pk=k;
bool pv=true;
for(i=1; i<=n; i++){
	cin>>x; nv.push_back(x);
	if(pv==true){
		if(x<=pk){
		pk-=x; pans++;	
		mxn=i;
		}else{
		if(pans>mx)mx=pans;
			pv=false;
		}
	}
}
pv=true;
for(i=0; i<m; i++){
	cin>>x; mv.push_back(x);
	if(pv==true){
		if(x<=pk){
		pk-=x; pans++;	
		mxm=i+1;
		}else{
			if(pans>mx)mx=pans;
			pv=false;
		}
	}
}
if(pans>mx)mx=pans;

while(mxn>0&&mxm<m){
pk+=nv[mxn-1];pans--;
while(mxm<m&&mv[mxm]<=pk){
	pk-=mv[mxm];pans++;mxm++;
}
mxn--;
if(pans>mx)mx=pans;	
}

cout<<mx;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> num(4);
    vector<char> op(3);
    num.at(0) = n/1000;
    n %= 1000;
    num.at(1) = n/100;
    n %= 100;
    num.at(2) = n/10;
    n %= 10;
    num.at(3) = n;

    for(int tmp = 0;tmp < (1<<3);tmp++)
    {
        bitset<3> b(tmp);//1:+,0:-
        int sum = num.at(0);
        for(int i=0;i<3;i++)
        {
            if(b.test(i))
            {
                op.at(i) = '+';
                sum += num.at(i+1);
            }else{
                op.at(i) = '-';
                sum -= num.at(i+1);
            }
        }
        if(sum == 7)
        {
            break;
        }
    }

    cout<<num.at(0)<<op.at(0)
    <<num.at(1)<<op.at(1)
    <<num.at(2)<<op.at(2)
    <<num.at(3)<<"=7"<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int solve(int,int);
int a[20];
int n;
int main(){
  int c,d[200],i,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&c);
  for(i=0;i<c;i++){
    scanf("%d",&d[i]);
  }
    for(i=0;i<c;i++){
    k= solve(0,d[i]);
      if(k==0) printf("yes\n");
      else printf("no\n");
    }
    return 0;
}




int solve(int i,int m){
  int c,b;
  if (m==0){
    return 0;
  }
  else if(i>=n){
    return 1;
  }
  else{
  c=solve(i+1,m);
  b=solve(i+1,m-a[i]);
  if(c==0||b==0){
    return 0;
  }
  else return 1;
}
}



Measured memory_bytes: 2140
//file_name:ABC45_C.cpp
#include <bits/stdc++.h>
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
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;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    ll n;
    scanf("%lld",&n);

    int keta = 0;
    ll nn = n;
    while(nn>0){
        keta++;
        nn/=10;
    }

    ll ans = 0;

    if(keta==1){
        ans = n;
        cout << ans << endl;
        return 0;
    }

    nn = n;
    rep(i,keta){
        rep(j,i+1){
            ans += nn%10 * pow(10,j) * pow(2,keta-1-1-j);
        }
        ans += nn%10 * pow(10,i) * pow(2,keta-2-i);
        nn/=10;
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
const int N = 500010;
char s[N];
int n, f[N][27], g[N][20];
void init() {
	dep(i,n,1) {
		int x = s[i] - 'a';
		f[i][x] = i + 1;
		rep(j,x + 1,26) f[i][j] = f[f[i][j - 1]][j - 1];
		g[i][0] = f[i][26];
		if (g[i][0]) { rep(j,0,x - 1) f[i][j] = f[g[i][0]][j]; }
	}
	rep(j,1,19) rep(i,1,n) g[i][j] = g[g[i][j - 1]][j - 1];
}

int main() {
 	scanf("%s",s + 1); n = strlen(s + 1);
	init(); int q; scanf("%d",&q);
	rep(i,1,q) {
		int a, b; scanf("%d%d",&a,&b);
		dep(j,19,0) if (g[a][j] && g[a][j] <= b + 1) a = g[a][j];
		if (a == b + 1) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a == b)
	cout << "Draw";
	else if (a == 1)
	cout << "Alice";
	else if (b == 1)
	cout << "Bob";
	else if (a > b)
	cout << "Alice";
	else if (a < b)
	cout << "Bob";
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        double r=sc.nextDouble();
        System.out.println(String.format("%.6f",r*r*Math.PI)+" "+String.format("%.6f",2*r*Math.PI));
    } 
}


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

int main() {
  int n;
  cin >> n;
  
  int sum = 0;
  
  for (int i = 0; i < n; i++){
    if (pow(10,2*i + 1) <= n){
      sum += pow(10,2*i + 1) - pow(10,2*i);
    }
    else {
      if (n - pow(10,2*i) >= 0){
        sum += n - pow(10,2*i) + 1;
      }
      break;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;



int main() {
    string S,T;
    cin>>S>>T;
    int count=0;
    rep(i,3){
        if(S.at(i)==T.at(i))count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
S = input()
n = len(S)

i, j, k = 0, 0, 0
ans = [0] * n
s = 0
while True:
    for x in range(i, n):
        if S[x] == "L":
            j = x
            break
    for x in range(j + 1, n):
        if S[x] == "R":
            k = x
            break
    else:
        k = n
    s = k - i
    a = s // 2
    if s % 2 == 0:
        ans[j - 1] = a
        ans[j] = a
    else:
        if (j - i) % 2 == 0:
            ans[j] = a + 1
            ans[j - 1] = a
        else:
            ans[j] = a
            ans[j - 1] = a + 1
    if k == n:
        break
    i = k
print(*ans)

Measured memory_bytes: 6400
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val s, t = sc.next()
    val ss = s.toCharArray.sorted
    val tt = t.toCharArray.sorted.reverse

    if (ss.mkString("") < tt.mkString("")) {
      println("Yes")
    } else {
      println("No")
    }
  }

}


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

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

    bool ans = false;
    int z=0;

      for(int x=0; x<=N; x++){
        for(int y=0; y<=N-x; y++){
          z = N-x-y;
            if(10000*x+5000*y+1000*z==Y){
              cout << x << " " << y << " " << z << endl;
              ans = true;
            }

        if(ans) break;
      }
      if(ans) break;
    }
    if(ans == false){
      cout << -1 << " " << -1 << " " << -1 << endl;
    }
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vvll a(n, vll(3));
    rep(i, n) cin >> a[i][0] >> a[i][1] >> a[i][2];
    ll ans = 0;
    for (int bit = 0; bit < 1<<3; ++bit) {
        vll b(n, 0);
        rep(j, 3) {
            if (bit>>j&1) {
                rep(i, n) b[i] += a[i][j];
            } else {
                rep(i, n) b[i] -= a[i][j];
            }
        }
        sort(b.rbegin(), b.rend());
        chmax(ans, accumulate(b.begin(), b.begin()+m, 0LL));
    }
    cout << ans << endl;
}

Measured memory_bytes: 384