akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

        String str = sc.nextLine();
        int commandNum = sc.nextInt();//命令の数
// System.out.println(str);

        for(int i = 0; i < commandNum; i++){
            String strCommand = sc.next();
// System.out.println("strCommand " + strCommand);
//            String[] part = strCommand.split(" ");
  
/*  for(String p :part){
     System.out.println(p);
} */
            if(strCommand.startsWith("print")){
                int a = sc.nextInt();
                int b = sc.nextInt();
                System.out.println(str.substring(a,b+1));
// System.out.println(str);
            }
            else if(strCommand.startsWith("reverse")){
                int a = sc.nextInt();
                int b = sc.nextInt();                
                String copy = str.substring(a,b+1);
                char[] preReverse = copy.toCharArray();
                String reverseCopy ="";
                
                for(int j = copy.length() -1; j >= 0; j--){
                    reverseCopy = reverseCopy + preReverse[j]; 
 //System.out.println("reverseCopy " + reverseCopy);
                    
                }
                    String strAns = str.replace(copy, reverseCopy);
                    str = strAns;
 //System.out.println(strAns);
            }
            else if(strCommand.startsWith("replace")){
                int a = sc.nextInt();
                int b = sc.nextInt();
                String c = sc.next();
                String copy = str.substring(a,b+1);
//    System.out.println("c " + c);
 //   System.out.println("copy " + copy);
                String first = str.substring(0,a);
                String last = str.substring(b+1,str.length());    
                String replaceCopy = first + c + last;
//    System.out.println("replaceCopy " + replaceCopy);
                
                str = replaceCopy;
                replaceCopy="";
            }
        }
    }
}


                



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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

ll di[8]={1,1,0,-1,-1,-1,0,1};
ll dj[8]={0,-1,-1,-1,0,1,1,1};

ll nx(vector<string> v, ll li, ll lj, ll turn){
  char c;
  if(turn%2==0) c='x';
  else c='o';

  ll res=0;
  FOR(d,0,8){
    ll x=1;

    if(li+x*di[d]<0 || 7<li+x*di[d] || lj+x*dj[d]<0 || 7<lj+x*dj[d]  )continue;
    while(v[li+x*di[d]][lj+x*dj[d]]==c){
      x++;

      if(li+x*di[d]<0 || 7<li+x*di[d] || lj+x*dj[d]<0 || 7<lj+x*dj[d]  )break;
    }

    if(li+x*di[d]<0 || 7<li+x*di[d] || lj+x*dj[d]<0 || 7<lj+x*dj[d]  )continue;

    if(v[li+x*di[d]][lj+x*dj[d]]!='.'&&v[li+x*di[d]][lj+x*dj[d]]!=c){
      res+=x-1;
    }
  }
  return res;
}


vector<string> nch(vector<string> v, ll li, ll lj, ll turn){
  char c;
  if(turn%2==0) c='o';
  else c='x';
  v[li][lj]=c;
  FOR(d,0,8){
    ll x=1;
    if(li+x*di[d]<0 || 7<li+x*di[d] || lj+x*dj[d]<0 || 7<lj+x*dj[d]  )continue;

    while(v[li+x*di[d]][lj+x*dj[d]]!=c&&v[li+x*di[d]][lj+x*dj[d]]!='.'){
      x++;
      if(li+x*di[d]<0 || 7<li+x*di[d] || lj+x*dj[d]<0 || 7<lj+x*dj[d]  ){
        x=0;
        break;
      }
      if(v[li+x*di[d]][lj+x*dj[d]]==c){
        break;
      }
      if(v[li+x*di[d]][lj+x*dj[d]]=='.'){
        x=1;
        break;
      }
    }
    FOR(j,0,x){
      v[li+j*di[d]][lj+j*dj[d]]=c;
    }

  }
    return v;

}

P toPut(vector<string> v, ll turn){
  ll li=0,lj=0,mres=0;
  FOR(i,0,8){
    FOR(j,0,8){
      if(v[i][j]=='.'){
        if(mres<nx(v,i,j,turn)&&turn%2==0){
          li=i;lj=j;
          mres=nx(v,i,j,turn);
        }
        if(mres<=nx(v,i,j,turn)&&turn%2==1){
          li=i;lj=j;
          mres=nx(v,i,j,turn);
        }

      }
    }
  }
  return P(li,lj);
}

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

  vector<string> v(8);
  cinv(v,0,8);
  FOR(i,0,150){
    P p = toPut(v,i);
    ll li=p.first;
    ll lj=p.second;
    if(nx(v,li,lj,i)!=0 && v[li][lj]=='.')v=nch(v,li,lj,i);
  }

  FOR(i,0,8){
    FOR(j,0,8){
      cout<<v[i][j];
    }
    cout<<endl;
  }

}



