akhauriyash/Code-Regression huggingface dataset:
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
#include <bits/stdc++.h>
using namespace std;
#define debug(...) cout<<__FUNCTION__<<":"<<__LINE__<<": ";debugger(#__VA_ARGS__, __VA_ARGS__);
template<typename arg>
void debugger(const char* varname, arg&& var) { cout<<varname<<" = "<<var<<endl; }
template<typename arg, typename... args>
void debugger(const char* varnames, arg&& var, args&&... vars) {
    const char* comma = strchr(varnames + 1, ',');
    cout.write(varnames, comma - varnames)<<" = "<<var<<" | ";
    int sz = 1; if(isspace(comma[sz])) sz++;
    debugger(comma + sz, vars...);
}
#define forr(i, s, n) for(ll i=(ll)(s); i<(ll)(n); ++i)
#define forn(i, n) forr(i, 0, n)
#define eb(n) emplace_back(n)
#define endl '\n'
#define fst first
#define snd second
using ll = long long;
using ii = pair<ll,ll>;
using vi = vector<ll>;
extern const int INF = INT_MAX - 5;
extern const ll LINF = LLONG_MAX - 5;
extern const int MOD = 1e9 + 7;
extern const int N = 2e5 + 200;

int main() {
    string s;
    cin>>s;
    deque<char> dq;
    for(auto i : s) {
        dq.push_back(i);
    }
    bool sp = false;
    int q;
    cin>>q;
    while(q--) {
        int t;
        cin>>t;
        if(t == 1) {
            sp = !sp;
        } else {
            int f;
            cin>>f;
            char c;
            cin>>c;
            if(!sp) {
                if(f == 1) {
                    dq.push_front(c);
                } else {
                    dq.push_back(c);
                }
            } else {
                if(f == 1) {
                    dq.push_back(c);
                } else {
                    dq.push_front(c);
                }
            }
        }
    }
    if(!sp) {
        for(int i = 0; i < (int) dq.size(); ++i) {
            cout<<dq[i];
        } cout<<endl;
    } else {
        for(int i = (int) dq.size() - 1; i >= 0; --i) {
            cout<<dq[i];
        } cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

int main(void){
    int w;
    int shift = 0;
    while(scanf("%d",&w) != EOF){
        while(w){
        if((w&0b1)<<shift){
        	printf("%d",(w&0b1)<<shift);
        	if(w>>1) printf(" ");//次があるとき
        }
        shift++;
        w >>= 1;
        }
        printf("\n");
        w = 0;
        shift = 0;
    }
    return 0;
}

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

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

long long gcd(long long x, long long y) {
    if (x < y)
        std::swap(x, y);
    while (y > 0) {
        long long r = x % y;
        x = y;
        y = r;
    }
    return x;
}

long long lcm(long long x, long long y) {
    return x * y / gcd(x, y);
}

inline void Main() {
  // code
  long long a,b,c,d;
  cin>>b>>a>>c>>d;

  long long x = a/c - (b-1)/c;
  long long y = a/d - (b-1)/d;
  long long z = a/lcm(c,d) - (b-1)/lcm(c,d);

  cout << a-b+1 - (x+y-z) << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin>>s;
    ll n=s.size();
    ll dp[200010][3];
    rep(i,n+1)rep(j,3) dp[i][j]=0;
    dp[0][1]=1,dp[0][2]=0;
    dp[1][2]=1;
    if(s[0]==s[1]) dp[1][1]=0;
    else dp[1][1]=2;
    rep2(i,2,n){
        if(s[i]!=s[i-1])dp[i][1]=max(dp[i][1],dp[i-1][1]+1);
        dp[i][1]=max(dp[i][1],dp[i-1][2]+1);
        dp[i][2]=max(dp[i][2],dp[i-2][1]+1);
        if(i>=3&&(s[i]!=s[i-2]||s[i-1]!=s[i-3]))dp[i][2]=max(dp[i][2],dp[i-2][2]+1);
    }
    cout<<max(dp[n-1][1],dp[n-1][2])<<endl;
    return 0;
}


Measured memory_bytes: 5268
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	set<char> s;
	int n;char e;cin >> n;
	rep(i, n) {
		cin >> e;
		s.insert(e);
	}
	if (s.size() == 4) cout << "Four" << endl;
	else cout << "Three" << endl;
}

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

#define sz(x) (int)(x).size()
typedef long long ll;
using namespace std;
const ll MOD=998244353;
const int mxN=2e5+5;
ll s[mxN<<2],lz[mxN<<2];
int n,q;
ll pt[mxN];
ll pref[mxN];

void build(int v,int tl,int tr) {
    if(tl==tr) {
        lz[v]=1;
        s[v]=pt[tl];
        return;
    }
    int mid=tl+(tr-tl)/2;
    build(v<<1,tl,mid);
    build(v<<1|1,mid+1,tr);
    s[v]=(s[v<<1]+s[v<<1|1])%MOD;
}

void push(int v,int tl,int tr) {
    if(lz[v]) {
        int mid=tl+(tr-tl)/2;
        ll fact=pref[tl];
        if(mid!=n-1)
            fact=(fact-pref[mid+1]+MOD)%MOD;
        s[v<<1]=(lz[v]*fact)%MOD;
        fact=pref[mid+1];
        if(tr!=n-1)
            fact=(fact-pref[tr+1]+MOD)%MOD;
        s[v<<1|1]=(lz[v]*fact)%MOD;
        lz[v<<1]=lz[v<<1|1]=lz[v];
        lz[v]=0;
    }
}

int qry(int v,int tl,int tr,int l,int r) {
    if(tl>r || tr<l)
        return 0;
    if(tl>=l && tr<=r)
        return s[v];
    push(v,tl,tr);
    int mid=tl+(tr-tl)/2;
    return (qry(v<<1,tl,mid,l,r)+qry(v<<1,mid+1,tr,l,r))%MOD;
}

void upd(int v,int tl,int tr,int l,int r,int val) {
    if(tl>r || tr<l)
        return;
    if(tl>=l && tr<=r) {
        lz[v]=val;
        ll fact=pref[tl];
        if(tr!=n-1)
            fact=(fact-pref[tr+1]+MOD)%MOD;
        s[v]=(lz[v]*fact)%MOD;
        return;
    }
    push(v,tl,tr);
    int mid=tl+(tr-tl)/2;
    upd(v<<1,tl,mid,l,r,val);
    upd(v<<1|1,mid+1,tr,l,r,val);
    s[v]=(s[v<<1]+s[v<<1|1])%MOD;
}

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

    cin >> n >> q;
    ll cur=1;
    for(int i=n-1; ~i; i--) {
        pt[i]=pref[i]=cur;
        cur=(cur*10)%MOD;
    }
    for(int i=n-2; ~i; i--)
        pref[i]=(pref[i]+pref[i+1])%MOD;
    build(1,0,n-1);
    while(q--) {
        int l,r,d;
        cin >> l >> r >> d;
        l--; r--;
        upd(1,0,n-1,l,r,d);
        cout << qry(1,0,n-1,0,n-1) << "\n";
    }

    return 0;
}


