akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define inf ((int)1e5)

int n, m = 3, tar[3], arr[8], dp[3][1<<8][9][8001];

int get_dp(int t, int mask, int i, int len) {
    if (t == m) {
        return 0;
    } else if (i == n) {
        return dp[t][mask][i][len] = len == 0 ? inf : get_dp(t+1, mask, 0, 0)+abs(len-tar[t]);
    } else if (!((mask>>i)&1)) {
        return dp[t][mask][i][len] = get_dp(t, mask, i+1, len);
    } else {
        int v1 = get_dp(t, mask, i+1, len);
        int v2 = get_dp(t, (mask^(1<<i)), i+1, len+arr[i])+(len == 0 ? 0 : 10);
        return dp[t][mask][i][len] = min(v1, v2);
    }
}

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

    cin >> n >> tar[0] >> tar[1] >> tar[2];
    for (int i = 0; i < n; ++i) cin >> arr[i];
    memset(dp, 255, sizeof(dp));
    cout << get_dp(0, (1<<n)-1, 0, 0) << "\n";
}

Measured memory_bytes: 216320
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
bool ispal (string s)
{
    ll n=s.length();
    string s1=s;
    reverse(all(s));
    rep (i,0,n)
    {
        if (s[i]!=s1[i])
        {
            return false;
        }
    }
    return true;

}
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    string s;
    cin>>s;
    ll n=s.length();
    ll x1=(n-1)/2;
    ll x2=(n+3)/2;
    string s1=s.substr(0,x1);
    string s2=s.substr(x2-1,n-x2+1);
    // cout<<s1<<" "<<s2<<"\n";
    if (ispal(s)&&ispal(s1)&&ispal(s2))
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
}


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