Measured memory_bytes: 3248
//Solution By SlavicG
#include <bits/stdc++.h>
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	int a,b;
	cin >> a >> b;
	cout << (a < b ? 0 : 10);
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int [] s = new int[n];
        long d = 0;
        for(int i = 0;i < n;i ++) {
            s[i] = in.nextInt();
            s[i] -= i + 1;
        }
        Arrays.sort(s);
        for(int i = 0;i < n;i ++) {
            d += Math.abs(s[i] - s[n / 2]);
        }
        System.out.println(d);
    }
}

Measured memory_bytes: 84388
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, u, v, w, a[32][100005] = {}, z = 0;
    cin >> n >> m;
    while (n--) {
        cin >> u >> v >> w;
        for (int i = u; i <= v; i++) a[w][i] = 1;
    }
    for (int i = 1; i <= 100000; i++) {
        int y = 0;
        for (int j = 1; j <= m; j++) y += a[j][i];
        z = max(z, y);
    }
    cout << z;
}


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

int n;
vector<pair<int,int> > sortpos;
int small[200005];
int big[200005];
vector<pair<int,int> > sortvel;
vector<pair<int,int> > intervals;
int numways[200005];
int prefsum[200005];

int main(){
    scanf("%d",&n);
    for (int x = 0; x<n; x++){
        int p,v;
        scanf("%d%d",&p,&v);
        sortpos.push_back({p,v});
        sortvel.push_back({v,p});
    }
    sort(sortpos.begin(),sortpos.end());
    sort(sortvel.begin(),sortvel.end());
    big[0] = sortpos[0].second;
    for (int x = 1; x<n; x++){
        big[x] = max(big[x-1],sortpos[x].second);
    }
    small[n-1] = sortpos[n-1].second;
    for (int x = n-2; x>=0; x--){
        small[x] = min(small[x+1],sortpos[x].second);
    }
    for (int x = 0; x<n; x++){
        int mn = small[x];
        int mx = big[x];
        int mnpos = lower_bound(sortvel.begin(),sortvel.end(),make_pair(mn,-1))-sortvel.begin();
        int mxpos = lower_bound(sortvel.begin(),sortvel.end(),make_pair(mx,-1))-sortvel.begin();
        intervals.push_back({mxpos,mnpos});
    }
    sort(intervals.begin(),intervals.end());
    for (int x = 0; x<n; x++){
        int r = intervals[x].first;
        int l = intervals[x].second;
        int ans = 0;
        if (l==0) ans++;
        ans += x==0?0:prefsum[x-1];
        int temp = lower_bound(intervals.begin(),intervals.end(),make_pair(l-1,-1))-intervals.begin();
        ans -= temp==0?0:prefsum[temp-1];
        ans %= 1000000007;
        ans += 1000000007;
        ans %= 1000000007;
        numways[x] = ans;
        prefsum[x] = x==0?ans:ans+prefsum[x-1];
        prefsum[x] %= 1000000007;
    }
    int finalans = 0;
    for (int x = 0; x<n; x++){
        if (intervals[x].first>=n-1){
            finalans += numways[x];
            finalans %= 1000000007;
        }
    }
    printf("%d",finalans);
}


Measured memory_bytes: 8164
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int a,b,c,d;
	cin >> a >> b >> c>>d;
	if (abs(c-a) <= d||(abs(c-b)<=d&&abs(b-a)<=d)) {
		cout << "Yes";
	} else cout <<"No";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

const LL MOD = 1e9 + 7;
const int N = 1e5 + 100;
int p[N];
int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        scanf("%d", &p[i]);
    }
    LL ans = 1;
    LL c = 0;
    for(int i = 1; i <= n; i ++) {
        if(p[i] >= c * 2 + 1) c ++;
        else ans = (ans * (c + 1)) % MOD;
    }
    while(c) {
        ans = ans * c % MOD;
        c --;
    }
    printf("%d\n", (int)ans);
}


Measured memory_bytes: 640
#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;

int field[3009][3009], csum[3009][3009];
int N,K,K2,x,y;
char c;

