akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
char c[3] =	{'+', '-', '*'};
void calc(vector<int> v1, vector<int> v2, int a[4], int r, bool &f) {
	if(f) return;
	if(r == 2) {
		vector<int> nv;
		nv.push_back(a[2] + a[3]);
		nv.push_back(a[2] - a[3]);
		nv.push_back(a[2] * a[3]);
		for(int x : v1) {
			for(int y : nv) {
				v2.push_back(x + y);
				v2.push_back(x - y);
				v2.push_back(x * y);
			}
		}
	}
	if(r == 4) {
		for(int i = 0; i < v1.size(); i++) {
			if(v1[i] == 10) {
				int x = i % 3;
				int y = (i / 3) % 3;
				int z = i / 9;
				if(x == 2) {
					cout << "((" << a[0] << " " << c[z] << " " << a[1] << ")" << c[y] << " " << a[2]
					<< ")" << c[x] << " " << a[3] << endl;
				} else if(y == 2) {
					cout << "(" << a[0] << " " << c[z] << " " << a[1] << ")" << c[y] << " " << a[2] << " "
					<< c[x] << " " << a[3] << endl;
				} else {
					cout << a[0] << " " << c[z] << " " << a[1] << " " << c[y] << " " << a[2] << " "
					<< c[x] << " " << a[3] << endl;
				}
				f = 1;
				return;
			}
		}
		for(int i = 0; i < v2.size(); i++) {
			if(v2[i] == 10) {
				int x = i % 3;
				int y = (i / 3) % 3;
				int z = i / 9;
				cout << "(" << a[0] << " " << c[z] << " " << a[1] << ")" << c[x] << "(" << a[2] << " "
					<< c[y] << " " << a[3] << ")" <<  endl;
				f = 1;
				return;
			}
		}
		return;
	}
	vector<int> nv;
	for(int x : v1) {
		nv.push_back(x + a[r]);
		nv.push_back(x - a[r]);
		nv.push_back(x * a[r]);
	}
	calc(nv, v2, a, r + 1, f);
}

int main() {
	int n[4];
	while(cin >> n[0] >> n[1] >> n[2] >> n[3] && (n[0] || n[1] || n[2] || n[3])) {
		bool b[4];	
		rep(i,4) {
			b[i] = 0;
		}
		bool f = 0;
		rep(i,4) {
			b[i] = 1; 
			rep(j,4) {
				if(b[j]) continue;
				b[j] = 1;
				rep(k,4) {
					if(b[k]) continue;
					b[k] = 1;
					int m = 0;
					while(b[m]) m++;					
					vector<int> v1;
					vector<int> v2;
					v1.push_back(n[i]);
					int a[4] = {n[i], n[j], n[k], n[m]};
					calc(v1, v2, a, 1, f);
					if(f) break;
					b[k] = 0;
				}
				if(f) break;
				b[j] = 0;	
			}
			if(f) break;
			b[i] = 0;
		}
		if(!f) cout << 0 <<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
# -*- coding: utf-8 -*-

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#整数値龍力　複数の入力(配列で1つずつ渡される)
def input_multiple_number_as_list_sep(N):
    ins = []
    for i in range(N):
        ins.append(input())
    return ins

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = fractions.gcd(gcd, l[i])
    return gcd

#各桁の和
def sum_digit(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

givenN,givenK = input_multiple_number()
lst_h = input_multiple_number_as_list()

lst_h.sort()

if givenK != 0:
    lst_h = lst_h[:-givenK]

damage = 0
for a in lst_h:
    damage += a

print(damage)



Measured memory_bytes: 27404
for i in range(1,10):
    a=1*i
    print('1x{0}={1}'.format(i,a))
for i in range(1,10):
    b=2*i
    print('2x{0}={1}'.format(i,b))
for i in range(1,10):
    c=3*i
    print('3x{0}={1}'.format(i,c))
for i in range(1,10):
     d=4*i
     print('4x{0}={1}'.format(i,d))
for i in range(1,10):
    e=5*i
    print('5x{0}={1}'.format(i,e))
for i in range(1,10):
    f=6*i
    print('6x{0}={1}'.format(i,f))
for i in range(1,10):
    g=7*i
    print('7x{0}={1}'.format(i,g))
for i in range(1,10):
    h=8*i
    print('8x{0}={1}'.format(i,h))
for i in range(1,10):
    j=9*i
    print('9x{0}={1}'.format(i,j))


Measured memory_bytes: 5544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    long c;
    long[] xs, vs;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        c = sc.nextLong();
        xs = new long[n + 2];
        vs = new long[n + 2];
        for (int i = 1; i <= n; i++) {
            xs[i] = sc.nextLong();
            vs[i] = sc.nextLong();
        }
        xs[n + 1] = c;
        solve();
    }

    void solve() {
        long[] vSumToI = new long[n + 1];
        long[] vSumToI2 = new long[n + 1];
        long[] vSumToJ = new long[n + 2];
        long[] maxVSumForJ = new long[n + 1];
        long[] maxVSumForJ2 = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            vSumToI[i] = vSumToI[i - 1] + vs[i];
            vSumToI2[i] = vSumToI2[i - 1]+ vs[i];
        }
        for (int i = n; i >= 1; i--) {
            vSumToJ[i] = vSumToJ[i + 1] + vs[i];
        }
        for (int i = 1; i <= n; i++) {
            maxVSumForJ[i] = Math.max(maxVSumForJ[i - 1],
                    vSumToI[i] - xs[i]);
            maxVSumForJ2[i] = Math.max(maxVSumForJ2[i - 1],
                    vSumToI[i] - 2 * xs[i]);
        }
        long maxCal = 0;
        for (int i = 1; i <= n + 1; i++) {
            long tempMaxCal = maxVSumForJ[i - 1] +
                    vSumToJ[i] - 2 * (c - xs[i]);
            maxCal = Math.max(maxCal, tempMaxCal);
            long tempMaxCal2 = maxVSumForJ2[i - 1] + vSumToJ[i] - c + xs[i];
            maxCal = Math.max(maxCal, tempMaxCal2);
        }
        System.out.println(maxCal);
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 48496
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  VV<> a; assign(a, n, n, 0);
  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) cin >> a[i][j];
  V<lint> s(1 << n);
  for (int bit = 0; bit < 1 << n; ++bit) {
    for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) if (bit & 1 << i and bit & 1 << j) {
      s[bit] += a[i][j];
    }
  }
  V<lint> dp(1 << n, -9e18);
  dp[0] = 0;
  for (int bit = 1; bit < 1 << n; ++bit) {
    int x = bit ^ bit & -bit;
    dp[bit] = dp[x];
    for (int y = x; y > 0; y = y - 1 & x) {
      int z = y | bit & -bit;
      dp[bit] = max(dp[bit], dp[x ^ y] + s[z]);
    }
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 1280
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  n: usize,
  mut l: [i64; n],
  }

  l.sort();

  let mut cnt = 0_u64;
  for i in 0..n {
    for j in i + 1..n {
      if l[i] == l[j]{
        continue;
      }
      for k in j + 1..n {
        if l[j] == l[k]{
          continue;
        }

        if l[k] < l[i] + l[j]
        {
          cnt += 1;
        }
      }
    }
  }

  println!("{}", cnt);
}


