akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  sort(a,a+n);
  int used[n+1]={};
  ll ans=0,sum=0;
  ll tmp=a[0];
  used[0]=1;
  int l=1,r=n-1;
  sum=sum+abs(a[r]+a[r-1]-tmp*2);
  tmp=a[r]+a[r-1];
  used[r]=1;
  used[r-1]=1;
  int lastl=r-1,lastr=r;
  r-=2;

  while(l<r){

    ll w=a[l]+a[l+1];
    used[l]=1;
    used[l+1]=1;
    lastl=l,lastr=l+1;
    l+=2;
    sum=sum+abs(tmp-w);
    tmp=w;

    if(r<=l) break;

    ll z=a[r]+a[r-1];
    used[r]=1;
    used[r-1]=1;
    lastl=r-1;
    lastr=r;
    r-=2;
    sum=sum+abs(z-tmp);
    tmp=z;
  }
  if(n%2==0){
    for(int i=0;i<n;i++){
      if(used[i]==0){
        sum=sum+max(abs(a[i]-a[lastl]),abs(a[lastr]-a[i]));
        break;
      }
    }
  }

  ans=max(ans,sum);

  reverse(a,a+n);
  tmp=a[0];
  for(int i=0;i<n;i++) used[i]=0;
  used[0]=1;
  l=1;
  r=n-1;
  sum=abs(a[r]+a[r-1]-tmp*2);
  tmp=a[r]+a[r-1];
  used[r]=1;
  used[r-1]=1;
  lastl=r-1;
  lastr=r;
  r-=2;

  while(l<r){

    ll w=a[l]+a[l+1];
    used[l]=1;
    used[l+1]=1;
    lastl=l;
    lastr=l+1;
    l+=2;
    sum=sum+abs(tmp-w);
    tmp=w;

    if(r<=l) break;

    ll z=a[r]+a[r-1];
    used[r]=1;
    used[r-1]=1;
    lastl=r-1;
    lastr=r;
    r-=2;
    sum=sum+abs(z-tmp);
    tmp=z;
  }
  if(n%2==0){
    for(int i=0;i<n;i++){
      if(used[i]==0){
        sum=sum+max(abs(a[i]-a[lastl]),abs(a[lastr]-a[i]));
        break;
      }
    }
  }
  //cout<<sum<<endl;
  ans=max(ans,sum);

  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 1408
#include <vector>
#include <iostream>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge> >;

Graph G;
vector<int> d; // d[i]根から頂点iまでの距離
void Dfs(int v, int parent)
{ 
    for (auto e : G[v])
    {
        if (e.first == parent) continue; // 逆流を防ぐ(探索の肝！)
        d[e.first] = d[v] + e.second;
        Dfs(e.first, v);
    }
}

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

    int u, v, w;
 
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N - 1; ++i)
    {
        cin >> u >> v >> w;
        --u; --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    d.assign(N, 0);
    Dfs(0, -1);

    for (auto ans : d) cout <<(ans & 1)<< endl;

    return 0;
};


Measured memory_bytes: 8192
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e8;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	ll n, m, x;
	cin >> n >> m >> x;
	vl c(n);
	vvl a(n, vl(m));
	loop(i, n)
	{
		cin >> c[i];
		loop(j, m)	cin >> a[i][j];
	}
	ll ans = inf;
	loop(i, 1 << 12)
	{
		vl curr(m, 0);
		ll cost = 0;
		loop(j, n)
		{
			if ((i >> j) & 1)
			{
				cost += c[j];
				loop(k, m)
				{
					curr[k] += a[j][k];
				}
			}
		}
		bool ok = 1;
		loop(j, m)
		{
			if (curr[j] < x)
			{
				ok = 0;
			}
		}
		if (ok)
		{
			ans = min(ans, cost);
		}
	}
	if (ans == inf)
		ans = -1;
	cout << ans << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

