akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

struct WeightedUnionFind {
  vector<int> par;
  vector<int> rank;
  vector<int> size;
  vector<int> diff_weight;
  
  WeightedUnionFind(int N) : par(N), rank(N), size(N), diff_weight(N) {
    for (int i = 0; i < N; i++) {
      par[i]  = i;
      rank[i] = 0;
      size[i] = 1;
      diff_weight[i] = 0;
    }
  }
  
  int root(int x) {
    if (par[x] == x) return x;
    else {
      int r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }


  bool unite(int x, int y, int w) {
    w += weight(x); w -= weight(y); 
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y), w = -w;    
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x; 
    diff_weight[y] = w; 
    return true;
  }

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

  int weight(int x) {
    root(x);
    return diff_weight[x];
  }

  int diff(int x, int y) {
    if (root(x) != root(y)) return -1;
    return weight(y) - weight(x);
  }
  
  int get_size(int x) {
    int rx = root(x);
    return size[rx];
  }
  
};


int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N, M;
  int L, R, D;
  cin >> N >> M;

  WeightedUnionFind wuf = WeightedUnionFind(N);
  for (int i = 0; i < M; i++) {
    cin >> L >> R >> D;
    L--; R--; // zero-based index
    
    if (!wuf.same(L, R)) wuf.unite(L, R, D);
    else {
      int d = wuf.diff(L, R);
      if (d != D) {
	cout << "No" << endl;
	return 0;
      }
    }
  }

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


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  ll a,b,c;cin >> a >> b >> c;
  ll x = 4*a*b;
  ll y = (c-a-b);
  if(y<0){
    cout << "No" << "\n";
    return 0;
  }
  if(x<y*y) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {

	int N, M, X, Y;

	scanf("%d %d %d %d", &N, &M, &X, &Y);

	int x[N], y[M], i, j;

	for (i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}

	for (j = 0; j < M; j++) {
		scanf("%d", &y[j]);
	}

	int flag = 1;

	if (X < Y) {
		flag = flag * 1;
	}
	else {
		flag = flag * 0;
	}

	int maxx = X;

	for (i = 0; i < N; i++) {
		if (x[i] >= maxx) {
			maxx = x[i];
		}
	}


	int miny = Y;

	for (i = 0; i < M; i++) {
		if (y[i] <= miny) {
			miny = y[i];
		}
	}

	if (maxx < miny) {
		flag = flag * 1;
	}else{
      	flag = 0;
    }

	if (flag == 1) {
		printf("No War");
	}
	else {
		printf("War");
	}

	return 0;

}


Measured memory_bytes: 128
N, K = map(int, input().split())

ans = dict()
for i in range(N):
    a, b = map(int, input().split())
    if a in ans:
        ans[a] += b
    else:
        ans[a] = b
    
ans = sorted(ans.items(), key=lambda x:x[0])    
count = 0
for k, v in ans:
    count += v
    if count >= K:
        print(k)
        exit()

