akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
using namespace std;



class SizeUnionFind{
public:
	vector<int> _size;
	SizeUnionFind(){}
	SizeUnionFind(int n){
		this->_size = vector<int>(n,-1);
	}
	int root(int x){
		if (this->_size[x] < 0) return x;
		this->_size[x] = root(this->_size[x]);
		return this->_size[x];
	}
	int unite(int x, int y){
		int rx = this->root(x);
		int ry = this->root(y);
		if (rx == ry) return true;
		this->_size[ry] += this->_size[rx];
		this->_size[rx] = ry;
		return false;
	}
	int same(int x, int y){
		int rx = this->root(x);
		int ry = this->root(y);
		return rx == ry;
	}
	int size(int x){
		return -this->_size[this->root(x)];
	}
};


int main(){
	int n,m,k; cin >> n >> m >> k;
	vector<set<int>> relation(n+1);
	SizeUnionFind suf(n+1);
	for (int i=0;i<m;i++){
		int a,b; cin >> a >> b;
		relation[a].insert(b);
		relation[b].insert(a);
		suf.unite(a,b);
	}
	for (int i=0;i<k;i++){
		int a,b; cin >> a >> b;
		relation[a].insert(b);
		relation[b].insert(a);
	}
	for (int i=1;i<n+1;i++){
		int ans = suf.size(i) - 1;
		for (auto itr = relation[i].begin(); itr != relation[i].end(); ++itr){
			if (suf.same(*itr,i)) ans--;
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 25472
import collections
cc = collections.Counter([raw_input()[0] for _ in range(int(raw_input()))])


def dfs(i, total ,cumul, cc, k, s):
	if i == len(s) or k == 0:
		if k == 0: total[0] += cumul
		return 
	
	dfs(i+1, total, cumul * cc[s[i]], cc,k - 1, s)
	dfs(i+1, total, cumul, cc, k, s)

total = [0]
dfs(0, total, 1 , cc, 3, 'MARCH')
print total[0]

Measured memory_bytes: 82792
#include<bits/stdc++.h>
using namespace std;
#define LL long long 
#define ULL unsigned long long 

const int N = 2e3+11;
const int M = 1e6+11;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const LL inff = 0x3f3f3f3f3f3f3f3f;


/*-----------------------------------------*/

int t[N],x[N];
map<int,int>mp;
int main(){
	mp.clear();
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&t[i]);
	}
	int m; scanf("%d",&m);
	for(int i=1;i<=m;i++){
		int a,b; scanf("%d%d",&a,&b);
		x[i]=a;  mp[i]=b; 
	}
	
	//for(int i=1;i<=m;i++) printf("%d  %d\n",x[i],mp[x[i]]);
	for(int i=1;i<=m;i++){
		int ans=0;
		for(int j=1;j<=n;j++){
			if(x[i]==j) ans+=mp[i];
			else ans+=t[j];
		}
		printf("%d\n",ans);
	}
	
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	string s;
	cin >> s;

	s[3] = '8';
	cout << s << endl;
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;


class UnionFind {
    private:
        vi par;
        vi siz;

    public:
        UnionFind(int sz_) : par(sz_), siz(sz_, 1) { // すべて根とする
            rep(i, 0, sz_) par[i] = i;
        }

        void init(int sz_) { // 初期化
            par.resize(sz_);
            siz.resize(sz_, 1);
            rep(i, 0, sz_) par[i] = i;
        }

        int root(int x) { // 根を求める
            if(par[x] == x) return x;
            return par[x] = root(par[x]);
        }

        void unite(int x, int y) {
            int rx, ry;
            rx = root(x);
            ry = root(y);
            if(rx == ry) return;
            if(siz[rx] < siz[ry]) swap(rx, ry);
            siz[rx] += siz[ry];
            par[ry] = rx;
        }

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

        int size(int x) {
            return siz[root(x)];
        }
};  

int N, K, L;

signed main() {

    cin >> N >> K >> L;
    UnionFind tree1(N);
    UnionFind tree2(N);

    rep(i, 0, K) {
        int p, q;
        cin >> p >> q;
        tree1.unite(p-1, q-1);
    }
    rep(i, 0, L) {
        int r, s;
        cin >> r >> s;
        tree2.unite(r-1, s-1);
    }

    map<P, int> m;
    vi a(N), b(N);
    rep(i, 0, N) {
        a[i] = tree1.root(i);
        b[i] = tree2.root(i);
        P p = make_pair(a[i], b[i]);
        auto itr = m.find(p);
        if(itr != m.end()) {
            int nn = itr->second;
            nn++;
            itr->second = nn;

        }else{
            m[p] = 1;
        }
    
    }
    rep(i, 0, N) {
        P p = make_pair(a[i], b[i]);
        cout << m[p] << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 21120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=202;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++)
      {
            cin>>a[i];
      }
      int ans=0;
      for(int i=1;i<n-1;i++)
      {
            vector<int> v={a[i],a[i-1],a[i+1]};
            sort(all(v));
            if(a[i]==v[1]) ans++;
      }
      cout<<ans;
}  
// I never lose. I either win or I learn

Measured memory_bytes: 256
X = int(input())
DP = [0]*100001
DP[100] = 1
DP[101] = 1
DP[102] = 1
DP[103] = 1
DP[104] = 1
DP[105] = 1

for i in range(106, 100001):
    if any([DP[i-100], DP[i-101], DP[i-102], DP[i-103], DP[i-104], DP[i-105]]):
        DP[i] = 1
print(DP[X])

Measured memory_bytes: 40560
# D

s = input().strip()

n = len(s)

a = [0] * n

for i in range(n):
    if s[i] == 'R' and s[i+1] == 'L':
        x = 0
        for j in range(i, -1, -1):
            if s[j] == 'L' :
                break
            x += 1
        a[i] += (x+1) // 2
        a[i+1] += x // 2
        
        x = 0
        for j in range(i+1, n):
            if s[j] == 'R' :
                break
            x += 1
        a[i] += (x) // 2
        a[i+1] += (x+1) // 2
        
for i in range(n):
    print(a[i], end=' ')
    

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll gcd(ll a, ll b){
  while(b!=0){
    ll r=a%b;
    a=b;
    b=r;
  }
  return a;
}
ll lcm(ll a, ll b){
  return (a/gcd(a,b)*b);
}
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  a--;
  ll e=lcm(c,d);
  ll v=b/c-a/c;
  ll f=b/d-a/d;
  ll r=b/e-a/e;
  cout<<b-a-(v+f-r)<<endl;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0, pre = 0;
    rep(i, n) {
        ans += max(0LL, pre-a[i]);
        pre = max(0LL, pre-a[i])+a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,d;cin >> h >> w >> d;
    vector<P> v(h*w);
    rep(i,h) rep(j,w){
        int a;cin >> a;
        --a;
        v[a] = {i,j};
    }

    auto f =[&](int a,int b){
        return abs(v[a].first - v[b].first) + abs(v[a].second - v[b].second);
    };

    vector<vl> table(d, vl(dup(h*w,d)+1,0)); 
    for(int i=0;i<d;++i){
        for(int j=1;i+j*d<h*w;++j){
            table[i][j] = table[i][j-1] + f(i+(j-1)*d,i+j*d);
            //cerr << "i=" << i << ":j=" << j << " ";
            //call(table[i][j]);
        }
    }

    int q;cin >> q;
    while(q--){
        int x,y;cin >> x >> y;
        --x;--y;
        //cerr << "ans is ";
        printf("%lld\n", table[x%d][y/d] - table[x%d][x/d]);
        //cout << table[x%d][y] - table[x%d][x] << endl;
        //cerr << table[x%d][y/d]  << " " <<  table[x%d][x/d] << "\n";
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)

ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
ll field[401][401];
bool used[401][401];
ll H,W;
ll tmp1=0,tmp2=0; //# .
ll ans=0;

void dfs(ll x,ll y,bool c){
    used[x][y]=true;

    if(c){
        if(field[x][y]=='.') tmp2++;
        else tmp1++;
    }

    rep(i,4){
        ll nx=x+dx[i],ny=y+dy[i];
        if(1ll<=nx && nx<=H && 1ll<=ny && ny<=W && !used[nx][ny] && field[nx][ny]!=field[x][y]){
            if(field[nx][ny]=='.') tmp2++;
            else tmp1++;

            dfs(nx,ny,false);
        }      
    }

    if(c){
        ans+=tmp1*tmp2;
        tmp1=tmp2=0;
    }
    //cout<<"x:"<<x<<" y:"<<y<<" ans:"<<ans<<endl;
}

int main(){
	//input
	cin>>H>>W;
    rep1(i,H){
        string tmp; cin>>tmp;
        rep(j,W) field[i][j+1]=tmp[j];
    }
    rep1(i,H)rep1(j,W) used[i][j]=false;

	//solve
	rep1(i,H){
        rep1(j,W){
            if(!used[i][j]){
                dfs(i,j,true);
            }
        }
    }

	//output
	cout<<ans;
}

Measured memory_bytes: 9216
N = int(input())
A = list(map(int, input().split()))

def kabu(N, A_list, money):
    for i in range(0, N-1):
        kounyuu = money // A_list[i]
        if A_list[i+1] > A_list[i]:
            money += (A_list[i+1]-A_list[i]) * kounyuu
    return money
        
print(kabu(N, A, 1000))

Measured memory_bytes: 61916
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, k, i, j, ans;

    cin >> n >> m >> k;

    for(i = 0; i <= n; ++i)
    {
        for(j = 0; j <= m; ++j)
        {
            ans = i * m + j * n - i * j * 2;
            if(ans == k)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";

return 0;
}


Measured memory_bytes: 256
// g++ -std=gnu++1y -O2 main.cpp

#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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 (b<a) { a=b; return 1; } return 0; }

int main() {
	long long X;
	cin >> X;

	long long c500 = X / 500;
	long long p = X % 500;
	long long c5 = p / 5;

	cout << (c500 * 1000 + c5 * 5) << endl;
	return 0;
}

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

int main(){
    int num[5],order[5] = {0,1,2,3,4};
    for(int i = 0;i < 5;i++){
        cin >> num[i];
    }
    int ans = 100000,time = 0;
    do{
        time = num[order[0]];
        for(int i = 1;i < 5;i++){
            while(time % 10 != 0){time++;}
            time += num[order[i]];
        }
        ans = min(ans,time);
    }
    while(next_permutation(order,order + 5));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;



int main() {
  io();
  
  vi arr;
  fori(i, 3) {
    int a; 
    cin >> a;
    arr.pb(a);
  }
  qsort(arr);
  cout << arr[0] + arr[1];
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

struct factorial
{
    vector<ll> fac, finv, inv;

    factorial(int n) : fac(2, 1), finv(2, 1), inv(2, 1)
    {
        int i;

        rep(i, 2, n + 1)
        {
            fac.push_back(fac[i - 1] * i % MOD);
            inv.push_back(MOD - inv[MOD % i] * (MOD / i) % MOD);
            finv.push_back(finv[i - 1] * inv[i] % MOD);
        }
    }

    ll comb(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    ll perm(int n, int k)
    {
        if (n < k)
        {
            return 0;
        }

        if (n < 0 || k < 0)
        {
            return 0;
        }

        return fac[n] * finv[n - k] % MOD;
    }
};

int main(void)
{
    ll s;
    cin >> s;

    factorial f(s);

    ll ans = 0;

    for (int i = 1; i <= s / 3; i++)
    {
        ll m = s - i * 3;

        ans += f.comb(m + i - 1, m);
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] N = new int[10];
	public static void main(String[] args) {
		for (int i = 0; i < 4; i++) {
			N[sc.nextInt()] = 1;
		}
		if (N[1] == 1 && N[7] == 1  && N[4] == 1  && N[9] == 1 ) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 22608
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
const long long INF=4000000000000000000LL;
typedef pair<long long,int> P;
int main(){
	long long ans=INF;
	int R,G;
	int BX[55],BY[55],nx,ny;
	cin>>R>>G;
	cout<<2*G-R<<endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::{input};

fn main(){
    input!{
        n: usize,
        a: [usize; n - 1]
    }
    let mut ans = vec![0; n];
    for b in a {
        ans[b-1] += 1;
    }
    for i in ans {
        println!("{}", i);
    }
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    string s;
    cin >> s;

    string s1 = s.substr(0, n / 2);
    string s2 = s.substr(n / 2);


    string ans = "No";
   
    if (s1 == s2)
    {
        ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	s := readString()

	m := make(map[byte]int)
	for i := range s {
		m[s[i]]++
	}

	if len(m) != 2 {
		fmt.Println("No")
		return
	}
	for _, v := range m {
		if v != 2 {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
int main (){
  Bint a;
  Bint c=0;
  string b;
  cin>>a>>b;
  c+=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
  cout<<a*c/100;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n,mm;
    cin>>n>>mm;
    map<int,vector<int>>m;
    while(mm--){
        int prob;string verdict;
        cin>>prob>>verdict;
        if(!m[prob].empty() && m[prob].back()==1)   continue;
        if(verdict=="AC")   m[prob].push_back(1);
        else                m[prob].push_back(0);
    }
    int solved=0,pen=0;
    for(auto x:m){
        if(x.second.back()==1){
            solved++;
            pen+=x.second.size()-1;
        }
    }   
    cout<<solved<<" "<<pen<<"\n";
}   

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'
#define M_PI           3.14159265358979323846

void solve(){
 	double r; cin>>r;   
 	setd(2*M_PI*r, 20);
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define u64 uint64_t
#define ll long long
#define endl "\n"
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    fast
    ll n,m,x,y,i,j,k,p,f=0,tc,cnt=0,sum=0,pro=1,mi=1e18,ma=-1e18;
    string str;
    char ch;
    double db;
    deque<ll>dq;
    map<ll,ll>mp;
    set<ll>st;
    vector<ll>vt;
    //code
    ll h1,h2,m1,m2,h;
    cin>>h1>>m1>>h2>>m2>>x;
    ll t1=h1*60+m1;
    ll t2=h2*60+m2;
    if(t1<=t2)
   cout<<t2-t1-x<<endl;
   else
   {
       n=t2;
       n+=(24*60-t1);
       cout<<n-x<<endl;
   }


    //code
    return 0;
}


Measured memory_bytes: 3640
import math
A, B, H, M = map(int, input().split())
J = H * 60 + M
all = 12 * 60
AAA = J / all
tan = AAA * 360
tyou = AAA * 12 * 360
kakudo = tan - tyou
ans = A**2 + B**2 - 2 * A * B * math.cos(math.radians(kakudo))
print(ans**(1 / 2))


Measured memory_bytes: 9440
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 100010
int n;
ll X;
ll x[N];
int main(){
	int i;
	ll ans=0;
	read(n);
	readl(X);
	for(i=1;i<=n;i++)readl(x[i]);
	sort(x+1,x+n+1);
	if(n==1){
		printf("%lld",abs(x[1]-X));
		return 0;
	}
	if(X>=x[n]){
		ans=X-x[n];
		for(int j=n-1;j>=1;j--) {
			ans=__gcd(ans,x[j+1]-x[j]);
		}
		printf("%lld",ans);
	} else {
		if(X<=x[1]){
			ans=x[1]-X;
			for(int j=2;j<=n;j++)ans=__gcd(ans,x[j]-x[j-1]);
			printf("%lld",ans);
		} else {
			for(i=1;i<=n;i++)if(x[i]<=X&&x[i+1]>=X) break;
			ans=X-x[i];
			ans=__gcd(ans,x[i+1]-X);
			for(int j=i-1;j>=1;j--)ans=__gcd(ans,x[j+1]-x[j]);
			for(int j=i+1;j<=n;j++)ans=__gcd(ans,x[j]-x[j-1]);
			printf("%lld",ans);
		}
	}
	return 0;
}


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

ll gcd(ll c,ll d) {return d ? gcd(d,c%d) : c;}

ll lcm(ll c,ll d) {return(c/gcd(c,d)*d);}

ll f(ll x,ll c,ll d){
  ll res = x;
  res -= x/c;
  res -= x/d;
  res += x/lcm(c,d);
  
  return res;
}

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = 0;
  
  ans = f(b,c,d) - f(a-1,c,d);
  
  cout << ans << endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long k, a, b;
  cin >> k >> a >> b;
  if (b <= a + 2) {
    cout << k + 1 << '\n';
  } else {
    cout << max(0LL, (k - a + 1) / 2) * (b - a) + ((k - a + 1) % 2) + a << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    cin >> x >> y;
    int b_ = (y-2*x);
    int a_ = (4*x-y);
    if(b_&1 || a_&1 || b_<0 || a_<0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
double S[200005];
int main() {
  ios::sync_with_stdio(false);
  int N, K, P;
  cin >> N >> K;
  for (int i=1; i<=N; i++) {
    cin >> P;
    double p = (double)(1.0 + P) / 2.0;
    S[i] = S[i-1] + p;
  }
  double ret = 0.0;
  for (int i=K; i<=N; i++) {
    ret = max(ret, S[i] - S[i-K]);
  }
  printf("%.12f\n", ret);
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223000000000000000
#define INF 2147000000
#define MOD 1000000007
using namespace std;

pair<long,string> dp[10][10005];

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);

    long num[9]={2,5,5,4,5,6,3,7,6};

    vector<pair<long, long> > zz(m);
    long i,j;
    for(i=0; i<m; i++) {
        long a;
        scanf("%ld", &a);
        zz[i]=make_pair(a, num[a-1]);
    }
    sort(zz.rbegin(), zz.rend());

    for(j=0; j<=n; j++) {
        for(i=0; i<m; i++) {
            dp[i][j].first = (j==0? 0: -1);
        }
    }

    for(j=0; j<=n; j++) {
        for(i=0; i<m; i++) {
            if(i>0) {
                dp[i][j] = dp[i-1][j];
            }
            if(j-zz[i].second>=0 && dp[i][j-zz[i].second].first>=0 ) {
                char str[5]={0};
                sprintf(str, "%ld", zz[i].first);
                string tmpstr = dp[i][j-zz[i].second].second + string(str);
                pair<long,string> tmp = make_pair( tmpstr.size(), tmpstr );
                dp[i][j] = MAX( dp[i][j], tmp );
            }
        }
    }

    printf("%s\n", dp[m-1][n].second.c_str());

    return 0;
}


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

int main() {
  ll ans=0,n;
  cin >> n;
  vector<ll>p(n);
  rep(i,n) cin >> p.at(i);
  rep(i,n-2) 
    ans+= (p.at(i) < p.at(i+1) &&  p.at(i+1) < p.at(i+2)) ||
      (p.at(i) > p.at(i+1) &&  p.at(i+1) > p.at(i+2))? 1:0;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int r, D, x_2000;
	cin >> r >> D >> x_2000;

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

		x_2000 = x_2000 * r - D;
		cout << x_2000 << "\n";

	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static int modNum = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		if(a == b){
			System.out.println("Draw");
			return;
		}
		
		if(a == 1){
			System.out.println("Alice");
			return;
		}
		
		if(b == 1){
			System.out.println("Bob");
			return;
		}
		
		if(a > b){
			System.out.println("Alice");
		}else{
			System.out.println("Bob");
		}
		
		
		
	}
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = int(2e5), inf = 0x3f3f3f3f;
int n, rt = 1, a[nsz + 5], siz[nsz + 5], dfn[nsz + 5];
vector<int> g[nsz + 5], p[nsz + 5], fm[nsz + 5];

void dfs(int u = rt, int p = -1) {
	static int t = 0;
	dfn[u] = ++t;
	siz[u] = 1;
	int c = a[u], pc = p != -1 ? a[p] : 0;
	loop (i, g[u].size()) {
		int v = g[u][i];
		if (v == p)  continue;
		dfs(v, u);
		siz[u] += siz[v];
	}
	if (pc && c != pc) {
		::p[pc].push_back(u);
	}
	::p[c].push_back(u);
}

bool inline in(int a, int l, int r) { return a >= l && a <= r; }

num inline f(num a) { return a * (a + 1) / 2; }

num inline solve(int c) {
	static int sum[nsz + 5];
	num res = f(n);
	loop (i, p[c].size()) {
		int u = p[c][i], l = i;
		for (; l - 1 >= 0 && in(dfn[p[c][fm[c][l - 1]]], dfn[u], dfn[u] + siz[u] - 1); l = fm[c][l - 1]);
		fm[c].push_back(l);
		if (a[u] == c) {
			sum[i + 1] = sum[i] + siz[u] - (sum[i] - sum[l]);
		} else {
			sum[i + 1] = sum[i];
			res -= f(siz[u] - (sum[i] - sum[l]));
		}
	}
	res -= f(n - sum[p[c].size()]);
	return res;
}

int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
	}
	cont (i, n - 1) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs();
	cont (c, n) {
		printf("%lld\n", solve(c));
	}
}

Measured memory_bytes: 50452
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  ll K;
  cin>>N>>M>>K;
  vector<ll> A(N+1), B(M+1);
  A[0] = 0;
  B[0] = 0;
  for(int i=1;i<=N;++i) cin>>A[i];
  for(int i=1;i<=M;++i) cin>>B[i];
  for(int i=1;i<=N;++i) A[i] += A[i-1];
  for(int i=1;i<=M;++i) B[i] += B[i-1];
  ll sum;
  int index;
  int ans = 0;
  for(int i=0;i<=N;++i) {
    sum = A[i];
    if(sum>K) continue;
    index = upper_bound(B.begin(), B.end(), K-sum) - 1 - B.begin();
    ans = max(ans, i+index);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
int INF = 1e9+7;
using ll = long long;
using P = pair<int, int>;

void normalize(vector<P> &tmp)
{
    if(tmp.size() == 1) return;
    if(tmp.back().first == tmp[tmp.size()-2].first)
    {
        tmp[tmp.size()-2].second += tmp.back().second;
        tmp.pop_back();
    }
}

void updateLast(vector<P> &tmp)
{
    if(tmp.back().second == 1)
    {
        tmp.back().first++;
        normalize(tmp);
    }
    else
    {
        tmp.back().second--;
        tmp.push_back(P(tmp.back().first+1, 1));
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    int lb = 0;
    int ub = n;

    while(ub - lb > 1)
    {
        int mid = (ub + lb) >> 1;
        vector<P> tmp;
        tmp.push_back(P(1, a[0]));
        bool flag = true;
        for(int i = 1; i < n; i++)
        {
            if(a[i] > a[i-1])
            {
                tmp.push_back(P(1, a[i]-a[i-1]));
                normalize(tmp);
            }
            else if(a[i] == a[i-1])
            {
                if(tmp.back().first != mid)
                {
                    updateLast(tmp);
                }
                else
                {
                    int size = tmp.back().second;
                    tmp.pop_back();
                    if(tmp.size() == 0)
                    {
                        flag = false;
                        break;
                    }
                    updateLast(tmp);
                    tmp.push_back(P(1, size));
                }
            }
            else
            {
                int diff = a[i-1] - a[i];
                int sum = 0;
                while(sum + tmp.back().second < diff)
                {
                    sum += tmp.back().second;
                    tmp.pop_back();
                }
                int dsize = diff - sum;
                if(dsize == tmp.back().second)
                {
                    tmp.pop_back();
                }
                else
                {
                    tmp.back().second -= dsize;
                }
                if(tmp.back().first != mid)
                {
                    updateLast(tmp);
                }
                else
                {
                    int size = tmp.back().second;
                    tmp.pop_back();
                    if(tmp.size() == 0)
                    {
                        flag = false;
                        break;
                    }
                    updateLast(tmp);
                    tmp.push_back(P(1, size));
                }
            }
        }
        if(flag) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
}


Measured memory_bytes: 1024
if __name__ == '__main__':
    #s = list(map(int,input().split()))
    s = input()
    if 'RRR' in s:
        print(3)
        exit()
    if 'RR' in s:
        print(2)
        exit()
    if 'R' in s:
        print(1)
        exit()
    else:
        print(0)


Measured memory_bytes: 8904
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string T;
    cin >> T;
    int C;
    int A;
    C = T.size() / 2;
    A = T.size() % 2;
    int N = 0;
    bool flag = 0;
    /*if (C % 2 == 1){
        C = C + 1;
    }*/
  
  	//cout << C << A << endl;

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


        if (T.at(N) == 'L'){
          flag = 1;
        }
      	
      	//cout << flag << T.at(N) << endl;

        N = N + 1;

        if (T.at(N) == 'R'){
          flag = 1;
        }
		//cout << flag << T.at(N) << endl;
      
      	N = N + 1;



    }

    if (A == 1){
        if (T.at(N) == 'L'){
          flag = 1;
        }
    }

    if (flag == 1){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


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

int main()
{

    string S;
    cin >> S;
    int win {0}, lose{0};

    for(int i=0; i<S.size(); ++i){
        if( S[i] == 'o')
            ++win;
        else
            ++lose;
    }

    if( 15-S.size() + win >= 8 )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}
class Solution {
public:
	void solve() {
		int n, m, l;
		cin >> n >> m >> l;
		vector<vector<int>> d(n, vector<int>(n, 0x3f3f3f3f)), d2(n, vector<int>(n, 0x3f3f3f3f));
		for(int i=0; i < m; i++){
			int a, b, c;
			cin >> a >> b >> c;
			a--, b--;
        	d2[a][b] = d2[b][a] = c;
		}
		for(int k=0; k < n; k++){
			for(int i=0; i < n; i++){
				for(int j=0; j < n; j++){
					updmin(d2[i][j], d2[i][k] + d2[k][j]);
				}
			}
		}
      	for(int i=0; i < n; i++)for(int j=0; j < n; j++)if(d2[i][j] <= l)d[i][j] = 1;
		for(int k=0; k < n; k++){
			for(int i=0; i < n; i++){
				for(int j=0; j < n; j++){
					updmin(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
 
		int Q;
		cin >> Q;
		for(int q=0; q < Q; q++){
			int s, t;
			cin >> s >> t;
			if(d[s-1][t-1] == 0x3f3f3f3f)cout << -1 << "\n";
			else cout << d[s-1][t-1]-1 << "\n";				
		}
 
	
		return;
	};
};
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>

using namespace std;

long long a[111111], b[111111];


long long n, k, ans = 0;

bool issub(long long x, long long y) {
    for (long long i = 0; i < 30; i++) {
        if (((1 << i) & x) > 0) {
            if (((1 << i) & y) == 0)
                return false;
        }
    }
    return true;
}

long long check(long long k) {
    long long ret = 0;
    for (long long i = 0; i < n; i++)
        if (issub(a[i], k))
            ret += b[i];
    return ret;
}

int main() {
    cin >> n >> k;
    for (long long i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    ans = check(k);
    for (long long i = 0; i <= 30; i++) {
        long long tmp = k;
        long long x = i;
        for (long long z = 0; z < 30; z++) {
            if (((1 << z) & tmp) > 0) {
                if (x > 0)
                    x--;
                else {
                    tmp -= (1 << z);
                    break;
                }
            } else {
                tmp += (1 << z);
            }
        }
        if (x == 0 and tmp <= k)
            ans = max(ans, check(tmp));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
main(){
   
  int x,y,i,a;
   
  for(i = 0 ; 1 ; i++){
    scanf("%d%d",&x,&y);
    if(x == 0 && y == 0) break;
     
    if(x > y){
      a = x;
      x = y;
      y = a;
    }
    printf("%d %d\n",x,y);
  }
}

Measured memory_bytes: 2572
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    string s,t;cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        ans += s[i] != t[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3856
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[1000001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=200000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}

lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans=0;
lld n,i,j,k,m;
lld x,y,n1,b=0,a,n2,h,z,c;
vector<vector<lld> > v(200001);
vector<bool > visited(200001,false);
vector<lld> w(200001),pa(200001);

queue<lld> q;
void bfs()
{
    q.pu((lld)1);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        if(visited[x]==true)
            continue;
        visited[x]=true;
        l=v[x].size();
        for(i=0;i<l;i++)
        {
            if(visited[v[x][i]]==false)
            {
                w[v[x][i]] = w[x]+1;
                pa[v[x][i]] =x;
                q.pu(v[x][i]);
            }
        }
    }
}
void solve()
{
    cin>>n>>m;
    cout<<(n/m)+(n%m?1:0);
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
     //getfac(p1);
    //check the value by which modulo is to be taken
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
           solve();
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 8064
//
// Created by 李青坪 on 2018/10/14.
//

#include "cstdio"
using namespace std;
typedef long long llong;

int a[200001];
int MAXINT = 2000000000;
llong count = 0;

int merge(int low, int mid, int high){
    int lenLow = mid - low;
    int lenHigh = high - mid;
    int lowNum[lenLow+1], highNum[lenHigh+1];
    for (int i = 0; i < lenLow; ++i) {
        lowNum[i] = a[i+low];
    }
    for (int j = 0; j < lenHigh; ++j) {
        highNum[j] = a[j+mid];
    }
    lowNum[lenLow] = MAXINT;
    highNum[lenHigh] = MAXINT;
    int i=0, j=0;
    for (int k = low; k < high; ++k) {
        if (lowNum[i] <= highNum[j]){
            a[k] = lowNum[i];
            ++i;
        }
        else{
            a[k] = highNum[j];
            count += (lenLow - i);
            ++j;
        }
    }
}
int countInversion(int low, int high){
    if (low + 1 < high){
        int mid = (low + high)/2;
        countInversion(low, mid);
        countInversion(mid, high);
        merge(low, mid, high);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    countInversion(0, n);
    printf("%ld\n", count);
}
/*
5
3 5 2 1 4
 */


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

int main(void) {
  int n;
  cin >> n;
  ll l[87];
  l[0] = 2LL, l[1] = 1LL;
  f1(i, 2, n) l[i] = l[i - 2] + l[i - 1];
  cout << l[n] << endl;
  return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
typedef long long ll; 
using namespace std;
const int maxn=2e5+10;
struct node{
	int val,pos,id;
	bool operator<(const node& a)const{
		return val<a.val;
	}
};
multiset<int>st;
node event[maxn<<1];
int main()
{
	int n,q;
	int num=0;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++){
		int s,t,x;
		scanf("%d%d%d",&s,&t,&x);
		s-=x,t-=x;
		event[num++]={s,x,1};
		event[num++]={t,x,0};
	}
	sort(event,event+num);
	int now=0;
	for(int i=1;i<=q;i++){
		int d;
		scanf("%d",&d);
		while(now<num&&event[now].val<=d){
			if(event[now].id)st.insert(event[now].pos);
			else st.erase(st.find(event[now].pos));
			now++;
		}
		int ans=-1;
		if(st.size())ans=*st.begin();
		printf("%d\n",ans);
	}
}



Measured memory_bytes: 15360
#include<stdio.h>

int main(void) {
int N, D, X;
scanf("%d %d %d", &N, &D, &X);
int A[N];
for (int i = 0; i < N; i++) {
 scanf("%d", &A[i]);
}

int cnt = X;
for (int i = 0; i < N; i++) {
int j = 0;
 while (j*A[i]+1 <= D) {
   cnt++;
   j++;
 }
}

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

Measured memory_bytes: 128
#include<stdio.h>
int t[101][3];
int d[200][3];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)for(int j=0;j<3;j++){scanf("%d",&d[i][j]);t[d[i][j]][j]++;}
	for(int i=0;i<a;i++){
		int ret=0;
		if(t[d[i][0]][0]==1)ret+=d[i][0];
		if(t[d[i][1]][1]==1)ret+=d[i][1];
		if(t[d[i][2]][2]==1)ret+=d[i][2];
		printf("%d\n",ret);
	}
}



Measured memory_bytes: 2612
#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;

int main()
{
	int a[3];
	while(~scanf("%d%d%d",a,a + 1,a + 2)){
		sort(a,a + 3);
		if(a[0] + a[1] == a[2]) printf("Yes\n");
		else printf("No\n");
	}
    return 0;
}

Measured memory_bytes: 128