akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A[3]; for (int& a : A) cin >> a;
    sort(begin(A), end(A));
    int S = A[1] - A[0], T = A[2] - A[1];
    if ((A[0] | A[1] | A[2]) & 1) cout << 0 << endl;
    else if (S == 0 && T == 0) cout << -1 << endl;
    else if (S == 0) cout << __builtin_ctz(T) << endl;
    else if (T == 0) cout << __builtin_ctz(S) << endl;
    else cout << min(__builtin_ctz(T), __builtin_ctz(S)) << endl;
    return 0;
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll K, N; cin >> K >> N;
    ll max_dis = 0;
    vector<ll> v;
    REP(i, N) {
        ll tmp; cin >> tmp;
        v.push_back(tmp);
    }
    REP(i, N) {
        ll dist;
        if (i == 0) {
            dist = v[0] + K - v[N-1];
        }
        else dist = v[i] - v[i-1];
        max_dis = max(max_dis, dist);
    }
    cout << K - max_dis << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


signed main() {
	// your code goes here
	string s,t;
	cin>>s>>t;
	string ans=t+s;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,m,w;
	scanf("%d %d",&n,&m);
	w=n+m;
	if(w==0) printf("0\n");
	else if(w<0) printf("-1\n");
	else printf("1\n");
	return 0;
}

Measured memory_bytes: 2628
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int X; cin>>X;
	ll ans = 1;
	while(X * ans %360 != 0){
		++ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  int N, K;
  vector<int> H;

  cin >> N >> K;

  H.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  sort(H.begin(), H.end(), greater<int>());

  int64_t attack_num = 0;

  for (int i = 0; i < N; i++) {
    if (K > 0) {
      K--;
    }
    else {
      attack_num += H[i];
    }
  }

  cout << attack_num << endl;

  return 0;
}


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