Measured memory_bytes: 3640
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    D=[int(_) for _ in input().split()]
    dc=Counter(D)
    mod,ans=998244353,1
    if D[0]!=0 or dc[0]!=1:
        print(0)
        sys.exit()
    for i,_ in enumerate(list(dc.items())):
        if i>1:
            ans*=dc[i-1]**dc[i]%mod
    print(ans%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 64180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(reader.readLine());

        String[] line;

        int[][] input = new int[n][3];

        for (int i = 0; i < n; i++) {
            line = reader.readLine().split(" ");
            input[i][0] = Integer.parseInt(line[0]);
            input[i][1] = Integer.parseInt(line[1]);
            input[i][2] = Integer.parseInt(line[2]);
        }


        for (int i = 1; i < n; i++) {

            input[i][0] = Math.max(input[i-1][1], input[i-1][2]) + input[i][0];
            input[i][1] = Math.max(input[i-1][0], input[i-1][2]) + input[i][1];
            input[i][2] = Math.max(input[i-1][0], input[i-1][1]) + input[i][2];

        }

        System.out.println(Arrays.stream(input[n-1]).max().getAsInt());


    }
}


Measured memory_bytes: 47692
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

    ll N, M, C ;
    vector<ll> B;
    vector<vector<ll> > A;
    cin >> N >> M >> C;

    rep(i, M){
        ll inp; cin >> inp;
        B.pb(inp);
    }

    ll ans =0 ;
    rep(i, N){
        ll ret = C ;

        rep(j, M){
            ll inp; cin >> inp;
            ret += (inp * B[j]);
        }

        if(ret > 0) ans ++ ;
    }

    cout << ans << endl;


	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  string s;
  cin>>s;
  ll ans=0;
  rep(i,s.size()){
    if(s[i]=='x')ans++;
  }
  if(ans>=8)op("NO")
  else op("YES")
  return 0;
}


Measured memory_bytes: 256
N = int(input())

if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(N - 99 + 9)
elif N < 10000:
    print(900 + 9)
elif N < 100000:
    print(N - 9999 + 909)
else:
    print(90909)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

map<ll, int> prime_factor(vector<ll> X) {
    map<ll, int> ret;
    for (int j = 0; j < X.size(); j++) {
        int n = X[j];
        map<ll, int> mp;
        for (int i = 2; i * i <= n; i++) {
            while (n % i == 0) {
                mp[i]++;
                n /= i;
            }
        }
        if (n != 1) mp[n]++;

        for(auto x: mp){
            if(ret[x.fi] < x.se) ret[x.fi] = x.se;
        }
    }
    return ret;
}

ll beki(ll x, ll n, const ll &p) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
    vector<ll> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    auto mp = prime_factor(A);
    ll g = 1;
    for(auto x: mp){
        for (int i = 0; i < x.se; i++) g = g * x.fi % mod;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans = (ans + g * beki(A[i], mod - 2, mod)) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

const int M = 1e9+7;
int n;
bool a[21][21];
int bitcnt[1 << 21];
long long dp[1 << 21];

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }

  dp[0] = 1;

  for (int s = 1; s < (1 << n); s++) {
    bitcnt[s] = bitcnt[s/2] + s % 2;
    for (int l = 0; l < n; l++) {
      if ((s >> l) % 2 == 0) continue;
      dp[s] += dp[s - (1 << l)] * a[bitcnt[s]-1][l];
      dp[s] %= M;
    }
  }

  cout << dp[(1 << n) - 1] << endl;
  return 0;
}

Measured memory_bytes: 24832
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var c = new int[361];
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var m = int.Parse(line[0]);
            var d = int.Parse(line[1]);
            var a = int.Parse(line[2]);
            var s = int.Parse(line[3]);
            setC(c, m, d, a, s);
        }
        var ans = getAns(c);
        Console.WriteLine(ans);
    }
    static int getAns(int[] c)
    {
        var ans = int.MaxValue;
        for (int i = 1; i <= 360; i++) ans = Min(ans, c[i]);
        return ans;
    }
    static void setC(int[] c, int m, int d, int a, int s)
    {
        var w = (m - 1) * 30 + d;
        for (int i = 1; i < s; i++)
        {
            var t = w - i;
            while (t < 1) t += 360;
            c[t] = Max(c[t], s - i);
            var t2 = w + a - 1 + i;
            while (t2 > 360) t2 -= 360;
            c[t2] = Max(c[t2], s - i);
        }
        var imax = w + a - 1;
        for (int i = w; i <= imax; i++)
            if (i > 360) c[i - 360] = Max(c[i - 360], s);
            else c[i] = Max(c[i], s);
    }
}



Measured memory_bytes: 17984
/// DONOT COPY PASTA WITHOUT AUTHOR'S PERMISSION ///
 ///                   S S S                      ///