int main(){
	string s;
	while( getline(cin,s) ){
		if( s == "." ) break;
		stack<char> st;
		bool flag = true;

		for(int i=0 ; i < s.size() ; i++ ){
			char c = s[i];
			if( c == '(' || c == '[' ){
				st.push( c );
			}else if( s[i] == ')' ){
				if( st.empty() || st.top() == '[' ){
					flag = false;
					break;
				}else if( st.top() == '(' ){
					st.pop();
				}
			}else if( s[i] == ']' ){
				if( st.empty() || st.top() == '(' ){
					flag = false;
					break;
				}else if( st.top() == '[' ){
					st.pop();
				}
			}
		}
		if( flag && st.empty() )
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
}

Measured memory_bytes: 904
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int tb[50][26];

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

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

		for (char c : s) {
			tb[i][c - 'a']++;
		}
	}

	for (int j = 0; j < 26; j++) {
		int mi = tb[0][j];

		for (int i = 1; i < n; i++) {
			mi = min(mi, tb[i][j]);
		}

		for (int l = 0; l < mi; l++) {
			cout << (char)('a' + j);
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a;
	cin >> a;
	int b = 2;
	int c = 1;
	while (true) {
		if (c <= a && a < b ) {
			break;
		}
		else {
			c = c * 2;
			b = b * 2;
		}
	}
	cout << c;
}

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

bool prime(int a) {
	if (a == 3)return true;
	for (int b = 3;; b+=2) {
		if (a%b == 0)return false;
		if ((b + 1)*(b + 1) > a)return true;
	}
}
int main() {
	while (1) {
		int s = 0;
		int a;
		cin >> a;
		if (a == 0)break;
		for (int b = 3; b < a / 2 + 1; b += 2) {
			if (prime(b) && prime(a - b))s++;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 2988
import bisect

N = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.sort()

ans = 0
for i in range(N):
    top = bisect.bisect_left(A, B[i])
    bottom = N - bisect.bisect_right(C, B[i])
    ans += top * bottom

print(ans)

Measured memory_bytes: 23360
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll=long long;

int main(){
	const int m=100010;
	int n,tmp=m;
	ll a[m],b[m],c[m],ans=0;
	bool f;

	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)cin>>b[i];
	sort(b,b+n);
	for(int i=0;i<n;i++)cin>>c[i];
	sort(c,c+n);

	for(int i=0;i<n;i++){
		auto lb=lower_bound(a,a+n,b[i]);
		auto ub=upper_bound(c,c+n,b[i]);
		ans+=(lb-a)*(n-(int)(ub-c));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int n,k;cin>>n>>k;
    vector<int> a(n,0);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(full(a));
    int sm =0;
    for(int i=0;i<k;i++) sm+=a[i];
    cout<<sm<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,n)cin>>v[i];
	sort(v.begin(),v.end());
	double ave=v[0];
	for(int i=1;i<n;i++){
		ave=(ave+(double)v[i])/2.0;
	}
	printf("%.7lf\n",ave);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n;

int main()
{
	cin>>n;
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9) puts("hon");
	else if(n%10==0||n%10==1||n%10==6||n%10==8) puts("pon");
	else puts("bon");
	return 0;
}

Measured memory_bytes: 3636
// C - Slimes
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, string &S){
	vector<char> X;
	char pre = '-';
	rp(i, 0, N){
		char s = S[i];
		if(pre != s){
			X.push_back(s);
			pre = s;
		}
	}
	return X.size();
}

int main(){
	int N; string S; cin>>N>>S;
	cout<< solve(N, S) <<endl;
}

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

int main(){
	long N, X, T;
	cin >> N >> X >> T;

	if(N%X==0){
		cout << T*N/X << endl;
	}else{
		cout << T*(N/X+1) << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

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

int main() {
  fast();
  cin >> n;
  string s;
  cin >> s;
  set<char> st;
  int mx = 0;
  FOR(i, 0, n) {
    st.ins(s[i]);
    set<char> curr;
    FOR(j, i + 1, n) {
      if (st.find(s[j]) != st.end()) curr.ins(s[j]);
    }
    mx = max(mx, sz(curr));
  }
  cout << mx;

  return 0;
}



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

string dp[100100];
int f[] = { -1, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

void chmax(string &a, string b) {
  int a_len = a.size();
  int b_len = b.size();
  if (a_len < b_len || (a_len == b_len && a < b)) a = b;
}

signed main() {

  int N, M;
  cin >> N >> M;

  vector<int> A(M);
  for (int i = 0; i < M; ++i) cin >> A[i];
  sort(A.rbegin(), A.rend());

  for (int i = 0; i < N; ++i) {
    for (auto& a: A) {
      if (i == 0 || dp[i] != "") chmax(dp[i + f[a]], dp[i] + char(a + '0'));
    }
  }

  cout << dp[N] << endl;

}


Measured memory_bytes: 45952
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
using Graph =vector<vector<int>>;
//xor ^
int main(){
  int N;cin>>N;
  ll ans=0;
  ll tmp;
   REP(i,N){
     cin>>tmp;
     ans ^=tmp;
   }
   if(!ans){
     cout<<"Yes"<<endl;
   }else{
     cout<<"No"<<endl;
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;

int main(){
    int N,W;cin >> N >> W;
    vector<LL> w(N),v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    vector<LL> dp(W+1);
    for (int i = 0; i < N; i++) {
        for (int j = W; j >= 0; j--) {
            if(dp[j]==0&&j!=0) continue;
            if(j+w[i]<=W) dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
        }
    }
    LL ans=0;
    for (int i = 0; i <= W; i++) {
        ans=max(ans,dp[i]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<utility>
#include<algorithm>
#include<functional>
using namespace std;
typedef pair<int,int> PII;
PII t[1000000];
int main()
{
	int n,c,i,m1,m2,m3,m4,s1,s2,s3,s4;
	while(scanf("%d",&n),n)
	{
		for(i=0;i<n;++i)
		{
			scanf("%d%d%d%d%d%d%d%d%d",&c,&m1,&s1,&m2,&s2,&m3,&s3,&m4,&s4);
			t[i].first=(m1+m2+m3+m4)*60+s1+s2+s3+s4;
			t[i].second=c;
		}
		partial_sort(t,t+2,t+n);
		printf("%d\n%d\n",t[0].second,t[1].second);
		partial_sort(t,t+2,t+n,greater<PII>());
		printf("%d\n",t[1].second);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    K = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    cur=7%K
    cnt=1
    for _ in range(K+1):
        if cur==0:
            print(cnt)
            return
        cur*=10
        cur+=7
        cur%=K
        cnt+=1
    print(-1)




if __name__ == "__main__":
    main()

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

int main()
{
	int n;
	int a[10001];
	int max = -1000000, min = 1000000;
	long long  sum = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (max < a[i]) max = a[i];
		if (min > a[i]) min = a[i];
		sum += a[i];
	}
	cout << min << " " << max << " " << sum << endl;
    return 0;
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        s: [chars; h],
    }

    let mut cur_id = 1;
    let mut ans = vec![vec![0; w]; h];

    let check_line = |y: usize| {
        for x in 0..w {
            if s[y][x] == '#' {
                return true;
            }
        }
        false
    };

    let mut start_y = 0;

    let mut y = 0;
    while y < h {
        while y < h && !check_line(y) {
            y += 1;
        }
        let sb_y = y;
        while y + 1 < h && !check_line(y + 1) {
            y += 1;
        }

        let mut start_x = 0;
        let mut x = 0;
        while x < w {
            while x < w && s[sb_y][x] != '#' {
                x += 1;
            }
            while x + 1 < w && s[sb_y][x + 1] != '#' {
                x += 1;
            }

            // println!("{} {} {} {}", start_y, y, start_x, x);

            for yy in start_y..y + 1 {
                for xx in start_x..x + 1 {
                    ans[yy][xx] = cur_id;
                }
            }
            cur_id += 1;

            x += 1;
            start_x = x;
        }

        y += 1;
        start_y = y;
    }

    for y in 0..h {
        for x in 0..w {
            if x > 0 {
                print!(" ");
            }
            print!("{}", ans[y][x]);
        }
        println!();
    }
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
const double PI = acos(-1.0);
const long mod = 1000000007;
const long INF = 1e9 + 1;

int n;
vector<vector<pair<int, int>>> v;

bool judge(int bit) {
  for(int i = 0; i < n; i++) {
    if(!(bit & (1 << i))) continue;
    for(pair<int,int> xy : v[i]) { 
      int x = xy.first;
      int y = xy.second;
      if(y == 1 && !(bit & (1 << x))) return false;
      if(y == 0 && (bit & (1 << x))) return false;
    }
  }
  return true;
}

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; i++) {
    int a; cin >> a;
    v[i].resize(a);
    for(int j = 0; j < a; j++) {
      cin >> v[i][j].first >> v[i][j].second;
      v[i][j].first--;
    }
  }

  int res = 0;
  for(int bit = 0; bit < (1 << n); bit++) {
    if(judge(bit)) {
      int cnt = 0;
      for(int i = 0; i < n; i++) {
        if(bit & (1 << i)) cnt++;
      }
      res = max(res,cnt);
    }    
  }

  cout << res << endl;
}

Measured memory_bytes: 3580
//from PKU1125
main(){
	int a,b,c,t,k,n,i,j,time[101][101],cost[101][101];
	for(;scanf("%d%d",&k,&n),n;){
		/*initialize*/
		memset(time,11,sizeof(time));
		memset(cost,11,sizeof(cost));
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++)time[i][j]=cost[i][j]=99999999;
			time[i][i]=cost[i][i]=0;
		}
		for(;k;k--){
			scanf("%d%d%d%d",&a,&b,&c,&t);
			time[a][b]=time[b][a]=t;
			cost[a][b]=cost[b][a]=c;
		}
		
		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++){
						if(time[i][j]>time[i][k]+time[k][j])
							time[i][j]=time[i][k]+time[k][j];
						if(cost[i][j]>cost[i][k]+cost[k][j])
							cost[i][j]=cost[i][k]+cost[k][j];
					}
		}
		
		{/*query*/
			for(scanf("%d",&k);k;k--){
				scanf("%d%d%d",&a,&b,&t);
				printf("%d\n",t?time[a][b]:cost[a][b]);
			}
		}
	}exit(0);
}

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main(){
  int n; 
  string s;
  cin >>s;
  vector<int> a(n),b(n),c(n);
  if(s == "Sunny") cout << "Cloudy";
  if(s == "Cloudy") cout << "Rainy";
  if(s == "Rainy") cout << "Sunny";
}




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

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

    return 0;
    

}

Measured memory_bytes: 256
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort()

ans = sum(p[0:X]) + sum(q[0:Y])
p = sorted(p[0:X], reverse=True)
q = sorted(q[0:Y], reverse=True)

for i in range(C):
    if p and q and r:
        if p[-1] <= q[-1] < r[-1]:
            ans += r.pop(-1)
            ans -= p.pop(-1)
        elif q[-1] <= p[-1] < r[-1]:
            ans += r.pop(-1)
            ans -= q.pop(-1)
        elif q[-1] < r[-1]:
            ans += r.pop(-1)
            ans -= q.pop(-1)
        elif p[-1] < r[-1]:
            ans += r.pop(-1)
            ans -= p.pop(-1)
        else:
            break
    elif p and r:
        if p[-1] < r[-1]:
            ans += r.pop(-1)
            ans -= p.pop(-1)
        else:
            break
    elif q and r:
        if q[-1] < r[-1]:
            ans += r.pop(-1)
            ans -= q.pop(-1)
        else:
            break
    else:
        break

print(ans)


Measured memory_bytes: 25800
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n;
        double[] s;
        double m;
        double a;
        int i;
        while((n=sc.nextInt())!=0){
            s=null;
            s=new double[n];
            m=0;
            for(i=0;i<n;i++){
                s[i]=sc.nextDouble();
                m+=s[i];
            }
            m/=n;
            a=0;
            for(i=0;i<n;i++){
                a+=Math.pow(s[i]-m,2);
            }
            a/=n;
            System.out.println(Math.sqrt(a));
        }
    }
}



Measured memory_bytes: 40228
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    String t = sc.next();
    String ans = "No";
    
    String ts = t.substring(0, s.length());
    
    if(ts.equals(s)){
      ans = "Yes";
    }
        
    System.out.print(ans);
    
  }
}