Measured memory_bytes: 2160
#include "bits/stdc++.h"
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if (a == 1)
  {
    a = 14;
  }
  if (b == 1)
  {
    b = 14;
  }
  if (a == b)
  {

    cout << "Draw" << endl;
  }
  else if (a > b)
  {

    cout << "Alice" << endl;
  }
  else
  {

    cout << "Bob" << endl;
  }
  return 0;
}


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

using namespace std;

#define int long long
const int mod=(int)1e9+7;

void test_case(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<vector<int> > suff(n+1,vector<int>(3));
    for(int i=n-1;i>=0;i--){
        if(s[i]=='R'){
            suff[i][0]=suff[i+1][0]+1;
            suff[i][1]=suff[i+1][1];
            suff[i][2]=suff[i+1][2];
        }
        else if(s[i]=='G'){
            suff[i][1]=suff[i+1][1]+1;
            suff[i][0]=suff[i+1][0];
            suff[i][2]=suff[i+1][2];
        }
        else{
            suff[i][2]=suff[i+1][2]+1;
            suff[i][1]=suff[i+1][1];
            suff[i][0]=suff[i+1][0];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]!=s[j]){
                set<int> st={0,1,2};
                if(s[i]=='R'||s[j]=='R')st.erase(0);
                if(s[i]=='G'||s[j]=='G')st.erase(1);
                if(s[i]=='B'||s[j]=='B')st.erase(2);
                int idx=*st.begin();
                int ex=suff[j+1][idx];
                //cout<<i<<" "<<j<<" "<<ex<<"\n";
                if((j+(j-i)>=n)||(s[j]==s[j+(j-i)])||(s[i]==s[j+(j-i)]));
                else ex--;
                //cout<<i<<" "<<j<<" "<<ex<<"\n";
                ans+=ex;
            }
        }
    }
    cout<<ans;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        test_case();
    }
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  ll dp[3333],dp2[3333];
  mem(dp);mem(dp2);
  dp[0]=dp2[0]=1;
  rep(i,3333) {
    rep(j,3333) {
      if(i+a*100*j<=f) dp[i+j*a*100]|=dp[i];
      if(i+b*100*j<=f) dp[i+j*b*100]|=dp[i];
      if(i+c*j<=f) dp2[i+j*c]|=dp2[i];
      if(i+d*j<=f) dp2[i+j*d]|=dp2[i];
    }
  }
  double M=0;
  int x=100*a,y=0;
  rep(i,3333) {
    rep(j,3333) {
      if(i+j>f) break;
      if(!dp[i]||!dp2[j]) continue;
      if((double)i/100*e>=j) {
        double z=100.0*j/(i+j);
        if(M<z) {
          M=z;
          x=i+j;
          y=j;
        }
      }
    }
  }
  pr(x,y);
}

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


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

