akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int ans[100005]={0};
int main(){
	string str;
	cin>>str;
	int len=str.length();
	int cnt=0;
	for(int i=0;i<len;i++){
		if(str[i]=='R'){
			cnt++;
			ans[i]=0;
		}
		else {
			if(cnt==0) continue;
			else{
				ans[i-1]=cnt;
				cnt=0;
			}
		}
	}
	for(int i=len;i>=0;i--){
		if(str[i]=='L'){
			cnt++;
			ans[i]=0;
		}
		else {
			if(cnt==0) continue;
			else{
				ans[i+1]=cnt;
				cnt=0;
			}
		}
	}
	for(int i=0;i<len;i++){
		if(ans[i]==0||ans[i+1]==0) continue;
		if(ans[i]%2==ans[i+1]%2){
			int a=(ans[i]+ans[i+1])/2;
			ans[i]=a;
			ans[i+1]=a;
			i++;
			continue;
		}
		if(ans[i]%2==0){
			int a=(ans[i]+ans[i+1])/2;
			ans[i]=a;
			ans[i+1]=a+1;
			i++;
		}
		else {
			int a=(ans[i]+ans[i+1])/2;
			ans[i+1]=a;
			ans[i]=a+1;
			i++;
		}
	}
	for(int i=0;i<len;i++){
		cout<<ans[i]<<' ';
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define N 10500


int main () {
  int n = 0, q = 0, cnt = 0, i, j;
  int S[N], T[500];
 
  scanf("%d",&n);

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

  scanf("%d",&q);

  for(j = 0 ; j < q ; j++) {
    scanf("%d",&T[j]);
    S[i+j] = T[j];
  }

  i = 0;
  j = 0;

  while(j < q) {
    if(S[i] == T[j]) {
      j++;
      cnt++;
      i = 0;
    }
    else if(i < n + j - 1) i++;
    else {
      i = 0;
      j++;
    }
  }

  printf("%d\n",cnt);

  return 0;

}



Measured memory_bytes: 2104
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
vector<int> A;

void solve(void) {
    int M = 0;
    vector<int> B(N+2,0);

    for(int i = N;i > 0;i--) {
        int sum = 0;
        for(int j = 1;i*j <= N;j++) {
            sum += B[i*j];
        }
        
        if((sum % 2) == A[i]) {
            B[i] = 0;
        } else {
            B[i] = 1;
            M++;
        }

    }

    for(int i = 1;i <= N;i++) {
        int sum = 0;
        for(int j = 1;j*i <= N;j++) {
            sum += B[i*j];
        }
       
        if((sum % 2) != A[i]) {
            cout<<-1<<endl;

            return;
        }
    }

    cout<<M<<endl;
    for(int i = 1;i <= N;i++) {
        if(B[i] == 1)
            cout<<i<<" ";
    }
    if(M != 0)
        cout<<endl;


    return;
}

int main(void) {
    cin>>N;
    A.push_back(-1);
    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;

        A.push_back(a);
    }

    solve();

    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include<queue>
#include<climits>
#include<cassert>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<sstream>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef pair<int,int> ii;

#define MAX 810
int H,W,K;
string A[MAX];
bool first_step[MAX][MAX];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

bool isValid(int x,int y) { return 0 <= x && x < W && 0 <= y && y < H; }

ii getSP() {
  rep(i,H) rep(j,W) if( A[i][j] == 'S' ) { return ii(i,j); }
  assert(false);
}

void first_BFS(int sx,int sy) {
  memset(first_step,false,sizeof first_step);
  deque<ii> deq;
  deq.push_back(ii(sx+sy*W,K));
  first_step[sy][sx] = true;
  while( !deq.empty() ) {
    ii v = deq.front(); deq.pop_front();
    int p = v.first;
    int step = v.second;
    int x = p % W;
    int y = p / W;
    rep(i,4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if( !isValid(nx,ny) ) continue;
      if( A[ny][nx] == '#' ) continue;
      if( first_step[ny][nx] ) continue;
      int nstep = step - 1;
      if( nstep < 0 ) continue;
      first_step[ny][nx] = true;
      deq.push_back(ii(nx+ny*W,nstep));
    }
  }
}

int mini[MAX][MAX];

void compute() {
  ii sp = getSP();
  int sx = sp.second, sy = sp.first;
  A[sy][sx] = '.';

  first_BFS(sx,sy);
  /*
  rep(i,H) {
    rep(j,W) {
      if( first_step[i][j] ) cout << "o";
      else cout <<"x";
    }
    puts("");
  }
  */
  rep(i,H) if( first_step[i][0] || first_step[i][W-1] ) {
    puts("1");
    return;
  }
  rep(i,W) if( first_step[0][i] || first_step[H-1][i] ) {
    puts("1");
    return;
  }

  deque<ii> deq;
  rep(i,H) rep(j,W) mini[i][j] = INT_MAX;
  rep(i,H) rep(j,W) if( first_step[i][j] ) {
    mini[i][j] = 0;
    deq.push_back(ii(j+i*W,0));
  }
  while( !deq.empty() ) {
    ii tmp = deq.front(); deq.pop_front();
    int p = tmp.first;
    int cost = tmp.second;
    int x = p % W;
    int y = p / W;
    rep(i,4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if( !isValid(nx,ny) ) continue;
      if( mini[ny][nx] > cost + 1 ) {
	mini[ny][nx] = cost + 1;
	deq.push_back(ii(nx+ny*W,mini[ny][nx]));
      }
    }
  }
  int ans = INT_MAX;
  rep(i,H) {
    int cost = 1;
    cost += ceil(mini[i][0]/(double)K);
    ans = min(ans,cost);
    cost = 1;
    cost += ceil(mini[i][W-1]/(double)K);
    ans = min(ans,cost);
  }
  rep(i,W) {
    int cost = 1;
    cost += ceil(mini[0][i]/(double)K);
    ans = min(ans,cost);
    cost = 1;
    cost += ceil(mini[H-1][i]/(double)K);
    ans = min(ans,cost);
  }
  cout << ans << endl;
}

int main() {
  cin >> H >> W >> K;
  rep(i,H) cin >> A[i];
  compute();
  return 0;
}


Measured memory_bytes: 4608
n= int(input())
li = list(map(int, input().split()))

while 1:
    minimam = min(li)
    maximam = max(li)
    temp = li.copy()
    li = [i % minimam if i% minimam != 0 else i for i in li]
    if temp == li:
        print(minimam)
        break

Measured memory_bytes: 14252
from collections import Counter

def fParse(iN,aV):
    oV0 = Counter(aV[0::2]).most_common(2)
    oV1 = Counter(aV[1::2]).most_common(2)
    oV0 += [(0,0)]
    oV1 += [(0,0)]

    if oV0[0][0] != oV1[0][0] :
        return iN - oV0[0][1] - oV1[0][1]
    else:
        return iN - max(oV0[0][1],oV1[0][1]) - max(oV0[1][1],oV1[1][1])

if __name__ == "__main__":
    iN = int(input())
    aV = [int(_) for _ in input().split()]
    print(fParse(iN,aV))


Measured memory_bytes: 15580
#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 h, n;
  cin >> h >> n;
  int sum = 0;
  rep(i, n)
  {
    int a;
    cin >> a;
    sum += a;
  }
  string ans = (h <= sum) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}

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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c;
    int d=max({a,b,c});
    int ans = a + b + c - d;
    cin >> k;
    for(int i=0;i<k;i++){
        d = d*2;
    }
    ans = ans + d;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, x, y, z, p = 1000000007;
long long f[42][1 << 17];
long long ans = 1;
int main() {
	scanf("%d%d%d%d", &n, &x, &y, &z);
	f[0][0] = 1;
	int b = (1 << (x + y + z - 1)) | (1 << (y + z - 1)) | (1 << (z - 1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 1 << (x + y + z); j++) {
			if (f[i][j]) {
				for (int k = 1; k <= 10; k++) {
					int l = ((j << k) | (1 << (k - 1))) % (1 << (x + y + z));
					if ((l & b) != b) {
						f[i + 1][l] = (f[i + 1][l] + f[i][j]) % p;
					}
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		ans = ans * 10 % p;
	}
	for (int i = 0; i < 1 << (x + y + z); i++) {
		ans = (ans + p - f[n][i]) % p;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 41216
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    cout<<(n+1)/2;

} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  int a[10], b[10], sum = 0;
  reps(i, 5){
    cin >> a[i];
    b[i] = (a[i] + 9) / 10 * 10;
    sum += b[i];
  }
  int ans = INF;
  reps(i, 5){
    ans = min(ans, sum - b[i] + a[i]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i = (a);i <= (b);++i)
typedef long long ll;
const int maxn = 1e6+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res = 1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int a[maxn];
int vis[maxn];
bool prime[maxn];
int cnt[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i)scanf("%d",&a[i]),vis[a[i]]++;
	memset(prime,1,sizeof(prime));
	for(int i = 2;i <= 1000000;++i){
		if(prime[i]){
			for(int j = i;j <= 1000000;j+=i){
				if(vis[j]){
					cnt[i]+=vis[j];
				}
			}
		}
	}
	int ans = 2;
	for(int i = 2;i <= 1000000;++i){
		if(cnt[i]>1){
			ans = 1;
		}
	}
	int tmp = a[1];
	for(int i = 2;i <= n;++i){
		tmp = __gcd(tmp,a[i]);
	}
	if(tmp>1)ans = 0;
	if(ans==2)printf("pairwise coprime\n");
	else if(ans==1)printf("setwise coprime\n");
	else printf("not coprime\n");
	return 0;
}

Measured memory_bytes: 16344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){
    ll h,w;cin>>h>>w;
    string s[h];rep(i,0,h-1)cin>>s[i];
    ll dp[h][w];
    if(s[0][0]=='.'){
        dp[0][0]=0;
    }else{
        dp[0][0]=1;
    }
    rep(i,0,h-1){
        rep(j,0,w-1){
            if(i==0 && j==0){
                continue;
            }
            if(i==0){
                ll comp1;
                if(s[i][j]=='#' && s[i][j-1]=='.'){
                    comp1=dp[i][j-1]+1;
                }else{
                    comp1=dp[i][j-1];
                }
                dp[i][j]=comp1;
            }else if(j==0){
                ll comp1;
                if(s[i][j]=='#' && s[i-1][j]=='.'){
                    comp1=dp[i-1][j]+1;
                }else{
                    comp1=dp[i-1][j];
                }
                dp[i][j]=comp1;
            }else{
                ll comp1,comp2;
                if(s[i][j]=='#' && s[i][j-1]=='.'){
                    comp1=dp[i][j-1]+1;
                }else{
                    comp1=dp[i][j-1];
                }
                if(s[i][j]=='#' && s[i-1][j]=='.'){
                    comp2=dp[i-1][j]+1;
                }else{
                    comp2=dp[i-1][j];
                }
                dp[i][j]=min(comp1,comp2);
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    
    
    return 0;
}



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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;


int top(ll x) {
  while(true) {
    if (x/10 == 0) {
      return x;
    }
    x /= 10;
  }
}

int N;
ll count(int a, int b) {
  ll ret = 0;
  REP(i, N+1) {
    if (i%10 != b) continue;
    if (top(i) != a) continue;
    ret++;
  }
  return ret;
}

int main(int argc, char** argv) {
  cin >> N;


  ll C[10][10] = {{0}};

  REP(i, 1, 10) {
    REP(j, 1, 10) {
      C[i][j] = count(i, j);
    }
  }

  ll ret = 0;

  REP(i, 1, 10) {
    REP(j, 1, 10) {
      ll first  = C[i][j];
      ll second = C[j][i];

      ret += first*second;
    }
  }

  cout << ret << endl;
  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256
# ABC 091: B – Two Colors Card Game
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

announced = set(s + t)
earned = 0

for word in announced:
    earned = max(earned, s.count(word) - t.count(word))

print(earned if earned > 0 else 0) 

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <bitset>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 200005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;


int main()
{
	stack <int> st;
	string s;
	cin >> s;
	for (int i = 0; i < (int) s.size(); ++i)
	{
		if(s[i] == '0')
		{
			if((int) st.size() > 0)
			{
				if(st.top() == '1')
				{
					st.pop();
				}
				else
				{
					st.push(s[i]);
				}
			}
			else
			{
				st.push(s[i]);
			}
		}
		else
		{
			if((int) st.size() > 0)
			{
				if(st.top() == '0')
				{
					st.pop();
				}
				else
				{
					st.push(s[i]);
				} 
			}
			else
			{
				st.push(s[i]);
			}	
		}
	}
	cout << (int) s.size() - (int) st.size();
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
    int n,m,x,b;cin>>n>>m>>x;
    int arr[n+1]={};
    fol(i,m){cin>>b;arr[b]=1;}
    int ans1=0,ans2=0;
    for(int i=x;i!=0;i--) ans1+=arr[i];
    for(int i=x;i<=n;i++) ans2+=arr[i];
    int ans = min(ans1,ans2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

A,B,Q = list(map(int, input().rstrip().split()))
s_list = [-10**11] + [int(input().strip()) for _ in range(A)] + [10**11]
t_list = [-10**11] + [int(input().strip()) for _ in range(B)] + [10**11]
x_list = [int(input().strip()) for _ in range(Q)]
#-----

# x_dic={ x : [a1,a2,b1,b2]}
#    距離xに対して、最も近い神社・寺のindexを保存
#      a1(xより西の最寄りの神社)、a2(xより東の最寄りの神社)
#      b1(xより西の最寄りの寺)、  b2(xより東の最寄りの寺)
x_dic={}

x_sort = sorted(x_list)

i_x=0
for i in range(len(s_list) - 1):
    
    while s_list[i] <= x_sort[i_x] <= s_list[i+1]:
        x_dic[x_sort[i_x]] = [i,(i+1)]
        i_x += 1
        
        if i_x > len(x_sort)-1: break
    if i_x > len(x_sort)-1: break
    

i_x=0
for i in range(len(t_list) - 1):
    
    while t_list[i] <= x_sort[i_x] <= t_list[i+1]:
        x_dic[x_sort[i_x]].extend( [i,(i+1)] )
        i_x += 1
        
        if i_x > len(x_sort)-1: break
    if i_x > len(x_sort)-1: break


for x in x_list:
    dist_min=10**11
    
    for s in x_dic[x][0:2]:
        for t in x_dic[x][2:4]:
            diff1 = abs(s_list[s] - x) + abs(t_list[t] - s_list[s])
            diff2 = abs(t_list[t] - x) + abs(s_list[s] - t_list[t])
            dist_min = min(dist_min, diff1, diff2)
    
    print(dist_min)


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

int N;
char abc[11];
string S="";
vector<vector<int>> graph(11);

void DFS(int K){
	S.push_back(abc[K]);
	if(S.size()==N)cout << S << endl;
	else{
		int max_used=0;
		for(int i=0;i<S.size();i++)max_used=max(max_used,S[i]-'a');
		for(auto t:graph[K])if(t<=max_used+1)DFS(t);
	}
	S.erase(S.size()-1);
}

int main(){
	cin >> N;
	abc[0]='a';
	for(int i=0;i<N-1;i++)abc[i+1]=abc[i]+1;
	
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)graph[i].push_back(j);
	
	DFS(0);
	
	return 0;
}

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	class Vertex {
		int id;
		int[] vertices;
		int visited = -1;
		int completed = -1;
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Vertex[] vertices = new Vertex[n];
		for (int i = 0; i < n; i++) {
			vertices[i] = new Vertex();
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int id = Integer.parseInt(st.nextToken());
			vertices[i].id = id;
			int cnt = Integer.parseInt(st.nextToken());
			vertices[i].vertices = new int[cnt];
			for (int j = 0; j < cnt; j++) {
				vertices[i].vertices[j] = Integer.parseInt(st.nextToken());
			}
		}
		reader.close();
		
		DFS(vertices, n);
		
		for (int i = 0; i < n; i++) {
			Vertex vertex = vertices[i];
			System.out.println(vertex.id + " " + vertex.visited + " " + vertex.completed);
		}
	}

	private void DFS(Vertex[] vertices, int n) {
		int time = 0;
		for (int i = 0; i < n; i++) {
			Vertex vertex = vertices[i];
			Stack<Integer> stack = new Stack<Integer>();
			if (vertex.visited == -1) {
				stack.push(vertex.id);
			}
			while (!stack.isEmpty()) {
				vertex = vertices[stack.peek()-1];
				if (vertex.visited == -1) {
					vertex.visited = ++time;
				}
				boolean allVisited = true;;
				for (int j = 0; j < vertex.vertices.length ; j++) {
					int childId = vertex.vertices[j];
					if (vertices[childId-1].visited == -1) {
						vertices[childId-1].visited = ++time;
						allVisited = false;
						stack.push(childId);
						break;
					}
				}
				if (allVisited) {
					vertex.completed = ++time;
					stack.pop();
				}
			}
		}
	}
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = (int)3e5 + 9;

int main(){
    fastIO;
    int n;
    cin >> n;
    int a[3 * n];
    for(int i = 0 ;i < 3 * n; i ++ )
        cin >> a[i];
    sort(a, a + 3 * n);
    ll ret = 0;
    for(int i = 0 ; i < 2 * n; i ++ ){
        if(i % 2 == 0){
            ret += a[i + n];
        }
    }
    cout << ret << "\n";
    return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	ll a[n], b[n];
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	ll suma = 0, sumb = 0;
	rep(i, n) {
		suma += a[i];
		sumb += b[i];
	}
	if (suma < sumb) {
		cout << -1 << endl;
		return 0;
	}
	
	priority_queue<ll> bigger;
	int cnt = 0;
	ll sum = 0;
	rep(i, n) {
		if (a[i] - b[i] < 0) {
			sum += abs(a[i] - b[i]);
			cnt++;
		} else if (a[i] - b[i] > 0) bigger.push(a[i] - b[i]);
	}
//	cout << sum << endl;
	
	while (sum > 0) {
//		cout << bigger.top() << endl;
		sum -= bigger.top();
		bigger.pop();
		cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
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++)
typedef long long ll;

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

const int NUM = 3010;
ll combi[NUM][NUM];
void calcCombi(ll mod) {
  combi[0][0] = 1;
  REP(i, NUM-1) {
    combi[i][0] = combi[i][i] = 1;
    REP(j, i)
      combi[i+1][j+1] = (combi[i][j] + combi[i][j+1]) % mod;
  }
}

int main() {
  ll mod = 1e8+7;
  calcCombi(mod);
  int r, c, y1,x1,y2,x2;
  cin>>r>>c>>y1>>x1>>y2>>x2;
  int a = min(abs(y2-y1),y1+r-y2);
  a = min(a,y2+r-y1);
  int mul = 1;
  if (abs(y2-y1) == y1+r-y2 || abs(y2-y1) == y2+r-y1) mul *= 2;
  int b = min(abs(x2-x1),x1+c-x2);
  b = min(b,x2+c-x1);
  if (abs(x2-x1) == x1+c-x2 || abs(x2-x1) == x2+c-x1) mul *= 2;
  cout << combi[a+b][a] * mul % mod << endl;
}

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

int main()
{
	int64_t a, b;
	cin >> a >> b;

	if ((a % 2) == (b % 2))
	{
		cout << (a + b) / 2 << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h> 
using namespace std;
int main()
{
    string str;
    cin>>str;
    int n= str.length(),i,x=0,y=0;
    for (i=0;i<n;i++)
    {
        if (i%2==0)
        {
            if (str[i]=='R'||str[i]=='U'||str[i]=='D')
                x++;
        }
        else 
        {
            if (str[i]=='L'||str[i]=='U'||str[i]=='D')
                y++;
        }
    }
    if (n%2==0)
    {
        if (x==n/2 && y==n/2)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
    {
        if (x==n/2+1 && y==n/2)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>

using namespace std;

long minTime2goHome(long x){

    return ceil((-1+ceil(sqrt(1+8*x)))/2.0);
}

int main(int argc, char *argv[])
{
    long x;
    cin>>x;
    long time = minTime2goHome(x);
    cout<<time<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXN 9500000

int p[MAXN][26], minn[MAXN];
int n, top, i, j, k, c, best, x;
string s;

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

	cin >> n >> s;
	best = 0;
	top = 0;
	for (i = 0; i < n; i++) {
		x = 0;
		for (j = 0; (i + j < n) && (j < n / 2); j++) {
			c = s[i + j] - 'a';
			if (p[x][c] == 0) p[x][c] = ++top;
			x = p[x][c];
			if (minn[x] == 0) minn[x] = i + 1;
			else {				
				if (i + 1 - minn[x] >= j + 1) best = max(best, j + 1);
			}
		}
	}

	cout << best << "\n";

	return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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 ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> m;
  rep(i,n){
    ll a; cin>>a;
    m[a]++;
  }
  
  ll ans=0;
  for(auto e: m){
    if(e.second>e.first){
      ans+=e.second-e.first;
    }else if(e.second<e.first){
      ans+=e.second;
    }
  }
  cout<<ans<<endl;
}

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

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

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

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

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

using namespace std;

#define isok(a,b) ((a)=='?'||(b)=='?'||(a)==(b))

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c; cin>>a>>b>>c;
    int n = a.size();
    int m = b.size();
    int l = c.size();
    vector<bool> ab_ok(n+m,true),ac_ok(n+l,true),bc_ok(m+l,true);
    //A-B Match
    rep(i,n+m)rep(j,n){
        if (m-i+j<0 || m-i+j>=m) continue;
        if (!isok(b[m-i+j],a[j])) ab_ok[i]=false;
    }
    //A-C Match
    rep(i,n+l)rep(j,n){
        if (l-i+j<0 || l-i+j>=l) continue;
        if (!isok(c[l-i+j],a[j])) ac_ok[i]=false;
    }
    //B-C Match
    rep(i,m+l)rep(j,m){
        if (l-i+j<0 || l-i+j>=l) continue;
        if (!isok(c[l-i+j],b[j])) bc_ok[i]=false;
    }
    int w=n+(m+l)*2;
    int ans = 101010;
    rep(i,w-m+1)rep(j,w-l+1){
        if (0<=i-l && i-l<n+m && !ab_ok[i-l]) continue;
        if (0<=j-m && j-m<n+l && !ac_ok[j-m]) continue;
        if (0<=j-i+l && j-i+l<m+l && !bc_ok[j-i+l]) continue;
        int left = min(m+l, min(i,j));
        int right = max(n+m+l, max(i+m,j+l));
        chmin(ans, right-left);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 384
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int H,W;
char S[22][22];

int DFS(int x, int y, int max){

    return 0;
}


int main(void) {

    ll N;cin>>N;

    cout<<(N*2)/__gcd(N,(ll)2)<<endl;

}

Measured memory_bytes: 256
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val a = List.fill(n)(sc.nextInt)
  val b = List.fill(n)(sc.nextInt)
  val c = List.fill(n - 1)(sc.nextInt)

  val ans =
    a.foldLeft((0, -1)) { case ((acc, previousIndex), in) =>
      if (in - 1 == previousIndex) (acc + b(in - 1) + c(in - 2), in)
      else (acc + b(in - 1), in)
    }._1
  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 169156
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    string a, b;
    cin>>a>>b;
    string c=a+b;
    int d=stoi(c);
    if (sqrt(d)==floor(sqrt(d)))
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		long n = kb.nextLong();
		long a = kb.nextLong();
		long b = kb.nextLong();
		long count = n / (a + b);
		if (a == 0)
			System.out.println(0);
		else if (0 < a && a <= n) {
			if (a + b >= n)
				System.out.println(a);
			else {
				if (n - count * (a + b) >= a && n - count * (a + b) != 0)
					System.out.println(count * a + a);
				else if (n - count * (a + b) < a && n - count * (a + b) != 0)
					System.out.println(count * a + n - count*(a + b));
				else if (n - count * (a + b) == 0)
					System.out.println(count * a);
			}
		} else {
			System.out.println(n);
		}
		kb.close();
	}

}


Measured memory_bytes: 22996
#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の値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(all(p));
  int ans = 0;
  rep(i, n) ans += (i != n - 1) ? p[i] : p[i] / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
  int N;
  long T;
  std::cin >> N >> T;
  std::vector<long> A(N);
  for(int i = 0; i < N; i++) std::cin >> A.at(i);
  
  long base = A.at(0);
  std::vector<long> diff(N);
  long maxDiff = 0;
  
  for(int i = 0; i < N; i++){
    long temp = A.at(i) - base;
    if(temp < 0){
      diff.at(i) = 0;
      base = A.at(i);
    }else{
      diff.at(i) = temp;
    }
    maxDiff = std::max(maxDiff, temp);
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    if(diff.at(i) == maxDiff) count++;
  }
  std::cout << count << std::endl;
  
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 100010


int main(){
	IOS;
	tihs;
	
	string s;
	cin>>s;
	ll x=0,y=0;
	rep(i,0,sz(s)){
		if(s[i]=='A')x++;
		else y++;
	}
	if(x and y)cout<<"Yes";
	else cout<<"No";


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <map>
#include <vector>
using namespace std;



int main()
{
    int a, b;
    cin >> a >> b;

    int ans = (a -2*b > 0)?(a-2*b):0;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
long a[100010],n,k,i,j,x,c,res;
int main()
{
  cin>>n>>k;
  for(i=0;i<n;++i)cin>>a[i];
  for(i=62;i>=0;--i){
    c=0;
    for(j=0;j<n;++j)c+=(a[j]>>i)&1;
    if(2*c<n&&(x|(1L<<i))<=k)x|=1L<<i;
  }
  res=0;
  for(i=0;i<n;++i)res+=x^a[i];
  cout<<res<<endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        long X = scanner.nextLong();
        long A = 100;
        int Y = 0;
        
        while(A<X){
            A *= 1.01;
            Y++;
        }
        
        System.out.println(Y);
        
    }
}


Measured memory_bytes: 35600
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    ll X_MAX = 35, Y_MAX = 3005;
    bool x[X_MAX], y[Y_MAX];
    for (ll i = 0; i <= X_MAX; i++) x[i] = false;
    for (ll i = 0; i <= Y_MAX; i++) y[i] = false;
    int tw, water = 0, sugar = 0;
    int a_max = f / (100 * a), b_max = f / (100 * b), c_max = f / c, d_max = f / d;
    for (ll i = 0; i <= a_max; i++) {
        x[i * a] = true;
        for (ll j = 0; j <= b_max; j++) {
            x[j * b] = true;
            tw = i * a + j * b;
            if (100 * tw <= f) x[tw] = true;
        }
    }
    for (int i = 0; i <= c_max; i++) {
        y[i * c] = true;
        for (int j = 0; j <= d_max; j++) {
            y[j * d] = true;
            tw = i * c + j * d;
            if (tw <= f) y[tw] = true;
        }
    }
    double conc, maxc = -1, conc_lim = (double)(100 * e) / (100 + e);
    for (ll i = 0; i <= X_MAX; i++) {
        if (!x[i]) continue;
        for (ll j = 0; j <= Y_MAX; j++) {
            if (y[j] && 100 * i + j <= f) {
                conc = (double)(100 * j) / (100 * i + j);
                if (conc <= conc_lim && conc == (maxc = max(maxc, conc))) {
                    water = 100 * i;
                    sugar = j;
                }
            }
        }
    }
    cout << water + sugar << ' ' << sugar << endl;
}

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

#define N_MAX n+1

int main() {
	
	int n,x;
	cin >> n >> x;
	int m[N_MAX],mm=0,ans=0,mn=1000000;
	for(int i=0;i<n;++i){
	    cin>>m[i];
	    mm+=m[i];
	    ans++;
	    if(mn>m[i])mn=m[i];
	}
	ans+=(x-mm)/mn;
	
	
	cout << ans;
	
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

void solve(long long K, long long A, long long B) {
    string ans = "NG";
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            ans = "OK";
        }
    }
    cout << ans << endl;
}

int main() {
    long long K;
    scanf("%lld", &K);
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(K, A, B);
    return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

ll a(int i, vector<ll> &vecA) {
    if (i == 0) return 1;
    if (vecA[i-1] != -1) {
        return 2ll * vecA[i-1] + 3;
    } else {
        return 2ll * a(i-1, vecA) + 3;
    }
}

ll p(int i, vector<ll> &vecP) {
    if (i == 0) return 1;
    if (vecP[i-1] != -1) {
        return 2ll * vecP[i-1] + 1;
    } else {
        return 2ll * p(i-1, vecP) + 1;
    }
}

ll f(int n, ll x, vector<ll> &a, vector<ll> &p) {
    if (x == 1) {
        if (n == 0) return 1;
        else return 0;
    } else if (x < a[n-1] + 2) {
        return f(n-1, x-1, a, p);
    } else if (x == a[n-1] + 2) {
        return p[n-1] + 1;
    } else if (x < a[n]) {
        return p[n-1] + 1 + f(n-1, x-2-a[n-1], a, p);
    } else {
        return p[n];
    }
}

void solve() {
    int N;
    ll X;
    cin >> N >> X;

    vector<ll> A(N+1, -1), P(N+1, -1);
    REP(i, N+1) {
        A[i] = a(i, A);
        P[i] = p(i, P);
    }
    ll ans = f(N, X, A, P);
    cout << ans << endl;
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100005];
ll p[100005];
int n;
ll m;
bool check(int x){
    ll numtaken = 0;
    for (int i = 0; i < n; i++){
        int k = a+n-lower_bound(a,a+n,x-a[i]);
        numtaken += k;
    }
    return numtaken >= m;
}
int main(){
    scanf("%d%lld",&n,&m);
    p[0] = 0;
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for (int i = 0; i < n; i++){
        p[i+1] = p[i] + a[i];
    }
    int lo = 0, hi = 2e5+1;
    ll ans = 0;
    while (lo + 1 < hi){
        int mid = (lo+hi)/2;
        if (check(mid)){
            lo = mid;
        }
        else hi = mid;
    }
    if (lo+1 == hi){
        if (check(hi)){
            lo = hi;
        }
        else hi = lo;
    }
    ll numtaken = 0;
    ll sum = 0;
    for (int i = 0; i < n; i++){
        int k = a+n-lower_bound(a,a+n,lo-a[i]);
        numtaken += k;
        sum += p[n]-p[n-k]+(ll)k*a[i];
    }
    ans = sum-(numtaken-m)*lo;
    printf("%lld",ans);
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
    int counter=0,counterr=0;
    string S;
    cin >> S;
    if (S[0]!='A'){
        cout << "WA";
    }
    else {
        for (int i=2; i<=S.length()-2; i++){
            if (S[i]=='C'){
                counter+=1;
            }
        }
        if (counter!=1){
            cout << "WA";
        }
        else {
            for (int i=0; i<S.length(); i++){
                if (S[i]>=65 && S[i]<=90){
                    counterr+=1;
                }
            }
            if (counterr!=2){
                cout << "WA";
            }
            else if (counter==1){
                cout << "AC";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
N,T = map(int, input().split())
t = list(map(int, input().split()))

res = 0
tmp = T
for i in t[1:]:
  if tmp < i:
    res += T
  else:
    # print('-', i)
    res += i - (tmp - T)
  # print(i, tmp, res)
  tmp = i + T
print(res+T)


Measured memory_bytes: 26708
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
#define add push_back
 
using namespace std; 


int main() {

    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);

    int t;  t = 1; //cin >> t;
    while(t--){
        ll n; cin >> n;
        vector<ll> v(n);
        ll left[n];
        ll right[n];
        ll sum = 0;
        for(int i = 0; i < n; i++){
            cin >> v[i];
            sum ^= v[i];
        }
        ll answ[n];
        for(int i = 0; i < n; i++)
            answ[i] = sum ^ v[i];
        for(int i = 0; i < n; i++)
            cout << answ[i] << " ";
        cout << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> Vector;
typedef vector<vector<ll>> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX/3
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define rep(i,n)    repl(i,0,n-1)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<int>())
#define mkp(x,y)    make_pair(x,y)

int main(){
  cin.sync_with_stdio(false);
  char x,y;
  cin >> x >> y;
  char ans;
  if(x == y)ans = '=';
  else if(x > y)ans = '>';
  else ans = '<';
  cout << ans << endl;
}


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

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

	int N;
	scanf("%d", &N);

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

	vector<int> result(N);
	for (int i = N - 1; i >= 0; i--) {
		for (int j = i; j >= 0; j--) {
			if (B[j] == j + 1) {
				B.erase(B.begin() + j);
				result[i] = j + 1;
				goto find;
			}
		}
		printf("-1");
		return 0;
	find:
		continue;
	}

	for (int i = 0; i < N; i++) {
		printf("%d\n", result[i]);
	}
	return 0;
}

Measured memory_bytes: 256
def create_set(a, b, out):
    for i in range(a, b):
        out.add(i)

param = input()
a, b, c, d = param.split(' ')
a = int(a)
b = int(b)
c = int(c)
d = int(d)

alice = set()
bob = set()
create_set(a, b, alice)
create_set(c, d, bob)

total = alice & bob

time_total = 0
for i in total:
    time_total += 1

print(time_total)


Measured memory_bytes: 3060
# ALDS1_12_B: Single Source Shortest Path 1

class Graph
  def initialize(n_v)
    @n_v   = n_v
    @costs = Array.new(n_v) { Hash.new }
  end

  def connect(v_from, v_to, cost)
    @costs[v_from][v_to] = cost
  end

  def calc_min_costs_from(v_start)
    costs_from_start = Array.new @n_v, Float::INFINITY
    visiting = {}
    costs_from_start[v_start] = 0
    visiting[v_start] = 0

    while visiting.any?
      v_from, _ = visiting.min_by do |v, _|
        costs_from_start[v]
      end
      visiting.delete v_from

      @costs[v_from].each do |v_to, cost|
        through_cost = costs_from_start[v_from] + cost
        if through_cost < costs_from_start[v_to]
          costs_from_start[v_to] = through_cost
          visiting[v_to] = true
        end
      end
    end

    costs_from_start
  end
end

# Read input.
n_v   = gets.to_i
graph = Graph.new(n_v)
n_v.times do
  v_from, n_degs, *inputs = gets.split.map &:to_i
  inputs.each_slice(2) do |v_to, cost|
    graph.connect v_from, v_to, cost
  end
end

graph.calc_min_costs_from(0).each_with_index do |cost, idx|
  puts "#{idx} #{cost}"
end

Measured memory_bytes: 9084