int main() {
    int N, C, K;
    cin >> N >> C >> K;
    int T[N];
    rep(i, N) { cin >> T[i]; }
    sort(T, T + N);
    int ans = 1;
    int total = 1;
    int t = T[0];
    for (int i = 1; i < N; i++) {
        if (T[i] <= t + K && total < C) {
            total++;
        } else {
            ans++;
            total = 1;
            t = T[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4032
#include <stdio.h>
int main() {
	int x;
	scanf("%d", &x);
	int ri = 100,
		sa = 101,
		cu = 102,
		cak = 103,
		can = 104,
		pc = 105;
	int anc = 0;
	int sum;
	switch (x % 10)
	{
	case 0:
		for (int i = 0; i < 1000; i++) {
			for (int j = 0; j < 1000; j += 2) {
				sum = ri * i + pc * j;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	case 1:
		for (int i = 0; i < 1000; i++) {
			for (int j = 0; j < 1000; j += 2) {
				sum = ri * i + pc * j + sa;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	case 2:
		for (int i = 0; i < 1000; i++) {
			for (int j = 0; j < 1000; j += 2) {
				sum = ri * i + pc * j + cu;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	case 3:
		for (int i = 0; i < 1000; i++) {
			for (int j = 0; j < 1000; j += 2) {
				sum = ri * i + pc * j + cak;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	case 4:
		for (int i = 0; i < 1000; i++) {
			for (int j = 0; j < 1000; j += 2) {
				sum = ri * i + pc * j + can;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	case 5:
		for (int i = 0; i < 1000; i++) {
			for (int j = 1; j < 1000; j += 2) {
				sum = ri * i + pc * j;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	case 6:
		for (int i = 0; i < 1000; i++) {
			for (int j = 0; j < 1000; j += 2) {
				sum = ri * i + pc * j + cak * 2;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	case 7:
		for (int i = 0; i < 1000; i++) {
			for (int j = 0; j < 1000; j += 2) {
				sum = ri * i + pc * j + cak + can;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	case 8:
		for (int i = 0; i < 1000; i++) {
			for (int j = 0; j < 1000; j += 2) {
				sum = ri * i + pc * j + can * 2;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	case 9:
		for (int i = 0; i < 1000; i++) {
			for (int j = 0; j < 999; j += 2) {
				sum = ri * i + pc * j + can + pc;
				if (x == sum) {
					anc = 1;
					break;
				}
			}
			if (anc == 1)break;
		}
		break;
	default:
		break;
	}
	printf("%d", anc);
}

Measured memory_bytes: 128
import bisect as bs
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(len(L)-1):
    for j in range(i+1, len(L)):
        ans += bs.bisect_left(L, L[i]+L[j])-j-1
print(ans)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N; cin >> N;
    unordered_map<string, int> um;
    rep(i, N){
        string s; cin >> s;
        um[s]++;
    }

    int res=0;
    for(auto a: um){
        res++;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  bool flg = true;

  if (s[0] != 'A') flg = false;
  int cnt = 0;
  REP(i, 2, s.size() - 1) if (s[i] == 'C') cnt++;
  if (cnt != 1) flg = false;
  cnt = 0;
  rep(i, s.size()) if ('a' <= s[i] && s[i] <= 'z') cnt++;
  if (cnt + 2 != s.size()) flg = false;

  cout << (flg ? "AC" : "WA") << endl;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, k;
    cin >> n >> k;

    vector<double> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        v[i] = (v[i] + 1.0) / 2.0;
    }
    long double ans = 0, cur = 0;
    for (int i = 0; i < k; i++)cur += v[i];
    ans = max(ans, cur);
    for (int i = 0, j = k; j < n; i++, j++) {
        cur += v[j];
        cur -= v[i];
        ans = max(ans, cur);
    }
    cout << fixed << setprecision(10) << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

bool dfs(vector<int> A){
	int c = 0;
	for(int i=0;i<A.size();i++){
		c += (A[i]-1)%2;
		c%=2;
	}
	
	if(c==1)return true;
	c += A.size();
	c %= 2;
	if(c==0)return false;
	
	int ind = -1;
	for(int i=0;i<A.size();i++){
		if(A[i]%2==1){
			if(A[i]==1)return false;
			if(ind!=-1)return false;
			ind = i;
			A[i]--;
		}
	}
	int g = 0;
	for(int i=0;i<A.size();i++)g = gcd(A[i],g);
	for(int i=0;i<A.size();i++)A[i]/=g;
	
	if(dfs(A))return false;
	return true;
}

bool dfs2(vector<int> A){
	int c = A[0]+A[1]-2;
	c %= 2;
	if(c==1)return true;
	return false;
}

int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	
	if(N==1)cout<<"Second"<<endl;
	else if(N==2){
		if(dfs2(A))cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	}
	else{
		if(dfs(A))cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D,x,y;
scanf("%d%d%d%d",&A,&B,&C,&D);
x=A*B;
y=C*D;
if(x>y)
printf("%d",x);
else if(x<y)
printf("%d",y);
else
printf("%d",x);

}

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

int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    ans += a - 1;
  }
  cout << ans << endl;
  return 0;
}

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

typedef vector<int> vi;
typedef long long int ll;
typedef pair<int,int> ii;
typedef vector<ii > vii;
typedef vector<vi > vvi;
typedef pair<ll, ll> pll;
typedef vector<pll > vll;
// Please.. please be patient.. This is just a template
// Ignore my naming convention...

set<char> thin, fat;
void init() {
	char i = 'a';
	for(; i <= 'z'; i++) {
		thin.insert(i);
	}
}


string s;
int i, j, n, m, k, l;
vector<char> afs;
int main() {
	init();
	cin >> s;
	for(auto e: s) {
		fat.insert(e);
	}
	for(auto e: thin) {
		if(!fat.count(e)) {
			afs.push_back(e);
		}
	}
	if(afs.size() == 0) {
		puts("None");
		return 0;
	}
	sort(afs.begin(), afs.end());
	cout << afs[0] << endl;
}

Measured memory_bytes: 512
#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() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  for (int r = k; r < n; r++) {
    int l = r-k;
    if (a[l] < a[r]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  long ans = 0, a;
  for(int i = 1; i <= S.size(); i++) {
    for(int j = 0; j < S.size() - i + 1; j++) {
      a = S.size() - 1 - i;
      if(j == 0 || j == S.size() - i)ans += stol(S.substr(j, i)) * pow(2, max(a, 0L));
      else ans += stol(S.substr(j, i)) * pow(2, max(a - 1, 0L));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef long double ld;
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define rep(i, a, b) for (ll i = a; i < (b); ++i)
#define reb(i, a, b) for (ll i = a; i >= (b); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
ll vis[100005]={},n1;
ll dis[100005]={};
void dfs(vi adj[] ,ll u)
{
   vis[u] = 1;
   for(auto v:adj[u])
   {
      if(!vis[v])
         dfs(adj, v);
      dis[u] = max(dis[u], dis[v] + 1);
      // rep(i,1,n1+1)
      // {
      //    cout << dis[i] << "* ";
      // }
      // cout <<u <<endl;
   }
}
int main()
{
// #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
// #endif
   ll n, m,u,v,ans=-1;
   cin >> n >> m;
   n1 = n;
   vi adj[n + 1];
   rep(i,0,m)
   {
      cin >> u >> v;
      adj[u].pb(v);
   }
   rep(i,1,n+1)
   {
      if(!vis[i])
         dfs(adj, i);
   }
   rep(i,1,n+1)
   {
      ans = max(ans, dis[i]);
   }
   cout << ans << endl;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<ll> dis;
vector<vector<pair<int, ll>>> nei;
deque<int> stk;

int main()
{
    int n;
    cin>>n;
    dis.resize(n, 0ll);
    nei.resize(n);
    REP(i,n-1) {
        int u, v;
        ll w;
        cin>>u>>v>>w;
        nei[u-1].push_back(make_pair(v-1, w));
        nei[v-1].push_back(make_pair(u-1, w));
    }
    stk.push_back(0);
    while (!stk.empty()) {
        int ti = stk.back();
        stk.pop_back();
        REPALL(i,nei[ti]) {
            pair<int, ll> tp(nei[ti][i]);
            if (tp.first != 0 && dis[tp.first] == 0) {
                dis[tp.first] = dis[ti] + tp.second;
                stk.push_back(tp.first);
            }
        }
    }
    REP(i,n) {
        cout<<dis[i] % 2<<endl;
    }

    return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
int main(){
string text;
cin >> text;
bool flag=false;
int p=text.size();
  for(int i=0;i<p;i++){
  for(int j=i+1;j<p;j++){
  char a=text.at(i);
  char b=text.at(j);
  if(a==b)flag=true;
  }}
  if(flag)cout << "no" <<endl;
  else cout << "yes" <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> i_i;
int MOD = 1000000007;

ll F[1001], C[1001][1001], unko[1001][1001], pw[1001][1001];

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

vector<vector<int> > f(int N, ll x) {
	vector<vector<int> > dp(N + 1);
	for (int n = 1; n <= N; n++) {
		dp[n] = vector<int>(N / n + 1);
		dp[n][0] = 1;
	}
	for (int k = 1; k <= N; k++) {
		int d = gcd(k, x), n = k / d;
		for (int i = N / n; i >= 0; i--)
			for (int j = 1; j * d <= i; j++)
				dp[n][i] = (dp[n][i] + dp[n][i - j * d] * C[i * n][j * k] % MOD * unko[k][j * k]) % MOD;
	}
	return dp;
}

vector<vector<int> > g(int N, ll x) {
	vector<vector<int> > dp(N + 1);
	for (int n = 1; n <= N; n++) {
		dp[n] = vector<int>(N / n + 1);
		dp[n][0] = 1;
	}
	for (int k = 1; k <= N; k++) {
		int d = gcd(k, x), n = k / d;
		for (int i = N / n; i >= 0; i--)
			for (int j = 1; j * d <= i; j++)
				dp[n][i] = (dp[n][i] + dp[n][i - j * d] * C[i][j * d] % MOD * unko[d][j * d] % MOD * pw[n][j * (d - 1)]) % MOD;
		/*for (int i = 0; i <= N; i++)
			cout << dp[1][i] << ' ';
		cout << endl;*/
	}
	return dp;
}

int main() {
	F[0] = 1;
	for (int i = 1; i <= 1000; i++)
		F[i] = F[i - 1] * i % MOD;
	for (int i = 0; i <= 1000; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}
	for (int i = 1; i <= 1000; i++) {
		unko[i][0] = 1;
		for (int j = 1; j <= 1000; j++)
			unko[i][j] = unko[i][j - 1] * (j % i ? j : 1) % MOD;
	}
	for (int i = 1; i <= 1000; i++) {
		pw[i][0] = 1;
		for (int j = 1; j <= 1000; j++)
			pw[i][j] = pw[i][j - 1] * i % MOD;
	}
	int N; ll X, Y, Z;
	cin >> N >> X >> Y >> Z;
	vector<vector<int> > a = f(N, 2), b = g(N, abs(X - Y + Z));
	/*for (int n = 1; n <= N; n++) {
		for (int i = 0; i < b[n].size(); i++)
			cout << b[n][i] << ' ';
		cout << endl;
	}*/
	if (!X && !Y && !Z) {
		int ans = a[1][N];
		for (int t = 0; t < N; t++)
			ans = (ll)ans * N % MOD;
		cout << ans << endl;
		return 0;
	}
	vector<int> dp(N + 1);
	dp[0] = 1;
	for (int n = 1; n <= N; n++)
		for (int j = N; j >= 0; j--)
			for (int i = 1; i * n <= j; i++)
				dp[j] = (dp[j] + (ll)dp[j - i * n] * C[j][i * n] % MOD * a[n][i] % MOD * b[n][i]) % MOD;
	cout << dp[N] << endl;
}

Measured memory_bytes: 24848
#include <iostream>

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		int W, H;
		cin >> W >> H;
		char Field[100][100] = {0};
		for(int i = 0; i < N; ++i)
		{
			int x, y;
			cin >> x >> y;
			Field[y - 1][x - 1] = 1;
		}		
		int ans = 0;
		int S, T;
		cin >> S >> T;
		for(int i = 0; i <= H - T; ++i)
		{
			for(int j = 0; j <= W - S; ++j)
			{
				int t = 0;
				for(int k = 0; k < T; ++k)
				{
					for(int l = 0; l < S; ++l)
					{
						t += Field[i + k][j + l];
					}
				}
				if(ans < t)
				{
					ans = t;
				}
			}
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
def main():
    n=int(input())
    def yakusuu(a):
        yakusuu=set()
        for i in range(1,int(a**0.5)+1):
            if a%i==0:
                yakusuu.add(i)
                yakusuu.add(a//i)
        yakusuu=sorted(list(yakusuu))
        return yakusuu
    y=yakusuu(n)
    print(min([i+(n//i)-2 for i in y]))
        
main()

Measured memory_bytes: 3828
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

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

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

template <typename T>
void printArr(const T * arr, int s, int fn) {
    for (int i = s; i <= fn; ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <typename T>
long long minArr(const T * arr, int s, int fn) {
    ll res = 1e16 + 1;
    for (int i = s; i <= fn; ++ i) {
        res = min(res, arr[i]);
    }
    return res;
}

template <typename T>
void printVec(const T * arr) {
    for (int i = 0; i < sz(arr); ++ i) cout << arr[i] << " ";
    cout << '\n';
}

template <class T>
bool uax(T&a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool uin (T&a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 1e5 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);



int main () {
    to_pray();

    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b));

    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cout << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int sum(int n){
  int a = 0;
  while(n > 0){
    a += n%10;
    n /= 10;
  }
  return a;
}
int main() {
  int N, A, B;
  int t = 0;
  cin >> N >> A >> B;
  for(int i = 1; i <= N; i++)
    if ((A <= sum(i)) && (B >= sum(i)))
        t += i;
  cout << t;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;

int main(){
	int N,K;
	cin >> N >> K;
	long long ans = K;
	rep(i,N-1) ans *= K-1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 100000
using namespace std;
typedef long long LL;
vector<int> turns[MAXN+5];//用vector来记录每一个循环
LL k;
int n,m,tcnt=0,chs[MAXN+5],id[MAXN+5],id2[MAXN+5];
//id存的是单次操作之后的状态,id2存的是k次操作之后的操作
LL x[MAXN+5],a[MAXN+5];
LL a2[MAXN+5],x2[MAXN+5];
//a2是之后的差分序列，x2是之后的兔子位置
bool vis[MAXN+5];
int main()
{
//	freopen("rabbit.in","r",stdin);
//	freopen("rabbit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&x[i]),id[i]=i;
	for(int i=1;i<=n;i++)
		a[i]=x[i]-x[i-1];
	scanf("%d %lld",&m,&k);
	for(int i=1;i<=m;i++)
		scanf("%d",&chs[i]),swap(id[chs[i]],id[chs[i]+1]);
	for(int i=1;i<=n;i++)
	{
		int p=i;
		if(vis[p]==true)
			continue;
		tcnt++;
		while(vis[p]==false)
		{
			vis[p]=true;
			turns[tcnt].push_back(p);
			p=id[p];
		}
	}
	for(int i=1;i<=tcnt;i++)
	{
		int T=(int)turns[i].size();//对于每一个循环单独计算
		int pos=k%T;
		//处理出开头位置所对应的最终位置，然后向后挪到来求出这个循环里的其他元素所对应的答案
		for(int j=0,p=pos;j<(int)turns[i].size();j++,p=(p+1)%T)
			id2[turns[i][j]]=turns[i][p];
	}
	for(int i=1;i<=n;i++)
		a2[i]=a[id2[i]];
	for(int i=1;i<=n;i++)
		x2[i]=x2[i-1]+a2[i];
	for(int i=1;i<=n;i++)
		printf("%lld.0\n",x2[i]);//因为题目要求，强行加一个.0
	return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    ll num = n;
    int sum = 0;
    while (num > 0)
    {
        sum += num % 10;
        num /= 10;
        // cout << num << endl;
    }
    // cout << sum << endl;

    if (n % sum == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    for (int i = 0; i < a - 1; i++) {
      cout << b;
    }
    cout << b << endl;
  } else {
    for (int i = 0; i < b - 1; i++) {
      cout << a;
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int d, i, x;
	scanf("%d", &d);
	i = 1;
	while (i <= d) {
		x = i;
		if (x % 3 == 0) printf(" %d", i);
		else if (x % 10 == 3) printf(" %d", i);
		else {
			while (x /= 10) {
				if (x % 10 == 3) {
					printf(" %d", i);
					break;
				}
			}
		}
		i ++;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
n=int(input())
s=list(input())
ans="No"
if n%2==1:
  print(ans)
  exit()
form=[s[i] for i in range(n//2)]
latt=[s[i+n//2] for i in range(n//2)]
if form==latt:
  ans="Yes"
print(ans)  

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> as(3 * N, 0);
    rep(i, 3 * N){
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    ll sum = 0;
    for(int i = N + 1; i < 3 * N; i += 2){
        sum += as[i - 1];
    }
    cout << sum << endl;

    return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

  vi a(n);
  rep(i, 0, n) cin >> a[i];

  multiset<int> st; 
  st.insert(inf);

  rep(i, 0, n){
    auto x = st.lower_bound(a[i]);
    if(x != st.begin()){
      st.erase(--x);
    }
    st.insert(a[i]);
  }

//  for(int i : st) cout << i << endl;
  cout << st.size()-1 << endl;

  return 0;
}


Measured memory_bytes: 5760
n = int(input())
S = [input() for i in range(n)]

import collections
c = collections.Counter(S)
c = c.most_common()

ans = [c[0][0]]

for i in range(len(c)-1):
    if c[i][1] == c[i+1][1]:
        ans.append(c[i+1][0])
    else:
        break
        
ans = sorted(ans)
        
print("\n".join(ans))

Measured memory_bytes: 45064
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        int e = scanner.nextInt();
        System.out.println(e - a <= scanner.nextInt() ? "Yay!" : ":(");
    }
}

Measured memory_bytes: 21844
n=int(input())
for i in range(n):
    x=list(map(float,input().split()))
    if x[0]**2+x[1]**2==x[2]**2:
        print("YES")
    elif x[1]**2+x[2]**2==x[0]**2:
        print("YES")
    elif x[2]**2+x[0]**2==x[1]**2:
        print("YES")
    else:
        print("NO")


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



int main(){
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	sort(p.begin(), p.end());
	int ans = 0;
	rep(i,k){
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
from collections import deque

move = ((0,1),(1,0),(0,-1),(-1,0))

def inmap(x,y):
    if 0 <= x <= Lx-1 and 0<= y <= Ly-1:
        return True
    return False

while True:
    Lx,Ly = map(int,input().split())
    if Lx == 0:
        break
    curx= -1
    cury = -1
    orimap = [[] for _ in range(Ly)]
    for i in range(Ly):
        for j in input():
            orimap[i].append(j)
    for y in range(len(orimap)):
        for x in range(len(orimap[y])):
            if orimap[y][x] == "@":
                curx,cury = x,y
                orimap[y][x]="#"
                break
        if curx != -1:
            break
    Q = deque()
    Q.append([curx,cury])
    count = 1
    while len(Q)>0:
        curx,cury = Q.popleft()
        for dx,dy in move:
            nextx = curx + dx
            nexty = cury + dy
            if inmap(nextx,nexty):
                if orimap[nexty][nextx] != "#":
                    orimap[nexty][nextx] = "#"
                    Q.append([nextx,nexty])
                    count += 1
    print(count)



Measured memory_bytes: 6012
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
  string s;
  cin >> s;
  
  int ans = 999;
  for(unsigned int i = 0; i < s.length() - 2; ++i)
  {
    int num = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 +(s[i+2] - '0'); 
    ans = min(ans, abs(753 - num));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<iostream>

using namespace std;

int main(void)
{
  int r; cin>>r;
  
  if(r<2800){
    if(r<1200){
      puts("ABC");
    }else{
      puts("ARC");
    }
  }else{
    puts("AGC");
  }
  
  return 0;
}

Measured memory_bytes: 256
// finish date: 2018/03/16

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int I, O, T, J, L, S, Z;
    cin >> I >> O >> T >> J >> L >> S >> Z;
    ll K = 0;
    K += O * 2;
    K += (I / 2) * 4;
    K += (J / 2) * 4;
    K += (L / 2) * 4;

    if ((I&&J&&L)&&((I % 2 == 1 && J % 2 == 1) || (J % 2 == 1 && L % 2 == 1) || (L % 2 == 1 && I % 2 == 1))) {
        K += 6;
        if ((I != 0 && I % 2 == 0) || (J != 0 && J % 2 == 0) || (L != 0 && L % 2 == 0)) K -= 4;
    }

    cout << K / 2 << endl;


    return 0;
}

Measured memory_bytes: 256
N=int(input())
ans=''
for i in range(1,99):
    if N<=26**i:
        N-=1 #０インデックス使う方がやりやすい？から−１してるそのままなら下のchr(ord('a'))を一つ前の文字にすればいい
        for j in range(i):
            ans+=chr(ord('a')+N%26)
            N//=26
        break
    else:
        N-=26**i
print(ans[::-1])

Measured memory_bytes: 9064
#ifndef ___Geometry_Library
#define ___Geometry_Library

// ------ Includes ------ //
#include <cmath>
#include <complex>
#include <utility>
#include <algorithm>

// ------ Defines ------ //
typedef long double GType;
typedef std::complex<GType> Point;
typedef std::pair<Point, Point> Segment;

// ------ Constants ------ //
const GType EPS = 1.0e-10L;

// ------ Functions Level 1 ------ //
GType dot(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).real();
}
GType cross(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).imag();
}
int ccw(const Point& p1, const Point& p2, const Point& p3) {
	Point v1 = p2 - p1, v2 = p3 - p1;
	if (cross(v1, v2) > EPS) return +1;
	if (cross(v1, v2) < -EPS) return -1;
	if (dot(v1, v2) < -EPS) return +2;
	if (std::norm(v1) < std::norm(v2)) return -2;
	return 0;
}

// ------ Functions Level 2 ------ //
bool intersect(const Segment& s1, const Point& p1, bool segflag) {
	if (!segflag) return std::abs(cross(s1.second - p1, s1.first - p1)) < EPS;
	return (std::abs(s1.first - p1) + std::abs(s1.second - p1) - std::abs(s1.second - s1.first)) < EPS;
}
bool intersect(const Segment& s1, const Segment& s2, bool segflag) {
	if (!segflag) return cross(s1.second - s1.first, s2.first - s1.first) * cross(s1.second - s1.first, s2.second - s1.first) < EPS;
	return (ccw(s1.first, s1.second, s2.first) * ccw(s1.first, s1.second, s2.second)) <= 0 && (ccw(s2.first, s2.second, s1.first) * ccw(s2.first, s2.second, s1.second)) <= 0;
}
Point projection(const Segment& s1, const Point& p1) {
	GType mul = dot(p1 - s1.first, s1.first - s1.second) / norm(s1.first - s1.second);
	return s1.first + (s1.first - s1.second) * mul;
}
Point reflection(const Segment& s1, const Point& p1) {
	return p1 + (projection(s1, p1) - p1) * (GType)(2);
}

#endif

#include <iomanip>
#include <iostream>
using namespace std;
int q, xa, ya, xb, yb; Segment s; Point p1, p2;
int main() {
	cin >> xa >> ya >> xb >> yb; s = make_pair(Point(xa, ya), Point(xb, yb));
	cin >> q;
	while (q--) {
		cin >> xa >> ya; p1 = Point(xa, ya);
		p2 = reflection(s, p1);
		cout << fixed << setprecision(15) << p2.real() << ' ' << p2.imag() << endl;
	}
	return 0;
}

Measured memory_bytes: 3372
#include <iostream>
#include<cmath>
using namespace std;
long long int T,rs=0,sh;
int shu[3]={3,5,7};
bool g=0;int v[3]={0,0,0};
void cdt(int a,int b,long long int c)
{
	if(b==a)
	{
		if(c<=T)
			rs++;
		else
			g=1;
	}
	else
	{
		if(sh>=a-b)
		{
			for(int i=0;i<3;i++)
			{
				if(v[i]==0)
				{
					sh--;v[i]++;
					cdt(a,b+1,c+shu[i]*pow(10.0,a-b-1));
					sh++;v[i]--;
				}
				if(g)break;
			}
		}
		else
		{
			for(int i=0;i<3;i++)
			{
				if(v[i]==0){sh--;}
				v[i]++;
				cdt(a,b+1,c+shu[i]*pow(10.0,a-b-1));
				if(v[i]==1){sh++;}
				v[i]--;
				if(g)break;
			}
		}
	}
}
int main()
{
	cin>>T;
	for (int i=3;;i++)
	{	
		sh=3;
		cdt(i,0,0);
		if(g)break;
	}
	cout<<rs;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  
  rep(i,N) cin >> A[i];
  sort(A.begin(),A.end(),greater<int>());
  
  int M = A[0];
  int G = A[0];
  rep(i,N-1) G = gcd(G,A[i+1]);
  
  if(K%G == 0 && K <= M) cout << "POSSIBLE" <<endl;
  else cout << "IMPOSSIBLE" <<endl;

}
  



Measured memory_bytes: 640
def resolve():
    N, A, B = [int(i) for i in input().split()]
    S = input()
    ac = 0
    abc = 0
    for s in S:
        flg = False
        if s == "a":
            if ac < A + B:
                flg = True
                ac += 1
        elif s == "b":
            if ac < A + B and abc < B:
                flg = True
                ac += 1
                abc += 1
        else:
            pass

        if flg:
            print("Yes")
        else:
            print("No")


resolve()


Measured memory_bytes: 4016
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;
char s[205],ss[105];
int k[205];
int main()
{
    int n;
    scanf("%d%s",&n,ss);
    int cnt=1,co=0,t=0;
    for(int i=1;i<205;++i) k[i]=1;
    for(int i=0;i<n;++i)
    {
        if(ss[i]=='(')
        {
            ++co;
            s[cnt++]='(';
            //t=cnt++;
        }else
        {
            if(co==0)
                ++k[0];
            else
                --co;
            s[cnt++]=')';
        }
    }
    while(co--)
    {
        s[cnt++]=')';
    }
    s[0]='(';
    for(int i=0;i<cnt;++i)
    {
        while(k[i]--) putchar(s[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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 a,b,c,d; cin>>a>>b>>c>>d;
    if(abs(a-b)<=d && abs(b-c)<=d) cout<<"Yes"<<endl;
    else if(abs(a-c)<=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
info = int(input())
all = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

for _ in range(info):
    build, floor, room, num = map(int, input().split())
    all[build - 1][floor - 1][room - 1] += num
    
def show_building(arr, sep):
    for floor in arr:
        print("", " ".join(map(str, floor)))
        
    if sep:
        print("#" * 20)
        

for build in range(len(all)):
    show_building(all[build], build != 3)


Measured memory_bytes: 5608
#include <algorithm>

#include <iostream>
using namespace std;

typedef long long ll;

ll disLoad()
{
    ll n, k;
    cin >> n >> k;
    ll x[n], dis[n];

    for (ll i = 0; i < n; ++i)
    {
        cin >> x[i];
        if (i > 0)
        {
            dis[i - 1] = x[i] - x[i - 1];
        }
    }

    // 発電機の数が十分に多い場合
    if (k >= n)
    {
        return 0;
    }

    ll result = x[n - 1] - x[0];
    sort(dis, dis + n - 1);

    for (ll i = 0; i < k - 1; ++i)
    {
        result -= dis[n - 2 - i];
    }
    return result;
}

int main()
{
    ll t;
    cin >> t;

    for (ll i = 0; i < t; ++i)
    {
        ll min_dis = disLoad();
        cout << min_dis << endl;
    }
}


Measured memory_bytes: 4716
N=int(input())
W=[str(input()) for i in range(N)]
def main():
    if len(set(W))!=N:
        return 'No'
    for i in range(N):
        j=i+1
        if i<N-1 and W[i][len(W[i])-1]!=W[j][0]:
            return 'No'
            break
        if i==N-1:
            return 'Yes'
            
print(main())

Measured memory_bytes: 3060
import sys
#from collections import defaultdict, deque, Counter
#from bisect import bisect_left
#import heapq
#import math
#from itertools import groupby as gb
#from itertools import permutations as perm
#from itertools import combinations as comb
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split())
W,H,x,y = map(int, stdin.readline().rstrip().split())
#AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)]

half = W*H/2
if x*2==W and y*2==H:
    print(half, 1)
else:
    print(half,0)


Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>

using namespace std;




int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  
  int n = s.length() + 1;
  int a[n];
  for (int i = 0; i < n; ++i) a[i] = -1;
  if (s[0] == '<') a[0] = 0;
  if (s[n - 2] == '>') a[n - 1] = 0;
  for (int i = 1; i < n - 1; ++i) {
  	if (s[i] == '<' && s[i - 1] == '>') a[i] = 0;
  }
  
  for (int i = 0; i < n; ++i) {
  	if (a[i] != 0) continue;
    
    for (int j = i - 1; j >= 0; --j) {
      if (s[j] == '>') a[j] = max(a[j + 1] + 1, a[j]);
      else break;
    }
  
    for (int j = i + 1; j < n; ++j) {
      if (s[j - 1] == '<') a[j] = max(a[j], a[j - 1] + 1);
      else break;
    }
  }
  
  long long ans = 0;
//   s = s + 'x';
//   for (int i = 0; i < n; ++i) cerr << " " << a[i] << " " << s[i];
//   cerr << endl;
  for (int i = 0; i < n; ++i) ans += a[i];
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2844
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

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

	ll cost = 0, mx = v[0];
	for(int i = 0; i < n; i++){
		if(mx > v[i]){
			cost += mx-v[i];
		}
		mx = max(mx,v[i]);
	}
	cout << cost << "\n";
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long Pow(long long a,long long b){
    long long res=1ll;
    a%=mod;
    while(b){
        if (b & 1)
            res = (1ll*res * a) % (1ll*mod);
        a = (1ll*a * a) % (1ll*mod);
        b >>= 1ll;
    }
    return 1ll*res%mod;
}
long long C(long long n,long long m){
	if (m*2>n)  m=n-m;
	if(m==0) return 1;	
	if(m>n-m) m=n-m;
	long long up=1,down=1;	
	for(long long i=1;i<=m;i++){
		up=(up*(n-i+1))%mod;		
		down=(down*i)%mod;	
	}	
	return up*Pow(down,mod-2)%mod;
}
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	long long k=Pow(2ll,n)-1ll;
	long long cc=C(n,a);
	long long ccc=C(n,b);
	long long sum=((k-cc-ccc)%mod+mod)%mod;
	cout<<sum<<endl; 
}

Measured memory_bytes: 256
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
a = int(input())
l =[]
for i in range(a):
    c,d,e = ma()
    l.append([c,d,e])
dp =[[0, 0, 0] for _ in [0]*(a+1)]
for i in range(a):
    for j in range(3):
        for k in range(3):
            if j == k:continue
            if i==0:dp[i][j] = l[i][j]
            else:dp[i][j] = max(dp[i][j],dp[i-1][k]+l[i][j])
print(max(dp[a-1]))

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<ULL> A(N); rep(i, N) cin >> A[i];
		vector<vector<UL>> E(N);
		rep(i, N - 1) {
			UL a, b; cin >> a >> b; a--; b--;
			E[a].push_back(b);
			E[b].push_back(a);
		}
		vector<UL> F(N);
		queue<UL> Q; Q.push(0);
		vector<UL> V;
		vector<UL> P(N);
		while (Q.size()) {
			UL p = Q.front(); Q.pop();
			F[p] = 1;
			V.push_back(p);
			for (UL e : E[p]) {
				if (F[e]) continue;
				P[e] = p;
				Q.push(e);
			}
		}
		//rep(i, N) cout << P[i] << " "; cout << endl;
 		reverse(V.begin(), V.end());
		vector<vector<ULL>> dp(N);
		rep(i, V.size() - 1) {
			UL p = V[i];
			//cout << "p = " << p << ",dp[p] = ";
			//for (ULL v : dp[p]) { cout << v << " "; } cout << endl;

			if (E[p].size() == 1) {
				dp[P[p]].push_back(A[p]);
				continue;
			}

			ULL M = 0; ULL S = 0;
			for (ULL v : dp[p]) { M = max(M, v); S += v; }
			if (M > A[p]) { cout << "NO" << endl; return; }
			if (S > A[p] * 2 || A[p] > S) { cout << "NO" << endl; return; }
			dp[P[p]].push_back(A[p] * 2 - S);
		}
		//cout << "p = " << 0 << ",dp[p] = ";
		//rep(i, dp[0].size()) cout << dp[0][i]<< " "; cout << endl;
		ULL S = 0;
		for (ULL v : dp[0]) { S += v; }
		if (E[0].size() == 1) {
			if (S == A[0]) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
		else {
			if (S == A[0] * 2) cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 13176
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	string S;
	cin >> S;
	vector<int>v(S.size(),0);
	int cnt = 1;
	for (int i = 0; i < S.size() ; i++)
	{
		if (S[i] == S[i + 1])cnt++;
		else
		{
			if (S[i] == 'R')
			{
				int num = cnt - cnt / 2;
				v[i + 1] += cnt / 2;
				v[i] += num;
				cnt = 1;
			}
			else
			{
				int num = cnt - cnt / 2;
				v[i - cnt] += cnt / 2;
				v[i - cnt + 1] += num;
				cnt = 1;
			}
		}
	}
	for (int i = 0; i < S.size(); i++)
	{
		cout << v[i] << " ";
	}
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n,k,c; cin >>n >>k >>c;
  string s; cin >>s;
  int cnt=0;
  vector<int> ans;
  rep(i,n){
    if(s[i]=='x') continue;
    cnt++;
    ans.push_back(i);
    if(cnt>k) return 0;
    i+=c;
  }
  int m=ans.size(),lim=n;
  while(m){
    m--;
    int r=ans[m];
    repa(i,r+1,lim){
      if(s[i]=='o') r=i;
    }
    if(r!=ans[m]) ans[m]=-1;
    lim=r-c;
  }
  for(int x:ans){
    if(x>=0) print(x+1);
  }
}


Measured memory_bytes: 2552
n,k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')]*n
dp[0] = 0
for i in range(1,n):
    dp[i] = min([dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i)])
print(dp[-1])

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

int main(){
    ll A, B;
    cin >> A >> B;
    
    for(int i = 1; i < 10000; i++){
        double a = i*8/100;
        double b = i*10/100;
        if(floor(a) == A && floor(b) == B){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
sss = input().split(' ')
ma = -9999999999
mi = 9999999999
s = 0
for i in sss:
	num = int(i)
	if ma < num: ma = num
	if mi > num: mi = num
	s += num
print('{0} {1} {2}'.format(mi, ma, s))


Measured memory_bytes: 8312