akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<stack>
#include<string>
#include<sstream>
int StoI(std::string str) {
	int ret;
	std::stringstream ss;
	ss << str;
	ss >> ret;
	return ret;
}
class Equation {
	std::stack<int>st;
public:
	void RenewStack(int num);
	int ReturnStack(void);
	void DeleteStack(void);
};
void Equation::RenewStack(int num) {
	//????°???????????????????
	st.push(num);
}
int Equation::ReturnStack(void) {

	return st.top();
}
void Equation::DeleteStack(void) {
	st.pop();
}
int main(void) {
	Equation Sequence;
	std::string Input;
	//while (std::getline(std::cin,Input)) {
	int a, b;
	while (std::cin >> Input) {
		if ((Input) == "=") { break; }
		if (Input == "+") {
			a = Sequence.ReturnStack();
			Sequence.DeleteStack();
			b = Sequence.ReturnStack();
			Sequence.DeleteStack();
			Sequence.RenewStack(a + b);
		}
		else if (Input == "-") {
			a = Sequence.ReturnStack();
			Sequence.DeleteStack();
			b = Sequence.ReturnStack();
			Sequence.DeleteStack();
			Sequence.RenewStack(b - a);

		}
		else if (Input == "*") {

			a = Sequence.ReturnStack();
			Sequence.DeleteStack();
			b = Sequence.ReturnStack();
			Sequence.DeleteStack();
			Sequence.RenewStack(a * b);
		}
		else if (Input == "/") {

			a = Sequence.ReturnStack();
			Sequence.DeleteStack();
			b = Sequence.ReturnStack();
			Sequence.DeleteStack();
			Sequence.RenewStack(b / a);
		}
		else {
			Sequence.RenewStack(StoI(Input));
		}
	}
	std::cout << Sequence.ReturnStack() << std::endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3172
// C - Lower
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int ans = 0;
	int count = 0;
	int pre, now; cin>>pre;;
	while(--N){
		cin>>now;
		ans = max(ans, (count = pre>=now? count+1: 0));
		pre = now;
	}
	cout<< ans <<endl;
}

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

ll combination(int n, int r)
{
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int main()
{
    int n;
    ll ans;

    cin >> n; 
    vector<string> s(n);
    rep(i, n) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    sort(s.begin(), s.end());
    ans = 0;
    int cnt = 0;
    rep(i,n-1) {
        if (s[i] == s[i + 1])
            ++cnt;
        else {
            if (cnt>0)
                ans += combination(cnt+1, 2);
            cnt = 0;
        }
    }
    if (cnt > 0)
        ans += combination(cnt + 1, 2);

    cout << ans << endl;

    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a >= 1 && a <= 9 && b >= 1 && b <= 9) cout << a * b << "\n";
	else cout << "-1" << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define A first
#define B second

using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w, n;
	cin >> h >> w >> n;
	
	int mx = max(h, w);
	cout << (n + mx - 1) / mx  << endl;

}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#include <stack>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int H,W;
vector<string> S;

int black[2020][2020];
int white[2020][2020];
int same[2020][2020];
int diff[2020][2020];

void preprocess(){
    rep(i,H) rep(j,W){
        if(S[i][j]=='#') black[i][j]=1;
        if(i>0&&S[i][j]=='#') black[i][j]+=black[i-1][j];
    }
    rep(i,H) rep(j,W){
        if(S[i][j]=='.') white[i][j]=1;
        if(i>0&&S[i][j]=='.') white[i][j]+=white[i-1][j];
    }

    rep(i,H) rep(j,W){
        if(j==0) continue;
        if(S[i][j]==S[i][j-1]) same[i][j]=1;
        if(i>0&&S[i][j]==S[i][j-1]) same[i][j]+=same[i-1][j];
    }
    rep(i,H) rep(j,W){
        if(j==0) continue;
        if(S[i][j]!=S[i][j-1]) diff[i][j]=1;
        if(i>0&&S[i][j]!=S[i][j-1]) diff[i][j]+=diff[i-1][j];
    }
}

