akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  for(int i=0; i<s.size(); i++) {
    s[i]+=n;
    if(s[i]>90)
      s[i]-=26;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll A,B,K;
    cin >> A >> B >> K;
    ll C[100];
    rep(i,100) C[i] = 0;
    ll cnt = 0;
    rep(i,A){
        if(A%(i+1)==0&&B%(i+1)==0){
            C[cnt] = i+1;
            cnt++;
        }
    }
    cout << C[cnt-K] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

const int limit = 2000;
int main() {
    int w;
    int c = 0;
    while (cin >> w && w) {
        c++;
        int n; cin >> n;
        int dp[limit] = {0};
        rep(i, n) {
            int v, ww; char ch;
            cin >> v >> ch >> ww;
            for (int i = 1000; i >= 0; --i) {
                if (dp[i]) chmax(dp[i + ww], dp[i] + v);
            }
            chmax(dp[ww], v);
        }
        int key = 0;
        rep(i, w + 1) if (dp[key] < dp[i]) key = i;
        cout << "Case " << c << ":" << endl;
        cout << dp[key] << endl << key << endl;
    }
    
}



Measured memory_bytes: 3060
unittest
{
	assert( [ "3 3", "1 2 1", "2 3 1", "1 3 2" ].parse.expand.solve == "Yes" );
	assert( [ "3 3", "1 2 1", "2 3 1", "1 3 5" ].parse.expand.solve == "No" );
	assert( [ "4 3", "2 1 1", "2 3 5", "3 4 2" ].parse.expand.solve == "Yes" );
	assert( [ "10 3", "8 7 100", "7 9 100", "9 8 100" ].parse.expand.solve == "No" );
	assert( [ "100 0" ].parse.expand.solve == "Yes" );
	
	assert( [ "5 4", "1 2 1", "3 4 2", "3 5 1", "4 5 1" ].parse.expand.solve == "No" );		// 追加ケース
}



import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto lrds = new long[][]( nm[ 1 ], 3 );
	foreach( ref lrd; lrds )
	{
		input.popFront;
		lrd = input.front.split.to!( long[] );
	}
	return tuple( nm[ 0 ], lrds );
}

auto solve( long n, long[][] lrds )
{
	// 辺配列を頂点基準に変換
	Tuple!( long, long )[][ long ] ess;
	foreach( lrd; lrds )
	{
		ess[ lrd[ 0 ] ] ~= tuple( lrd[ 1 ], +lrd[ 2 ] );
		ess[ lrd[ 1 ] ] ~= tuple( lrd[ 0 ], -lrd[ 2 ] );
	}
	
	// 島が複数ある可能性があるので全頂点対象でループ
	auto ps = new long[]( 1 + n );
	ps[] = long.max;
	DList!long queue;
	foreach( k; ess.keys )
	{
		if( ps[ k ] != long.max ) continue;
		
		// bfsで島一つ分の辺情報を整合性チェック
		ps[ k ] = 0;
		queue.insertBack( k );
		while( !queue.empty )
		{
			auto i = queue.front;
			queue.removeFront;
			foreach( e; ess[ i ] )
			{
				if( ps[ e[ 0 ] ] == long.max )
				{
					ps[ e[ 0 ] ] = ps[ i ] + e[ 1 ];
					queue.insertBack( e[ 0 ] );
				}
				else
				{
					if( ps[ e[ 0 ] ] != ps[ i ] + e[ 1 ] ) return "No";
				}
			}
		}
	}
	return "Yes";
}


Measured memory_bytes: 49916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

 
// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }
 

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    int n, m; cin >> n >> m;
    vector<pair<int, ll>> ab(n);
    for(int i=0; i<n; ++i) cin >> ab[i].first >> ab[i].second;
    sort(ab.begin(), ab.end());

    ll ans = 0;
    priority_queue<ll> pq;

    int cur = 0;
    for(int i=m-1; i>=0; --i){
        while(cur < n){
            pair<int, ll> job = ab[cur];
            if(i+job.first <= m) { pq.push(job.second); ++cur; }
            else break;
        }
        if(!pq.empty()){
            ans += pq.top(); pq.pop();
        }
    }

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

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