Measured memory_bytes: 14984
// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

LL bin(LL a, LL b, LL p) {
	LL res = 1;
	for (a%=p; b; b>>=1, a=a*a%p)
		if (b & 1)
			res = res * a % p;
	return res;
}


const double pi = 3.141592653;
int main(int argc, char const *argv[]) {
    // code
    int n, m, x;
    scanf("%d%d", &n, &m);
    for (int i=0; i<m; ++i) {
    	scanf("%d", &x);
    	n -= x;
    }
    if (n < 0)
    	puts("-1");
    else
    	printf("%d\n", n);
    return 0;
}

Measured memory_bytes: 3824
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;

int main(){
	string S, T;
	int n=0;
	cin >> S >> T;
	
	for(int i=0;i<S.length();i++){
			if(S[i]!=T[i])
				n+=1;
	}
	
	cout << n;
	return 0;
}


Measured memory_bytes: 3928
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

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

int main(void){
	int n, i;
	int a[100001];
	scanf("%d", &n);
	for(i=0; i<=n; i++){
		scanf("%d", a+i);
	}
	long ans=0;
	for(i=0; i<n; i++){
		int b;
		scanf("%d", &b);
		if(b<=a[i]){
			ans+=b;
		}else{
			ans+=a[i];
			b-=a[i];
			if(b<a[i+1]){
				a[i+1]-=b;
				ans+=b;
			}else{
				ans+=a[i+1];
				a[i+1]=0;
			}
		}
	}
	printf("%ld\n", ans);
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

int main(void)
{
	int n, w;
	cin >> n >> w;
	vector<P> vs(n);
	rep(i, n) {
		cin >> vs[i].first >> vs[i].second;
	}
	vector<vector<ll>> dp(2, vector<ll>(w + 1, 0));
	rep(i, n) {
		ll v = vs[i].first;
		ll we = vs[i].second;
		rep(j, w + 1) {
			ll p = j - we;
			dp[1][j] = dp[0][j];
			if (p >= 0) {
				dp[1][j] = max(dp[1][j], dp[0][p] + v);
			}
		}
		swap(dp[0], dp[1]);
	}
	ll m = 0;
	rep(j, w + 1) {
		m = max(m, dp[0][j]);
	}
	cout << m << endl;
	return 0;
}




Measured memory_bytes: 3300
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;
ll max_kouyaku(ll a, ll b) {
    if (a<b) {
        swap(a, b);
    }
    ll r = a%b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
ll min_koubai(ll a, ll b) {
    ll ab = max_kouyaku(a, b);
    return (a*b)/ab;
}

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll cd = min_koubai(c, d);
    ll a_waru = (a-1)/c;
    a_waru += (a-1)/d;
    a_waru -= (a-1)/cd;

    ll b_waru = b/c;
    b_waru += b/d;
    b_waru -= b/cd;

    ll ans = (b-a+1)-(b_waru-a_waru);
    OUT(ans);
    return 0;
}

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

int main(void){
  string s;
  getline(cin,s);
  for(int i = 0 ; i < s.size() ; i ++){
    if('a' <= s[i] && s[i] <= 'z')
      s[i] = s[i] - 'a' + 'A';
  }
  cout<<s<<endl;
}

Measured memory_bytes: 1172
a,b = map(int,input().split())
n = input()
if len(n) == a+b+1:
  if n[a] == '-':
    n = n.split('-')
    if len(n) == 2:
      if len(n[0]) == a and len(n[1]) == b:
        print('Yes')
      else:
        print('No')
    else:
        print('No')
  else:
        print('No')
else:
  print('No')

Measured memory_bytes: 38384
def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    grid = [[0] * W for _ in range(H)]
    for i in range(H):
        seq = 0
        start = 0
        for j in range(W):
            if S[i][j] == "#":
                for x in range(start, j):
                    grid[i][x] += seq
                seq = 0
                start = j+1
            else:
                seq += 1
        if seq:
            for x in range(start, W):
                grid[i][x] += seq
    for j in range(W):
        seq = 0
        start = 0
        for i in range(H):
            if S[i][j] == "#":
                for x in range(start, i):
                    grid[x][j] += seq
                seq = 0
                start = i+1
            else:
                seq += 1
        if seq:
            for x in range(start, H):
                grid[x][j] += seq
    ans = 1    
    for i in range(H):
        for j in range(W):
            if grid[i][j]:
                ans = max(grid[i][j] - 1, ans)
    print(ans)



if __name__ == "__main__":
    main()


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

int main(){
    int a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 1e9 + 7;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll mult(ll a, ll b) {
    return (a * b) % mod;
}


const int MAXN = 2e6 + 120;
const int MAXK = 20 + 3;

vector<int> g[MAXN];

int gcd(int x, int y) {
    return y ?  gcd(y, x % y) : x;
}

bool wss[MAXN];

const int MAXSQRT = 1000;

bool is_primes[MAXSQRT];


vector<int> primes;

void prec(){

    for (int i = 0; i < MAXSQRT; ++ i) is_primes[i] = true;

    is_primes[0] = is_primes[1] = false;

    for (int i =  2; i < MAXSQRT; ++i) {
        if (!is_primes[i]) continue;
        primes.push_back(i);

        for (int j =  2 * i; j < MAXSQRT; j += i) {
            is_primes[j] = false;
        }

    }

}

void solve() {

    prec();
    int n;
    cin >> n;


    vector<int> v;

    for (int i = 0; i < n; ++ i){
        int curr;
        cin >> curr;
        v.push_back(curr);
    }

    bool pair = true;

    for (int i = 0; i < n; ++ i) {

        int x = v[i];

        for (auto e : primes) {
            if (x % e == 0) {
                if (wss[e]) pair = false;
                wss[e] = true;


                while (x % e == 0) x /= e;
            }
        }

        if (x > 1) {

            if (wss[x]) {
                pair = false;
            }
            wss[x] = true;
        }
    }

    if (pair) {
        cout << "pairwise coprime\n";
        return;
    }

    int gcd_all = v[0];
    for (int i = 1; i < n; ++ i){
        gcd_all = gcd(gcd_all, v[i]);
    }

    if (gcd_all == 1) {
        cout << "setwise coprime\n";
        return;
    }

    cout << "not coprime\n";
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
//    freopen("../input.in", "r", stdin);
#else

#endif
#ifdef multi
//        gen();
    multisolve();
#else
    solve();
//    gen();
#endif

}


Measured memory_bytes: 55144
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		String s=sc.next();
		if (s.toLowerCase().equals(s)) {
			System.out.println("a");
		} else {
			System.out.println("A");
		}
	}

	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
        	ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


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

#define db(x) cerr << #x ": " << (x) << '\n';

#define int long long

using namespace std;

typedef long long ll;

typedef long double ld;

const int oo = 1e18;

vector<int> arr = {500,5,1};
vector<int> ct = {1000,5,0};

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;

    int sum = 0;

    for(int i = 0 ; i < 6 ; i++)
    {
        while(N >= arr[i])
        {
            N -= arr[i];
            sum += ct[i];
        }
    }

    cout << sum << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

public class Main{
static class Node implements Comparable<Node>{
	int id;
	long d;
	public Node(int id,long d) {
		this.id=id;
		this.d=d;
	}
	public int compareTo(Node c) {
		return Long.compare(this.d, c.d);
	}
}
//public static PrintWriter pw; 	
public static PrintWriter pw=new PrintWriter(System.out);
public static void solve() throws IOException{
//	pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));
	FastReader sc=new FastReader();
	int n=sc.I();
	long a[]=new long[n+1];
	long sum1[]=new long[n+1];
	long sum2[]=new long[n+1];
	for(int i=1;i<=n;i++)a[i]=sc.L();
	for(int i=1;i<=n;i++)sum1[i]=sum1[i-1]+a[i];
	for(int i=n;i>0;i--) if(i==n)sum2[i]=a[i]; else sum2[i]=sum2[i+1]+a[i];
	long mn=Long.MAX_VALUE;
	for(int i=1;i<n;i++)mn=Math.min(mn, Math.abs(sum1[i]-sum2[i+1]));
	pw.println(mn);
	pw.close(); 
	
	
}

public static void main(String[] args)  {
    new Thread(null ,new Runnable(){
      public void run(){
          try{
          
              solve();
          } catch(Exception e){
              e.printStackTrace();
          }
      }
  },"1",1<<26).start();
 
}

static long M=(long)Math.pow(10,9)+7;
 
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() throws FileNotFoundException{
            //br=new BufferedReader(new FileReader("C:\\Users\\shree\\Downloads\\B-small-practice.in"));	
        	 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 I(){   return Integer.parseInt(next()); }
        long L(){  return Long.parseLong(next()); }
        double D() {  return Double.parseDouble(next()); }
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
     }
}

Measured memory_bytes: 50408
use std::io;
use std::str::FromStr;
use std::cmp::max;

fn input_tuple() -> (i64, i64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (n, k) = input_tuple();
    let mut count = 0;
    if k == 0 {
        println!("{}", n * n);
        return;
    }
    for i in k+1..(n+1) {
        // println!("i = {}: {}", i, n / i * (i - k) + max(n % i as i64 + 1 - k, 0));
        count += n / i * (i - k) + max(n % i as i64 + 1 - k, 0);
    }
    println!("{}", count);
}


Measured memory_bytes: 2116
# 2043
# 2114 解法 X,Yについて素因数分解をする．お互いに共通の素因数の数＋１が答えになるのでは？
# 約数はどっちにしても素因数もしくはその倍数になる．互いに素な共役数で素因数と合成数の両方を持つことはできないので
# 共通な素因数をたし上がればいい
# 実装
def prime_fac(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

X, Y = map(int,input().split())
X_prime = set(prime_fac(X))
Y_prime = set(prime_fac(Y))
Common = X_prime & Y_prime
print(1+len(Common))



Measured memory_bytes: 9156
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
#define RB rbegin
#define RE rend
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const int Q = 47;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}


signed main()
{
    hello();
    
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string x;
    cin >> x;
    if (s == x)
        --a;
    else if (t == x)
        --b;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
using System;

class Solution
{
  public static void Main(string[] args)
  {
    var n = int.Parse(Console.ReadLine());
    var cards = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    Array.Sort(cards, (a, b) => b - a);
    var alice = 0;
    var bob = 0;
    for (var i = 0; i < n; i++)
    {
      if ((i + 1) % 2 == 1) alice += cards[i];
      else bob += cards[i];
    }
    Console.WriteLine($"{alice - bob}");
  }
}


Measured memory_bytes: 13268
#include <atcoder/all>
#include <iostream>

using namespace std;
using namespace atcoder;

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

  for(int i = 0; i < n; i++){
        long long N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
typedef long long ll;
const int N = 5e5+10;
ll or_tree[4*N];
ll a[4*N];
int n, q;
string s;

void build(int node, int begin, int end){
  if(begin == end) or_tree[node]=a[begin];
  else {
    build(2*node, begin, (begin+end)/2);
    build(2*node+1,(begin + end)/2 + 1, end);
    or_tree[node] = or_tree[2*node]|or_tree[2*node+1];
  }
}

ll get_or(int node, int begin, int end, int z, int y){
  if(begin >= z && end <= y) return or_tree[node];
  ll fz = (begin+end) /2;
  ll res = 0;
  if(z <= fz) res |= get_or(2*node, begin,fz,z,y);
  if(y > fz) res |= get_or(2*node+1, fz+1,end,z,y);
  return res;
}

void update(int node, int begin, int end, int x, int num){
  if(begin == end){
    or_tree[node] = num;
    return;
  }
  int fz = (begin+end)/2;
  if(x <= fz)update(node*2,begin,fz,x,num);
  else update(node*2+1,fz+1,end,x,num);
  or_tree[node] = or_tree[node*2]|or_tree[node*2+1];
}

int main(){
  cin >> n >> s >> q;
  for(int i = 1; i <= n; i ++){
	ll temp = (1 << ((s[i-1])-'a'));
    a[i] = temp;
  }
  build(1,1,n);
  while(q--){
    int op;
    cin >> op;
    //cout << op << " "<< u <<" " << v << endl;
    if(op == 1){
      int u;
      char v;
      cin >> u >> v;
      ll curr = (1 << (v - 'a'));
      update(1,1,n,u,curr);
    }
    if(op == 2){
      int u, v;
      cin >> u >> v;
      ll curr = get_or(1,1,n,u,v);
      int cnt = 0;
      while(curr){
        if(curr & 1) cnt ++;
        curr >>= 1;
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 17400
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = 9999999999999

for i in range(N-K+1):
    ans = min((abs(x[i])+abs(x[i]-x[i+K-1])),(abs(x[i+K-1])+abs(x[i]-x[i+K-1])),ans)
print(ans)

Measured memory_bytes: 14224
N = int(input())
B = list(map(int,input().split()))
C = [10**6]
for b in B:
    C.append(b)
B.append(10**6)
sm = 0
# print(B)
# print(C)
for n in range(N):
    sm+=min(B[n],C[n])
print(sm)


Measured memory_bytes: 38256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string S;

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

  cin >> S;
  int N = S.size();
  ll ret = 0ll;
  bool plus1 = false;
  for (int i=N-1; i>=0; i--) {
    ll n = S[i] - '0';
    n = plus1?n+1:n;
    if (n>5) {
      plus1 = true;
      ret+=10-n;
    } else if (n==5){
      if (i>0& S[i-1]-'0' >= 5) {
        plus1 = true;
        ret+=5ll;
      } else {
        plus1 = false;
        ret+=5ll;
      }
    } else {
        plus1 = false;
        ret+=n;
    }
  }
  cout << ret + plus1<< "\n";
  return 0;
}

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

int N,Y;

const int MAX_N = 2000;
const int MAX_Y = 2 * 100000;

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

  for (int i=0;i<(Y/10000+1);i++) {
    for (int j=0;j<(Y/5000+1);j++) {
      int k = N - i - j;
      if (k < 0)
        continue;
      int total = i*10000 + j*5000 + k*1000;
      if (total==Y) {
        cout << i << " " << j << " " << k << "\n";
        return 0;
      } else {
#if 0
        cout << "i=" << i
             << ",j=" << j
             << ",k=" << k
             << ",total=" << total << "\n";
#endif
      }
    }
  }
  cout << "-1 -1 -1\n";

#if 0
  cout << N << " " << Y << "\n";
#endif
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; scanf("%d", &n);
  double a[1000000];
  for(int i = 0; i < n; i++) scanf("%lf", &a[i]);
  sort(a, a+n);
  int maxn=a[n-1];
  printf("%d ", maxn);
  double mid = a[n-1]/2;
  double sa=abs(a[0]-mid);
  int ans=0;
  for(int i = 1; i < n-1; i++){
    if(abs(a[i]-mid) < sa){
      ans=i;
      sa = abs(a[i]-mid);
    }
  }
  printf("%.0f\n", a[ans]);
}

Measured memory_bytes: 2944
n = int(input())
h = list(map(int, input().split()))[::-1]

for i in range(n - 1):
    if h[i] < h[i + 1]:
        h[i + 1] -= 1
        if h[i] < h[i + 1]:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 14224
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

int n;
Vl va;

void init()
{
	cin >> n;
	va.resize(n + 1);
	REP(i, n + 1) cin >> va[i];
}


int main()
{
	init();

	ll ans = 0;
	REP(i, n)
	{
		ll b; cin >> b;
		
		ans += min(va[i], b);
		b -= min(va[i], b);

		ans += min(va[i + 1], b);
		va[i + 1] = max( va[i + 1] - b, (ll)0);
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

typedef long long ll;

ll A,B;

int main(){
	cin>>A>>B;
	if (A==B){
		cout<<1<<endl;
	}else{
		int n=0;
		{
			ll a=B;
			while(a>0){
				n++;
				a>>=1;
			}
		}
		int r=0;
		REP(i,n){
			if ((A&(1ll<<(n-i-1)))!=(B&(1ll<<(n-i-1)))){
				r=n-i-1;
				break;
			}
		}
		A&=((1ll<<(r+1))-1);
		B&=((1ll<<(r+1))-1);
		ll ans=(1ll<<r)-A;
		int k=-1;
		REP(i,r){
			if ((B&(1ll<<(r-i-1)))){
				k=r-i-1;
				break;
			}
		}
		ans+=(1ll<<(k+1));
		ans+=(1ll<<r)-A;
		ans-=max((1ll<<(k+1))-A,0ll);
		cout<<ans<<endl;
	}
	return 0;
}

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

ll N, A[10010];
ll min() {
  return *min_element(A, A+N);
}
ll max() {
  return *max_element(A, A+N);
}
ll sum() {
  return accumulate(A, A+N, 0LL);
}
int main() {
  cin >> N;
  for (int i=0; i<N; ++i)
    cin >> A[i];
  cout << min() << ' ' << max() << ' ' << sum() << endl;
}



Measured memory_bytes: 3168
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    a = LI()
    q = I()
    b = [0]*q
    c = [0]*q
    for i in range(q):
        b[i], c[i] = MI()
    a_num = [0]*100001
    for ai in a:
        a_num[ai] += 1
    a_sum = sum(a)
    for i in range(q):
        a_sum += (c[i]-b[i])*a_num[b[i]]
        a_num[c[i]] += a_num[b[i]]
        a_num[b[i]] = 0
        print(a_sum)

if __name__ == '__main__':
    main()

Measured memory_bytes: 22068
#include <iostream>

using namespace std;

int main()
{
    int A , B , C , D ;
    cin >> A >> B >> C >> D ;
    if((A + B)>(C + D))
    {
      cout << "Left" << endl;
    }else if((A + B)<(C + D))
    {
      cout << "Right" << endl;
    }else
    {
      cout << "Balanced" << endl;
    }

    return 0;
}


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

int x[100010], nx[100010][20];

int main() {
	int N, L, Q;
	cin >> N;
	for(int i=1; i<=N; ++i) cin >> x[i];
	cin >> L;
	int now=1;
	for(int i=1; i<=N; ++i){
		while(now<N){
			if(x[now+1]-x[i]<=L){
				++now;
			}
			else break;
		}
		nx[i][0]=now;
	}
	nx[N][0]=nx[N+1][0]=N+1;
	int mx=0;
	while(nx[1][mx]<N){
		for(int j=1; j<=N+1; ++j){
			nx[j][mx+1]=nx[nx[j][mx]][mx];
		}
		++mx;
	}
	cin >> Q;
	for(int q=0; q<Q; ++q){
		int a, b;
		cin >> a >> b;
		if(a>b) swap(a, b);
		int ans=0, tak=a;
		for(int i=mx; i>=0; --i){
			if(nx[tak][i]<b){
				ans |= (1<<i);
				tak=nx[tak][i];
			}
		}
		cout << ans+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 9088
#include<stdio.h>
int main(void) {
	int n;
	int	ans = 0;
	int a = 10;
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++)
	{
		if (i<a)
		{
			ans++;
		}
		if (i == a * 10)
		{
			ans++;
			a *= 100;
		}
		

	}
	printf("%d", ans);
	return 0;
}


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

#define ll long long

using namespace std;


int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n, p;
    scanf("%d %d", &n, &p);
    vector<vector<ll>> c(n + 1, vector<ll>(n + 1));
    for (int i = 0; i <= n; ++i) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < i; ++j) {
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
        }
    }
    int a = 0, b = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        if (x % 2 == 0)
            ++a;
        else
            ++b;
    }
    ll ans = 0;
    int start = p;
    for (int i = 0; i <= a; ++i) {
        for (int j = start; j <= b; j += 2) {
            ans += c[a][i] * c[b][j]; 
        }
    }
    printf("%lld", ans);

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

const int INF = 1e9;
const int N_MAX = 20;

struct P{int dat,i;};
bool operator<(const P &a, const P &b){return a.dat<b.dat;}
ostream &operator<<(ostream &os, const P &a){
    return os<<"("<<a.dat<<","<<a.i<<")";
}

int N;
P xx[N_MAX],yy[N_MAX];
int x[N_MAX],y[N_MAX],p[N_MAX];
ll ans[N_MAX];
int X=0,Y=0;
int sx[N_MAX],sy[N_MAX],vx[N_MAX],vy[N_MAX];
int Min[N_MAX];

void dfs(int idx=0)
{
    if (idx==N){
        int pcnt = X+Y;

        vx[0]=-INF; vx[1]=INF; vx[2]=0;
        rep(i,X) vx[i+3]=sx[i];
        vy[0]=-INF; vy[1]=INF; vy[2]=0;
        rep(i,Y) vy[i+3]=sy[i];
        sort(vx,vx+(X+3));
        sort(vy,vy+(Y+3));

        ll sum=0;
        int j=0;
        rep(i,N){
            while(vx[j]<=xx[i].dat) j++;
            Min[xx[i].i] = min(vx[j]-xx[i].dat,xx[i].dat-vx[j-1]);
        }
        j=0;
        rep(i,N){
            while(vy[j]<=yy[i].dat) j++;
            sum += (ll)min(Min[yy[i].i], min(vy[j]-yy[i].dat,yy[i].dat-vy[j-1])) * p[yy[i].i];
        }
        chmin(ans[pcnt],sum);
        return;
    }
    sx[X++]=x[idx]; dfs(idx+1); X--;
    sy[Y++]=y[idx]; dfs(idx+1); Y--;
    dfs(idx+1);
}

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N;
    rep(i,N){
        cin>>x[i]>>y[i]>>p[i];
        xx[i] = {x[i],i};
        yy[i] = {y[i],i};
    }
    sort(xx, xx+N);
    sort(yy, yy+N);
    rep(i,N+1) ans[i] = (ll)1e18;
    dfs();
    rep(i,N+1) cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#define f(x) (x)%2?3*(x)+1:(x)/2
int main(void)
{
  long long cnt=0,a[1000000]={},ans=0;
  int judge=1;
  scanf("%lld",&a[ans]);
  while(judge){
    ans++;
    a[ans]=f(a[ans-1]);
    for(int i=0;i<ans;i++){
      if(a[ans]==a[i]){
        judge=0;
        break;
      }
    }
  }
  printf("%lld",ans+1);
  return 0;
}


Measured memory_bytes: 7936
import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val N = sc.nextInt()

    data class abc(val a:Long, val b:Long, val c:Long) {
        fun max() = Math.max(Math.max(a,b),c)
    }

    val DP = Array(N){abc(0L,0L,0L)}//abcを選んだ時の最大幸福度
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    DP[0] = abc(a,b,c)
    for (i in 1 until N) {
        val a = sc.nextLong() + Math.max(DP[i-1].b, DP[i-1].c)
        val b = sc.nextLong() + Math.max(DP[i-1].c, DP[i-1].a)
        val c = sc.nextLong() + Math.max(DP[i-1].a, DP[i-1].b)

        DP[i] = abc(a,b,c)
    }
    //for ((n,h) in DP) print("$n ")
    println(DP[N-1].max())
}

Measured memory_bytes: 118884
class proc:
    def __init__(self, id, val):
        self.id=id
        self.val=int(val)

class queue:

    def __init__(self, n, datas):
        self.max=n*2
        self.head=0
        self.tail=0
        #print("n="+str(n))

        self.q=[None for _ in range(self.max)]
        for d in datas:
            p=proc(d[0],int(d[1]))
            self.enque(p)
            #print(self.tail)

        #print(self.tail)



    def enque(self,p):
        self.q[self.tail]=p
        self.tail=(self.tail+1)%self.max

    def deque(self):
        x=self.q[self.head]
        self.head=(self.head+1)%self.max
        return x

n, sec =map(int, input().split())
datas=[]
for i in range(n):
    datas.append(input().split())

q=queue(n,datas)
total=0
while(q.head !=q.tail):
    top=q.deque()
    usage=min(top.val, sec)
    total=total+usage
    top.val=top.val-usage
    if(top.val > 0):
        q.enque(top)
    else:
        print(top.id+" "+str(total))








Measured memory_bytes: 26116
#include <cstdio>
#include <algorithm>
using namespace std;
int shop[100001];
int main(){
	int n,m,d,k,i,s;
	for(;scanf("%d",&d),d;){
		scanf("%d%d",&n,&m);
		for(i=2;i<=n;i++){
			scanf("%d",&k);
			shop[i-1] = k;
		}
		shop[n] = d;
		sort( shop+1, shop+n );
		s=0;
		for(;m--;){
			scanf("%d",&k);
			int* it = lower_bound( shop, shop+n+1, k );
			s+=min(*it - k, k - it[-1] );
		}
		printf("%d\n",s);
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  string s;
  cin >> s;
  if(s=="AAA" || s=="BBB"){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll inf=1000000007;
const ll maxinput=200005;
const ll mod=998244353;
#define mp make_pair
ll n,h[maxinput],a[maxinput],dp[maxinput]; //dp[i] is the max value obtained till index i
vector <pair <ll,ll>> vec;
unordered_map <ll,ll> mapper; //maps height in range 0 to n-1 aka cordinate compression
ll BIT[maxinput];
ll query(ll idx)
{
    ll ret=0;
    ll x=idx;
    for( ;x>0;x-= x&-x)
        ret=max(ret,BIT[x]);
    return(ret);
}
void update(ll idx,ll val,ll i)
{
    ll x=idx;
    ll temp=query(idx-1)+val;
    dp[i]=temp;
    for(;x<=n;x+= x&-x)
        BIT[x]=max(temp,BIT[x]);
}
int main()
{
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>h[i];
        vec.push_back(mp(h[i],i));
    }
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    sort(vec.begin(),vec.end());
    for(ll i=0;i<n;i++)
        mapper[vec[i].first]=i+1;

    memset(BIT,0,sizeof(BIT));
    for(ll i=1;i<=n;i++)
        update(mapper[h[i]],a[i],i);
    
    ll ans=0;
    for(ll i=1;i<=n;i++)
        ans=max(ans,dp[i]);

    cout<<ans<<endl;
}

Measured memory_bytes: 18796
n,a,b=gets.split.map(&:to_i)
puts gets.chomp.chars.map{|c|
	if c=='c'
		:No
	elsif c=='b'
		if b>0
			b-=1
			:Yes
		else
			:No
		end
	else
		if a>0
			a-=1
			:Yes
		elsif b>0
			b-=1
			:Yes
		else
			:No
		end
	end
}

Measured memory_bytes: 10620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;
const LL mod = 1e9 + 7;

int main()
{
	char S[3][15];
	while(~scanf("%s%s%s",S,S + 1,S + 2)){
		for(int i = 0;i < 3;i++) printf("%c",S[i][0] - 'a' + 'A');
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n;cin>>n;
    ll x[n],y[n];for(ll i=0;i<n;i++)cin>>x[i]>>y[i];
    map< pair<ll,ll> , ll > mp;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++){
            if(i==j)continue;
            ll p=x[i]-x[j];
            ll q=y[i]-y[j];
            mp[{p,q}]++;
        }
    }
    ll mx=0;
    for(auto &ele:mp)mx=max(mx,ele.second);
    cout<<n-mx;
}





Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String s;
	static String g;
	static int a[]=new int[4];
	public static void main(String[] args) {
		String N=sc.next();
		for(int i=0;i<4;i++) {
			a[i]=N.charAt(i)-48;
		}
		if(dfs(1,a[0],"")) {
		p(a[0]+""+g.charAt(0)+""+a[1]+""+g.charAt(1)+""+a[2]+""+g.charAt(2)+""+a[3]+"=7");
		}
	}
	static boolean dfs(int b,int sum,String v) {
		g=v;
		if(b==4)return sum==7;
		if(dfs(b+1,sum+a[b],v+"+"))return true;
		if(dfs(b+1,sum-a[b],v+"-"))return true;
		return false;
	}
	

	
	
	
}


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

using namespace std;

bool is_prime[(1 << 21) + 10];
vector<int> prime;

void sieve(int n) {
  fill(is_prime, is_prime + n, true);
  for (int i = 2; i <= n; i++) {
    if (!is_prime[i]) continue;
    prime.push_back(i);
    for (int j = 2 * i; j <= n; j += i) {
      is_prime[j] = false;
    }
  }
}

int main(void) {
  sieve(1 << 21);
  
  int n;
  while (cin >> n, n) {
    auto p = upper_bound(prime.begin(), prime.end(), n);
    cout << (is_prime[n] ? 0 : *p - *(p - 1)) << endl;
  }

  return 0;
}


Measured memory_bytes: 5680
#include <cstdio>
#include <numeric>
#include <cmath>
#include <assert.h>
#include <deque>
#include <iostream>
#include <queue>
#include <string.h>
#include <set>
#include <algorithm>
#include <map>
#include <vector>
#include <bitset>
#include <array>
#define loop(i, n) for (int i = 0; i < n; i++)
#define testcase int _t; cin >> _t; while (_t--)
#define all(x) (x).begin(), (x).end()
using i64 = long long;
using namespace std;
 
void yes(bool y) {
  cout << (y ? "YES\n" : "NO\n");
}
 
template<typename T>
ostream& operator<<(ostream& os, vector<T> const &v) {
  for (T x: v) {
    os << x << ' ';
  }
  cout << '\n';
  return os;
}
 
template<typename T>
istream& operator>>(istream& is, vector<T> &v) {
  for (T &x: v) {
    is >> x;
  }
  return is;
}

const int maxn = 1e5;

vector<int> adj[maxn];
const int mod = 1e9 + 7;
const int white = 0;
const int black = 1;
bitset<int(1e5)> vis;
vector<int> adj2[maxn];
int dp[maxn][2];

void reroot(int x, int p) {
  if (p != -1) adj2[p].push_back(x);
  vis[x] = 1;
  for (int y : adj[x]) if (!vis[y]) {
    reroot(y, x);
  }
}

int dfs(int x, int pc) {
  if (dp[x][pc] != -1) return dp[x][pc];
  int b_ways = pc == black ? 0 : 1;
  int w_ways = 1;
  for (int y : adj2[x]) {
    if (pc == white) {
      b_ways = (i64) b_ways * dfs(y, black) % mod;
      w_ways = (i64) w_ways * dfs(y, white) % mod;
    } else {
      w_ways = (i64) w_ways * dfs(y, white) % mod;
    }
  }

  return dp[x][pc] = (b_ways + w_ways) % mod;
}


int main() {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0, u, v; i < n - 1; i++) {
    cin >> u >> v;
    --u; --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  reroot(0, -1);
  memset(dp, -1, sizeof dp);
  cout << dfs(0, white) <<  '\n';
  
}

Measured memory_bytes: 18944
// AtCoder
// ABC 179 A - Plural Form

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <random>
#include <vector>
#include <chrono>

using namespace std;

int main()
{
	string S;
	size_t l;

	cin >> S;
	l = S.size();
	
	// 計算
	if (S[l-1] != 's') {
		cout << S << 's' << endl;
	} else {
		cout << S << "es" << endl;
	}
}



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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  rep(i,N) cin >> x[i];

  x.push_back(X);
  sort(x.begin(), x.end());

  vector<int> diff(N);
  for (int i = 1; i < N+1; i++) {
    diff[i-1] = x[i] - x[i-1];
  }
  int ans = diff[0];
  for (int i = 1; i < N; i++) {
    ans = GCD(ans, diff[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
int main(){
    int a[1000],n,m,sum=0;
    cin>>n>>m;
    for (int i = 0; i <n ; ++i) {
        cin>>a[i];
    } sort(a, a+n);
    for (int i = 0; i <m ; ++i) {
        sum+=a[i];
    }cout<<sum;
}

Measured memory_bytes: 3612
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
#define MAX 100005
#define NIL -1

vector<int> V[MAX];
int color[MAX];


void search(int v, int c) {
	if (color[v] != NIL)return;
	color[v] = c;
	for (int i = 0; i < V[v].size(); i++) {
		search(V[v][i], c);
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	V->reserve(n);
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		V[s].push_back(t);
		V[t].push_back(s);
	}

	int id = 1;
	for (int i = 0; i < n; i++)color[i] = NIL;
	for (int u = 0; u < n; u++) {
		if (color[u] == NIL)search(u, id++);
	}

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int s, t;
		cin >> s >> t;
		if (color[s] == color[t])cout << "yes\n";
		else cout << "no\n";
	}

	return 0;
}


Measured memory_bytes: 11936