typedef long long ll;
typedef unsigned long long ull;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int P[200010];
int r[200010];
int c[200010];

int main(){

    cin >> N;
    vector<int> v[2];
    for(int i = 0; i < N; i++){
        cin >> P[i];
        r[P[i]] = i;
        v[0].push_back(P[i]);
        v[1].push_back(P[i]);
    }
    
    sort(v[0].begin(), v[0].end());
    if(v[0] == v[1]){
        cout << 0 << endl;
        return 0;
    }

    c[1]=1;
    int max_con = -1;
    for(int i = 2; i <= N; i++){
        if(r[i-1] < r[i]){
            c[i] = c[i-1] + 1;
        }
        else{
            c[i] = 1;
        }
        max_con = max(max_con, c[i]);
    }
    cout << N - max_con << endl;


    return 0;
}


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

struct HashPair {

    //注意 constがいる
    template<class T1, class T2>
    size_t operator()(const pair<T1, T2> &p) const {

        //first分をハッシュ化する
        auto hash1 = hash<T1>{}(p.first);

        //second分をハッシュ化する
        auto hash2 = hash<T2>{}(p.second);

        //重複しないようにハッシュ処理
        size_t seed = 0;
        seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        return seed;
    }
};

int main() {
  int h,w,m;
  cin >> h >> w >> m;
  vector<P>x(h);
  vector<P>y(w);
  rep(i,0,h) x[i].second = i;
  rep(i,0,w) y[i].second = i;
  unordered_map<P,int,HashPair> mp;
  rep(i,0,m){
    int vx,vy;
    cin >> vx >> vy;
    vx--;vy--;
    mp[P(vx,vy)] = 1;
    x[vx].first++;
    y[vy].first++;
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  reverse(x.begin(),x.end());
  reverse(y.begin(),y.end());
  int ans = x[0].first+y[0].first;
  auto itr = mp.find(P(x[0].second,y[0].second));
  if(itr != mp.end()) ans--;
  else{
    cout << ans << endl;
    return 0;
  }
  rep(i,0,h){
    if(x[i].first != x[0].first) break;
    rep(j,0,w){
      if(y[j].first != y[0].first) break;
      auto itr = mp.find(P(x[i].second,y[j].second));
      if(itr == mp.end()){
        cout << ans+1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 26048
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, m;
	while (cin >> n >> m, n, m) {
		int a[1100], ans = -1;
		for (int i = 0; i < n; i++)cin >> a[i];
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] + a[j] <= m) {
					if (ans < a[i] + a[j])ans = a[i] + a[j];
				}
			}
		}
		if (ans < 0)cout << "NONE\n";
		else cout << ans << endl;
	}
}


Measured memory_bytes: 3028
import numpy as np


N = int(input())
XY = []
ANS = []


for _ in range(N):
    a = int(input())
    tmp = []

    for _ in range(a):
        xy = tuple(map(int, input().split()))
        tmp.append(xy)
    XY.append(tmp)


for b in range(2 ** N):
    status = []
    for i in range(N):
        j = b >> i & 1
        status.append(j)
    status = np.array(status)

    f = 1
    ans = 0

    for i in range(N):
        j = b >> i & 1
        if not j:
            continue
        for x, y in XY[i]:
            s = status[x - 1]
            if s != y:
                f = 0
                break
        if not f:
            break

    if f:
        ans = np.sum(status)
    ANS.append(ans)


print(max(ANS))

Measured memory_bytes: 13644
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N, A; cin >> N >> A;

    int B = N % 500;

    if (B <= A) cout << "Yes" << endl;
    else cout << "No" << endl;
  
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <queue>

using namespace std;

const int MOD = 998244353;
const int INF = (1 << 30);