int main() {
  int s; cin >> s;
  vector<int> flag(1000000, 0);
  flag[s] = 1;
  bool f = false;
  int cnt = 1;
  while(!f) {
    cnt++;
    if (s%2 == 0) {
      if (flag[s/2] == 1) {
        f = true;
      } else {
        flag[s/2] = 1;
        s = s/2;
      }
    } else {
      if (flag[s*3+1] == 1) {
        f = true;
      } else {
        flag[s*3+1] = 1;
        s = s*3+1;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define req(i,n) for(int i = 1;i <= n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define fix  fixed << setprecision(10)
const int MOD = 1000000007;
const ll INF = (1LL << 60);
string s,t; ll n,m, q, ans = 0, sum;
bool f = true;
int main() {
    cin >> n;
    cout << fix << n * 2.0 * acos(-1) << endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

int main() {
#ifdef LOCAL
  freopen("c.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = min(a, b); i >= 1; i--) {
    if (a % i == 0 && b % i == 0) c--;
    if (!c) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d", &a, &b);
    
    if (a == b)
        printf("a == b\n");
    else if (a > b)
        printf("a > b\n");
    else
        printf("a < b\n");
        
    return 0;
}


Measured memory_bytes: 2144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <iostream>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N_ = 100500;

int N;
ll A[N_], pref[N_], suff[N_];

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


int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) {
		scanf("%lld", &A[i]);
	}

	if(N <= 2) {
		return 0 & puts(N == 2 ? "First" : "Second");
	}

	for(int step = 0; ; step += 1) {
		if(accumulate(A+1, A+N+1, -(ll)N) % 2 == 1) {
			return 0 & puts(step % 2 == 0 ? "First" : "Second");
		}

		for(int i = 1; i <= N; i++) {
			pref[i] = gcd(pref[i-1], A[i]);
		}
		for(int i = N; i > 0; i--) {
			suff[i] = gcd(suff[i+1], A[i]);
		}

		bool good = false;
		for(int i = 1; i <= N; i++) {
			ll cur = gcd(gcd(pref[i-1], suff[i+1]), A[i]-1);
			if(A[i] >= 2 && cur >= 2) {
				good = true;
				A[i] -= 1;
				for(int j = 1; j <= N; j++) A[j] /= cur;
				break;
			}
		}

		if(!good) {
			return 0 & puts(step % 2 == 1 ? "First" : "Second");
		}
	}
	return 0;
}


Measured memory_bytes: 2688
n = int(input())
List = list(map(int,input().split()))
A = []
B = []
List = sorted(List,reverse=True)
for i in range(len(List)):
  if i%2 == 0:
    A.append(List[i])
  else:
    B.append(List[i])
Answer = sum(A) - sum(B)
print(Answer)

Measured memory_bytes: 3064
n = int(input())
A = [int(input()) for _ in range(n)]

g = [[] for _ in range(n)]
for i, a in enumerate(A):
    g[a-1].append(i)

from collections import deque
q = deque([1])
visit = [-1]*n
visit[1] = 0
while q:
    v = q.popleft()
    for u in g[v]:
        if visit[u] == -1:
            visit[u] = visit[v]+1
            q.append(u)
if visit[0] == -1:
    print(-1)
else:
    print(visit[0])


Measured memory_bytes: 95536
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
    bool operator<(const mint a){
        return x < a.x;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<mint> a(n+1);
    rep(i,n+1) a[i] = i;
    vector<mint> left(n+2, 0), right(n+2, 0);
    rep(i,n+1) left[i+1] = left[i] + a[i];
    rep(i,n+1) right[i+1] = right[i] + a[n-i];
    mint ans = 0;
    for(int i = k; i <= n+1; i++){
        mint add = right[i] - left[i] + 1;
        if(add < 0) continue;
        ans += add;
    }
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 7884
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
typedef long long int ll;
typedef pair<int, int> pii;
int M[10][10];

int calc(int i, int j, int k, int l, int h){
  int ret = 0;
  for(int a = i+1; a < k; ++a){
    for(int b = j+1; b < l; ++b){
      if(M[a][b] >= h) return 0;
      ret += h - M[a][b];
    }
  }
  return ret;
}

int main() {
  int d, w;
  while(cin >> d >> w, d){
    int ans = 0;
    for(int i = 0; i < d; ++i){
      for(int j = 0; j < w; ++j){
	cin >> M[i][j];
      }
    }
    for(int i = 0; i < d-2; ++i){
      for(int j = 0; j < w-2; ++j){
	for(int k = i+2; k < d; ++k){
	  for(int l = j+2; l < w; ++l){
	    int h = 10;
	    for(int m = i; m <= k; ++m){
	      h = min(h,M[m][j]);
	      h = min(h,M[m][l]);
	    }
	    for(int m = j; m <= l; ++m){
	      h = min(h,M[i][m]);
	      h = min(h,M[k][m]);	      
	    }
	    //printf("%d, %d, %d, %d, %d\n",i,j,k,l,h);
	    ans = max(ans, calc(i,j,k,l,h));
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}
int main(){
	ll n, h;
	cin >> n >> h;
	vector<pair<ll, bool>>attack;
	for(int i = 0; i < n; i++){
		ll temp1, temp2;
		cin >> temp1 >> temp2;
		pair<ll, bool>temp_attack;
		temp_attack.first = temp1;
		temp_attack.second = true;
		attack.push_back(temp_attack);
		temp_attack.first = temp2;
		temp_attack.second = false;
		attack.push_back(temp_attack);
	}
	sort(attack.begin(), attack.end());
	reverse(attack.begin(), attack.end());
	ll ans = 0;
	ll sord_num = 0;
	for(int i = 0; i < attack.size() && h > 0; i++){
		if(attack[i].second == false){
			h -= attack[i].first;
			ans += 1;
		}else{
			while(h > 0){
				h -= attack[i].first;
				ans += 1;
			}
		}
	}
	cout << ans << endl;

}


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

using namespace std;

void printnumber(int p,int line){
}

int main(int argc,char* argv[]){
	long N,K,Q;
	cin >> N >> K >> Q;
	long point,human[N];
	for(int i=0;i<N;i++) human[i] = K;
	for(int i=0;i<Q;i++) {
		cin >> point;
		human[point-1] ++;
	}

	for(int i=0;i<N;i++) {
		if(human[i]>Q) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

int main()
{
    long long L, R;
    cin >> L >> R;

    L = L;
    R = min(R, L + 2019);
    long long m = 2018;
    for ( long long i = L; i < R; i++)
    {
        for ( long long  j = i + 1; j <= R; j++) {
             long long c = (i * j) % 2019;
            m = min(m , c);
        }
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
#define mp make_pair

/*int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

string s;

int main(){
    int n;
    map<string ,ll> m;
    cin >> n;
    ll ans =0;
    rep(i,n){
        cin >> s;
        sort(s.begin(),s.end());
        auto ite = m.find(s);//find()について等価なキーが見つかった場合は、見つかった要素のイテレータを返す。そうでない場合end()を返す。
        //map内部ではキーと値はpairになっているので　　mapの要素の型宣言はautoを用いる
        if(ite==m.end()){//end()について　最後の要素の次を参照するイテレータ
            m.insert(mp(s,1));
        }else{
            ans+=m[s];
            ++m[s];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

//Union-Find
const int MAX_N=1000000;
int par[MAX_N];//親
int Rank[MAX_N];//木の深さ
int size[MAX_N];//子と自身の合計数（自身が根の時には集合のサイズを表す）


void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        Rank[i]=0;
        size[i]=1;
    }
}

//木の根を求める
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)    return ;
    if(Rank[x]<Rank[y]){
        par[x]=y;
        size[y]+=size[x];
    }else{
        par[y]=x;
        size[x]+=size[y];
        if(Rank[x]==Rank[y])    Rank[x]++;
    }
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m),y(m),z(m);
    for(int i=0;i<m;i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    init(n);
    for(int i=0;i<m;i++){
        unite(x[i],y[i]);
    }
    set<int> st;
    for(int i=0;i<n;i++){
        if(st.count(find(i))==0){
            st.insert(find(i));
        }
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 14592
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Jun  3 20:58:42 2018
//
package main

import (
	"fmt"
)

var N int
var P []int

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

func main() {
	fmt.Scan(&N)
	P = make([]int, N+1)
	Q := make([]int, N+1)
	for i := 1; i < len(P); i++ {
		fmt.Scan(&P[i])
		Q[P[i]] = i
	}

	m := 0
	dp := make([]int, N+1)
	for i := 1; i < len(P); i++ {
		dp[i] = dp[Q[P[i]-1]] + 1
		if m < dp[i] {
			m = dp[i]
		}
	}

	fmt.Println(N - m)
}


Measured memory_bytes: 9344
#template
def inputlist(): return [int(k) for k in input().split()]
#template

N,M = inputlist()
li = []
for i in range(N):
    A,B = inputlist()
    B *= -1
    li.append([A,B])
ans = 0
from heapq import *
li.sort()
k = []
heapify(k)
flag = 0
for i in range(1,M+1):
    if flag == N:
        for t in range(M+1-i):
            ans -= heappop(k)
        break
    while li[flag][0] <= i:
        heappush(k,li[flag][1])
        flag = flag + 1
        if flag == N:
            break
    if len(k)>=1:
        ans -= heappop(k)
print(ans)

Measured memory_bytes: 20824
#create date: 2020-07-01 11:45

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    bon = [3]
    pon = [0, 1, 6, 8]
    if n % 10 in bon:
        print("bon")
    elif n % 10 in pon:
        print("pon")
    else:
        print("hon")
if __name__ == "__main__":
    main()

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll x, y, a, b, c;

	cin >> x >> y >> a >> b >> c;

	vector<ll> p(a);
	for ( ll& tmp : p ) {
		cin >> tmp;
	}
	sort(all(p));

	vector<ll> q(b);
	for ( ll& tmp : q ) {
		cin >> tmp;
	}
	sort(all(q));

	vector<ll> r(c);
	for ( ll& tmp : r ) {
		cin >> tmp;
	}
	sort(all(r));

	vector<ll> ans;
	copy(p.begin() + (a - x), p.end(), back_inserter(ans));
	copy(q.begin() + (b - y), q.end(), back_inserter(ans));
	copy(all(r), back_inserter(ans));
	sort(all(ans));
	reverse(all(ans));
	ans.resize(x + y);

	ll out = 0;
	for ( ll& tmp : ans ) {
		out += tmp;
	}
	cout << out << endl;

	return 0;
}


Measured memory_bytes: 8688
#include <stdio.h>
#include <string.h>
int main(void){
  char a[100],b[100],c[100];
  scanf("%s %s %s",a,b,c);
  if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0]){
    printf("YES");
  }else{
    printf("NO");
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e6+10;
ll n,a[N],prime[N],k,vis[N];//RE就开小一点
int flag=0;
bool isprime[N];
void Prime(){
    fill(isprime,isprime+N,1);
    k=0;
    prime[1]=0;
    for(ll i=2;i<N;i++){
        if(isprime[i]){
            prime[k++]=i;
            for(ll j=2;i*j<N;j++)
                isprime[i*j]=0;
        }
    }
}

//质因子分解找因子数
void solve(ll n){
    for(ll i=0;i<k&&prime[i]*prime[i]<=n;i++){
        if(n%prime[i]==0){
            if(vis[prime[i]]==0) vis[prime[i]]=1;
            else{
                flag=1;
                return;
            }
            while(n%prime[i]==0){
                n/=prime[i];
            }
        }
    }
    if(n>1){
         if(vis[n]==0) vis[n]=1;
        else{
            flag=1;
            return;
        }
    }
}

inline ll gcd(ll a,ll b)
{
    return (a%b==0)?b:gcd(b,a%b);
//    if(!b) return a;
//    else{
//        while(1){
//            ll t=a%b;
//            if(t==0) return b;
//            else{
//                a=b; b=t;
//            }
//        }
//    }
}

int main(){
    Prime();
    cin>>n;
    ll GCD=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(!flag) solve(a[i]);
        if(GCD==0) GCD=a[i];
        else GCD=gcd(GCD,a[i]);
    }
    if(!flag) printf("pairwise coprime");
    else if(flag&&GCD==1) printf("setwise coprime");
    else printf("not coprime");
}




Measured memory_bytes: 13844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
ll mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

int main() {
  int X,Y; cin>>X>>Y;
  if ((X+Y)%3 != 0) {
    cout << 0 << endl; return 0;
  }
  int n = (2*Y-X);
  int m = (2*X-Y);
  if (n%3 != 0 || m%3 != 0) {
    cout << 0 << endl; return 0;
  }
  n/=3;
  m/=3;
  if (n<0 || m<0) {
    cout << 0 << endl; return 0;
  }
  if (n<m) swap(n,m); // n is now greater
  mint ans=1;
  for (int i=0; i<m; i++) {
    ans = ans * (m+n-i);
  }
  mint denom = 1;
  rep(i, m) denom = denom * (i+1);
  ans = ans/denom;
  cout << ans.x << endl;
  return 0;
}

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

int main() {
  int A, B ,C;
  cin >> A >> B >> C;
  
  if((A + B + 1) >= C)
    cout << B + C << endl;
  else
    cout << B + (A + B + 1) << endl;
  
  return 0;
}

Measured memory_bytes: 256
/* Manish Pant - insider_pants, hello_my_friend */
    
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int N = 2e5 + 5;
vector<vector<int>> v(N);
vector<int> val(N);
vector<int> pre(N);
vector<int> ans(N);
vector<int> segtree(4 * N);
int n, c = 1;

void update(int x, int val, int node = 0, int l = 0, int r = c)
{
    if(l == r)
    {
        segtree[node] = max(segtree[node], val);
        return;
    }
    int mid = (l+r)>>1;
    if(x <= mid) update(x, val, 2*node+1, l, mid);
    else update(x, val, 2*node+2, mid+1, r);
 
    segtree[node] = max(segtree[2*node+1], segtree[2*node+2]);
}

void update2(int x, int val, int node = 0, int l = 0, int r = c)
{
    if(l == r)
    {
        segtree[node] = val;
        return;
    }
    int mid = (l+r)>>1;
    if(x <= mid) update2(x, val, 2 * node + 1, l, mid);
    else update2(x, val, 2*node+2, mid + 1, r);
 
    segtree[node] = max(segtree[2*node+1], segtree[2*node+2]);
}
 
int query(int x, int y, int node = 0, int l = 0, int r = c)
{
    if(l > y || r < x || x > y) return 0;
    if(l >= x && r <= y)
    {
        return segtree[node];
    }
    int mid = (l + r) >> 1;
    return max(query(x, y, 2 * node + 1, l, mid), query(x, y, 2 * node + 2, mid + 1, r));
}

void dfs(int a, int par)
{
    int temp = query(0, val[a] - 1);
    pre[a] = query(val[a], val[a]);
    update(val[a], temp + 1);
    ans[a] = query(0, c);

    for(int i:v[a])
    {
        if(i == par) continue;
        dfs(i, a);
    }

    update2(val[a], pre[a]);
}


void solve()
{
    map<int, int> m;
    for(int i = 1; i <= n; i++) m[val[i]] = 0;
    
    for(auto &i:m) i.S = c++;

    for(int i = 1; i <= n; i++) val[i] = m[val[i]];

    dfs(1, 0);

    for(int i = 1; i <= n; i++) cout << ans[i] << endl;
}

int main()
{
    fast();
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> val[i];
    for(int i = 1; i < n; i++)
    {
        int a, b; cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    solve();
}

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

int root(vector<int>& uft, int x){
  if(uft[x] == x){
    return x;
  }
  return uft[x] = root(uft, uft[x]);
}

void unite(vector<int>& uft, int a, int b){
  uft[root(uft, a)] = root(uft, b);
}

int main(){
  int N, M, K;
  cin >> N >> M >> K;

  vector<int> friend_cnt(N);
  vector<int> uft(N);
  for(int i = 0; i < N; i++){
    uft[i] = i;
  }
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    friend_cnt[a]++; friend_cnt[b]++;
    unite(uft, a, b);
  }

  vector<set<int>> blocks(N);
  for(int i = 0; i < K; i++){
    int c, d;
    cin >> c >> d;
    c--; d--;
    blocks[c].insert(d);
    blocks[d].insert(c);
  }

  for(int i = 0; i < N; i++){
    root(uft, i);
  }

  vector<int> group_sizes(N);
  for(int i = 0; i < N; i++){
    group_sizes[root(uft, i)]++;
  }

  for(int i = 0; i < N; i++){
    if(i){
      cout << ' ';
    }
    int ans = group_sizes[root(uft, i)] - 1 - friend_cnt[i];
    for(auto x: blocks[i]){
      if(root(uft, x) == root(uft, i)){
        ans--;
      }
    }
    cout << ans;
  }
  cout << endl;
  

}


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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);

int a[N];

int main()
{
    int r,d,x;

    cin>>r>>d>>x;

    for(int i=2001;i<=2010;i++){
        a[i]=r*x - d;
        cout<<a[i]<<endl;
        x=a[i];
    }

    return 0;
}


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

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

using pii = pair<int, int>;

inline void Main() {
  // code
  vector<pii> X(5);
  rep(i, 5) {
    int a, b;
    cin >> a;
    b = (a / 10 + (a % 10 == 0 ? 0 : 1)) * 10 - a;
    X.at(i) = make_pair(b, a);
  }
  sort(all(X));
  int R = 0;
  rep(i, 4) {
    R += X.at(i).first + X.at(i).second;
  }
  cout << R + X.at(4).second << endl;
}

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


Measured memory_bytes: 256
import math

number = 123


def trial_division(target):
    dest = int(math.sqrt(target))

    for i in range(2, dest):
        if target % i == 0:
            return False
    return True

n = int(input())
while True:
    if(trial_division(n)):
        print(n)
        exit()
    n+=1

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string S;
	int N,F=0;
	cin >> S;
	N = S.size();
	
	for (int i=0; i<N; i++){
		if ((S.at(i) == 'L') && (i%2 == 0)){
			F = 1;
			break;
		}
		if ((S.at(i) == 'R') && (i%2 == 1)){
			F = 1;
			break;
		}
	}
	
	if (F == 1){
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	
	
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  char s[11];
  scanf("%s",s);
  s[4]=s[5];
  s[5]=s[6];
  s[6]=s[8];
  s[7]=s[9];
  s[8]='\0';
  int x = atoi(s);
  if(x<=20190430){
    printf("Heisei");
  }else{
    printf("TBD");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll x,k,d;

int main() {
	cin>>x>>k>>d;
	x=x>0?x:-x;
	if ((double)x/k>=(double)d) {
		x-=k*d;
		cout<<x<<endl;
		return 0;
	}
	ll t=x/d;
	k-=t;
	x-=t*d;
	if (k&1) cout<<d-x<<endl;
	else cout<<x<<endl;
/*	while (k--) {
		if (x-d>=0) {
			x-=d;
		} else {
			++k;
			break;
		}
	}
	if (k==-1) cout<<x<<endl;
	else {
		if (k&1) cout<<d-x<<endl;
		else cout<<x<<endl;
	}*/
	return 0;
}

Measured memory_bytes: 3628
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

N = int(input())
T = [int(input()) for _ in range(N)]

Ans = T[0]
for i in range(1,N):
    Ans //= gcd(Ans,T[i])
    Ans *= T[i]

print(Ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  sort(s.begin() , s.end());
  sort(t.begin() , t.end(),greater<int>());
  if(string(t).compare(s) > 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	int n, ans = 0;
	cin >> n;
	vector<bool> flag(n, false);
	VI v(n);
	rep(i, n) {
		cin >> v[i];
		v[i]--;
	}

	rep(i, n) {
		if (flag[i]) continue;
		if (i == v[v[i]]) {
			ans++;
			flag[v[i]] = true;
			flag[i] = true;
		}
	}

	cout << ans << endl;

}




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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 640
N = int(input())
As = [int(c) for c in input().split()]
counter = 0


while True:
    for i in range(N):
        if As[i] % 2 != 0:
            break
        As[i] = int(As[i] / 2)
    else:
        counter += 1
        continue
    break

print(counter)

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 4) << ' ' << s.substr(4) << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    
    X = [x[i+1]-x[i] for i in range(n-1)]
    Y = [y[i+1]-y[i] for i in range(m-1)]
    
    mod = pow(10, 9)+7
    for i in range(n-1):
        X[i] = X[i]*(n-i-1)*(i+1)%mod
    
    sum_x = sum(X)%mod
    
    ans = 0
    for j in range(m-1):
        ans += sum_x*Y[j]*(m-j-1)*(j+1)%mod
        ans %= mod
    
    print(ans)
    
    
    
if __name__ == "__main__":
    main()


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



using namespace std;



long int f(long int c, long int o, long int n){

	if(c>n)

		return 0;

	long int t=c, t3=0, t5=0, t7=0;

	while(t>0){

		if(t%10 == 3) t3++;

		if(t%10 == 5) t5++;

		if(t%10 == 7) t7++;

		

		t = t/10;

	}

	if(t3 > 0 && t5 > 0 && t7 > 0){

		//cout << c << " 3: " << t3 << " 5: " << t5 << " 7: " << t7 << endl;

		return (1 + f(c+3*o, 10*o, n) + f(c+5*o, o*10, n) + f(c+7*o, 10*o, n));

	}

	return (f(c+3*o, 10*o, n) + f(c+5*o, o*10, n) + f(c+7*o, 10*o, n));

}



int main(){



	long int n;

	cin >> n;



	long int cvp = f(3, 10, n) + f(5, 10, n) + f(7, 10, n);

	cout << cvp << endl;



	return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int K;
    string S;
    cin >> K;
    cin >> S;

    if(S.size()<=K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }


    return 0;
    
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void Main()
{
	int n, m;
  	cin >> n >> m;
  	if(n>9 || m>9) {
		cout << "-1" << endl;
    }
 	else {
     	cout << n*m << endl;
    }
	return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

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


int main()
{
	int r; cin >> r;
	cout << r * r << endl;
}


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

const int N = 4010;
typedef long long ll;

int n, m, i, j, k;
int cr, cb, cg;
char str[N];
ll ans;

int main() {
  scanf("%d", &n);
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) {
    if (str[i] == 'R') {
      cr++;
    } else if (str[i] == 'B') {
      cb++;
    } else if (str[i] == 'G') {
      cg++;
    }
  }
  ans = 1ll * cr * cb * cg;
  for (int j = 1; j <= n; j++) {
    for (int i = j - 1; i >= 1 && j + j - i <= n; i--) {
      int k = j + j - i;  
      if (str[i] != str[j] && str[i] != str[k] && str[j] != str[k]) {
        ans--;
      }
    }
  }  
  printf("%lld\n", ans);
  return 0;  
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int a[100005];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n ;
    ll ans = 0;
    rep(i,n){
        int t;
        cin >> t;
        a[t]++;
        ans += t;
    }
    int q;
    cin >> q;
    rep(i,q){
        ll b,c;
        cin >> b >> c;
        ans -= a[b] * b;
        ans += a[b] * c;
        a[c] += a[b];
        a[b] = 0;
        cout << ans << endl;
    }
}

Measured memory_bytes: 4016
a,b = map(int,input().split())
s = input()

f=True
for i in range(len(s)):
	if i==a:
		if s[i]!='-':
			f=False
			break
	else:
		if s[i] not in '0123456789':
			f=False
			break

if len(s)!=a+b+1:
	f=False

print('Yes' if f else 'No')

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

int main() {
  string s, t;
  cin >> s >> t;
  string ans;
  ans = t + s;
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#define MOD 1000000007
using namespace std;

int num_path[8][3];
int H, W, K;

void make_path(int n, int* path){
  if (n == (W-1)) {
    for (int i=0; i<W; i++) {
      if (i>0 && path[i-1] == 1) {
        num_path[i][0]++;
      } else if (i<(W-1) && path[i] == 1) {
        num_path[i][2]++;
      } else {
        num_path[i][1]++;
      }
    }
    return;
  }
  path[n] = 0;
  make_path(n+1, path);
  if (n == 0 || n > 0 && path[n-1] == 0) {
    path[n] = 1;
    make_path(n+1, path);
  }
}

int main() {
  cin >> H >> W >> K;
  int path[7] = {};
  make_path(0, path);

  long long dp[H+1][W] = {};
  dp[0][0] = 1;
  for (int i=1; i<=H; i++) {
    for (int j=0; j<W; j++) {
      dp[i][j] = dp[i-1][j] * num_path[j][1];
      dp[i][j] %= MOD;
      if (j > 0) {
        dp[i][j] += dp[i-1][j-1] * num_path[j][0];
        dp[i][j] %= MOD;
      }
      if (j < W-1) {
        dp[i][j] += dp[i-1][j+1] * num_path[j][2];
        dp[i][j] %= MOD;
      }
    }
  }
  cout << dp[H][K-1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	char temp;
	int i, len;
	while (cin >> s)
	{
		len = s.length();
		for (i = 0; i < len / 2; i++)
		{
			temp = s[i];
			s[i] = s[len - 1 - i];
			s[len - 1 - i] = temp;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
int co=0,f=0,g=0,a,b,c,d;
cin>>a>>b>>c>>d;
while(a>0 && c>0){
    if(co%2==0){
      if(c>b)  c-=b;
      else{
          g=1;
          break;
      }
      co++;
    }
    else{
        co++;
        if(a>d) a-=d;
        else{
            f=1;
            break;
        }
    }
}
if(f==1 && g==0) cout<<"No"<<endl;
else if(f==0 && g==1) cout<<"Yes"<<endl;
return 0;
}

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

using namespace std;

#define pii pair < int, int >
#define pb push_back
#define fr first
#define sc second
#define mk make_pair

const int N = (int)300 * 300 + 7;
const int NN = (int)300 + 7;

pii ar[N];
int a[NN][NN];
int n, m, d;
vector < vector < int > > pref;

int dist(pii x, pii y) {
	return abs(x.fr - y.fr) + abs(x.sc - y.sc);
}

void calc(int x) {
	vector < int > pre;
	pre.pb(0);
	int cur = x; 
	while (cur <= n * m) {
		cur += d;
		if (cur > n * m) break;
		pre.pb(pre.back() + dist(ar[cur - d], ar[cur]));
	}
	pref.pb(pre);
}

int get(int l, int r) {
	int ost = l % d;
	if (ost == 0) ost = d;
	l -= ost;
	r -= ost;
	ost--;

	int lt = l / d;
	int rt = r / d;
	// cout << lt << ' ' << rt << endl;
	return pref[ost][rt] - pref[ost][lt];
}

main() {      
	scanf("%d %d %d", &n, &m, &d);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf("%d", &a[i][j]);
			ar[a[i][j]] = mk(i, j);
		}
	}
	for (int i = 1; i <= d; i++) {
		calc(i);
	}
	/*for (int i = 0; i < d; i++) {
		for (int j = 0; j < (int)pref[i].size(); j++) {
			cout << pref[i][j] << ' ';
		}
		cout << endl;
	}*/
	int q; scanf("%d", &q);
	while (q--) {
		int l, r; 
		scanf("%d %d", &l, &r);
		printf("%d\n", get(l, r));	
	}
}

Measured memory_bytes: 7604
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 2e5 + 5;
const int M = 17 + 5;
const int W = 1000 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

string s;
map<pair<int,string>,int> dp,vis;

int solve(int idx, string x) {

    if(idx==s.size()) return 0;

    int &ret = dp[mp(idx,x)];

    if(vis[mp(idx,x)]) return ret;
    
    vis[mp(idx,x)] = 1;

    ret = -OO;

    string c;
    c += s[idx];

    if(x!=c) ret = max(ret,1+solve(idx+1,c));

    if(idx<s.size()-1) {
        c += s[idx+1];
        if(x!=c) ret = max(ret,1+solve(idx+2,c));
    }

    return ret;

}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s;

    cout << solve(0,"") << '\n';

    return 0;
}

Measured memory_bytes: 99348
import Data.List.Split

main = do
  ns <- getNums
  let sorted = quickSort ns
  printList sorted

printList :: Show a => [a] -> IO ()
printList [] = putStrLn ""
printList (x:[]) = putStrLn $ show x
printList (x:xs) = putStr (show (x) ++ " ") >> printList xs

quickSort :: Ord a => [a] -> [a]
quickSort [] = []
quickSort (c:as) = quickSort smaller ++ c : quickSort bigger
  where
    smaller = [a | a <- as, a <  c]
    bigger  = [a | a <- as, a >= c]

getNums :: IO ([Int])
getNums = do
  s <- getLine
  return $ map read $ splitOn " " s



Measured memory_bytes: 3652
import java.util.Scanner;

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

        int n = stdIn.nextInt();
        int k = stdIn.nextInt();

        int counter = 1;
        while(n >= Math.pow(k, counter)){
            counter++;
        }

        System.out.println(counter);
    }
}

Measured memory_bytes: 21716
fun main() {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map { it.toInt() }
    var cnt = 0
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            for (k in j + 1 until n) {
                if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
                    if (check(l[i], l[j], l[k])) cnt++
                }
            }
        }
    }
    println(cnt)
}

fun check(a: Int, b: Int, c: Int): Boolean = when {
    a + b <= c -> {
        false
    }
    a + c <= b -> {
        false
    }
    b + c <= a -> {
        false
    }
    else -> true
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>a(m);
  int sum = 0;
  rep(i,m){
    cin >> a[i];
    sum += a[i];
  }
  cout << (n - sum>=0?n - sum:-1) << endl;
}


Measured memory_bytes: 3664
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1, r = x;
    while(n){
        if(n % 2) res = res * r % MOD;
        r = r * r % MOD;
        n /= 2;
    }
    return res;
}

template <typename S>   //semi group
struct UnionFind
{
    using F = function<S(S, S)>;
    
    const F f;
    
    vector<int> par, rank;
    vector<S> dat;
    
    UnionFind(int n, const F f = [](S a, S b){return a + b;}) : f(f){
        par.resize(n);
        rank.resize(n);
        dat.assign(n, 1);
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int find(int i){
        if(i == par[i]) return i;
        return par[i] = find(par[i]);
    }
    
    bool same(int i, int j){
        return find(i) == find(j);
    }
    
    void unite(int i, int j){
        if(same(i, j)) return;
        i = find(i), j = find(j);
        if(rank[i] < rank[j]){
            par[i] = j;
            dat[j] = f(dat[i], dat[j]);
        }
        else{
            par[j] = i;
            dat[i] = f(dat[i], dat[j]);
            if(rank[i] == rank[j]) rank[i]++;
        }
    }
    
    S query(int i){
        return dat[find(i)];
    }
};

ll dp[5002][5002];

int main()
{
    int n;
    cin >> n;
    int p[5004];
    UnionFind<ll> uf(n);
    int k = 0;
    int l = 0;
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
        if(p[i] == -2) k++;
        else if(!uf.same(i, p[i])) uf.unite(i, p[i]);
        else l++;
    }
    ll ans = (n - l) * modpow(n - 1, k) % MOD;
    vector<int> v;
    for(int i = 0; i < n; i++) if(p[i] == -2) v.push_back(uf.query(i));
    dp[0][0] = 1;
    for(int i = 1; i <= k; i++){
        for(int j = 0; j <= i; j++){
            dp[i][j] = dp[i - 1][j];
            if(j) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] * v[i - 1] % MOD) % MOD;
        }
    }
    ll f[5002];
    f[0] = 1;
    for(int i = 1; i <= k; i++) f[i] = f[i - 1] * i % MOD;
    for(int i = 0; i < n; i++){
        if(p[i] == -2){
            ans = (ans + MOD - (uf.query(i) - 1) * modpow(n - 1, k - 1) % MOD) % MOD;
        }
    }
    for(int i = 2; i <= k; i++){
        ans = (ans + MOD - dp[k][i] * f[i - 1] % MOD * modpow(n - 1, k - i) % MOD) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 120320
#include <stdio.h>
#include <math.h>

int main()
{
  int i, j, N, x[8], y[8], k;
  double d[28], avg;
  k = scanf("%d", &N);
  for ( i=0;i<N;i++ )
    k = scanf("%d %d",&(x[i]), &(y[i]));
  k = 0;
  for ( i=0;i<N-1;i++ ) {
    for ( j=i+1;j<N;j++ ) {
      d[k] = sqrt( (double)((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])) );
      k++;
    }
  }
  avg = d[0];
  for ( i=1;i<k;i++ )
    avg += d[i];
  avg = (avg + avg) / (double)N;
  printf("%lf", avg);
}

Measured memory_bytes: 128