int calc(int h,vector<int> &A,vector<int> &P){
    stack<pair<int,int>> st;
    int res=0;
    rep(j,W){
        if(j==0) continue;
        int pos=j;
        while(st.size()&&st.top().first>=P[j]){
            auto f=st.top();
            st.pop();
            pos=f.second;
            chmax(res,f.first*(j-pos+1));
        }
        st.push(mkp(P[j],pos));
    }
    while(st.size()){
        auto f=st.top();
        st.pop();
        chmax(res,f.first*(W+1-f.second));
    }

    return res;
}

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

  cin>>H>>W;
  S.resize(H);
  rep(i,H) cin>>S[i];

  preprocess();

  int ans=max(H,W);
  rep(i,H){
      if(i==0) continue;
      {
          vector<int> A(W,0),P(W,0);
          vector<int> rev(W,0);
          rep(j,W){
              if(black[i][j]) A[j]=black[i][j];
              else{
                  A[j]=white[i][j];
                  rev[j]=1;
              }
          }
          rep(j,W){
              if(j==0) continue;
              if(rev[j]==rev[j-1]) P[j]=same[i][j];
              else P[j]=diff[i][j];
          }
          chmax(ans,calc(i,A,P));
      }

      {
          vector<int> A(W,0),P(W,0);
          vector<int> rev(W,0);
          rep(j,W){
              if(S[i][j]=='.') A[j]=black[i-1][j]+1;
              else{
                  A[j]=white[i-1][j]+1;
                  rev[j]=1;
              }
          }
          rep(j,W){
              if(j==0) continue;
              if(rev[j]==rev[j-1]) P[j]=same[i][j];
              else P[j]=diff[i][j];
          }
          chmax(ans,calc(i,A,P));
      }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 68096
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;

int main() {
	int n;
	cin >> n;
	map<int, int> m;
	for (int i = 2; i <=n;i++) {
		int num = i;
		for (int j = 2; j*j <= i; j++) {
			while (num % j == 0) {
				m[j]++;
				num /= j;
			}
		}
		if (num != 1) {
			m[num]++;
		}
	}

	

	vector<int> cnt(5);
	for (auto it = m.begin(); it != m.end();it++) {
		//cout << it->first << " " << it->second << endl;
		if (it->second >= 74) {
			cnt[0]++;
		}
		if (it->second >= 24) {
			cnt[1]++;
		}
		if (it->second >= 14) {
			cnt[2]++;
		}
		if (it->second >= 4) {
			cnt[3]++;
		}
		if (it->second >= 2) {
			cnt[4]++;
		}
	}

	int ans = cnt[0];
	if (cnt[4] > 1) {
		ans += cnt[1] * (cnt[4] - 1);
	}
	if (cnt[3] > 1) {
		ans += cnt[2] * (cnt[3] - 1);
	}
	if (cnt[4] > 2 && cnt[3] >= 2) {
		ans += (cnt[3] * (cnt[3] - 1)) / 2 * (cnt[4] - 2);
	}
	
	cout << ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 998244353
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    int n,a,b;cin>>n>>a>>b;
    V<int>p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    int ans=0;
    int A=0,B=0,C=0;
    for(int i=0;i<n;i++){
        if(p[i]<=a)A++;
        else if(p[i]>a&&p[i]<=b)B++;
        else C++;
    }
    cout<<mmin(A,mmin(B,C))<<endl;
    //-------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


















































Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }
int main() {
    int n,a,b,x; string p,q;
    cin>>n;
    vl A(n);
    rep(i,n)A[i]=i+1;
    rep(i,n){
        cin>>x;
        p+=to_string(x);
    }
    rep(i,n){
        cin>>x;
        q+=to_string(x);
    }
    ll cnt=0;
    do{
        cnt++;
        string s="";
        rep(i,n)s+=to_string(A[i]);
        if(s==p)a=cnt;
        if(s==q)b=cnt;
    }while (next_permutation(A.begin(),A.end()));
    
    cout<<abs(a-b)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <iomanip> // std::setprecision
using namespace std;
using ll = long long;

int main() {
    // get 1 <= a <= 1000, 1<= b <= 1000, 0 <= h <= 11, 0 <= m <= 59
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double m_angle = 2*M_PI * (m / 60);
    double h_angle = 2*M_PI * (h / 12) + 2*M_PI/12 * (m / 60);

    double x_diff_sq = pow(a*cos(h_angle) - b*cos(m_angle), 2);
    double y_diff_sq = pow(a*sin(h_angle) - b*sin(m_angle), 2);

    double length = sqrt(x_diff_sq + y_diff_sq);

    cout << setprecision(10) << length << endl;

    return 0 ;
}

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

int main(void){
	int N,M;
	cin >> N >> M;
	vector<long long> A(N);
	for(int i=0;i<N;i++)cin >> A[i];
	sort(A.begin(),A.end());
	vector< pair<long long,long long> > v(M);
	for(int i=0;i<M;i++){
		cin >> v[i].second >> v[i].first;
	}
	sort(v.rbegin(),v.rend());
	int cnt = 0;
	bool flag = false;
	for(int i=0;i<M;i++){
		while(v[i].second>0){
			if(A[cnt]<v[i].first){
				A[cnt] = v[i].first;
				cnt++;
			}else{
				flag = false;
				break;
			}
			v[i].second--;
		}
		if(flag)break;
	}
	long long ans = 0;
	for(int i=0;i<N;i++)ans+=A[i];
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
	long long n, a[10000];

	cin >> n;

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

	cout << *min_element(a, a + n) << " "
		 << *max_element(a, a + n) << " "
		 << accumulate(a, a + n, 0LL) << endl;

	return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

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

    P A[100005];
    int N, M; cin >> N >> M;
    for (int i = 0; i < N; i++) cin >> A[i].first >> A[i].second;

    sort(A, A+N);

    ll ans = 0, sum = 0;
    for (int i = 0; i < N; i++) {
        if (sum+A[i].second >= M) {
            ans += A[i].first*(M-sum);
            break;
        }

        ans += A[i].first*A[i].second;
        sum += A[i].second;
    }
    
    cout << ans << endl;
}

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

int main() {
    string n;
    cin >> n;
    int flag = 0;
    for(int i = 0; i < 3; i++){
        if(n.at(i) == '7'){
            flag = 1;
        }
    }
    if(flag == 1){
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

// 1 way is to find compute all the sorted permutations and find the 
// positions of the current permutation.

char _find(string &str){
    bool pres[26]={0};
    for(char ch:str){
        pres[ch-'a']=1;
    }
    for(int i=0;i<26;i++){
        if(pres[i]==0){
            return (char)(i+'a');
        }
    }
    return '%';
}

void solve(){
    string str;
    cin>>str;
    char ch=_find(str);
    str="";
    str.push_back(ch);
    cout<<( str=="%" ? "None" : str)<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3788
import sys, collections, copy

def solve():
    S = list(input())
    S2 = copy.deepcopy(S)
    K = int(input())
    lens = len(S)
    head_change = 0
    for i in range(1, lens):
        if S[i] == S[i - 1]:
            head_change += 1
            S[i] = "Changed"
    
    inner_change = 1
    S2[0] = "Changed"
    for i in range(1, lens):
        if S2[i] == S2[i-1]:
            inner_change += 1
            S2[i] = "Changed"

    if lens == 1: print(K // 2)
    elif S[lens-1] != "Changed" and S[0] == S[lens - 1]:
        if S2[lens-1] != "Changed":
            print(head_change + inner_change * (K - 1))
        else:
            print((head_change + inner_change) * (K // 2) + head_change * (K % 2))
    else:
        print(head_change * K)
    #print(S)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3444
a = int(input())
if a >= 100:
  a = a%100%10
else:
  a = a%10

if a ==2 or  a ==4 or  a ==5  or a ==7 or  a ==9:
  print("hon")
if  a ==0 or a ==1 or a ==6 or  a ==8:
  print("pon")
if a == 3:
  print("bon")

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    using i32 = int32_t; using u32 = uint32_t;
    using i64 = int64_t; using u64 = uint64_t;
    using f32 = float; using f64 = double;

    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n, k; cin >> n >> k;
    int ans = 0;
    while (n) {
        n /= k;
        ++ans;
    }
    cout << ans << endl;
}



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

int main() {
  int k, s;
  cin >> k >> s;

  int count = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      int z = s - i - j;
      if (0 <= z and z <= k) {
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <queue>
#include <cstring>
#define mp make_pair
#define pb push_back
#define p push

#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
#define MAXN 100005

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;


int main(){
   IOS
  string s;
   cin >>s;
   int size = s.size();
   int res =0;
   int son = size -1;
    for (int i = 0; i <size/2 ; ++i) {
        if(s[i] != s[son -i])res++;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 384
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut vec: Vec<usize> = vec![0; N];
    let mut zero_flag = false;
    for _ in 0..N {
        let v: usize = read();
        if v == 0 {
            zero_flag = true;
        }
        vec[v] += 1;
    }
    if zero_flag && vec[0] != 1 {
        println!("0");
        return;
    }
    let start = if zero_flag { 0 } else { 1 };
    for i in start..N {
        if i != 0 && (i - start) % 2 == 0 && vec[i] != 2 {
            println!("0");
            return;
        }
        if (i - start) % 2 == 1 && vec[i] != 0 {
            println!("0");
            return;
        }
    }
    let n = if zero_flag { N - 1 } else { N } / 2;
    let mut ans = 1;
    for _ in 0..n {
        ans *= 2;
        ans %= 10usize.pow(9) + 7;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  string S;
  cin >> N >> S;
  string S2 = S.substr(0, N / 2);
//  cout << S2 << endl;
  if (S == S2+S2)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
string str;
cin >> str;
int ans;
if(str == "SUN")
  ans = 7;
else if(str == "MON")
  ans = 6;
else if(str == "TUE")
  ans = 5;
else if(str == "WED")
  ans = 4;
else if(str == "THU")
  ans = 3;
else if(str == "FRI")
  ans = 2;
else if(str == "SAT")
  ans = 1;
cout << ans;
return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

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

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	if (K == 1) cout << 0 << endl;
	else cout << N - K << endl;
	return 0;
}


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


int main(){
  long long n,k;
  cin >> n >> k;
  vector<long long> a(n+1);
  for(int i = 1;i < n+1;i ++){
    cin >> a.at(i);
  }
  
  long long x = 0;
  long long now = 1;
  vector<int> check(n+1,0);
  check.at(1) = 1;
  while(1){
   // cout << a.at(now) << check.at(a.at(now)) << endl;
    
    x++;
    if(check.at(a.at(now)) != 1){
      check.at(a.at(now)) = 1;
      now = a.at(now);
    }
    else{
      break;
    }
  }
  now = a.at(now);
  //cout << "now:" << now << endl;
  //cout << "x:" << x << endl;
  long long p = now;
  long long y = 1;
  
  while(a.at(now) != p){
   // cout << "here" << endl;
    y++;
    now = a.at(now);
  }
  //cout << "y:" << y << endl;
  long long z = 0;
  long long ans = 1;
  if(k > x){  
    z = (k - x) % y;
    ans = p;
    for(int i = 0;i < z;i++){
      ans = a.at(ans);
    }
  }
  else{
    z = k;
    for(int i = 0;i < z;i++){
      ans = a.at(ans);
    }
  }
  cout << ans  << endl;
}





Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
cin >> s;
int a=0,b=0;
for(int i=0;i<3;i++){
if(s[i]=='A') a++;
else b++;}
if(a==2||b==2) cout << "Yes" << endl;
else cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fi(char a, char b)
{
	//cout<<a<<" "<<b<<endl;
	if(a == '0')
	{
		if( b == '0')
		{
			return 0;
		}
		else
		{
			return 1;
		}
	}
	else 
	{
		 if(a == '1')
		{
			if(b <= '2' )
			{
				return 1;
			}
			else
			{
				//cout<<"here"<<endl;
				return 2;
			}
		}
		else if(a > 1)
		{
			return 2;
		}
	}
}
main()
{
	//freopen("input.txt","rt",stdin);
	string str;
	cin>>str;
	if(fi(str[0],str[1]) == 1 && fi(str[2],str[3]) == 1)
	{
		cout<<"AMBIGUOUS"<<endl;
	}
	else if(fi(str[0],str[1]) == 1)
	{
			cout<<"MMYY"<<endl;
	}
	else if(fi(str[2],str[3]) == 1)
	{
		cout<<"YYMM"<<endl;
	}
	else
	{
		cout<<"NA"<<endl;
	}
}

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t, h, m, s;
    cin >> t;

    h = t / 3600;
    m = (t % 3600) / 60;
    s = (t % 60);

    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3180
local zones = io.read("*n")
local num = io.read("*n")
local data = {}
for j = 1,num do
	local idx = io.read("*n")
	local y = io.read("*n")
	local d = {n = 0, year = y,i=j,z = idx}
	table.insert(data,d)
end

local tmp = {}
table.sort(data,function(a,b)
 	return a.year < b.year
end)

-- for k,v in ipairs(data) do
-- 	v.k = k
-- end
for k,v in ipairs(data) do
	if not tmp[v.z] then
		tmp[v.z] = 1
	else
		tmp[v.z] = tmp[v.z] + 1
	end
	v.n = tmp[v.z]
end

local x = {}
for k,v in pairs(data) do
	x[v.i]={v.z,v.n}
end

for i = 1,#x do
	local digits = 5
	if x[i][1] < 100000 then
		digits = 0
		local num = x[i][1]
		for i= 1,5 do
			if num >= 10 then
				digits = digits + 1
			end
			num = num/10
		end
	end
	x[i][1] = string.rep("0",5-digits)..x[i][1]
	digits = 5
	if x[i][2] < 100000 then
		digits = 0
		local num = x[i][2]
		for i= 1,5 do
			if num >= 10 then
				digits = digits + 1
			end
			num = num/10
		end
	end
	x[i][2] = string.rep("0",5-digits)..x[i][2]
	print(x[i][1]..x[i][2])
end

Measured memory_bytes: 57316
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
#define SQR(n) (n*n)
#define CHR getchar()
#define NL printf("\n")
#define PI 2.0*acos(0.0)
#define ll              long long int
#define ull             unsigned long long int
#define sc              scanf
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define pf              printf
#define MOD             1000000007
#define mx              123456789
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define ff first
#define D double
#define sz size()
#define ss second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
using namespace std;
bool isok(ll n)
{
    ll i, j, k, l;
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;

    for ( i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}
ll next(ll n)
{
    if (n<= 1)
        return 2;
    ll prime = n;
    bool ok = false;
    while (!ok) {
        prime++;

        if (isok(prime))
            ok = true;
    }

    return prime;
}
int main()
{
    ll n, m, i, j, k, l;
    cin>>n;
    cout <<next(n-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
int main() {
	vector<int> N(4);
	rep(i,4)
	cin>>N[i];
	sort(all(N));
	string ans="NO";
	if(N[0]==1&&N[1]==4&&N[2]==7&&N[3]==9)ans="YES";
	cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x1 = a*c;
	ll x2 = a*d;
	ll x3 = b*c;
	ll x4 = b*d;
	cout<<(ll)max(max(max(x1,x2),x3),x4)<<endl;
	return 0;
}

Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	int h, w;
	while (cin >> h >> w&&h != 0 && w != 0) {
		int t = h*h + w*w;
		int h2 = h+1;
		while (true) {
			for (int i = h2; i*i < t; i++) {
				long double b = sqrt(t - i*i);
				if (b > (long double)i) {
					int c = b;
					if ((long double)c == b) {
						cout << i << " " << b << endl;
						goto stop;
					}
				}
			}
			t++;
			h2 = 1;
		}
	stop:;
	}
}

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

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

#define md 1000000007
#define mem(arr,x) memset(arr,x,sizeof(arr))
#define pb push_back
#define vi vector<lli>
#define vvi vi<vi>
typedef long long int lli;
typedef float fl;

bool sortinrev(const pair<lli, lli > &a,     const pair<lli , lli > &b)
{
	return (a.first > b.first);
}
lli power(lli x, lli y, lli p)
{
	lli res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)

			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

int main()
{
	fio();
	lli t = 1 ;

	while(t--)
	{
		lli n;
		cin >> n;

		lli ans = power(10, n , md );

		lli Z =  ( 2 * ( power( 9 , n  , md) ))  - power( 8 , n, md );

		cout << (( ans - Z ) % md + md ) % md << "\n" ;

	}
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string first, second, third;
  char ini_fir, ini_sec, ini_thir;
  
  cin >> first >> second >> third;
  ini_fir = first.at(0);
  ini_sec = second.at(0);
  ini_thir = third.at(0);

  cout << ini_fir << ini_sec << ini_thir << endl;
  
}

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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 2e5 + 5;

vector<int> adj [MAX_N];
deque<Modint> *dp [MAX_N];
deque<Modint> *lsz [MAX_N];

void dfs (int u) {
  pair<int, int> bigchp = make_pair(-1, -1);
  for (int nxt : adj[u]) {
    dfs(nxt);
    bigchp = max(bigchp, make_pair((int) dp[nxt]->size(), nxt));
  }

  int bigch = bigchp.second;
  if (bigch == -1) {
    dp[u] = new deque<Modint> ();
    lsz[u] = new deque<Modint> ();
  } else {
    dp[u] = dp[bigch];
    lsz[u] = lsz[bigch];
  }

  int maxk = 0;
  for (int nxt : adj[u]) {
    if (nxt != bigch) {
      maxk = max((int) dp[nxt]->size(), maxk);
    }
  }

  vector<Modint> exinv (maxk);
  for (int i = 0; i < maxk; i++) {
    exinv[i] = lsz[u]->at(i) - dp[u]->at(i);
  }
  
  for (int nxt : adj[u]) {
    if (nxt != bigch) {
      for (int k = 0; k < (int) dp[nxt]->size(); k++) {
        dp[u]->at(k) *= lsz[nxt]->at(k) - dp[nxt]->at(k);
        dp[u]->at(k) += exinv[k] * dp[nxt]->at(k);
        exinv[k] *= lsz[nxt]->at(k) - dp[nxt]->at(k);
        lsz[u]->at(k) *= lsz[nxt]->at(k);
      }
    }
  }
  
  dp[u]->push_front(Modint(1));
  lsz[u]->push_front(Modint(2));

  /*
  cerr << u << endl;
  for (int i = 0; i < (int) dp[u]->size(); i++) {
    cerr << dp[u]->at(i) << " ";
  }
  cerr << endl;
  for (int i = 0; i < (int) dp[u]->size(); i++) {
    cerr << lsz[u]->at(i) << " ";
  }
  cerr << endl << endl;
  */
}

int main () {
  ios::sync_with_stdio(false);

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

    adj[p].push_back(i);
  }

  dfs(0);
  Modint allw = exp(Modint(2), n + 1);
  Modint ans (0);
  for (int i = 0; i < (int) dp[0]->size(); i++) {
    ans += allw * inv(lsz[0]->at(i)) * dp[0]->at(i);
  }
  cout << ans << endl;
}


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

int main() {
    int H,W,A,B;
    cin >> H >> W >> A >>B;
    for(int y=0;y<H;y++){
        for(int x=0;x<W;x++){
            if(y<B&&x<A){
                cout<<1;
            }else if(y>=B&&x>=A){
                cout<<1;
            }else{
                cout<<0;
            }
         
            
        }
           cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N, K; int h[100010];
	cin >> N >> K;
	int dp[100010];
	for (int i = 0; i < N; ++i) {
		dp[i] = INF;
	}
	for (int i = 0; i < N; ++i) {
		cin >> h[i];
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; ++i) {
		for (int j = 1; j <= K; ++j) {
			if (i - j >= 0) {
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
			}
			else {
				break;
			}
		}
	}
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll powmod(ll x, ll k, ll m)
{
    ll ret = 1;
    for (ll i = 0; i < k; i++)
    {
        ret = (ret * x) % m;
    }
    return ret;
}

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

    ll ans = powmod(10, N, mod) - powmod(9, N, mod) - powmod(9, N, mod) + powmod(8, N, mod);
    ans = ans % mod;
    ans = (ans + mod) % mod;

    cout << ans << "\n";
}


Measured memory_bytes: 3144
#include <stdio.h>

int main(void){
	int n, p[20], i, cnt = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &p[i]);
	for (i = 1; i < n-1; i++){
		if ((p[i-1] <= p[i]) && (p[i] <= p[i+1])) cnt += 1;
		if ((p[i-1] >= p[i]) && (p[i] >= p[i+1])) cnt += 1;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
using namespace std;
int rtos(string str) {
    int num=0;
    /* I=1 V=5 X=10 L=50 C=100 D=500 M=1000 */
    for (int i=0; i<str.length(); i++) {
        switch (str[i]) {
            case 'I':
                num++;
                break;
            case 'V':
                num+=5;
                if (i&&str[i-1]=='I') num-=2;
                break;
            case 'X':
                num+=10;
                if (i&&str[i-1]=='I') num-=2;
                if (i&&str[i-1]=='V') num-=10;
                break;
            case 'L':
                num+=50;
                if (i&&str[i-1]=='I') num-=2;
                if (i&&str[i-1]=='V') num-=10;
                if (i&&str[i-1]=='X') num-=20;
                break;
            case 'C':
                num+=100;
                if (i&&str[i-1]=='I') num-=2;
                if (i&&str[i-1]=='V') num-=10;
                if (i&&str[i-1]=='X') num-=20;
                if (i&&str[i-1]=='L') num-=100;
                break;
            case 'D':
                num+=500;
                if (i&&str[i-1]=='I') num-=2;
                if (i&&str[i-1]=='V') num-=10;
                if (i&&str[i-1]=='X') num-=20;
                if (i&&str[i-1]=='L') num-=100;
                if (i&&str[i-1]=='C') num-=200;
                break;
            case 'M':
                num+=1000;
                if (i&&str[i-1]=='I') num-=2;
                if (i&&str[i-1]=='V') num-=10;
                if (i&&str[i-1]=='X') num-=20;
                if (i&&str[i-1]=='L') num-=100;
                if (i&&str[i-1]=='C') num-=200;
                if (i&&str[i-1]=='D') num-=1000;
                break;
        }
    }
    return num;
}
int main() {
    string roman;
    while (cin>>roman) {
        printf("%d\n",rtos(roman));
    }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define MAX 2000010
#define Ai 10000
int A[MAX],B[MAX],C[Ai]={0};
int n;
void countingsort()
{
	int i;
	for(i=1;i<=n;i++)
		C[A[i]]++;
	for(i=1;i<=Ai;i++)
		C[i]=C[i]+C[i-1];
	for(i=n;i>=1;i--)
	{
		B[C[A[i]]]=A[i];
		C[A[i]]--;
	}
	return;
}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&A[i]);
	countingsort();
	for(i=1;i<=n-1;i++)
		printf("%d ",B[i]);
	printf("%d\n",B[n]);
	return 0;
}


Measured memory_bytes: 17520
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s, t;
    cin >> s >> t;
    int ans = INF;
    for (int q = 0; q < s.size()-t.size()+1; q++){
        int now = 0;
        for (int q1 = 0; q1 < t.size(); q1++){
            now += (s[q+q1] != t[q1]);
        }
        ans = min(ans, now);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
n,m=map(int,input().split())
a=[]
edge=[[] for i in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
for i in edge[0]:
    for j in edge[i]:
        a.append(j)
    a.append(i)
print('POSSIBLE' if n-1 in a else 'IMPOSSIBLE')

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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

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

    int n;
    cin >> n;
    bool ok = false;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        int a, b;
        cin >> a >> b;
        bool db = (a == b);
        if (db)
            cnt++;
        else
            cnt = 0;
        if (cnt >= 3)
            ok = true;
    }
    if (ok)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3648
N = int(input())
NS = str(N)
D = len(NS)


if D % 2 == 0:
  if D == 2:
    print(9)
  elif D == 4:
    print(909)
  else:
    print(90909)
else:
  if N == (10 ** (D - 1)):
    if D == 3:
      print(10)
    elif D == 5:
      print(910)
    else:
      print(1)
  else:
    if D == 3:
      print(N - 90)
    elif D == 5:
      print(N - 9090)
    else:
      print(N)

Measured memory_bytes: 3064
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve() {
  string s, t;
  cin >> s >> t;
  int mini = INT_MAX;
  int n = (int)s.size(), m = (int)t.size();
  for(int i = 0; i < n-m+1; i++) {
    int count = 0;
    for(int j = 0; j < m; j++) {
      if(s[i+j] != t[j])
        count++;
    }
    mini = min(mini, count);
  }
  cout << mini << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(10);
  int t = 1;
 // cin >> t;
  for(int tt = 1; tt <= t; tt++) {
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 3668
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	//	"github.com/pkg/profile"
)

func partition(ar []int, p, r int) int {
	x := ar[r]
	i := p - 1
	for j := p; j <= r-1; j++ {
		if ar[j] <= x {
			i++
			ar[i], ar[j] = ar[j], ar[i]
		}
	}
	ar[i+1], ar[r] = ar[r], ar[i+1]
	return i + 1
}

func print(ar []int, p int) {
	var w = bufio.NewWriter(os.Stdout)

	n := len(ar)
	for i := 0; i < n-1; i++ {
		if i == p {
			fmt.Fprintf(w, "[%d] ", ar[i])
		} else {
			fmt.Fprintf(w, "%d ", ar[i])
		}
	}
	fmt.Fprintln(w, ar[n-1])

	_ = w.Flush()
}

func main() {
	//	defer profile.Start(profile.ProfilePath(".")).Stop()

	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	if !s.Scan() {
		log.Fatal("scan error")
	}

	n, _ := strconv.Atoi(s.Text())
	ar := make([]int, n)

	for i := 0; s.Scan() && i < n; i++ {
		x, _ := strconv.Atoi(s.Text())
		ar[i] = x
	}

	if s.Err() != nil {
		log.Fatal(s.Err())
	}

	p := partition(ar, 0, n-1)

	print(ar, p)
}



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

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u'
        || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
        }
    else {
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

string func(int x, int D, int a, int b) {
    if (a < b) swap(a, b);
    string res;
    REP (i, D) {
        if (x >> i & 1) res += string(1, a + '0');
        else res += string(1, b + '0');
    }
    reverse(res.begin(), res.end());
    return res;
}

string solve(int rem, int D, int d, int a) {
    for (int bb = 0; bb < 10; ++bb) {
        if (bb < a) {
            if (rem <= (1LL << (D - d))) {
                return string(1, bb + '0') + func(rem - 1, D - d, a, bb);
            }
            rem -= (1LL << (D - d));
        } else if (bb == a) {
            if (rem <= 9 * ((1LL << (D - d)) - 1)) {
                return string(1, a + '0') + solve(rem, D, d + 1, a);
            }
            rem -= 9 * ((1LL << (D - d)) - 1);
        } else {
            if (rem <= (1LL << (D - d))) {
                return string(1, bb + '0') + func(rem - 1, D - d, a, bb);
            }
            rem -= (1LL << (D - d));
        }
    }
    return "?";
}

void _main() {
    int N;
    while (cin >> N, N) {
        int D = 2, tmp = 0;
        while (N > 81 * ((1LL << D) - D - 1)) {
            tmp = 81 * ((1LL << D) - D - 1);
            D++;
        }
        int a = 1, sum = tmp;
        while (N > 9 * ((1LL << (D - 1)) - 1) + sum) {
            sum += 9 * ((1LL << (D - 1)) - 1);
            a++;
        }
        cout << string(1, a + '0') + solve(N - sum, D, 2, a) << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


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

int main(void){
    int l, r, d, ans = 0;
    cin >> l >> r >> d;
    for(int i = l; i <= r; i++){
        if(i%d == 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (1 << k) * max({a, b, c}) + (a + b + c - max({a, b, c})) << endl;
    return 0;
}


Measured memory_bytes: 256
=begin
=end

taro = hana = 0

n = gets.to_i

n.times do
  t, h = gets.chomp.split
  if t > h
    taro += 3
  elsif t < h
    hana += 3
  else
    taro += 1
    hana += 1
  end
end

puts "#{taro} #{hana}"


Measured memory_bytes: 8900
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, t;
    cin >> n >> t;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int ma = 0, mi = a[0];
    for (int i = 0; i < n; ++i)
    {
        mi = min(mi, a[i]);
        if (a[i] - mi > ma) ma = a[i] - mi;
    }
    int ans = 0;
    mi = a[0];
    for (int i = 0; i < n; ++i)
    {
        mi = min(mi, a[i]);
        if(a[i] - mi == ma) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3948
//競技プログラミング　テンプレ
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

const int max_v = 300;
const int INF = 1000000;



int main() {

	string x,y;

  cin >> x >> y; 
  sort(x.begin(),x.end());
  sort(y.begin(),y.end(),greater<char>());
  if(x < y ){ cout << "Yes" << endl; return 0;}
  else {cout << "No" << endl; return 0;}
  //else if(x ==y){ if()return 0;}
  

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int x , y, sum , tafaz , time;
    cin >> x >> y;
    sum = x + y;
    tafaz = x - y;
    time = x * y;
    if(tafaz == time && time == sum){
        cout << tafaz<<endl;
        return 0;
    }
    if(tafaz >= time && tafaz >= sum){
        cout << tafaz<<endl;
        return 0;
    }
    if(tafaz <= time && time >= sum){
        cout << time <<endl;
        return 0;
    }
    if(tafaz <= sum && time <= sum){
        cout << sum<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
n,m,x = map(int,input().split())
list = [list(map(int,input().split())) for i in range(n)]

skill = [0] + [0] * m
ans = float("inf")
for i in range(2**n):
    i = format(i,"0{}b".format(n))
    for j in range(n):
        if str(i)[j] =="1":
            for l in range(m+1):
                skill[l] += list[j][l]
    money = skill.pop(0)
    if all(i>=x for i in skill):
        if ans>money:
            ans = money
    skill = [0] + [0] * m
if ans ==float("inf"):
    ans = -1
print(ans)


Measured memory_bytes: 69376
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    long v[50];
    long comb[51][51];
    comb[0][0] = 0;
    long ans = 0;
    for(int i = 0; i < 51; i++){
        comb[i][0] = 1;
        comb[i][i] = 1;
        for(int j = 1; j < i; j++){
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
        }
    }
    for(int i = 0; i < N; i++){
        cin >> v[i];
    }
    sort(v, v+N, greater<long>());
    
    int cnt = 0;
    int first = -1;
    for(int i = 0; i < N; i++){
        if(v[i] == v[A-1]){
            if(first == -1) first = i;
            cnt++;
        }
    }
    
    if(v[0] == v[A-1]){
        for(int i = A-1; i <= B-1; i++){
            if(v[i] == v[0])ans += comb[cnt][i+1];
        }
        cout << v[0] << endl;
    }else{
        long sum = 0;
        for(int i = 0; i < A; i++){
            sum += v[i];
        }
        //cout << setprecision(10) << ((double)sum)/((double)A) << endl;
        printf("%.6f\n",((double)sum)/((double)A));
        ans = comb[cnt][A-first];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#coding:utf-8

x, y = map(int, input().split())
money = 0

#coding:
if x == 1:
  money += 300000
elif x == 2:
  money += 200000
elif x == 3:
  money += 100000

#device:
if y == 1:
  money += 300000
elif y == 2:
  money += 200000
elif y == 3:
  money += 100000
  
#bonus
if x == 1 and y == 1:
  money += 400000

print(money)


Measured memory_bytes: 3060