void fanc(){
    if(c=='B') x+=K;
    x%=K2,y%=K2;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>K;
    K2=2*K;
    rep(i,N){
        cin>>x>>y>>c;
        fanc();
        field[x][y]++;
    }
    
    rep(i,3*K)rep(j,3*K){
        if(i) field[i][j]+=field[i-1][j];
        if(j) field[i][j]+=field[i][j-1];
        if(i&&j) field[i][j]-=field[i-1][j-1];
    }
    
    rep(i,3*K)rep(j,3*K){
        csum[i][j]=field[i][j];
        if(i>=K) csum[i][j]-=field[i-K][j];
        if(j>=K) csum[i][j]-=field[i][j-K];
        if(i>=K&&j>=K) csum[i][j]+=field[i-K][j-K];
    }
    
    int mx=0;
    rep(i,K)rep(j,K){
        int n=csum[i][j]+csum[i+K2][j]+csum[i][j+K2]+csum[i+K][j+K]+csum[i+K2][j+K2];
        chmax(n,N-n);
        if(mx<n) mx=n;
    }
    cout1(mx)
}

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

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

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

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  int n;
  cin >> n;
  string a, b, c;
  cin >> a >> b >> c;
  int count = 0;
  for(int i = 0; i < n; i++)
  {
    vector<int> memo(26, 0);
    memo[a[i] - 'a']++;
    memo[b[i] - 'a']++;
    memo[c[i] - 'a']++;
    sort(memo.begin(), memo.end());
    reverse(memo.begin(), memo.end());
    count += 3 - memo.front();
  }
  cout << count << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <set>

using namespace std;

set<string> ans;
bool noans;

void solve(char a, string &str, int r = -1){
//	cout << "solve: " << str << " " << a << r << endl;
	if( a == 'a' ){
		ans.insert( str );
		return;
	}
	a--;
	int f = -1, count=0, countnow=0;
	for(int i=0; i<str.length(); i++){
		if( str[i] == a+1 ){
			count++;
			if( count > 1 && countnow == 0 ){
				noans = true;
				return;
			}
		}
		if( str[i] == a ){
			countnow++;
			if( (r == -1 || r > i )&& count == 0){
				if( f < 0 ){
					f = i;
				}else if( a < 'z' ){
					solve( a, str, f );
				}
				if( a < 'z' ){
				//	solve( a, tmp, f );
					string tmp = str;
					tmp[i] = a+1;
					solve( a, tmp );
				}
			}
		}
	}
	if( r<0 )
		solve( a, str, f );
}

int main(){
	string str;
	set<string>::iterator it;
	while(cin>>str, str[0] != '#'){
		ans.clear();
		noans = false;
		// ?§£???
		solve( 'z'+1, str );
		// ??????
		if( noans ){
			cout << 0 << endl;
			continue;
		}
		cout << ans.size() << endl;
		if( ans.size() <= 10 ){
			for(it = ans.begin(); it != ans.end(); it++){
				cout << *it << endl;
			}
		}else{
			int count=0;
			for(it = ans.begin(); count < 5; it++, count++){
				cout << *it << endl;
			}
			for(it = ans.end(); count > 0; it--, count--){}
			for(; count < 5; it++, count++){
				cout << *it << endl;
			}
		}
	}
	return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int rate;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> rate;
	cout << (rate >= 1200? "ARC" : "ABC") << endl;
	return 0;
}