///                1 7 0 7 0 5 3                 ///

#include<bits/stdc++.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>
#include<string>
///STL
#define mp make_pair
#define ss second
#define ff first
#define pb push_back
#define ist insert
///ONLINE JUDGE
#define io ios_base::sync_with_stdio;cin.tie(0);cout.tie(0)
#define READ freopen("input.txt","r", stdin)
#define case(i) "Case "<<i++<<": "
#define nscase(i) "Case "<<i++<<":"
///c shortcuts
#define sns(s) scanf("%s",&s)
#define snc(c) scanf("%c",&c)
#define snd(a) scanf("%d",&a)
#define snl(a) scanf("%lld",&a)
#define snul(a) scanf("%ull",&a)
///Loops
#define mem(a,b) memset(a, b, sizeof(a))
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rev(j,n,k) for(int j=n;j>=k;j--)
#define TC int tc;cin>>tc;while(tc--)

///GCD LCM
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a / __gcd(a, b) ) * b)

///CONSTANTS
#define PI 2*acos(0.0)
#define MAX 1000000000
#define inf 1e18

///functions
#define base(n,b) floor(log(n)/log(b))+1
#define onecnt(x) __builtin_popcount(x)
#define to_binary(n,b) bitset<b>(n).to_string()

#define endl '\n'
#define esc cout<<"\n"

/*------------------------------Graph Moves----------------------------*/
///const int fx[]= {+1,-1,+0,+0};
///const int fy[]= {+0,+0,+1,-1};
///const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
///const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
///const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
///const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef std::map<long long,int> mli;
typedef std::map<long long,long long> mll;
typedef std::map<int,int> mii;

///PBDS
using namespace __gnu_pbds;
typedef tree<
ll,
null_type,//set to another type while using map
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

template <typename T>
std::string toString( T Number )
{
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}

///constants
const ll ten5=100000;
const ll ten6 =1000000;
const ll ten7 =10000000;
const ll ten8 =100000000;
const ll ten9 =1000000000;
const ll mod=ten9+7;



int main()
{
    io;

    int n;
    cin>>n;

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

    pair< int,pii>p[n];

    for(int i=0;i<n;i++){
        p[i]=mp(a[i]-b[i],mp(a[i],b[i]));
    }
    sort(p,p+n);

    int sum=0;

    for(int i=n-1;i>=0;i--){
        if(p[i].ff>0) sum+=p[i].ff;
        else break;
    }

    cout<<sum;
}



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

using namespace std;

typedef long long ll;

ll N;

ll func ( ll K, ll pos )
{
  if ( K == N ) return 1;
  ll l,r,maxl,minl;
  ll ans = 0;
  l = pos-1; r = N-pos;
  maxl = max(l,r); minl = min(l,r);

  //cout << maxl << " " << minl << "\n";

  if ( minl < K ) {
    ++ans;
    maxl -=(K-minl-1);
    ans += ( maxl/(K-1) );
    if ( maxl%(K-1) > 0 ) ++ans;
  } else {
    ++ans;
    minl -= ( minl%(K-1) );
    ans += ( minl/(K-1) );
    maxl -= ( K-(minl%(K-1))-1 );
    ans += ( maxl/(K-1) );
    if ( maxl%(K-1) > 0 ) ++ans;
  }

  return ans;
}

int main()
{
  ll K;
  cin >> N >> K;
  ll pos;
  for ( int i = 1; i <= N; ++i ) {
    int tmp;
    scanf("%d", &tmp);
    if ( tmp == 1 ) pos = i;
  }

  cout << func ( K,pos) << endl;

}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  string s;cin>>s;
  bool lock[n];
  int left = 0;
  int right = 0;
  for(int i = 0; n > i; i++)lock[i] = false;
  for(int i = 0; n > i; i++){
    if(lock[i])continue;
    bool ok = false;
    if(s[i]=='('){
      for(int j = i+1; n > j; j++){
        if(!lock[j]&&s[j]==')'){
          ok = true;
          lock[j] = true;
          lock[i] = true;
          break;
        }
      }
      if(!ok)right++;
    }else{
      for(int j = i-1; 0 <= j; j--){
        if(!lock[j]&&s[j]=='('){
          ok = true;
          lock[j] = true;
          lock[i] = true;
          break;
        }
      }
      if(!ok)left++;
    }
  }
  for(int i = 0; left > i; i++)cout << "(";
  cout << s;
  for(int i = 0; right > i; i++)cout << ")";
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <iomanip>
using namespace std;
int main() {
    string s; cin>>s;
    int n1=0,n2=0;
    for(int i=0; i<(int)s.length();i++){
        //case w b w b
        if( (i%2 == 0) && s[i] !='0') n1++;
        else if( (i%2 == 1) && s[i] !='1') n1++;

        if( (i%2 == 0) && s[i] !='1') n2++;
        else if( (i%2 == 1) && s[i] !='0') n2++;
    }
    cout << min(n1,n2)<<endl; 
}

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