Measured memory_bytes: 35620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){

  char id[100];
  char new[100];
  
  
  scanf("%s",id);
  scanf("%s",new);
  
  for(int i=0;i<strlen(id);i++){
   if(id[i]!=new[i]){
    printf("No\n");
     return 0;
   }

}
  
  if(strlen(new)==strlen(id)+1){
   printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 1656
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] t = {"Sunny", "Cloudy", "Rainy"};
        String s = sc.next();

        int n;
        if(s.equals("Sunny")) {
        	n = 1;
        }else if(s.equals("Cloudy")) {
        	n = 2;
        }else {
        	n = 0;
        }

        System.out.println(t[n]);

        return;
    }

}

Measured memory_bytes: 20944
#include <iostream>
#include <cmath>

using namespace std;

const int N_MAX = 1000000;
int table[N_MAX];

int main() {
  table[0] = table[1] = 1;
  int sq = sqrt(N_MAX);
  for (int i = 2; i < sq+1; i++) {
    if (table[i] == 0) {
      for (int j = i*2; j < N_MAX; j += i) {
        table[j] = 1;
      }
    }
  }
  int n;
  while (cin >> n) {

    int ans = 0;
    for (int i = 0; i <= n; i++) {
      if (table[i] == 0) ans++;
    }
    cout << ans << endl;

  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
    int n,m,i,sum=0,count=0;
    float d;
    int array[100];
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
    {
        scanf("%d",&array[i]);
    }
    for(i=0;i<n;i++)
    {
        sum+=array[i];
    }
    d=(float)sum/(4.0*(float)m);
    for(i=0;i<n;i++)
    {
        if(array[i]<d)
        {
            continue;
        }
        else if(array[i]>=d)
        {
            count++;
        }
    }
    if(m<=count)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100010;

ll N,M;

map<string ,ll>mp;


int main(){
  cin>>N;
  string tmp;
  for(ll i=0;i<N;i++){
    cin>>tmp;
    mp[tmp]++;
  }
  cin>>M;
  for(ll i=0;i<M;i++){
    cin>>tmp;
    mp[tmp]--;
  }
  ll ans=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    ans=max(ans,itr->second);
  }
  cout<<ans<<endl;
  return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, K;
    cin >> N >> K;

    if (K > (N - 1) * (N - 2) / 2) {
        cout << -1 << endl;
        return;
    }

    vector<Pii> edges;
    for (ll i = 2; i <= N; i++) {
        edges.emplace_back(1, i);
    }

    ll cnt = (N - 1) * (N - 2) / 2;
    ll ucur = 2, vcur = 3;
    while (cnt > K) {
        edges.emplace_back(ucur, vcur);
        --cnt;
        if (vcur < N) {
            ++vcur;
        }
        else {
            ++ucur;
            vcur = ucur + 1;
        }
    }

    cout << edges.size() << "\n";
    for (const auto& p : edges) {
        cout << p.first << " " << p.second << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#define STR 10000000000
int main(){
    int a,b,c,k;
    int cnt = 0;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    if(a>=k){
        printf("%d\n",k);
    }else if((a+b)>=k){
        printf("%d\n",a);
    }else{
        printf("%d\n",a-(k-a-b));
    }
    return 0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <climits>
#include <queue>

using namespace std;

const int kSize = 100001;

vector<int> V;

struct Node {
    int to;
    int weight;

    Node(int _to, int _weight) {
        to = _to;
        weight = _weight;
    }
};

int n;
vector<Node> adj[kSize];
bool isMarked[kSize];
int tree[kSize];
int dis[kSize];

void Dijkstra(int s) {
    dis[s] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<> > pq;

    pq.push(make_pair(s, 0));
    //isMarked[s] = true;
    tree[s] = s;

    while (!pq.empty()) {
        pair<int, int> p = pq.top();
        pq.pop();
        int from = p.first;
        for (int i = 0; i < adj[from].size(); ++i) {
            int to = adj[from][i].to;
            if (dis[from] + adj[from][i].weight < dis[to]) {
                dis[to] = dis[from] + adj[from][i].weight;
                tree[to] = from;
                pq.push(make_pair(to, dis[to]));
            }
        }
    }

}

int main() {
    fill(isMarked, isMarked + kSize, false);
    fill(dis, dis + kSize, INT_MAX);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            adj[u].emplace_back(v, c);
        }
    }

    Dijkstra(0);
    for (int i = 0; i < n; ++i) {
        cout << i << " " << dis[i] << endl;
    }
}


Measured memory_bytes: 10672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}

void solve() {
  int n, k;
  cin >> n >> k;
  int cnt = 0;
  while (n) {
    n /= k;
    cnt++;
  }
  cout << cnt << endl;
}


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

int N, A[100], Count = 0;

void BubbleSort(int A[], int N) {
	bool flag = true;
	while (flag) {
		flag = false;
		for (int i = 0; i < N - 1; i++) {
			if (A[i] > A[i + 1]) {
				flag = true;
				swap(A[i], A[i + 1]);
				Count++;
			}
		}
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	BubbleSort(A, N);
	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << Count << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

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

    s64 maxCount = 0;
    s64 count = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R')
        {
            count++;
        }
        else
        {
            if(maxCount < count)
            {
                maxCount = count;
                count = 0;
            }
        }
    }

    if(maxCount < count)
    {
        maxCount = count;
        count = 0;
    }

    cout << maxCount << endl;

    return 0;
}


Measured memory_bytes: 3624
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);
use Math::BigInt;