int main(){

    int N;
    cin >> N;
    using PP = pair<pair<int, int>, int>;
    priority_queue<PP, vector<PP>, greater<PP>> pq;
    int x, d;
    for(int i = 0; i < N; i++){
        cin >> x >> d;
        pq.push(make_pair(make_pair(x, d), 0));
    }

    long long ans = 1;
    long long activeAns = 0;
    using P = pair<int, int>;
    priority_queue<P, vector<P>, greater<P>> pqActive;
    while(!pq.empty()){
        auto temp = pq.top();
        pq.pop();
        int x = temp.first.first;
        int d = temp.first.second;

        while(!pqActive.empty()){
            auto temp2 = pqActive.top();
            if(temp2.first > x){
                break;
            }
            activeAns = (activeAns - temp2.second + MOD) % MOD;
            pqActive.pop();
        }
        
        long long nonactiveAns = (ans - activeAns + MOD) % MOD;
        ans = (activeAns + nonactiveAns * 2) % MOD;
        activeAns += nonactiveAns;
        
        long long temp3 = nonactiveAns;
        while(!pqActive.empty()){
            auto temp2 = pqActive.top();
            if(temp2.first > x + d){
                break;
            }
            temp3 = (temp3 + temp2.second) % MOD;
            pqActive.pop();
        }
        pqActive.push(make_pair(x + d, temp3));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4980
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <numeric>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a; cin >> a;
    string s; cin >> s;
    ll b=0;
    for(char c:s){
        if(c=='.')continue;
        b*=10;
        b+=c-'0';
    }
    cout << a*b/100 << endl;
}

Measured memory_bytes: 3648
#include<iostream>

int N, W;
int ws[100], vs[100];
long mem[100][100001];

long get(int n, int w){
  if(mem[n][w] != -1){
    return mem[n][w];
  }
  long ans;
  if(n==0){
    if(w>=ws[0]){
      ans = vs[0];
    }else{
      ans = 0;
    }
  }else if(w<ws[n]){
    ans = get(n-1,w);
  }else{
    ans = std::max(get(n-1,w), get(n-1,w-ws[n])+vs[n]);
  }
  mem[n][w] = ans;
  return ans;
}

int main(){
  std::cin >> N >> W;
  for(int i=0; i<N; i++){
    std::cin >> ws[i] >> vs[i];
  }
  for(int i=0;i<N;i++){
    for(int w=0;w<=W;w++){
      mem[i][w] = -1;
    }
  }
  std::cout << get(N-1,W) << std::endl;
  return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
int main(){
   string S,T,U;
   int A,B;
   cin>>S>>T>>A>>B>>U;
   if(S==U) cout<<A-1<<" "<<B<<endl;
   else if(T==U) cout<<A<<" "<<B-1<<endl;
   return 0;
}

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

bool a[10];
int n,x,ans,temp;

int main()
  {
  	scanf("%d",&n);
  	while (n--)
  	  {
  	  	scanf("%d",&x);
  	  	if (x<400&&!a[1]) a[1]=true,ans++;
  	  	if (x>=400&&x<800&&!a[2]) a[2]=true,ans++;
  	  	if (x>=800&&x<1200&&!a[3]) a[3]=true,ans++;
  	  	if (x>=1200&&x<1600&&!a[4]) a[4]=true,ans++;
  	  	if (x>=1600&&x<2000&&!a[5]) a[5]=true,ans++;
  	  	if (x>=2000&&x<2400&&!a[6]) a[6]=true,ans++;
  	  	if (x>=2400&&x<2800&&!a[7]) a[7]=true,ans++;
  	  	if (x>=2800&&x<3200&&!a[8]) a[8]=true,ans++;
  	  	if (x>=3200) temp++;
	  }
  	printf("%d %d\n",max(ans,1),ans+temp);
  	return 0;
  }

Measured memory_bytes: 256
import Data.List
main=getLine>>=print.e
 where e (c:s) = f (if c=='?' then ((replicate 10 1)++[0,0,0]) else (take 13 ((replicate (read [c]) 0)++(1:(repeat 0))))) s
       f l [] = l!!5
       f l (c:s) = let k=(map (l!!) [0,4,8,12,3,7,11,2,6,10,1,5,9]) in (if c=='?' then (f (g k) s) else (f (h (read [c]) k) s))
       g k = let kk=(reverse (k++k)) in (map (i kk) [12,11..0])
       h c k = ((drop (13-c) k)++(take (13-c) k))
       i k j = mod(sum(take 10 (drop j k)))1000000007

Measured memory_bytes: 219516
#include<bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int dp[100001];
int solve(int src)
{
	if(dp[src] != -1)return dp[src];
	bool leaf = 1;
	int bestChild = 0;
	for(int child:graph[src]){
		leaf = 0;
		bestChild = max(bestChild, solve(child));
	}
	return dp[src] = leaf ? 0 : 1 + bestChild;
}
int main()
{
	int n, m;
	cin >> n >> m;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		graph[x].push_back(y);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, solve(i));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11304
N = int(input())
s = [int(input()) for i in range(N)]
s.sort()
S = sum(s)

if S % 10 != 0:
    print(S)
    exit()
for i in s:
    if (S - i) % 10 != 0:
        print(S-i)
        exit()

print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int n;cin>>n;
    ll res=0;
    vector<ll> a(n);
    cin>>a;
    ll mx=a[0];
    for(int i=1;i<n;i++){
        if(a[i]>=mx) chmax(mx,a[i]);
        else res+=mx-a[i];
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4760
#include <math.h>

#include <algorithm>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt  = 1;
    char col = s[0];
    rep(i, 1, n) {
        if (s[i] != col) {
            cnt++;
            col = s[i];
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    if(a[0]==a[1] && a[1] != a[2]){
        cout << "Yes" << endl;
    }else if(a[0] != a[1] && a[1] == a[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 764
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	double a, b, h, m; cin >> a >> b >> h >> m;
	double hh = h * 30 + 0.5*m, mh = 6 * m;
	double angle = abs(hh - mh);
	if (angle > 180)angle = 360 - angle;
	if (angle == 0)cout << abs(b - a) << endl;
	else if (angle == 180)cout << b + a << endl;
	else
	{
		double res;
		res = a * a + b * b - 2 * a*b*cos(angle*M_PI/180);
		res = sqrt(res);
		cout << fixed << setprecision(12) << res << endl;
	}
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 100;
const int lg = 17;
int x[N],d[N][lg + 1];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,L;
	cin >> n;
	for(int i = 1;i <= n;i++)cin >> x[i];
	cin >> L;
	for(int i = n;i >= 1;--i){
	    d[i][0] = ((upper_bound(x + 1,x + 1 + n, x[i] + L)) - x - 1);
	    for(int j = 1;j <= lg;++j){
	        d[i][j] = d[d[i][j - 1]][j - 1];
	    }
	}
	int q;
	cin >> q;
	while(q--){
	    int a,b;
	    cin >> a >> b;
	    if(a == b){
	        cout << 0 << '\n';
	        continue;
	    }
	    if(a > b)swap(a, b);
	    int ans = 1;
	    for(int i = lg;i >= 0;--i){
	        if(d[a][i] < b){
	            a = d[a][i];
	            ans += (1 << i);
	        }
	    }
	    cout << ans << '\n';
	}
	
  	return 0;
} 

Measured memory_bytes: 11072
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,n,ans=0,j;
    int p[1000005]={0};
    cin>>n;
    int a[n+2];
    a[0]=-1;
    a[n+1]=1000001;
    for(i=1;i<=n;i++){cin>>a[i];}
    sort(a,a+n+2);
    for(i=1;i<=n;i++){
        if(a[i]==a[i-1])p[a[i]]=2;
    }
    for(i=1;i<=n;i++){
        if(!p[a[i]])ans++;
        if(p[a[i]]==1)continue;
          p[a[i]]=1;
          for(j=a[i];j<=1000000;j+=a[i]){
              p[j]=1;
          }
    }
    cout<<ans;
    return 0;
}

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

/* constant */

#define MAX_N   (30)
#define MAX_C   (30)
#define NUM_L   (1 << 16)

/* typedef */

/* global variables */

static int n, c;
static int as[MAX_N], bs[MAX_C];

static int mscache[MAX_N][NUM_L];

/* subroutines */

int count_bits(int bits) {
  int c = 0;

  while (bits != 0) {
    if (bits & 1) c++;
    bits >>= 1;
  }

  return c;
}

int max_score(int k, int prev_l) {
  int bl, cur_l, i, l, max_sc, sc;

  if (k >= n) return 0;
  if (mscache[k][prev_l] >= 0) return mscache[k][prev_l];

  cur_l = prev_l | as[k];
  max_sc = 0;

  for (i = 0; i < c; i++) {
    bl = (cur_l & bs[i]);
    l = cur_l ^ bl;

    sc = count_bits(bl) + max_score(k + 1, l);

    if (max_sc < sc) max_sc = sc;
  }

  return (mscache[k][prev_l] = max_sc);
}

/* main */

int main(int argc, char **argv) {
  int b, i, j, k, ms;

  for (;;) {
    scanf("%d%d", &n, &c);
    if (n == 0 && c == 0) break;

    for (i = 0; i < n; i++) {
      k = 0;
      for (j = 0; j < 16; j++) {
        scanf("%d", &b);
        k = (k << 1) | b;
      }

      as[i] = k;
    }

    for (i = 0; i < c; i++) {
      k = 0;
      for (j = 0; j < 16; j++) {
        scanf("%d", &b);
        k = (k << 1) | b;
      }

      bs[i] = k;
    }

    for (i = 0; i < n; i++)
      for (j = 0; j < NUM_L; j++)
        mscache[i][j] = -1;

    ms = max_score(0, 0);
    printf("%d\n", ms);

  }

  return 0;
}

Measured memory_bytes: 8280
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

bool isprime(int n) {
    if (n < 2) {
        return false;
    }
    if (n == 2) {
        return true;
    }
    if ((n & 1) == 0) {
        return false;
    }
    for (int i=3; i*i<=n; i+=2) {
        if (n % i == 0 && n != i) {
            return false;
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    unordered_map<int,int> checked;
    int m, ans = 0;
    for (int i=0; i<N; ++i) {
        cin >> m;
        if (isprime(m) && ! checked[m]) {
            ans ++;
            checked[m] = 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(--tmp);}

    int ans = 0;
    rep(i, n){
        if (a[a[i]] == i){
            ans++; 
        }
    }
    cout << ans/2 << endl;
}



Measured memory_bytes: 892
import math
serach_number = int(input())

def search_prime_number(target):
    square  = int(math.sqrt(target))
 
    for i in range(2,square ):
        if target % i == 0:
            return False
    return True

while True:
  if search_prime_number(serach_number):
    print(serach_number)
    break
  serach_number+=1

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

#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(i) begin(i), end(i)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll ans = a[n-1] - a[0];
    rep(i,1,n/2){
        ans += a[n - i] - a[i];
        ans += a[n-i-1] - a[i-1];
    }
    if(n & 1) ans += max(a[n/2] - a[n/2 - 1],a[n-n/2] - a[n/2]);
    cout << ans << endl;
}

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


class UNF {
    public:
        std::vector<int> p, rank;
        UNF(int s) {
            p.resize(s, 0);
            rank.resize(s, 0);
            for (int i = 0; i < s; i++) {
                makeset(i);
            }
        }
        void makeset(int x) {
            p[x] = x;
            rank[x] = 0;
        }
        int findset(int x) {
            if (x != p[x]) {
                p[x] = findset(p[x]);
            }
            return p[x];
        }
        
        void link(int x, int y) {
            if (rank[x] > rank[y]) {
                p[y] = x;
            }
            else {
                p[x] = y;
            }
            if (rank[y] == rank[x]) {
                rank[y]++;
            }
        }
        
        void unite(int x, int y) {
            link(findset(x), findset(y));
        }

};

int main() {
    int n, m, q;
    std::cin >> n >> m;
    UNF unf = UNF(n);
    for (int i = 0; i < n; i++) {
        unf.makeset(i);
    }
    int a, b;
    for (int j = 0; j < m; j++) {
        std::cin >> a >> b;
        unf.unite(a, b);
    }
    std::cin >> q;
    for (int p = 0; p < q; p++) {
        std::cin >> a >> b;
        if (unf.findset(a) == unf.findset(b)) {
            std::cout << "yes" << std::endl;
        }
        else {
            std::cout << "no" << std::endl;
        }
    }
}



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

int main() {
    int N; cin >> N;
    vector<ll> l(N);
    for (int i = 0; i < N; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    ll tmp = l[0];
    int ans = 0;
    int cnt = 1;
    int i = 1;
  /*for (int j = 0; j < N; j++){
    cout << l[j] << endl;
  }*/
    while (i < N) {
      //cout << cnt << endl;
        if (tmp == l[i]) {
            cnt++;
        }
        else {
            if (cnt % 2 == 1){
                ans++;
            }
            tmp = l[i];
            cnt = 1;
        }
        i++;
    }
  if (cnt % 2 == 1){
                ans++;
            }
            tmp = l[i];
            cnt = 1;
    cout << ans << endl;
}



Measured memory_bytes: 1024
N = int(input())
A = list(map(str,input()))
B = list(map(str,input()))
C = list(map(str,input()))
counter = 0

for i in range(N):
    if A[i] == B[i] and A[i] != C[i]:
        C[i] = A[i]
        counter += 1
    if A[i] == C[i] and A[i] != B[i]:
        B[i] = C[i]
        counter += 1
    if B[i] == C[i] and B[i] != A[i]:
        A[i] = B[i]
        counter += 1
    if A[i] != B[i] and B[i] != C[i]:
        B[i] = A[i]
        C[i] = A[i]
        counter += 2

print(counter)




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

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

    int cnt0 = 0;
    int cnt1 = 0;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0') {
            cnt0++;
        } else {
            cnt1++;
        }
    }

    cout << min(cnt0, cnt1) * 2 << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_end=(a);i>=i##_end;--i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define foe(i,a) for(__typeof(a.begin())i=a.begin();i!=a.end();++i)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef double ld;
typedef long long L;
typedef long double lf;
typedef unsigned int uint;
typedef unsigned long long uL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f,mo=1e9+7;
template<typename A,typename B>inline bool upmx(A&x,const B&y){return x<y?x=y,1:0;}
template<typename A,typename B>inline bool upmn(A&x,const B&y){return x>y?x=y,1:0;}
template<typename T>inline T gcd(T x,T y){for(;y;swap(x,y))x%=y;return x;}
inline int Pow(int a,int b,int p=mo){int r=1;for(;b;b>>=1,a=1ll*a*a%p)if(b&1)r=1ll*r*a%p;return r;}
#ifdef flukehn
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
const int N=3e5+11;
char s[N];
int n,f[N],g[N];
int F[N],G[N];
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	ios::sync_with_stdio(0);
	cin>>n>>s+1;
	rep(i,1,n){
		f[i]=f[i-1]+(s[i]=='W');
		g[i]=g[i-1]+(s[i]=='E');
	}
	per(i,1,n){
		F[i]=F[i+1]+(s[i]=='W');
		G[i]=G[i+1]+(s[i]=='E');
	}
	int ans=n;
	rep(i,1,n){
		upmn(ans,f[i-1]+G[i+1]);
	}
	cout<<ans;
}

Measured memory_bytes: 5248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = new int[N];
            var B = new int[N];
            for(int i = 0; i < N; i++)
            {
                int[] read = Console.ReadLine().Split().Select(int.Parse).ToArray();
                A[i] = read[0];
                B[i] = read[1];
            }
            Array.Sort(B, A);
            long sum = 0;
            for(int i = 0; i < N; i++)
            {
                sum += A[i];
                if (sum > B[i])
                {
                    Console.WriteLine("No");
                    return;
                }
                    
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 18136
#include <iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a==b)
        cout<<a*2;
    else
    {
        if(b>a)a=b;
        cout<<a*2-1;
    }
    return 0;
}


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

int main() {
	long long int N;
	cin >> N;
	for( size_t i = 0; i < N; i++ ) {
		string S;
		cin >> S;
		vector<long long int>X( S.length() );
		for( size_t j = 0; j < S.length(); j++ ) {
			X[j] = S[j] - '0';
		}
		long long int ans = 0;
		while( X.size() != 1 ) {
			ans++;
			auto ite = X.end();
			long long int memo = *--ite + *--ite;
			X.pop_back();
			X.pop_back();
			if( memo / 10 ) {
				X.emplace_back( memo / 10 );
			}
			X.emplace_back( memo % 10 );
		}
		cout << (ans % 2 ? "Fabre wins." : "Audrey wins.") << endl;
	}
}

Measured memory_bytes: 3096
/* fifty */
#include<stdio.h>
int main(void)
{
  char s[4];
  scanf("%s",s);
  if((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])||(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[2]))
   printf("Yes\n");
 else
   printf("No\n");
 return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<queue>
#include <utility>
#include <functional>
//#include<>
using namespace std;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
//#define int long long;
signed main(){
  int w, h;
  while(cin >> w >> h, w){
    int cnt{};
    vector<string> v(h);
    for(int i = 0; i < h; ++i){
      cin >> v[i];
    }
    //initialize
    pair<int, int> p;
    queue<pair<int, int>> q;	
    for(int i = 0; i < h; ++i){
      for(int j = 0; j < w; ++j){
	if(v[i][j] == '@'){
	  p = make_pair(i,j);
	  q.push(p);
	}
      }
    }
    while(!q.empty()){
      pair<int, int> p;
      p = q.front();
      q.pop();

      for(int k = 0; k < 4; ++k){
	int x = p.first + dx[k]; int y = p.second + dy[k];
	if(0 > x || h <= x || 0 > y || w <= y)continue;
	if('.' == v[x][y]){
	  v[x][y] = '@';
	  ++cnt;
	  q.push(make_pair(x, y));
	}
      }
    }
    cout << cnt+1 << endl;
  }
  return 0;
}




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

const int K = 18, N = 1<<K, M = 1e9+7;
int prod[K][N];
int a[N];

vector<pair<int, int>> vp[N];

void add(int x, int z, int mul) {
    assert(vp[x].empty() || vp[x].back().first <= z);
    if (vp[x].empty() || vp[x].back().first < z)      vp[x].push_back({z, mul});
    else {
        vp[x].back().second += mul;
        if (vp[x].back().second >= M) vp[x].back().second -= M;
    }
}

int rgt[N];

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

    int k;
    cin>>k;

    int L = 1<<(k-1);

    for (int i=L; i<2*L; i++) {
        prod[0][i] = i;
        for (int j=1; j<k; j++) {
            prod[j][i] = (1LL*prod[j-1][i]*(i>>j))%M;
        }
    }

    for (int i=L; i<2*L; i++) {
        int x;
        cin>>x;
        a[i] = x+L-1;
    }

     for (int k1=k-1; k1>=0; k1--) {
        for (int k2=k-1; k2>=0; k2--) {
            for (int i=L; i<2*L; i++) {
                int x = a[i];
                int pr = (1LL*prod[k1][i]*prod[k2][x])%M;
                int a1 = (i>>k1), a2 = (x>>k2);
                add(a2, a1, pr);
            }
        }
    }

    long long ans = 0;
    for (int i=1; i<=L; i++) {
        int ll = 2*i, rr = 2*i+1;

        for (auto pr: vp[rr])       rgt[pr.first] = pr.second;

        for (auto pr: vp[ll]) {
            int x = pr.first;
            if (x == 1) continue;
            unsigned long long con = (1LL*pr.second*rgt[x^1])%M;
            con = (con*i*(x>>1))%M;
            ans += con;
        }

        for (auto pr: vp[rr])       rgt[pr.first] = 0;
    }
    cout<<ans%M<<endl;
}


Measured memory_bytes: 270908
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

double TriM(double T, double a) {
	return T / a * 2.0;
}

int main(void) {
	int num, i;
	double a, b, T, ans;
	const double pi = 3.141592653589793;
	cin >> a >> b >> T;
	if (T > a * a * b / 2.0) {
		T = TriM(a * a * b - T, a);
		ans = atan2(T / a, a);
	}
	else {
		T = TriM(T, a);
		ans = atan2(b, T / b);
	}
	ans = ans * 180 / pi;
	printf("%.10lf\n", ans);
	return 0;
}

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

int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
 
int main() {
   int n,x;
   cin>>n>>x;
   vector<int> h(n+1);
   rep(i,n)cin>>h[i];
   h[n]=x;
   sort(h.begin(),h.end());
   vector<int> sa(n);
   rep(i,n)sa[i]=h[i+1]-h[i];
   if(n==1){
       cout<<sa[0]<<endl;
       return 0;
   }
   int ans=gcd(sa[0],sa[1]);
   for(int i=2;i<n;i++){
       ans=gcd(ans,sa[i]);
   }
   cout<<ans<<endl;

}

Measured memory_bytes: 1024
// C - H and V
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int h,w,k; cin>>h>>w>>k;
	vector<string> C(h);
	rep(i, h) cin>>C[i];
	int ans = 0;
	rep(hbit, 1<<h) rep(wbit, 1<<w){
		int c = 0;
		rep(i,h) rep(j,w)
			if(hbit>>i & 1 && wbit>>j & 1 && C[i][j] == '#') c++;
		if(c == k) ans++;
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i;
  cin >> N;
  int sum = N % 10;
  int d = 1;

  for (i = 0; i < 8; i++) {
    d *= 10;
    sum += N / d % 10;
  }
  
  if (N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define N 505
int a[N],b[N],f[N],i,j,m,n,o,p,x;
int main()
{
    scanf("%d%d",&n,&m);
    for(*a=n-1,i=1;i<n;i++)for(a[i]=a[i-1];n*n<=a[i]*a[i]+i*i;a[i]--);
    for(*b=(n<<=1)-1,i=1;i<n;i++)for(b[i]=b[i-1];n*n<b[i]*b[i]+i*i;b[i]--);
    for(j=0;j<=n>>1;x=j&1?(m+x-f[j])%m:(x+f[j])%m,j++)for(memset(f+1,0,j<<2),*f=1,o=n>>1,p=n;o||(n>>1)<p;)
    if(!o||(n>>1)<p&&b[p-1]<=a[o-1])for(p--,i=0;i<=(n>>1)-o&&i<=j;i++)f[i]=f[i]*(b[p]+2ll-n+p-i)%m;
    else for(i=(i=(n>>1)-o--)<j?i:j;i>=0;i--)f[i+1]=(f[i+1]+f[i]*(a[o]+1ll-n+p-i))%m,f[i]=f[i]*(b[o]+2ll-n+o-j+i)%m;
    return 0*printf("%d\n",x);
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, K;
int b[4001][4001], sum[4001][4001];

int f(int x, int y) {
    return sum[x + K - 1][y + K - 1] + sum[x - 1][y - 1]
                    - sum[x - 1][y + K - 1] - sum[x + K - 1][y - 1];
}

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

    cin >> N >> K;
    for(int i = 0; i < N; ++i) {
        int x, y; char c;
        cin >> x >> y >> c;
        if(c == 'W') y += K;
        ++b[x % (2 * K) + 1][y % (2 * K) + 1];
    }
    for(int i = 1; i <= 4 * K; ++i) {
        for(int j = 1; j <= 4 * K; ++j) {
            sum[i][j] = sum[i - 1][j] + b[(i - 1) % (2 * K) + 1][(j - 1) % (2 * K) + 1];
        }
    }
    for(int i = 1; i <= 4 * K; ++i) {
        for(int j = 1; j <= 4 * K; ++j) {
            sum[i][j] += sum[i][j - 1];
        }
    }
    int res = 0;
    for(int i = 1; i <= 2 * K; ++i) {
        for(int j = 1; j <= 2 * K; ++j) {
            chmax(res, f(i, j) + f(i + K, j + K));
        }
    }
    cout << res << endl;
    return 0;
}

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

#define int long long
#define vi vector <int>
#define endl "\n"
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
const int N=1e5+5 , MOD=1e9+7;

//---------------------------------------------------------------


void solve()
{
    int h;
    cin >> h;
    int x=1;
    int ans=0;
    while(x<=h)
    {
    	ans += x;
    	x *= 2;
    }
    cout << ans << endl;
}

signed main()
{
    speed;
    
 //    int t; cin >> t;
 //    rep(tt,1,t+1)
 //    {
	// cout <<"Case #"<<tt<<": ";
	solve();
 //    }
    return 0;
}

Measured memory_bytes: 256