Measured memory_bytes: 764
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    ll N, K;
    cin >> N >> K;

    ll A[N];
    ll area[N + 1]; //N + 1は無視
    ll areaSum;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }

    ll tryMin = 1000;
    ll tryMinN = 1;
    while(tryMinN <= N){
        tryMinN *= 2;
        tryMin++;
    }
    tryMin = min(tryMin, K);
    for(ll rep = 0; rep < tryMin; rep++){
        for(ll i = 0; i < N; i++){
            area[i] = 0;
        }
        for(ll i = 0; i < N; i++){
            area[max(i - A[i], (ll)0)]++;
            area[min(i + A[i] + 1, N)]--;
        }
        areaSum = 0;
        for(ll i = 0; i < N; i++){
            areaSum += area[i];
            A[i] = areaSum;
        }
    }

    for(ll i = 0; i < N; i++){
        if(i != 0){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;



    return 0;
}


Measured memory_bytes: 6684
// 5/18
// ANT2-4-2. Map, Set
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LLP = pair<ll, ll>;
using Graph = vector<vector<int>>;

int main() {
    int N, M;
    map<string, int> blue, red;

    cin >> N;
    rep(i ,N) {
        string s;
        cin >> s;
        blue[s]++;
    }

    cin >> M;
    rep(i, M) {
        string t;
        cin >> t;
        red[t]++;
    }

    int ans = 0;
    for (auto p : blue) {
        int money = p.second - red[p.first];
        ans = max(ans, money);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k,d,a;
    cin>>n>>k;
    vector<bool> v(n,true);
    fr(i,k){
        cin>>d;
        fr(j,d){
            cin>>a;
            --a;
            v[a]=false;
        }
    }
    int ans{};
    fr(i,n) if(v[i]) ++ans;
    cout<<ans<<endl;
}

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

using namespace std;

#define fast_io ios::sync_with_stdio(false); cin.tie(NULL);

int main()
{
	fast_io;
	
	string str;
	cin >> str;
	int answer = 0;
	for (int i = 0; i < str.size(); ++i)
	{
		if (str[i] == '+')
			answer++;
		else
			answer--;
	}
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  vector<int> v;
  while(cin.peek() != '\n')v.push_back(getchar()-'0');
  int n = (int)v.size();
  int k; cin >> k;
  ll dp1[101][5] = {};
  ll dp2[101][5] = {};
  dp1[0][1] = v[0]-1;
  dp1[0][0] = 1;
  dp2[0][1] = 1;
  for(int i = 0; i < n-1; ++i){
    for(int j = 0; j <= k; ++j){
      dp1[i+1][j] += dp1[i][j]+dp2[i][j]*(v[i+1]!=0);
      dp1[i+1][j+1] += dp1[i][j]*9+dp2[i][j]*max<ll>(v[i+1]-1,0);
      dp2[i+1][j] += dp2[i][j]*(v[i+1]==0);
      dp2[i+1][j+1] += dp2[i][j]*(v[i+1]!=0);
    }
  }
  cout << dp1[n-1][k] + dp2[n-1][k] << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d", &a, &b);
    if (a == b){
        printf("a == b\n");
    }
    else if (a < b){
        printf("a < b\n");
    }
    else{
        printf("a > b\n");
    }
    return 0;
}


Measured memory_bytes: 2036
#include <iostream>

using namespace std;

int main()
{
   double a;
   cin>>a;
   double sum=0;
  for(int i=1;i<=a;i++)
  {
      if(i%2!=0)
      sum++;
  }
  double result=(sum/a);
  cout<<result;

    return 0;
}


Measured memory_bytes: 256
/*
author : seryu
title : ABC166E_"This Message Will Self-Destruct in 5s"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	map<ll,int> mp;
	rep(i, n)mp[-a[i]+i]++;
	ll ans = 0;
	rep(i, n)ans += mp[a[i]+i];
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 27436
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int sl=s.size();
    //cout<<sl<<endl;
    int tl=t.size();
    //cout<<tl<<endl;
    t.pop_back();
    //cout<<t<<endl;
    if(s == t)
    {
        cout << "Yes" << endl;
    }
    else
    {
       cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    i64 N, K;
    read(N, K);

    vector<i64> w(N), d(N);
    rep(i, N) {
        read(w[i], d[i]);
    }

    const auto countFlowerGEK = [&](i64 x) -> bool {
        i64 cnt = 0;
        rep(i, N) {
            if (x >= w[i]) {
                cnt += (x - w[i]) / d[i] + 1;
            }
            if (cnt >= K) return true;
        }
        return cnt >= K;
    };

    i64 ltK = 0;
    i64 geK = numeric_limits<i64>::max() - 1;
    while (geK - ltK > 1) {
        const i64 mid = ltK + (geK - ltK) / 2;
        if (countFlowerGEK(mid)) geK = mid;
        else ltK = mid;
    }

    print(geK);

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,f[110001][21],ans,s[110001];
vector<int> w[110001];
void dfs(int u,int p)
{
	for(int v:w[u])
		if(v!=p)
		{
			dfs(v,u);
			for(int j=0;j<18;j++)f[u][j]+=f[v][j];
		}
	int j=0;
	for(int i=17;i>=0;i--)
		if(f[u][i]>1){j=i+1;break;}
	while(f[u][j])j++;
	ans=max(ans,j);
	f[u][j]++;
	while(j--)f[u][j]=0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		w[x].push_back(y);
		w[y].push_back(x);
	}
	dfs(1,-1);
	printf("%d\n",ans);
}


Measured memory_bytes: 20224
n = int(input())
a = list(map(int, input().split()))
rate = [0] * 9
for ai in a:
    if ai < 400:
        rate[0] = 1
    elif ai < 800:
        rate[1] = 1
    elif ai < 1200:
        rate[2] = 1
    elif ai < 1600:
        rate[3] = 1
    elif ai < 2000:
        rate[4] = 1
    elif ai < 2400:
        rate[5] = 1
    elif ai < 2800:
        rate[6] = 1
    elif ai < 3200:
        rate[7] = 1
    else:
        rate[8] += 1
res = 0
for i in range(8):
    if rate[i] != 0:
        res += 1
print(str(max(1, res)) + " " + str(res+rate[8]))


Measured memory_bytes: 3064
const A_MAX=300_001

mutable struct SegmentTree
    data::Array{Int}
    ndata::Int

end

function init(st::SegmentTree,n::Int)
    x=1::Int
    while n > x
        x *=2
    end

    st.data=zeros(Int,2*x)
    st.ndata=x
end

function update(st::SegmentTree, i::Int, x::Int)
    idx = i+st.ndata-1
    st.data[idx] = x
    while idx > 1
        idx = div(idx, 2)
        st.data[idx] = max(st.data[2idx],st.data[2idx+1])
    end
end

function query(st::SegmentTree,a::Int, b::Int)::Int
    return query_sub(st, a,b,1,1,st.ndata+1)
end

function query_sub(st::SegmentTree, a::Int,b::Int, k::Int, l::Int, r::Int)
    if r <=a || b <= l
        return 0
    elseif a <= l && r <= b
        return st.data[k]
    else
        vl = query_sub(st, a,b,2k,l,div(l+r,2))
        vr = query_sub(st, a,b,2k+1,div(l+r,2),r)
        return max(vl, vr)
    end
end

function solve()
    N,K=parse.(Int,split(readline()))
    #D=zeros(Int,300_001)
    st=SegmentTree([],0)
    init(st,A_MAX)
    #println(st)
    for _ in 1:N
        Ai=parse(Int,readline())+1
        #mx=0
        #for i=Ai-K:Ai+K
        #    if 1<=i<=N
        #        if D[i]>mx
        #            mx=D[i]
        #        end
        #    end
        #end
        a=Ai-K
        if a <1
            a=1
        end
        b=Ai+K
        if b > A_MAX
            b=A_MAX
        end
        mx=query(st,a,b+1)
        #D[Ai]=mx+1
        update(st,Ai,mx+1)
        #println(D)
    end
    println(query(st,1,A_MAX))
end
solve()

Measured memory_bytes: 228380
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  	var one = nextIntArray();
	var A = one[0];
	var B = one[1];
	var N = one[2];
	var output = Math.floor(A * Math.min(B - 1, N) / B) - A * Math.floor(Math.min(B - 1, N) / B);
	myout(output);
}

Measured memory_bytes: 29636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

int main(int argc, char const *argv[]){
	char c1[3],c2[3];
	scanf("%s %s",c1,c2);
	if(c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		System.out.println(Math.max(c - (a - b), 0));
		
	}
}

Measured memory_bytes: 21716
from collections import Counter


def solve(string):
    n, *s = string.split()
    c = Counter(s)
    _, v = c.most_common(1)[0]
    l = sorted([k for k, _v in c.items() if _v == v])
    return "\n".join(l)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 40176
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<int> c = a, ans;
    for(int i = n; i >= 1; i--){
        int cnt = 0;
        for(int j = 2 * i; j <= n; j += i){
            if(c[j - 1]) cnt++;
        }
        if(cnt % 2 == a[i - 1]) c[i - 1] = 0;
        else{
            c[i - 1] = 1;
            ans.push_back(i - 1);
        }
    }
    cout << ans.size() << endl;
    for(int ii = 0; ii < ans.size(); ii++){
        cout << ans[ii] + 1 << endl;
    }
}

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

int main() 
{
   int a, b, c;
   cin >> a >> b >> c;
   
   if (a == b)
   {
      if (a == c)
         cout << 1 << endl;
      else
         cout << 2 << endl;
   }
   else
   {
      if (a == c || b == c)
         cout << 2 << endl;
      else
         cout << 3 << endl;
   }
}


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

int main() {
  int N,a=0;
  cin>>N;
  for(int i=0;i<N;i++){
    char X;
    cin>>X;
    if(X=='Y'){
      a++;
      break;
    }
  }
  if(a==0){
    cout<<"Three"<<endl;
  }
  else{
    cout<<"Four"<<endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int N,W;
int v[1005],w[1005];
int d[10005];
int ans=0;
int main()
{
	scanf("%d%d",&N,&W);
	for(int i=0;i<N;i++)
	    scanf("%d%d",&v[i],&w[i]);
    for(int i=1;i<=W;i++) 
	    for(int j=0;j<N;j++)   
	        if(i>=w[j])
	        {
	        	d[i]=max(d[i],d[i-w[j]]+v[j]);
	        	ans=max(ans,d[i]);
			}
	printf("%d\n",ans);      
	return 0;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 
int n,a,b,ans;
int qPow(int x,int y)
{
	int res=1;
	for(;y;y>>=1,x=1ll*x*x%MOD) if(y&1) res=1ll*res*x%MOD;
	return res; 
}
int C(int x,int y)
{
	int res=1;
	for(int i=x-y+1;i<=x;++i) res=1ll*res*i%MOD;
	for(int i=1;i<=y;++i) res=1ll*res*qPow(i,MOD-2)%MOD;
	return res; 
}
int main()
{
	scanf("%d %d %d",&n,&a,&b);ans=qPow(2,n)-1;
	ans=((ans-C(n,a))%MOD-C(n,b))%MOD;printf("%d\n",(ans+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b;
  cin >> a >> b;
  vector<int> tree(1000);
  rep(i, 1, 1001) tree[i] = tree[i - 1] + i;

  int diff = b - a;
  int ans = 0;
  rep(i, 1, 1001) {
    if (diff == tree[i] - tree[i - 1]) {
      cout << tree[i] - b << endl;
      return 0;
    }
  }
}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a/g * b; //prevent overflow
}

/////////////////////////  END OF TEMPLATE ////////////////////////////////////////


int main()
{
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;

    int statec;
    int statep = (s1[0] == s2[0]) ? 0 : 1;
    ll ans = (statep) ? 6 : 3;
    int i = (statep) ? 2 : 1;
    while(i < n)
    {
        statec = (s1[i] == s2[i]) ? 0 : 1;

        if(statec == 0 && statep == 0)
        {
            ans = (ans*2)%1000000007;
        }
        else if (statec == 1 && statep == 0)
        {
            ans = (ans*2)%1000000007;
        }
        else if (statec == 1 && statep == 1)
        {
            ans = (ans*3)%1000000007;
        }
        statep = statec;
        if(statec == 0)
        {
            i++;
        }
        else
        {
            i += 2;
        }
    }

    cout << ans << endl;


}


Measured memory_bytes: 256
n,k = map(int,input().split())
if k % 2 == 1:
    a = n // k
    print(a ** 3)
else:
    a = n // k
    t = a ** 3
    a1 = int(k/2)
    b1 = k - a1
    if n % k >= a1:
        s0 = (n // k) + 1
    else:
        s0 = n // k
    if n % k >= b1:
        s1 = (n // k) + 1
    else:
        s1 = n // k
    s = (s0 ** 2) * s1
    print(s + t)

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<ll> vll;

int main() {

    int N,A,B;
    cin >> N >> A >> B;

    string s;
    cin >> s;

    int tuka = 0, kaigai = 0;
    for(int i=0; i<N; i++) {

	if( s[i] == 'a' ) {
	    if( A+B > tuka ) {
		tuka++;
		cout << "Yes" << endl;
	    }
	    else {
		cout << "No" << endl;
	    }
	}
	else if (s[i] == 'b') {
	    if( A+B > tuka and B > kaigai ) {
		tuka++;
		kaigai++;
		cout << "Yes" << endl;
	    }
	    else{
		cout << "No" << endl;
	    }
	}
	else {
	    cout << "No" << endl;
	}
    }
	    


    return 0;
}


Measured memory_bytes: 896
/* ex 7_1
  bonbonc */

#include<stdio.h>

typedef struct point{
    int x_elem;
    int y_elem;
}point;

int main(void){
    point pt1,pt2,pt3,pt4;//四点の構造体を定義
    int x_diff,y_diff;//pt2とpt1の差の成分を格納する変数
    scanf("%d %d %d %d",&pt1.x_elem,&pt1.y_elem,&pt2.x_elem,&pt2.y_elem);//入力を受け取る
    
    x_diff=pt2.x_elem-pt1.x_elem;//pt2とpt1のx成分の差分
    y_diff=pt2.y_elem-pt1.y_elem;//pt2とpt1のy成分の差分
    
    //pt3の座標=pt2の座標+pt2とpt1の差分のベクトルを90度回転させたもの
    pt3.x_elem=pt2.x_elem-y_diff;
    pt3.y_elem=pt2.y_elem+x_diff;

    //pt4の座標=pt3の座標-pt2とpt1の差分
    pt4.x_elem=pt3.x_elem-x_diff;
    pt4.y_elem=pt3.y_elem-y_diff;

    printf("%d %d %d %d\n", pt3.x_elem,pt3.y_elem,pt4.x_elem,pt4.y_elem);//それぞれの値を出力
    return 0;
}

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

int main() {
  ll N[3][3];
  rep(i,3){
    rep(j,3){
      cin >> N[i][j];
    }
  }
  bool a = true;
  if(N[0][0]-N[0][1] != N[1][0]-N[1][1]){a=false;}
  if(N[0][0]-N[1][0] != N[0][1]-N[1][1]){a=false;}
  if(N[1][0]-N[1][1] != N[2][0]-N[2][1]){a=false;}
  if(N[1][0]-N[2][0] != N[1][1]-N[2][1]){a=false;}
  if(N[0][1]-N[0][2] != N[1][1]-N[1][2]){a=false;}
  if(N[0][1]-N[1][1] != N[0][2]-N[1][2]){a=false;}
  if(N[1][1]-N[1][2] != N[2][1]-N[2][2]){a=false;}
  if(N[1][1]-N[2][1] != N[1][2]-N[2][2]){a=false;}
  
  if(a){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

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

int main()
{
  int iDividend, iDivisor, iRest;
  int iGCD;
  
  cin >> iDividend >> iDivisor;
  while (iDividend % iDivisor != 0)
  {
    iRest = iDividend % iDivisor;
    iDividend = iDivisor;
    iDivisor  = iRest;
  }

  iGCD = iDivisor;
  cout << iGCD << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
// #define long long long long int
#define loop(i,start,end) for(long long i = start; i< end; i++)
using namespace std;
vector <vector<int>> dp;
vector <vector<int>> act;
int N;
int best(int prev, int n, int prev_prof){
    if(n+1==N){
        if(prev==0){
            return max(act[n][1],act[n][2]);
        }
        else if(prev==1){
            return max(act[n][0],act[n][2]);
        }
        else{
            return max(act[n][0],act[n][1]);
        }
    }
    else{
        if(dp[n][prev]!=-1){
            return dp[n][prev];
        }
        else{
            int opt1,opt2;
            if(prev==0){
                opt1 = act[n][1]+best(1,n+1,prev_prof+act[n][1]);
                opt2 = act[n][2]+best(2,n+1,prev_prof+act[n][2]);
            }
            else if(prev==1){
                opt1 = act[n][0]+best(0,n+1,prev_prof+act[n][0]);
                opt2 = act[n][2]+best(2,n+1,prev_prof+act[n][2]);
            }
            else{
                opt1 = act[n][1]+best(1,n+1,prev_prof+act[n][1]);
                opt2 = act[n][0]+best(0,n+1,prev_prof+act[n][0]);
            }
            dp[n][prev] = max(opt1,opt2);
            return dp[n][prev];
        }
    }
}
int main(){
    int n,el;
    vector <int> temp;
    cin>>n;
    N = n;
    for(int i = 0; i< n; i++){
        temp.clear();
        for(int j = 0;j<3;j++){
        cin>>el;
        temp.push_back(el);
        }
        act.push_back(temp);
    }
    if(n==1){
        cout<<max(max(temp[0],temp[1]),temp[2]);
    }
    else{
        dp.resize(n+1);
        for (int i = 0; i < n+1; ++i)
            dp[i].resize(3,-1);
        cout<<max(max(best(0,1,act[0][0])+act[0][0],best(1,1,act[0][1])+act[0][1]),best(2,1,act[0][2])+act[0][2]);
    }
}

Measured memory_bytes: 18096
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
using namespace std;
typedef pair<long long int,long long  int> Edge;
vector<Edge> G[100000];

long long int n[100008];
long long int A[200008], B[200008], C[200008];
long long int Y[100008];

void serch(long long int X) {

	if (Y[X] == 0) {
		Y[X]++;
		for (long long int i = 0; i < (long long int)G[X].size(); i++) {
			if (n[G[X][i].first] == 0) {
				n[G[X][i].first] = n[X] + G[X][i].second;
				serch(G[X][i].first);
				Y[G[X][i].first]++;
				
			}
		}
		return;
	}
}


int main() {
	long long int N, M;
	cin >> N >> M;
	long long int a, b,c;
	for (long long int i = 0; i < M; i++) {
		cin >> a >> b>>c;
		A[i] = a;
		B[i] = b;
		C[i] = c;
		G[a].push_back(Edge(b, c));
		G[b].push_back(Edge(a, -c));
	}
	long long int K = 1;
go:;
	serch(K);




	for (long long int i = K; i <= N; i++) {
		

		if (Y[i] == 0) {
			K = i;
			goto go;

		}

	}
	
	
	long long int Z = 0;
	for (long long int i = 0; i < M; i++) {
		if (n[B[i]] - n[A[i]] != C[i]) {
			Z++;
			
		}
	}

	if (Z > 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 21888
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

struct Trump
{
    char design;
    int value;
};

/* バブルソートは安定ソート */
void bubble_sort(struct Trump *A, int N)
{
    int flag = 1; // 逆の隣接行列が存在
    int i = 0;    // 未ソート部分列の先頭index
    struct Trump tmp;

    while (flag)
    {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--)
        {
            if (A[j].value < A[j - 1].value) // A[j] <= A[j - 1]だと安定ソートではなくなる
            {
                tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                flag = 1;
            }
        }
        i += 1;
    }
}

/* 選択ソートは安定ではない */
void selection_sort(struct Trump *A, int N)
{
    int minj; // 未ソート部分の最小の要素
    struct Trump tmp;

    for (int i = 0; i < N; i++)
    {
        minj = i;
        for (int j = i; j < N; j++)
        {
            if (A[j].value < A[minj].value)
            {
                minj = j;
            }
        }
        tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
    }
}

int main(void)
{
    int N;
    struct Trump B[36];  // bubble sort
    struct Trump S[36];  // selection sort
    int flag = 0;

    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        // %cの前に空白を入れる必要あり('\n'を読み込まないため)
        scanf(" %c%d", &B[i].design, &B[i].value);
        S[i].design = B[i].design;
        S[i].value = B[i].value;
    }

    bubble_sort(B, N);
    for (int i = 0; i < N; i++)
    {
        if (i == N - 1)
        {
            printf("%c%d\n", B[i].design, B[i].value);
        }
        else
        {
            printf("%c%d ", B[i].design, B[i].value);
        }
    }
    printf("Stable\n");  // 常にStable

    selection_sort(S, N);
    for (int i = 0; i < N; i++)
    {
        if (i == N - 1)
        {
            printf("%c%d\n", S[i].design, S[i].value);
        }
        else
        {
            printf("%c%d ", S[i].design, S[i].value);
        }
    }

    for (int i = 0; i < N; i++)
    {
        if(S[i].design != B[i].design || S[i].value != B[i].value)
        {
            flag += 1;
        }
    }
    if (flag == 0)
    {
        printf("Stable\n");
    }
    else
    {
        printf("Not stable\n");
    }

    return 0;
}


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

int main(){
    long long X;
    std::cin >> X;
    
    long long cur = 100;
    int year = 0;
    while(cur < X){
        cur = cur + cur / 100;
        year++;
    }
    
    
    std::cout << year << std::endl;
    return 0;
}



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

constexpr int mod=998244353;

ll beki_a[4000],beki_b[4000];

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;


template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;

  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }

  inline T fact(int k) const { return _fact[k]; }

  inline T rfact(int k) const { return _rfact[k]; }

  inline T inv(int k) const { return _inv[k]; }

  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }

  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}


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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define w(e) int e ; cin >> e ; while (e--)  
#define ll long long 
#define endl "\n"
#define mod  10000000007
#define pi 3.141592653589793
#define setbit(x) __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)  
/*
*/
int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n ; cin >> n;int no;
    no = n%10;
    if (no == 2 || no == 4 || no == 5 || no == 7 || no == 9)
    {
        cout << "hon" <<endl;
    }
    if (no == 0 || no == 1 || no == 6 || no == 8)
    {
        cout << "pon" <<endl;
    }
    if (no == 3 )
    {
        cout << "bon" <<endl;
    }
	return  0;
}

Measured memory_bytes: 3596
from collections import deque

S = input()
Q = int(input())
q = deque(S)
fg = False
for i in range(Q):
    que = list(map(str , input().split()))
    if que[0] == "1":
        fg = not fg
    elif (que[1] == "1" and fg == False) or (que[1] == "2" and fg == True) :
        q.appendleft(que[2])
    else:
        q.append(que[2])
if fg:
    q.reverse()
print("".join(q))



Measured memory_bytes: 8692
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
// 逆数
LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

// 除算
LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

map< LL, int > prime_factor(LL n) {
  map< LL, int > ret;
  for(LL i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

void Main()
{
    int n;cin>>n;
    VL a(n);
    REP(i,n){
        cin>>a[i];
    }

    map<LL,int> count;

    REP(i,n){
        map<LL, int> m = prime_factor(a[i]);
        for(auto itr : m) {
            count[itr.first]=max(count[itr.first],itr.second);
        }
    }

    LL l=1;
    for(auto itr : count){
        l *= modpow(itr.first, itr.second);
        l %= MOD;
    }

    LL result = 0;
    REP(i,n){
        result += moddev(l,a[i]);
        result %= MOD;
    }
    cout<<result<<endl;


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1024