my ($n, $e, $f) = split / /, <STDIN>;
my $MOD = 1e9 + 7;
my $modpow = sub {
  my ($a, $n) = @_;
  Math::BigInt->new($a)->bmodpow($n, $MOD)
};
my $modinv = sub {
  my $a = shift;
  Math::BigInt->new($a)->bmodinv($MOD);
};
my $combi = sub {
  my ($n, $k) = @_;
  my $c = reduce {$a * $b % $MOD} (($n-$k+1)..$n);
  my $d = reduce {$a * $b % $MOD} (1..$k);
  $c * $modinv->($d) % $MOD;
};
my $ans = $modpow->(2, $n) - 1;
$ans += $MOD - $combi->($n, $e);
$ans %= $MOD;
$ans += $MOD - $combi->($n, $f);
$ans %= $MOD;
say $ans;

Measured memory_bytes: 12544
/*
  Contest 115
  B - Christmas Eve Eve
  Rakesh Kumar --> 28/09/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    int n = 0;
    std::cin >> n;
    int total = 0;
    int max = 0;
    while (n--) {
        int p = 0;
        std::cin >> p;
        max = std::max(p, max);
        total += p;
    }
    total -= max;
    total += max >> 1;
    std::cout << total << std::endl;

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <string>
using namespace std;
static const int MAX = 100;

int main(){
    int n, A[MAX];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];

        for (int k = 0; k < n; k++){
            cout << A[k];
            if(k < n-1){
                cout << " ";
            }else{
            cout << endl;
            }
        }

    for (int i = 1; i < n; i++){
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        for (int k = 0; k < n; k++){
            cout << A[k];
            if(k < n-1){
                cout << " ";
            }else{
            cout << endl;
            }
        } 
    }
}


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N; cin >> N;
	N %= 10;
	if(N == 3) cout << "bon" << ln;
	else if(N == 0 or N == 1 or N == 6 or N == 8){
		cout << "pon" << ln;

	} else {
		cout << "hon" << ln;
	}
}


Measured memory_bytes: 3652
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var t = GeneratePrime(100000);
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var m = int.Parse(line[0]);
            var a = int.Parse(line[1]);
            var b = int.Parse(line[2]);
            if (m == 0 && a == 0 && b == 0) break;
            getAns(t, m, a, b);
        }
    }
    static void getAns(List<int> t, int m, int a, int b)
    {
        var maxpq = 0;
        var ansp = 0; var ansq = 0;
        var tc = t.Count();
        for (int i = 0; t[i] <= m / 2; i++)
        {
            var p = t[i];
            for (int j = i; t[j] <= m / 2; j++)
            {
                var q = t[j];
                if (p * q > m) break;
                if (q * a > b * p) break;
                if (p * q > maxpq) { maxpq = p * q; ansp = p; ansq = q; }
            }
        }
        Console.WriteLine("{0} {1}", ansp, ansq);
    }
    public static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Math.Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }
}



Measured memory_bytes: 16984
a, b = map(int, input().split())
s = input()
import sys
if len(s) != a + b + 1:
  print('No')
else:
  for i in range(a):
    if s[i].isdigit() == False:
      print('No')
      sys.exit(0)
  for i in range(b):
    if s[a+i+1].isdigit() == False:
      print('No')
      sys.exit(0)
  if s[a] != '-':
    print('No')
  else:
    print('Yes')


Measured memory_bytes: 3060
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] array = new int[6 + 1];
		array[0] = 0;
		for (int i = 1; i < array.length; i++) {
			array[i] = scan.nextInt();
		}
		String order = scan.next();
		scan.close();
		Dice dice = new Dice(array);
		array = dice.roll(order);
		System.out.println(array[1]);
	}
}
	

class Dice {
	int[] num = new int[6 + 1];
	Dice() {
	}

	Dice(int[] array) {
		for (int i = 0; i < array.length; i++) {
			this.num[i] = array[i];
		}
	}
	
	public int[] getNum() {
		return this.num;
	}
	
	public int getNumber(int i) {
		return this.num[i];
	}
	
	// ??????????????¢??????????????????
	public int[] roll(String order) {
		int now_1 = 1;	int now_2 = 2;	int now_3 = 3;	int tmp;
		int[] array = getNum();
		char[] check = {'N', 'E', 'S', 'W'};
		for (int i = 0; i < order.length(); i++) {
			for (int j = 0; j < check.length; j++) {
				if (order.charAt(i) == check[j]) {
					switch (j + 1) {
						case 1:
							tmp = now_1;
							now_1 = now_2;
							now_2 = 7 - tmp;
							break;
						case 2:
							tmp = now_1;
							now_1 = 7 - now_3;
							now_3 = tmp;
							break;
						case 3:
							tmp = now_1;
							now_1 = 7 - now_2;
							now_2 = tmp;
							break;
						case 4:
							tmp = now_1;
							now_1 = now_3;
							now_3 = 7 - tmp;
							break;
					}
				}
			}
		}
		int[] cp_array = new int[array.length];
		cp_array[1] = array[now_1]; cp_array[2] = array[now_2];
		cp_array[3] = array[now_3]; cp_array[4] = array[7 - now_3];
		cp_array[5] = array[7 - now_1]; cp_array[6] = array[7 -now_2];
		return cp_array;
	}
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 300001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(6);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    ll cur = 100;
    ll x;
    cin >> x;
    int ans = 0;
    while (cur < x) {
        cur = cur + cur / 100;
        ++ans;
    }
    cout << ans;
    auto end = chrono::steady_clock::now();

    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 3652
from fractions import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    a,b = map(int,input().split())
    c = gcd(a,b)
    cnt = factorization(c)
    if cnt[0][0]==1:
        print(len(cnt))
    else:
        print(len(cnt)+1)

if __name__ == "__main__":
    main()

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

int main() {
  int x[3];
  int k;
  cin >> x[0] >> x[1] >> x[2] >> k;
  
  sort(x, x + 3);
  for (int i = 0; i < k; i++) {
    x[2] *= 2;
  }
  cout << x[0] + x[1] + x[2] << endl;
}


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

int main() {
  int N;
  cin>>N;
  int a,b,c,d;
  a = N/1000;
  b = N%1000/100;
  c = N%1000%100/10;
  d = N%1000%100%10;
  if(a == b && b==c)
  cout <<"Yes" << endl;
  else if(b==c&&c==d)
  cout <<"Yes"<<endl;
  else
  cout <<"No"<<endl;
  
}


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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int i;
  vector<int> a(n);
  for(i=0;i<n;i++){
    a.at(i)=s.at(n-i-1)-'0';
  }
  
  vector<int> mod(n);
  mod.at(0)=1;
  for(i=1;i<n;i++){
    mod.at(i)=(10*mod.at(i-1))%2019;
  }
  
  vector<int> x(n+1);
  vector<long long> p(2019,0);
  x.at(0)=0;
  p.at(0)++;
  for(i=1;i<=n;i++){
    x.at(i)=(x.at(i-1)+a.at(i-1)*mod.at(i-1))%2019;
    p.at(x.at(i))++;
  }
  
  long long S=0;
  for(i=0;i<2019;i++){
    S=S+p.at(i)*(p.at(i)-1)/2;
  }
  
  cout << S << endl;
}

Measured memory_bytes: 5968
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
if a[0] <= b[0]:
    ans = a[0]
    count = b[0] - a[0]
else:
    ans = b[0]
    count = 0
for i in range(1,n):
    if count + b[i] >= a[i]:
        ans = ans + a[i]
        if count >= a[i]:
            count = b[i]
        else:
            count = b[i] + count - a[i]
    else:
        ans = ans + count + b[i]
        count = 0
if a[n] <= count:
    ans = ans + a[n]
else:
    ans = ans + count
print(ans)

Measured memory_bytes: 19004
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main() {
    double a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    double answ = 1, anss = 0;
    for (int ai = 0; ai*a*100 <= f; ai++) {
        for (int bi = 0; ai*a*100+bi*b*100 <= f; bi++) {
            for (int ci = 0; ci*c <= (ai*a+bi*b)*e && ci*c+ai*a*100+bi*b*100 <= f; ci++) {
                for (int di = 0; ci*c+di*d <= (ai*a+bi*b)*e && ci*c+di*d+ai*a*100+bi*b*100 <= f; di++) {
                    if (anss/(answ+anss) <= (ci*c+di*d)/(ci*c+di*d+ai*a*100+bi*b*100)) {
                        answ = (ai*a*100+bi*b*100), anss = ci*c+di*d;
                    }
                }
            }
        }
    }

    cout << answ + anss << " " << anss << endl;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
L = [0 for _ in range(N)]
flg = True
for i in range(N):
  cnt = -1
  for j in range(N-i, 0, -1):
    if j == A[j-1]:
      cnt = j
      break
  if cnt == -1:
    flg = False
    break
  else:
    L[N-i-1] = cnt
    for j in range(cnt, N-i):
      A[j-1] = A[j]
if flg:
  for i in range(N):
    print(L[i])
else:
  print(-1)

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n, m;
  cin >> n >> m;
  if (m / 2 <= n) {
    cout << m / 2 << '\n';
    return;
  }
  int r = (m - 2 * n) / 2;
  if (r % 2) r--;
  n += r / 2;
  m -= r;
  cout << min(n, m / 2) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3624
n = int(input())
arr = list(map(int, input().split()))
for i in range(n-1, 1, -1):
  if(arr[i-1] <= arr[i]):
    a = 1
  else:
    if(arr[i-1] - 1 > arr[i]):
      print("No")
      exit()
    else:
      arr[i-1] = arr[i - 1] - 1
if(sorted(arr) == arr):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14380
from collections import deque

N = int(input())
ABC=[map(int,input().split(' ')) for i in range(N-1)]
Q,K =  map(int,input().split(' '))
query = [map(int,input().split(' ')) for i in range(Q)]
tree = [[] for i in range(N+1)]
for a,b,c in ABC:
    tree[b].append((a,c))
    tree[a].append((b,c))
k_shortest = [0]*(N+1)
stack=deque([K])
while stack:
    k = stack.popleft()
    for v,d in tree[k]:
        if k_shortest[v] == 0:
            k_shortest[v] = k_shortest[k]+d
            stack.append(v)
for i,j in query:
    print(k_shortest[i]+k_shortest[j])

Measured memory_bytes: 124512