int calcDebt(int debt){
	double tmp = debt * 1.05;
	int result = (int) ceil(tmp);
	if(result % 1000 == 0){
		return result;
	}else{
		return (result / 1000 + 1) * 1000;
	}
}
int main(){
	int result = 100000;
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		result = calcDebt(result);
	}
	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 1024
from math import sin, cos, pi, sqrt
a, b, C = map(int, input().split())
S = a*b*sin(C*pi/180)/2
c = sqrt(a**2 + b**2 - 2*a*b*cos(C*pi/180))
h = 2*S/a
print(S)
print(a+b+c)
print(h)



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

typedef long long ll;

ll beki(ll a, ll n){
    if(n == 0){
        return 1;
    }
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1){
        ans = ans * a;
    }
    return ans;
}

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

    ll n,k;
    cin >> n >> k;
    ll ans;
    for(int i=1;i<61;i++){
        ll a = beki(k,i-1);
        ll b = beki(k,i);
        if(a<=n && n<b){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char s[100],t[100];
  int i;
  int flag = 0;
  
  scanf("%s %s",s,t);
  
  for(i = 0; s[i] != '\0'; i++){
    if(s[i] != t[i]){
      printf("No\n");
      return 0;
    }
  }
  
  printf("Yes\n");
  return 0;
}
 
  
      

Measured memory_bytes: 1648
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
	VI a(3);
	REP(i, 3) cin >> a[i];
	SORT(a);
	cout << (a[0] + a[1] == a[2] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
// Author--> darklight13
#define _CRT_SECURE_NO_DEPRECATE
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int dp[101][100007],w[100][100007];
int32_t main()
{
	int n,w;cin>>n>>w;
	int a[n+1],b[n+1];
	memset(dp,-1,sizeof dp);
	for(int i=1;i<=n;i++)	cin>>a[i]>>b[i];
	for(int i=0;i<=n;i++)	dp[i][0]=0;
	if(a[1]<=w)	dp[1][b[1]]=a[1];
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<=100000;j++)
		{
			if(dp[i-1][j]!=-1)
			{
				if(j+b[i]<=100000 && dp[i-1][j]+a[i]<=w)
				{
					dp[i][j+b[i]] = dp[i-1][j]+a[i];
				}
				if(dp[i][j]==-1){
					dp[i][j] = dp[i-1][j];
					continue;
				}
				dp[i][j] = min(dp[i-1][j],dp[i][j]);
			}
		}
	}
	int ans =0;
	for(int i=0;i<=100000;i++)
	{
		if(dp[n][i]!=-1)	ans = i;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 79488
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 74884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#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, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int maxn = 100000;
const int maxm = 200000;

template <class Abel> struct UnionFind{
    vector<int> parent;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n,Abel sum_unity = 0){
        parent.resize(n); rank.resize(n); diff_weight.resize(n);
        REP(i,n){
            parent[i] = i; rank[i] = 0; diff_weight[i] = sum_unity;

        }
    }

    int  root(int x){
        if(parent[x] == x) return x;
        else{
            int r = root(parent[x]);
            diff_weight[x] += diff_weight[parent[x]];
            return parent[x] = r;
        }
    }

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

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

    bool unite(int x,int y,int w){
        w+= diff_weight[x];
        w-= diff_weight[y];
        x = root(x);
        y = root(y);

        if(x == y) return false;

        else{
            if(rank[x] < rank[y]) swap(x,y) , w = -w;
            if(rank[x] == rank[y]) rank[x]++;
            parent[y] = x;
            diff_weight[y] = w;
            return true;
        }
    }

    Abel diff(int x, int y){
        return weight(y) - weight(x);
    }

};

int N,M;
int L[maxm], R[maxm], D[maxm];
//vector<int> x(maxn,INF);

int main(){
    cin >> N >> M;
    UnionFind<int> uni(N, 0);

    bool ans = true;
    REP(i,M){
        int l,r,d;
        cin >> l >> r >> d;
        l--; r--;
        
        if(uni.issame(l,r)){
            if(uni.diff(l,r) != d){
                ans = false;
                //cout << l << " " << r << endl;
                break;
            }
        }
        else{
            uni.unite(l,r,d);
        }

    }
    cout << (ans ? "Yes" : "No") << endl;

}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }


int n,a[N],cum;


void solve() {
    cin>>n;
    vi a(n,0);
    rep(i,0,n) {
		  cin>>a[i];
		  cum^=a[i];
		}
	vi ans;
	
	rep(i,0,n) {
		   int yo=cum^a[i];
		   ans.pb(yo);
		}	
		
	for(auto to:ans)
	  cout<<to<<" ";
	  cout<<endl;	
    
    
 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	  solve();

return 0;	   
}


Measured memory_bytes: 6860
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

bool isnum(char c){
    return (c>='0'&&c<='9');
}

void no(){
    cout1("No")
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    string s;
    cin>>a>>b>>s;
    
    rep(i,a){
        if(!isnum(s[i])) no();
    }
    
    if(s[a]!='-') no();
    
    rep(i,b){
        if(!isnum(s[a+1+i])) no();
    }
    cout1("Yes")
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int n,m;cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
}

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

int main() {

  long long N;
  cin >> N;

  int keta = 0;
  long long ban_min = 1;
  long long ban_max = 26;

  while(true){
    keta++;
    if(N <= ban_max){
      break;
    }else{
      ban_min = ban_max + 1;
      ban_max = (ban_max + 1) * 26;
    }
  }



  N -= ban_min;
  string s = "";

  long long beki;
  for(int i = keta; i > 0; i--){
    beki = 1;
    for(int j = 1; j < i; j++){
      beki *= 26;
    }

    s = s + char('a' + (N / beki));
    N = N % beki;
  }
  cout << s << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int cnt = 0;
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = min(a, b); i > 0; i--)
    {
        if(a % i == 0 && b % i == 0)
        {
            cnt++;
        }
        if(cnt == k)
        {
            cout << i;
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (x, a, b) = (line[0], line[1], line[2]);
    if (a-x).abs() < (b-x).abs(){
        println!("A");
    }else{
        println!("B");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(){
 int A,B;
 scanf("%d%d",&A,&B);
 
 int i,cnt=1,num=A;
 if(B==1){
   printf("0\n");
 }
 else{
 while(num<B){
   num += A-1;
   cnt++;
 }
 printf("%d\n",cnt);
 }
 return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int n;
const ll mod=1e9+7;
ll mem[100][10][10];
char s[2][100];
ll dp(int x, int c1, int c2){
  if(x==n)
    return 1;
  if(mem[x][c1][c2]!=-1)
    return mem[x][c1][c2];
  int tmp1=-1, tmp2=-1;
  if(s[0][x]==s[0][x-1]){
    tmp1=c1;
  }
  if(s[1][x]==s[1][x-1]){
    tmp2=c2;
  }
  ll res=0;
  if(s[0][x]==s[1][x]){
    for(int i=0; i<3; ++i){
      if(i==c1||i==c2)
        continue;
      res+=dp(x+1, i, i);
      res%=mod;
    }
    mem[x][c1][c2]=res;
    return res;
  }
//  cout<<x<<"::"<<tmp1<<" "<<tmp2<<endl;
  if(tmp1!=-1){
    if(tmp2!=-1){
      res=dp(x+1, tmp1, tmp2);
      res%=mod;
    }
    else{
      for(int i=0; i<3; ++i){
        if(i!=tmp1&&i!=c2)
          res+=dp(x+1, tmp1, i);
        res%=mod;
      }
    }
  }
  else{
    if(tmp2!=-1){
      for(int i=0; i<3; ++i){
        if(i!=tmp2&&i!=c1)
          res+=dp(x+1, i, tmp2);
        res%=mod;
      }
    }
    else{
      for(int i=0; i<3; ++i){
        if(i==c1)
          continue;
        for(int j=0; j<3; ++j){
          if(i==j||j==c2)
            continue;
          res+=dp(x+1, i,j);
          res%=mod;
        }
      }
    }
  }
  res%=mod;
  mem[x][c1][c2]=res;
  return res;
}
int main(){
  while(cin>>n){
    memset(mem, -1, sizeof mem);
    scanf("%s",s[0]);
    scanf("%s",s[1]);
    ll ans;
    if(s[0][0]==s[1][0])
      ans=dp(1,0,0)+dp(1,1,1)+dp(1,2,2);
    else
      ans=dp(1,0,1)+dp(1,1,0)+dp(1,2,1)+dp(1,1,2)+dp(1,0,2)+dp(1,2,0);
    ans%=mod;
    cout<<ans<<endl;
  }
  return 0;
}




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

typedef long long ll;
const int MaxN = 212345;
const ll mod = 998244353;


void solve_case() {
	int n;
	cin >> n;
	
	ll mat[n][3];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; ++j) {
			cin >> mat[i][j];
		}
	}
	
	ll dp[n + 1][3];
	memset(dp, 0, sizeof(dp));
	
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			int ff = j + 1;
			int ss = j + 2;
			ff %= 3, ss %= 3;
			
			dp[i][j] = max(dp[i - 1][ff], dp[i - 1][ss]);
			dp[i][j] += mat[i - 1][j];
		}
	}
	
	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << "\n";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll t=1;
    //cin >> t;
    while(t--) solve_case();
}