Measured memory_bytes: 15040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n;
  cin >> n;
  vector<int>v(n + 1,-113);
  rep(i,n)cin >> v[i];
  ll ans = 1000,cnt = 0;
  rep(i,n){
    int j = 0;
    while(v[i + j] <= v[i + j + 1])j++;
    ll tmp = ans / v[i];
    ans -= tmp * v[i];
    ans += tmp * v[i + j];
    i += j;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int Alice = 0;
    int Bob = 0;
    rep(i,n){
        if(i % 2 == 0) Alice+=a[i];
        else Bob+=a[i];
    }
    int ans = abs(Alice - Bob);
    cout << ans << endl;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N = 0;
    cin >> N;

    vll X(N);
    REP(i,N) cin >> X[i];
    ll ans = INF;

    REP(i,100){
      ll count = 0;
      REP(j,N){
      count += (X[j]-i)*(X[j]-i);
      }
      ans = min(ans, count);
    }

    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3580
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
#define int ll 
using namespace std;             
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int n, m, k;
int a[25][N];
int pref[25][N];
vector <int> v;
int sum[N];
int get (int x1, int y1, int x2, int y2) {
	return pref[x2][y2] - pref[x2][y1 - 1] - pref[x1 - 1][y2] + pref[x1 - 1][y1 - 1];
}
void solve () {
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= m; j ++) {
			char c;
			cin >> c;
			a[i][j] = (c == '1');
			pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + a[i][j];
		}
	}
	int mini = n * m;
	for (int mask = 0; mask < (1 << (n - 1)); mask ++) {
		v.clear ();
		v.pb (0);
		for (int i = 0; i < n - 1; i ++) {
			sum[i + 1] = 0;
			if ((mask & (1 << i))) v.pb (i + 1);
		}
		sum[n] = 0;
		v.pb (n);
		bool all = 1;
		int kol = sz (v) - 2;
		for (int j = 1; j <= m; j ++) {
			bool check = 0;
			for (int o = 0; o < sz (v) - 1; o ++) {
				int y1 = j, y2 = j;
				int x1 = v[o] + 1, x2 = v[o + 1];
				int sumkek = get (x1, y1, x2, y2);
				if (sumkek > k) {
					all = 0;
					break;
				}
				if (sumkek + sum[o + 1] > k) {
					check = 1;
					kol ++;
					break;
				}		
				else {      	
					sum[o + 1] += sumkek;
				}
			}
			if (all == 0) break;
			if (check == 1) {
				for (int o = 0; o < sz (v) - 1; o ++) {
					int y1 = j, y2 = j;
					int x1 = v[o] + 1, x2 = v[o + 1];
					sum[o + 1] = get (x1, y1, x2, y2);
				}
			}
		}
		if (all == 0) ;
		else {
			mini = min (mini, kol);
		}
	}
	cout << mini;
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 33152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    vector<vector<ll> > d(N,vector<ll>(N)),d1(N,vector<ll>(N));
    REP(i,N)REP(j,N){cin>>d[i][j];d1[i][j]=d[i][j];}
    REP(k,N)REP(i,N)REP(j,N){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
    bool f=true;
    REP(i,N)REP(j,N){
        if(d[i][j]!=d1[i][j])f=false;
    }
    if(!f)cout<<-1<<endl;
    else{
        ll res=0;
      vector<vector<bool> > used(N,vector<bool>(N,false));
        REP(i,N)REP(j,N){
            if(j>i)res+=d[i][j];
        }
        REP(i,N)REP(j,N)REP(k,N){
            if(j>i && i!=k && j!=k && d[i][j]==d[i][k]+d[k][j] && !used[i][j]){
              res-=d[i][j];used[i][j]=true;used[j][i]=true;
            }
        }
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    cout << a - b - ((a-b)/c) * c << endl;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
    }
    let mut ans = n;
    for i in 0..n+1 {
        if n < 9 * i { continue }
        let r = n - 9 * i;
        let j = r / 6;
        let k = r % 6;

        let mut num = k;
        let mut t = i;
        while t > 0 {
            num += t % 9;
            t = t / 9;
        }
        let mut t = j;
        while t > 0 {
            num += t % 6;
            t = t / 6;
        }
        // println!("{} = 9*{} + 6*{} + {}; cnt={}", n, i, j, k, num);
        ans = min(ans, num);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
a, b, c = map(int, input().split())

list1 = [a, b, c]

list1.sort()

for i in range(len(list1)):
    if i == 0:
        a = list1[i]
    elif i == 1:
        b = list1[i]
    else:
        c = list1[i]

print('{} {} {}'.format(a, b, c))


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <set>
using namespace std;

set<string> s;

int main()
{
    int n;
    cin >> n;
    
    string prev = "";
    for(int i = 0; i < n; i++)
    {
        string t;
        cin >> t;
        
        if(i && t[0] == prev[prev.length() - 1] && s.end() == s.find(t))
        {
            ;
        }
        else if(i)
        {
            cout << "No";
            return 0;
        }
        
        s.insert(t);
        prev = t;
    }
    
    cout << "Yes";
    return 0;
}



Measured memory_bytes: 256
// Aizu Vol-2 0240: Interest Rates
// 2017.8.7

#include <stdio.h>
#include <math.h>

int main()
{
	int n, y, b, r, t;
	int i, id;
	double max, m, yy;

	while (1) {
		scanf("%d", &n); if (n == 0) break;
		scanf("%d", &y), yy = y;
		for (id = -1, i = 0; i < n; i++) {
			scanf("%d%d%d", &b, &r, &t);
			if (t == 1) m = yy * (r / 100.0) + 1;
			else m = pow(r / 100.0 + 1, yy);
			if (id < 0 || m >= max) id = b, max = m;
		}
		printf("%d\n", id);
	}
	return 0;
}

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

int calculate( int a, int b, char c )
{
    if( c == '+' )
        return a + b;
    else if( c == '-' )
        return a - b;
    else if( c == '*' )
        return a * b;
    else if( c == '/' )
        return a / b;
    else
        return a;
}

int getMax( int a, int b )
{
    return a > b ? a : b;
}

int main()
{
    int n;
    string s;
    vector<int> d, p;
    vector<char> c;

    cin >> n;

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

        int a = 0, b = 0;
        for( int j = 0; j < s.size(); j++ )
        {
            if( '0' <= s[j] && s[j] <= '9' )
                a = a * 10 + s[j] - '0';
            else if( '0' <= s[j-1] && s[j-1] <= '9' )
            {
                d.push_back(a);
                a = 0;
            }
            else;
            
            if( s[j] == '+' || s[j] == '-' )
            {
                c.push_back(s[j]);
                p.push_back(b+1);
            }
            else if( s[j] == '*' || s[j] == '/' )
            {
                c.push_back(s[j]);
                p.push_back(b+2);
            }
            else if( s[j] == '(' )
                b += 10;
            else if( s[j] == ')' )
                b -= 10;
            else;
        }

        int cnt = c.size();
        while( cnt-- )
        {    
            int m = 0;
            for( int j = 0; j < p.size(); j++ )
                m = max( m, p[j] );

            for( int j = 0; j < p.size(); j++ )
                if( p[j] == m )
                {
                    p[j] = 0;
                    d[j] = calculate( d[j], d[j+1], c[j] );
                    for( int k = j; k < c.size() - 1; k++ )
                    {
                        c[k] = c[k+1];
                        p[k] = p[k+1];
                        p[k+1] = 0;
                    }
                    for( int k = j + 1; k < d.size() - 1; k++ )
                        d[k] = d[k+1];
                    break;
                }
        }
        cout << d[0] << endl;
        d.clear();
        c.clear();
        p.clear();
    }
    return 0;
}


Measured memory_bytes: 3140
#include<stdio.h>

int main()
{

    int n,m,x,a,b,c=0,d=0;
    scanf("%d %d %d",&n,&m,&x);

    for(a=1;a<=m;a++){
    scanf("%d",&b);

    if(b>x){
    c=c+1;


    }
    else{

    d=d+1;
    }



    }
    if(c>d){
    printf("%d\n",d);
    }
    else{
    printf("%d\n",c);
    }
return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
const int MAXN=1e5;

struct edge{int to;
            long long cost;
           };
vector<edge> G[MAXN];
vector<long long> dis(MAXN);
int N,Q,K;

void dfs(int v,int p,long long d){
  dis[v]=d;
  for(auto& e:G[v]){
    if(e.to==p) continue;
    dfs(e.to,v,d+e.cost);
  }
  return;
}

int main(){
  cin>>N;
  int a,b,c;
  for(int i=0;i<N-1;i++){
    cin>>a>>b>>c;
    a--;b--;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
  }
  cin>>Q>>K;
  dfs(K-1,-1,0);
  int x,y;
  for(int i=0;i<Q;i++){
    cin>>x>>y;
    x--;y--;
    cout<<dis[x]+dis[y]<<endl;
  }
  return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
typedef  long long ll;
using namespace std;
const int maxn = 3e5 + 100;
int main() {
	ios::sync_with_stdio(0);
	ll n;
	cin >> n;
	ll p = 1;
	while (n >= p)
		p *= 2;
	cout << p - 1 << endl;
	return 0;
}
/*
1 1
2 3
3 3
4 7
5 7
6 7
7 7
8 15
9 15
10 15
11 15
12 15
13 15
14 15
15 15
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};

int main() {
  int H, W; cin >> H >> W;
  vector<string> field(H);
  rep(i, H) cin >> field[i];

  VV dp(H, V(W));
  dp[0][0] = 1;

  rep(h, H) rep(w, W) rep(dir, 2) {
    if (field[h][w] == '#') continue;
    int nh = h + dx[dir];
    int nw = w + dy[dir];
    if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;

    (dp[nh][nw] += dp[h][w]) %= MOD;
  }

  int ans = dp[H-1][W-1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


typedef struct {
    int start;
    int end;
} lineInfo_t;


bool operator<(const lineInfo_t &lhs, const lineInfo_t &rhs){
    if (lhs.start == rhs.start){
        return lhs.end < rhs.end;
    } else {
        return lhs.start < rhs.start;
    }
}

map<lineInfo_t, int> lineinfo;

int dfs(int parent, int node, int usedColor, vector<vector<int>>& g){
    int maxColor = 0;
    if (node != 0 && g[node].size() == 1) return 1;
    int tmpColor = 1;
    for (auto line: g[node]){
        if (line == parent) continue;
        if (tmpColor == usedColor) tmpColor++;
        lineInfo_t tmpline = {node, line};
        //cout << tmpline.start << " " << tmpline.end << " " <<tmpColor << endl;
        lineinfo.insert(make_pair(tmpline, tmpColor));
        maxColor = max(maxColor, dfs(node, line, tmpColor, g));
        tmpColor++;
    }
    return max(maxColor, (int)g[node].size());
}

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> line;
    vector<vector<int>> g(n);
    rep(i, n - 1){
        int tmpa, tmpb;
        cin >> tmpa >> tmpb;
        tmpa--; tmpb--;
        g[tmpa].push_back(tmpb);
        g[tmpb].push_back(tmpa);
        line.push_back(make_pair(tmpa, tmpb));
    }
    //parent: 初期値は存在しない(-1), node:開始位置, usedColor:使用色(0), map:g
    int size = dfs(-1, 0, 0, g);

    cout << size << endl;
    for (auto l: line){
        if (lineinfo.count({l.first, l.second}) == 0){ cout << "none" << endl;}
        cout << lineinfo[{l.first, l.second}] << endl;
    }
}


Measured memory_bytes: 14968
import sys
from sys import stdin
n = int(stdin.readline().rstrip())
al = [int(_) for _ in stdin.readline().rstrip().split()]
count=0
while True:
    for i,a in enumerate(al):
        if a%2 != 0:
            print(count)
            sys.exit()
        al[i]=a/2
    count+=1

Measured memory_bytes: 3060
s = input()
l = len(s)
n = 0

for i in range(l):
  if i % 2 ==0:
    if s[i] == "L":
      n += 1
  
  else:
    if s[i] == "R":
      n += 1
      
if n == 0:
  print("Yes")
  
else:
  print("No")

Measured memory_bytes: 3060
using System;

namespace _159a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int N = input[0];
            int M = input[1];
            int gu = N * (N-1) / 2;
            int ki = M * (M-1) / 2;
            Console.WriteLine(gu+ki);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
#define lnt(s) (ll)s.length()
#define mt(cnt) cnt.empty()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;
using pl = pair<ll, pll>;
using tll = tuple<ll, ll, ll>;

const ll maxN = 1e5 + 11;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

bool isP[maxN];

void init(){
	memset(isP, 1, sizeof(isP));
	isP[0] = isP[1] = 0;
	for(ll i=2; i<maxN; i++){
		if(isP[i]){
			for(ll j=(i<<1); j<maxN; j+=i)
				isP[j] = 0;
		}
	}
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t;
	init();
	cin >> t;
	for(ll i=2; i<maxN; i++){
		if(isP[i] and i>=t){
			cout << i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3728
#include<iostream>
using namespace std;
int main()
{
int a1,b1,c1,d1,a2,b2,c2,d2,T1,T2,T;
cin >> a1 >> b1 >> c1 >> d1;
cin >> a2 >> b2 >> c2 >> d2;
if(a1>100){
        cout << "エラー" << endl;
        return 0;
}
if(b1>100){
        cout << "エラー" << endl;
        return 0;
}
if(c1>100){
        cout << "エラー" << endl;
        return 0;
}
if(d1>100){
        cout << "エラー" << endl;
        return 0;
}
if(a2>100){
        cout << "エラー" << endl;
        return 0;
}
if(b2>100){
        cout << "エラー" << endl;
        return 0;
}
if(c2>100){
        cout << "エラー" << endl;
        return 0;
}
if(d2>100){
        cout << "エラー" << endl;
        return 0;
}

T1=a1+b1+c1+d1;
//cout << T1 << endl;
T2=a2+b2+c2+d2;
//cout << T2 << endl;
if(T1>T2){
        T=T1;
	//cout << "T1" << endl;
}
if(T2>T1){
        T=T2;
	//cout << "T2" << endl;
}
if(T1==T2){
        T=T1=T2;
	//cout << "T1=T2" << endl;
}
cout << T << endl;
return 0;
}

Measured memory_bytes: 1160
import math
import sys
import os
from operator import mul
import numpy as np

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

MOD = 10 ** 9 + 7

N = I()
A = LI()
ans = 0

# A = np.array(A)
sum = [0]*(N+1)
for i in range(N):
        sum[i+1] = sum[i]+A[i]

for i in range(N-1):
    ans += A[i] * (sum[N] - sum[i+1]) % MOD

       
print(ans%MOD)

Measured memory_bytes: 49772
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = format(A[i],'050b')
#print(A)
K = format(K,'050b')
lis = [[0] * 2 for i in range(51)]
for i in range(50):
    for j in range(N):
        lis[i+1][int(A[j][i])] += 1
    lis[i+1].reverse()
# print(K)
#print(lis)

dp = [[-1] * 2 for  i in range(51)]
dp[0][0] = 0
for i in range(50):
    nd = int(K[i])
    for j in range(2):
        if dp[i][j] == -1:
            continue
        for d in range(2):
            ni = i+1
            nj = j
            if j == 0:
                if d > nd:
                    continue
                if d < nd:
                    nj = 1
            dp[ni][nj] = max(dp[ni][nj],dp[i][j] + (lis[ni][d] * 2**(49-i)))

# print(dp)
print(max(dp[50][0],dp[50][1]))


Measured memory_bytes: 94612
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#define EPS (1e-7)
using namespace std;






int main() {


	long long N, M, ans =0;
	cin >> N >> M;


	ans += min(N, M / 2);
	N -= ans;
	M -= 2 * ans;	

	ans += M / 4;


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
def main():
    a, b = map(int, input().split())
    if a > 0:
        print('Positive')
    elif b >= 0:
        print('Zero')
    else:
        if (b-a+1) % 2 == 0:
            print('Positive')
        else:
            print('Negative')


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int a[100][100];
int main()
{
    int A,B;
    cin>>A>>B;
    char s[20];
    cin>>s;
    int flag=1;
    if(s[A]!='-') flag=0;
    else{
        int len=strlen(s);
        if(len!=A+B+1) flag=0;
        else{
            for(int i=0;i<A&&flag;i++){
                if(s[i]>='0'&&s[i]<='9') continue;
                else flag=0;
            }
            for(int i=A+1;i<A+B+1&&flag;i++)
            {
                if(s[i]>='0'&&s[i]<='9') continue;
                else flag=0;
            }
        }
    }
    printf("%s\n",flag?"Yes":"No");
    return 0;
}



Measured memory_bytes: 256
using System;

namespace ABC124
{
    class Program
    {
        static int Main(string[] args)
        {
            Program.ProblemB();
            return 0;
        }

        static void ProblemB()
        {
            string n = Console.ReadLine();
            string[] input = Console.ReadLine().Split(' ');

            int max = 0;
            int count = 0;

            for(int i = 0; i<int.Parse(n); i++)
            {
                if (int.Parse(input[i]) >= max)
                {
                    count += 1;
                    max = int.Parse(input[i]);
                }                
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a&&c <= b) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;

}




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

int main( int argc, char** argv )
{
  std::string s;
  std::cin >> s;
  
  int x = 0;
  for( size_t i = 0, n = s.length(); i < n; ++i ) {
  	x += int( s[ i ] - '0' );
  }
  
  if( x % 9 == 0 ) {
    std::cout << "Yes\n";
  } else {
  	std::cout << "No\n";
  }
  
  return 0;
}

Measured memory_bytes: 3280
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[11],f[11],g,h,i,j,q[11];
	char z[11][11],x[11];
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a;i++){
		d[i]=0;
		f[i]=0;
		q[i]=i;
			scanf("%s",z[i]);
			for(j=0;j<a-1;j++){
				scanf("%d",&s);
				if(s==0) d[i]++;
				if(s==1) f[i]++;
			}
		}
		for(i=0;i<a-1;i++){
			for(j=i+1;j<a;j++){
				if(d[i]<d[j]){
					g=q[i];
					q[i]=q[j];
					q[j]=g;
					g=d[i];
					d[i]=d[j];
					d[j]=g;
					h=f[i];
					f[i]=f[j];
					f[j]=h;
					strcpy(x,z[i]);
					strcpy(z[i],z[j]);
					strcpy(z[j],x);
				}
				else if(d[i]==d[j]){
					if(f[i]>f[j]){
						g=q[i];
						q[i]=q[j];
						q[j]=g;
						g=d[i];
						d[i]=d[j];
						d[j]=g;
						h=f[i];
						f[i]=f[j];
						f[j]=h;
						strcpy(x,z[i]);
						strcpy(z[i],z[j]);
						strcpy(z[j],x);
					}
					else if(f[i]==f[i]){
						if(q[i]>q[j]){
							g=q[i];
							q[i]=q[j];
							q[j]=g;
							g=d[i];
							d[i]=d[j];
							d[j]=g;
							h=f[i];
							f[i]=f[j];
							f[j]=h;
							strcpy(x,z[i]);
							strcpy(z[i],z[j]);
							strcpy(z[j],x);
						}
					}
				}
			}
		}
		for(i=0;i<a;i++) printf("%s\n",z[i]);
	}
	return 0;
}

Measured memory_bytes: 2732
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for x in range(N)]
ws = [x[0] for x in wv]
vs = [x[1] for x in wv]

# # depthまでの荷物で、value以上になる重さの最小
dp = [[None] * (sum(vs) + 1) for _ in range(N + 1)]
# def dfs(value=0, depth=N - 1):
#     if value <= 0:
#         return 0
#
#     if depth == -1:
#         return float("inf")
#
#     if dp[depth][value] is not None:
#         return dp[depth][value]
#
#     weight = min(dfs(value, depth - 1), dfs(value - vs[depth], depth - 1) + ws[depth])
#     dp[depth][value] = weight
#     return weight
#
# for i in range(sum(vs) + 1):
#     if dfs(i) > W:
#         print(i - 1)
#         break
# else:
#     print(i)

dp[-1] = [float("inf")] * len(dp[-1])
s = sum(vs)
for depth in range(N):
    for value in range(s + 1):
        if value - vs[depth] >= 0:
            dp[depth][value] = min(dp[depth - 1][value], dp[depth - 1][value - vs[depth]] + ws[depth])
        else:
            dp[depth][value] = min(dp[depth - 1][value], ws[depth])


import bisect
print(bisect.bisect_left(dp[N - 1], W + 1))


Measured memory_bytes: 258432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main(){
ll n;
cin >> n;
vector<ll> a(n), b(n);
for (ll i = 0; i < n; i++) cin >> a[i];
for (ll i = 0; i < n; i++) cin >> b[i];
ll sum = 0;
for (ll i = 0; i < n; i++) {
    sum += (b[i] - a[i]);
}
ll cost1 = 0;
ll cost2 = 0;
for (ll i = 0; i < n; i++) {
    if (a[i] > b[i]) cost1 += (a[i] - b[i]);
    if (a[i] < b[i]) cost2 += (b[i] - a[i] + 1) / 2;
}
ll ans = -INF;
chmax(ans, cost1);
chmax(ans, cost2);
cout << ((sum >= ans) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
char a[105];
char b[105];
char c[105];
int n;
int ans = 0;
cin >> n ;
for (int i = 0; i < n; i++) {
	cin >> a[i];
}
for (int i = 0; i < n; i++) {
	cin >> b[i];
}
for (int i = 0; i < n; i++) {
	cin >> c[i];
}
for (int i = 0; i < n; i++) {
	
	if (a[i] == b[i]&&b[i] == c[i])ans+=0;
	else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i])ans++;
	else if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i])ans+=2;
	

}
cout << ans << endl;
}


Measured memory_bytes: 384
import math

def getNumsOfDivisorsOfEachNumbers(n: int):
    c = 0
    # validation check
    if not isinstance(n, int):
        raise("[ERROR] parameter must be integer")
    if n < 0:
        raise("[ERROR] parameter must be not less than 0 (n >= 0)")
    nums = [0] * (n + 1) # 0-indexed
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            nums[j] += 1
    nums.pop(0)
    for i in range(len(nums)):
        c+=nums[i]
    return c




#N = map(int,input().split())
#AB=[]
N = int(input())
#C = input()
#D, T, S=map(int,input().split())



if N == 1:
    print("0")
    exit(0)
elif N == 2:
    print("1")
    exit(0)
c = 0



print(getNumsOfDivisorsOfEachNumbers(N-1))

'''
for i in range(1,N):
    for j in range(1, i + 1):
        if j*j > i:
            break
        if i%j == 0:
            if j*j == i:
                c += 1
            else:
                c += 2
print(c)

'''

Measured memory_bytes: 16748
/*
 * C言語のサンプルプログラム - Webkaru
 * - 入力した2つの自然数の最小公倍数を求める -
 */
#include <stdio.h>

int main(void)
{

  long a, b, r, x, tmp;

  scanf("%ld", &a);
  scanf("%ld", &b);

  x = a * b;

  /* 自然数 a > b を確認・入替 */
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  /* 最小公倍数を出力 */
  printf("%ld", x / b);

  return 0;
}


Measured memory_bytes: 128
/* kadai5_3
   nabe9393 */
 
#include <stdio.h>
 
int main(void){
  int height, width, i, j;
  //タテとヨコのマスの数を入力
  scanf("%d %d", &height, &width);
  int row[height],column[width];
  char square[height][width];
  for(i=0;i<height;i++){
    for(j=0;j<width;j++){
      //文字列の入力　空白文字を飛ばす
      scanf(" %c",&square[i][j]);
      //値の初期化
      row[i]=0;
      column[j]=0;
    }
  }
  for(i=0;i<height;i++){
    for(j=0;j<width;j++){
      if(square[i][j]=='#'){
        //i行j列目の文字が#ならrow[i]とcolumn[j]を１にする
        row[i]=1;
        column[j]=1;
      }
    }
  }
  for(i=0;i<height;i++){
    if(row[i]==1){
      for(j=0;j<width;j++){
        if(column[j]==1){
          //rowとcolumnが１のものをプリントしていく
          printf("%c",square[i][j]);
        }
      }
      //改行の場所を間違えると正しい答えにならなくなる
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 128
num = int(input())
mod = 10 ** 9 + 7
ans = [0] * 2001
for x in range(num+1):
    if x <= 2: continue
    elif x <= 5: ans[x] += 1
    else:
        val = x - 2
        ans[x] += sum(ans[3:val]) + 1
print(ans[num] % mod)


Measured memory_bytes: 9232
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define x first
#define y second
typedef long long LL;
typedef pair<int, int> PII;
void R(char &c){c = getchar();};void R(string &s){scanf("%s",s.c_str());}void R(char s[]){scanf("%s",s);}template<typename T>void R(T&x){int f=1;x=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch-48);ch=getchar();}x*=f;}template<typename T,typename...Args>void R(T&x,Args&...args){R(x),R(args...);}void _W(const string&s){printf("%s",s.c_str());}void _W(const char&c){putchar(c);};void _W(const char s[]){printf("%s",s);}template<typename T>void _W(T x){if(x<0){putchar('-');x=-x;}static int dig[130];int top=0;do{dig[top++]=x%10,x/=10;}while(x);while(top)putchar(dig[--top]+48);}template<typename T>void _W(const vector<T> a){for(int i=0;i<SZ(a);++i)_W(a[i]),putchar(' ');}void W(){}template<typename T,typename...Args>void W(const T&x,const Args&...args){_W(x);putchar(sizeof...(args)?' ':'\n');W(args...);}
const int N = 100010;
LL q[N << 2];
vector<LL> ans;

void bfs(){
	int hh = 0, tt = -1;
	for(int i = 1; i <= 9; ++ i) q[ ++ tt] = i, ans.push_back(i);
	while(hh < tt){
		LL u = q[hh ++ ];
		LL t = u * 10 + u % 10;
		ans.push_back(t); q[ ++ tt] = t;
		if(t % 10 != 0) ans.push_back(t - 1), q[ ++ tt] = t - 1;
		if(t % 10 != 9) ans.push_back(t + 1), q[ ++ tt] = t + 1;
		if(ans.size() > 2 * N) return;
	}
}

void solve(){
	bfs();
	sort(all(ans));
	int k; R(k);
	W(ans[k - 1]);
}

signed main(){
	//int T; R(T); while(T -- )
	solve(); return 0;
}


Measured memory_bytes: 3568
N, K = gets.split.map(&:to_i)
X = []
Y = []

N.times.map{ gets.split.map(&:to_i) }
  .sort_by(&:last)
  .reverse_each
  .with_index(0)
  .with_object({}) do |((k, v), i), used|
    if i < K && used[k]
      X.push(v)
    elsif !used[k]
      Y.push(v)
      used[k] = 1
      break if used.size == K
    end
  end

sumX = Array.new(X.size + 1, 0)
sumY = Array.new(Y.size + 1, 0)

X.each_with_index {|v,i| sumX[i + 1] = sumX[i] + v }
Y.each_with_index {|v,i| sumY[i + 1] = sumY[i] + v }

puts (K - X.size .. Y.size).map{|k| sumY[k] + sumX[K - k] + k ** 2 }.max

Measured memory_bytes: 16080
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
 
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
 
//template functions
/////////////////////////
void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

/////////////////////////


//Answer


int main() {

long N,max=0;
cin>>N;
vector<long> A(N);
vector<long> B(N);
vector<long> C;
long PR=1000001;
vector<long> P(PR,0);
vector<long> R;
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        R.push_back(i);
    }
}



  
for(long i=0;i<N;i++){
cin>>A.at(i);
B.at(i)=A.at(i);
if(max<A.at(i)){
    max=A.at(i);
}
}
vector<long> X(max+1,0);
for(long i=0;i<N;i++){
    long j=0;
    long flag=0;
    while(j<R.size()){
        if(B.at(i)%R.at(j)==0){
            if(flag==0){
                X.at(R.at(j))++;
            }
            B.at(i)=B.at(i)/R.at(j);
            flag=1;
        }else{
            j++;
            flag=0;
        }
    }
  if(B.at(i)>1){
    X.at(B.at(i))++;
  }
}
long t=1;

for(long i=0;i<max+1;i++){

    if(X.at(i)>1){
        t=0;
        break;
    }
}
  
sort(A.begin(),A.end());
long mark=0;
long j=2;
while(A.at(0)>1){
        if(A.at(0)%j==0){
            if(mark==0){
                C.push_back(j);
            }
            A.at(0)=A.at(0)/j;
            mark=1;
        }else{
            j++;
            mark=0;
        }
    }
  
for(long i=1;i<N;i++){
    for(long k=0;k<C.size();k++){
        if(!(A.at(i)%C.at(k)==0)){
          auto itr=next(C.begin(),k);
            C.erase(itr);
        }
    }
}

long s=0;
if(C.size()==0){
    s=1;
}
if(s==1&t==1){
cout<<"pairwise coprime"<<endl;
}else if(s==1&&t==0){
cout<<"setwise coprime"<<endl;
}else{
cout<<"not coprime"<<endl;
}


}





Measured memory_bytes: 268760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc082/tasks/abc082_b

int main() {
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    cout << (s<t?"Yes":"No") << "\n";

    return 0;
}


Measured memory_bytes: 256
module Main where

import           Data.List

main :: IO ()
main = do
    [h, w] <- (map read . words) <$> getLine :: IO [Int]
    list   <-
        (map (map read . words)) <$> (sequence . take h . repeat) getLine :: IO
            [[Int]]
    let res1    = (map goRight . enumerate2d) list
    let list2   = (map snd) res1
    let result1 = (concat . map fst) res1
    let res2    = (map goRight . transpose) list2
    let result2 = (concat . map fst) res2
    let result  = concat [result1, result2]

    putStr
        $ (unlines . (((show . length) result) :) . map
              (unwords . (\((a, b), (c, d)) -> (map show) [a, b, c, d]))
          )
              result

    return ()
goRight
    :: [((Int, Int), Int)] -> ([((Int, Int), (Int, Int))], [((Int, Int), Int)])
goRight list@[_         ] = ([], list)
goRight (     a : b : xs) = if even (snd a)
    then let res = goRight (b : xs) in (fst res, a : (snd res))
    else
        let res = goRight (mapSnd (+ 1) b : xs)
        in  ((fst a, fst b) : (fst res), mapSnd (subtract 1) a : (snd res))

enumerate :: [a] -> [(Int, a)]
enumerate = zip [1 ..]

enumerate2d :: [[a]] -> [[((Int, Int), a)]]
enumerate2d list =
    (map (\(y, a) -> (map (\(x, b) -> ((y, x), b)) . enumerate) a) . enumerate)
        list

mapTuple f1 f2 (a, b) = (f1 a, f2 b)

mapFst f = mapTuple f id
mapSnd f = mapTuple id f


Measured memory_bytes: 84476
object Main extends App {
  val scan = new java.util.Scanner(System.in)
  val n = scan.next().toInt
  val a = scan.next().toDouble
  val xs = (1 to n).toArray.map(_ => scan.next().toInt)
  val memo = Array.fill(n+1, n+1,2501)(-1L)
  memo(0)(0)(0) = 1L
  for (i<-1 to n; j<-0 to n; k<-0 to 2500) {
    if (memo(i-1)(j)(k) != -1) { 
      if (memo(i)(j)(k) == -1) memo(i)(j)(k) = 0L
      memo(i)(j)(k) = memo(i-1)(j)(k)
    }
    if ((k-xs(i-1)>=0 && j-1>=0 && memo(i-1)(j-1)(k-xs(i-1)) != -1)) {
      if (memo(i)(j)(k) == -1) memo(i)(j)(k) = 0L
      memo(i)(j)(k) += memo(i-1)(j-1)(k-xs(i-1))
    } 
  }

  val ans = (for (j<-1 to n; k<-0 to 2500; if memo(n)(j)(k) != -1 && k%j==0 && k/j==a) 
            yield memo(n)(j)(k)).foldRight(0L)((x,s)=>x+s)
  println(ans)
}

Measured memory_bytes: 112932
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  cout<<fixed<<setprecision(10);
  llong L, R;
  int num=2018;
  cin >> L >> R;
  int modL, modR;
  modL = L%2019;
  modR = R%2019;
  if(modL < modR && L+2019 > R){
    for(int i=modL; i<modR; ++i) for(int j=i+1; j<=modR; ++j) num = min(num, (i*j)%2019);
    cout << num << endl;
  }else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

using namespace std;

int main() {
	ll n;
	cin >> n;
	
	ll sum = 0;
	for(ll i = 0; i <= n; i++) {
		if(i % 3 != 0 && i % 5 != 0) sum += i;
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
int main()
{
  string s;
  cin >> s;// s.size()>=3
  int n = s.size() - 2;
  cout << s[0] << std::to_string(n) << s[s.size()-1] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

bool is(vll& und, ll X)
{
    bool flg = true;
    rep(i, 0, und.size()) {
        if (und[i] < X) {
            flg = false;
        }
    }
    return flg;
}

int main()
{
    ll N, M, X;
    cin >> N >> M >> X;
    vll C(N);
    vllvll A(N, vll(M));
    rep(i, 0, N) {
        cin >> C[i];
        rep(j, 0, M) {
            cin >> A[i][j];
        }
    }

    ll min = INF;
    rep(bit, 0, 1<<N) {
        vll S;
        vll und(M, 0);
        rep(i, 0, M){
            und[i] = 0;
        }
        ll sum = 0;
        rep(i, 0, N) {
            if (bit&(1<<i)) {
                S.push_back(i);

                rep(j, 0, M) {
                    und[j] += A[i][j];
                    //cout << i << endl;
                } 
                sum += C[i];
               // cout << "\n\n\n\n";
            }
            if (is(und, X)) {
                if (min > sum) {
                    min = sum;
                }
            }
        }


    }

    if (min >= INF) {
        cout << -1 << endl;
    } else
        cout << min << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    while(true) {
        int W, D;
        cin >> W >> D;
        if(!W && !D) break;

        int ans = 0;
        map<int,int> v1, v2;
        for(int i = 0; i < W; ++i) {
            int h;
            cin >> h;
            v1[h]++;
        }

        for(int i = 0; i < D; ++i) {
            int h;
            cin >> h;
            if(v1[h] > 0) {
                --v1[h];
            }
            ans += h;
        }

        for(map<int,int>::iterator it = v1.begin(); it != v1.end(); ++it) {
            ans += it->first * it->second;
        }

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

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<stack>
#include<vector>
using namespace std;
int main()
{
	int a=0,b=0;
	scanf("%d %d",&a,&b);
	if(a+b>=10)
		printf("error");
	else
	printf("%d",a+b);
}

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

int main()
{
	cin>>s;
	int len=s.size();
	for(int i=0;i<=len;i++)
	{
		if(s[i]=='C')
		{
			for(int j=i;j<=len;j++)
			{
				if(s[j]=='F')
				{
					printf("Yes\n");
					return 0;
				}
			} 
		}
	}
	printf("No\n");
	return 0;
} 

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

int main() {
	int w,h,x,y;
	cin>>w>>h>>x>>y;
	double m = w*1.0*h*1.0/2.0;
	bool mul = x+x==w && y+y==h;
	cout<<m<<" "<<(mul?'1':'0')<<endl; 
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  int n;
  string s;
  s ="";
  cin >> n;
  for(int i= 0; i < n; i++){
    s+="ACL";
  }
  
  cout << s <<endl;
}


Measured memory_bytes: 3632