Measured memory_bytes: 8240
/*input
-3 -1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	ll a,b;
	cin>>a>>b;
	if(a<=0&&b>=0){
		cout<<"Zero\n";
		return 0;
	}

	if(b>0) b=0;
	if((a-b)%2==0) cout<<"Negative";
	else cout<<"Positive";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#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 REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

vector<vl> a(22, vl(22, 0));
vector<vl> table(22, vl(1<<21, -1));

ll dp(ll n, ll b) {
  // cout << n << " " << b << endl;
  if (table[n][b] != -1) return table[n][b];
  ll v = 0;
  if (n == N) {
    ll r = 1;
    ll _b = b;
    while((_b & 1) == 0) {
      r++;
      _b >>= 1;
    }
    if (a[n][r] == 1) v = 1;
    else v = 0;
  } else {
    FOR(r, 1, N+1) {
      ll _b = (b >> (r-1)) & 1;
      if (_b == 1 && a[n][r] == 1) {
        v += dp(n+1, b - (1<<(r-1)));
        v %= MOD;
      }
    }
  }
  table[n][b] = v;
  return v;
}

int main(void){
  
  IN(N);
  FOR(i, 1, N+1) {
    FOR(j, 1, N+1) {
      IN(a[i][j]);
    }
  }

  ret = dp(1, (1<<N)-1);
  PRINT(ret);

}


Measured memory_bytes: 377216
#include <iostream>
#include <fstream>

using namespace std;

typedef struct trump{
    char suit;
    int num,id;
} trump_t;

void pp_trump(trump_t *t){
    cout << t->suit << " " << t->num << endl;
}

void swap(trump_t *a, trump_t *b){
    trump_t temp = *a;
    *a = *b;
    *b = temp;
    return;
}

int partition(trump_t *t,int t_size, int p, int r){
    int x = t[r].num;
    int i = p-1;
    for(int j=p;j<r;j++){
        if(t[j].num <= x){
            i++;
            swap(t+i,t+j);
        }
    }
    swap(t+i+1,t+r);
    return i+1;
}

void quickSort(trump_t *t, int t_size, int p ,int r){
    if(p<r){
        int q = partition(t,t_size,p,r);
        quickSort(t,t_size,p,q-1);
        quickSort(t,t_size,q+1,r);
    }
}

int checkStable(trump_t *t, int t_size){
    for(int i=0;i<t_size;i++){
        if(t[i].num == t[i-1].num){
            if(t[i].id < t[i-1].id){
                return 0;
            }
        }
    }
    return 1;
}

int main(){
    int n;
    cin >> n;
    trump_t *t = new trump_t[n];
    for(int i=0;i<n;i++){
        cin >> t[i].suit >> t[i].num;
        t[i].id = i;
    }
    quickSort(t,n,0,n-1);
    if(checkStable(t,n)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    for(int i=0;i<n;i++){
        pp_trump(t+i);
    }
    return 0;
}



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

int main()
{
    string s;
    cin >> s;
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) 
        cout << "Yes" << endl;
    else if (s[0] == s[2] && s[2] != s[1] && s[1] == s[3])
        cout << "Yes" << endl;
    else if (s[0] == s[3] && s[3] != s[1] && s[1] == s[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main(){
    string s;
    cin >> s;
    bool ans=true;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]) ans=false;
    }
    if(ans) cout << "Good" << endl;
    else cout << "Bad" << endl;
}

Measured memory_bytes: 256
from sys import stdin 
n,m = map(int,stdin.readline().split())
a = []
b = []
valid = [0] * m
for i in xrange(n):
    x,y = map(int,stdin.readline().split())
    a.append((x,y))
for i in xrange(m):
    x,y = map(int,stdin.readline().split())
    b.append((x,y))
for i in xrange(n):
    ans = 10**18 
    ind = -1
    for j in xrange(m):
        #if valid[j]:
         #   continue 
        fir = a[i][0] - b[j][0]
        sec = a[i][1] - b[j][1]
        if fir < 0:
            fir = -fir 
        if sec < 0:
            sec = -sec
        if fir + sec < ans:
            ans = fir + sec 
            ind = j 
    print ind + 1 
    #valid[j] = 1 



Measured memory_bytes: 2696
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

int main(){
        int N, M;
        cin >> N >> M;
        string A[50];
        string B[50];
        for (int i = 0; i < N; i++) {
                cin >> A[i];
        }
        for (int i = 0; i < M; i++) {
                cin >> B[i];
        }

        bool can = false;
        for (int i = 0; i <= N-M; i++) {
                for (int j = 0; j <= N-M; j++) {

                        bool can2 = true;
                        for (int k = 0; k < M; k++) {
                                for (int l = 0; l < M; l++) {
                                        if (A[i+k][j+l] != B[k][l]) {
                                                can2 = false;
                                        }
                                }
                        }
                        if (can2) can = true;
                }
        }

        if (can) cout << "Yes" << endl;
        else cout << "No" << endl;

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int x,y;
	cin>>x>>y;
	if(x<=y){
		while(x != 0){
			int v;
			v = x;
			x = y%x;
			y = v;
		}
		cout<<y<<endl;
	}
	else if(y <= x){
		while(y != 0){
			int v;
			v = y;
			y = x%y;
			x = v;
		}
		cout<<x<<endl;
	}
	return 0;
}



















//解けるけど時間がかかるやつ
/*int main(){
	int x,y;
	cin>>x>>y;
	if(x<=y){
		for(int i = x;i>=1;i--){
			if(x%i == 0 && y%i == 0){
				cout<<i<<endl;
				break;
			}
		}
	}
	else if(x>=y){
		for(int i = y;i>=1;i--){
			if(x%i == 0 && y%i == 0){
				cout<<i<<endl;
				break;
			}
		}
	}
	return 0;
}*/


Measured memory_bytes: 3100
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

nn = inputs[0][0]
aa = inputs[0][1]
bb = inputs[0][2]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p nn
  p aa
  p bb
end

ans = 0
for j in 1..nn
  sum = 0
  jj = j.to_s
  jj.length.times do |i|
    sum += jj[i].to_i
  end
  if sum <= bb and aa <= sum
    ans += j
  end
end

puts ans


Measured memory_bytes: 1788
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    A = list(map(int, input().split()))
    K = int(input())

    for i in range(K):
        A[A.index(max(A))] *= 2

    print(sum(A))

main()


Measured memory_bytes: 5056
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if((a + b)% 2 == 0){
            System.out.println((a + b) / 2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 21844
n, q = map(int, input().split())
s = input()
a = [0]*n
for i in range(n-1):
    if s[i:i+2] == 'AC':
        a[i+1] = 1
    if i > 0:
        a[i] += a[i-1]
a[n-1] += a[n-2]

for i in range(q):
    l, r = map(int, input().split())
    t = a[r-1]-a[l-1]
    print(t)


Measured memory_bytes: 9076
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll lcm(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll gcd(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){

    int x;
    cin >> x;

    int mx = 1;
    for (int b = 2; b <= x; ++b) {
        for (int p = 2; ; ++p) {
            if (pow(b, p) <= x) {
                mx = max((double)mx, pow(b, p));
            }
            else break;
        }
    }


    cout << mx << endl;

   



}



//              g++ -std=c++1z


Measured memory_bytes: 384