akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
using ull = unsigned long long;
const static int MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    ull sz = S.size(), power[sz+1], undecided_left[sz+1], a[sz+1], c = 0, answer = 0;
    power[0] = 1;
    for (unsigned i = 0; i < sz; i++){
        power[i+1] = power[i]*3 %MOD;
    }
    undecided_left[0] = a[0] = 0;
    for (unsigned i = 0; i < sz; i++){
        undecided_left[i+1] = undecided_left[i];
        a[i+1] = a[i];
        if(S[i] == '?') undecided_left[i+1]++;
        else if(S[i] == 'A') a[i+1]++;
    }
    for (int i = sz-1; i >= 0; i--){
        if(S[i] == 'C') c++;
        else if(S[i] == 'B' || S[i] == '?'){
            answer = (answer + a[i]*c*power[undecided_left[sz] - (ull)(S[i] == '?')]) %MOD;
            if(undecided_left[sz] > undecided_left[i+1]) answer = (answer + a[i]*(undecided_left[sz] - undecided_left[i+1])*power[undecided_left[sz] - (ull)(S[i] == '?') - 1]) %MOD;
            if(undecided_left[i]) answer = (answer + undecided_left[i]*c*power[undecided_left[sz] - (ull)(S[i] == '?') - 1]) %MOD;
            if(undecided_left[sz] > undecided_left[i+1] && undecided_left[i]) answer = (answer + undecided_left[i]*(undecided_left[sz] - undecided_left[i+1])*power[undecided_left[sz] - (ull)(S[i] == '?') - 2]) %MOD;
        }
    }
    printf("%llu\n", answer);
	return 0;
}

Measured memory_bytes: 6116
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> 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().expect("failed to parse token")
}

fn main() {
    let N: u32 = read();
    println!("{}", N*N*N);
}

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



int main() {
  ll n;
  cin>>n;
  vector<P> v;
  rep(i,5){
  ll a;
  cin>>a;
  v.emplace_back(P (a,i+1));
  }
  sort(v.begin(),v.end());
  ll v1=v[0].first;
  //  int bef=v[0].second;
  ll p=n%v1;
  ll ans;
  //cout<<v1<<'v'<<endl;
  if (p==0)ans=n/v1+4;
  else {ans=(n+v1-p)/v1+4;}
  cout<<ans;

  }


Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

vector<int>g[110000];
long long dp[110000][2];
void calc(int a,int b){
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		calc(g[a][i],a);
	}
	long long s=1;
	long long t=1;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		s=s*(dp[g[a][i]][0]+dp[g[a][i]][1])%mod;
		t=t*(dp[g[a][i]][0])%mod;
	}
	dp[a][0]=s;
	dp[a][1]=t;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	calc(0,-1);
	printf("%lld\n",(dp[0][0]+dp[0][1])%mod);
}

Measured memory_bytes: 14464
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>

#define N 100000

using namespace std;

struct Process{char name[10]; int time;};

Process Queue[N];
int head = 0, tail = 0;

void push(Process data){
    Queue[tail] = data;

    tail = (tail + 1) % N;
}

Process pop(){
    Process ret;
    ret = Queue[head];

    head = (head + 1) % N;

    return ret;
}

int main(){
    int time_sum=0;

    int n, q;

    cin >> n >> q;

    Process tmp;
    for (int i = 0; i < n; ++i) {
        cin >> tmp.name >> tmp.time;

        if (tmp.time > q){
            time_sum += q;
            tmp.time -= q;
            push(tmp);
        }else{
            time_sum += tmp.time;
            printf("%s %d\n", tmp.name, time_sum);
        }
    }

    while (head != tail){
        tmp = pop();

        if (tmp.time > q){
            time_sum += q;
            tmp.time -= q;
            push(tmp);
        }else{
            time_sum += tmp.time;
            printf("%s %d\n", tmp.name, time_sum);
        }
    }
}

Measured memory_bytes: 4740
#include <cmath>
#include <cstdio>
#include<string>
#include <vector>
#include <iostream>
#include<bits/stdc++.h>
#include <algorithm>
#define pb push_back
#define ll long long
#define mk make_pair
using namespace std;
int main()
{
    int n;
    cin>>n;
    cout<<"ABC"<<n<<endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        a: [i32; 3],
    }
    println!("{}", if a.iter().fold(0, |sum, x| sum + x) >= 22 { "bust" } else { "win" });
}


Measured memory_bytes: 4352
//itp1_8-a
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
 char num[1001];

 while(true){
  int res=0;
  scanf("%s",num);
  if(num[0]=='0') return 0;
  for(int i=0;num[i]!='\0';i++){
   res+=num[i]-'0';
  }
  cout<<res<<endl;
 }
 return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a, b; cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) out("Possible");
    else out("Impossible");
}



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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

int main(){
  int n,k;
  string s;
  cin >> n >> s >> k;
  k--;
  REP(i,n) {
    if (s[i] == s[k]) cout << s[k] ;
    else cout << "*";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n;
  cin >> n;
  map<string,int> dic;
  int t=0;
  for(int i=0; i<n; i++){
     string s;
    cin >> s;
    dic[s]++;
    t = max(dic[s],t);
  }
   for(auto q : dic){
     if(q.second == t){
       cout << q.first << endl;
     }
   }
}


Measured memory_bytes: 25216
using System;

class PG{
    public static void Main(string[] args){
        
        int n=int.Parse(Console.ReadLine());
        var array=new int[n];
        for(int i=0;i<n;i++){
            array[i]=int.Parse(Console.ReadLine());
        }
        int min=array[0];
        int max=array[1]-min;
        for(int i=1;i<n;i++){
            if(array[i]-min>max){
                max=array[i]-min;
            }
            if(array[i]<min){
                min=array[i];
            }
        }
        Console.WriteLine(max);
    }
}


Measured memory_bytes: 20308
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define N 102
char board[N][N];
 //int hang[N],lie[N];
 int vis[N][N];
int h,w;
void cut(){
	int i,j,cnt;
	for( i=0;i<h;i++ )
	{
		cnt=0;
		for( j=0;j<w;j++ ){  //一行都是点 
			if( board[i][j]=='.' )
				cnt++;
			else
				break;
		}
		if( cnt==w )  //一行都是点就删除 
		{
			for( j=0;j<w;j++ )
				vis[i][j]=0;
		}
	}
	for( i=0;i<w;i++ ){
		cnt=0;
		for( j=0;j<h;j++ ){
			if( board[j][i]=='.' )
				cnt++;
			else
				break;
		}
		if( cnt==h )  //一列都是点
		{
			for( j=0;j<h;j++ )
				vis[j][i]=0;
		} 
	}
} 
int main() {
	int i,j;
	cin>>h>>w;
		int flag1;
	//	for( i=0;i<w;i++ )
	//		lie[i]=0;
		for( i=0;i<h;i++ ){
			flag1=0;
			for( j=0;j<w;j++ ){
				cin>>board[i][j];
			/*	if( board[i][j]=='#' )  //这行这列有#,不要删除 
				{
					hang[i]=1;
					lie[j]=1;
					flag1=1;
				} */
				vis[i][j]=1;
			}
		//	if( !flag1 )
		//		hang[i]=0;
		}
		cut();
		int flag;
		for( i=0;i<h;i++ )
		{
			flag=0;
			for( j=0;j<w;j++ )
			{
				if( vis[i][j] )
				{
					cout<<board[i][j];
					flag=1;
				}
			}
			if( flag )
				cout<<endl;
		}
	return 0;
	}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val dp = mutableListOf(IntArray(3){scn.nextInt()})
	repeat(n-1){
		val hps = IntArray(3){scn.nextInt()}
		dp.add(IntArray(3){l ->
			val i = mutableListOf(0,1,2)
			i.removeAt(l)
			val last = dp.last()
			return@IntArray Math.max(last[i[0]]+hps[l], last[i[1]]+hps[l])
		})
	}
	print(dp.last().max())
}

Measured memory_bytes: 113160
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
  if((i+1)%2==1){
    if(s.at(i)=='L'){
      cout<<"No"<<endl;
      return 0;
  }
  }
    else {
     if(s.at(i)=='R'){
       cout<<"No"<<endl;
       return 0;
  }
    }
  }
  cout<<"Yes"<<endl;
}


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

using namespace std;

typedef long long ll;

const int inf = 1e9;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &a[i]);
	}
	set<int> s;
	for (int i = 1; i*i <= N; ++i) {
		if (N % i == 0) {
			s.insert(i);
			s.insert(N/i);
		}
	}
	int ans = 1;
	for (int k : s) {
		int t = N/k;
		bool f = true;
		for (int i = 0; i < k; ++i) {
			for (int j = i; j < N; j += k) {
				if (a[i] != a[j]) {
					f = false;
					break;
				}
			}
			if (!f) break;
		}
		if (f) ans = max(ans, t);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
using System;

class Program
{
    static void Main(string[] args)
    {

        int N = int.Parse(Console.ReadLine());
        string[] word = Console.ReadLine().Split(' ');
        int Count = 0;
        int a = 0;
        for(int i = 1;i <= N; i++)
        {
            if (i == 1&& (int.Parse(word[a]) % 2 == 1 || int.Parse(word[a]) == 1))
            {
                Count++;
                
            }
            else if (i % 2 == 1 && (int.Parse(word[a]) % 2 == 1 || int.Parse(word[a]) == 1))
            {
                Count++;
                
            }
            a++;
        }
        Console.WriteLine(Count);
        

    }
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

static const ll INF = 1e15;

static const ll mod = 1e9 + 7;

int main() {
	ll x, n;
	cin >> x >> n;
	set<ll> s;
	rep(i, n) {
		ll v;
		cin >> v;
		s.insert(v);
	}
	for (int i = 0; i < 1000; i++) {
		ll low = x - i;
		if (!s.count(low)) {
			cout << low << endl;
			return 0;
		}
		ll high = x + i;
		if (!s.count(high)) {
			cout << high << endl;
			return 0;
		}
	}
	return 0;
}
	

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 300000;
int mod = 1e9 + 7;
int x[N], y[N];
map < pair < int, int >, int > m;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
        m[{x[i], y[i]}] = 1;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            int p = x[j] - x[i];
            int q = y[j] - y[i];
            if (i == j) continue;
            int c = 0;
            for (int l = 1; l <= n; l++){
                if (m[{x[l] - p, y[l] - q}] == 1) c++;
            }
            ans = max(ans, c);
        }
    }
    cout << n - ans;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t a,b,c;
  cin >> a >> b >> c;
  if(a >= c || b >= c){
    cout << "No" << endl;
  }else{
    if((b+c-a)*(b+c-a) > 4*b*c){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }   
    int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
 return 0;   
}

Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <array>
#include <memory>
#include <iostream>

using namespace std;
int main(void) {
	//boost::shared_ptr<vector<string>>  log(boost::make_shared<vector<string>>());
	//log->push_back("dd");
	//log->push_back("dde");
	//boost::shared_ptr<vector<string>>  blog(boost::make_shared<vector<string>>());
	//blog->push_back("fsdfsdfd");
	//OpChara a(3,log);
	//OpChara b(2,log);
	//OpChara c(1, log);
	//log->push_back("dde3");
	//std::ofstream ofs("output1.txt");
	//assert(ofs);
	//boost::archive::text_oarchive oa(ofs);
	//oa << (a);
	//ofs.close();
	//std::ofstream cofs("output2.txt");
	//assert(cofs);
	//boost::archive::text_oarchive coa(cofs);
	//coa << (b);
	//cofs.close();

	//// de-serialize
	//std::ifstream ifs("output1.txt");
	//assert(ifs);
	//boost::archive::text_iarchive ia(ifs);

	//ia >> (b);
	//
	//ifs.close();
	//std::ifstream cifs("output2.txt");
	//assert(cifs);
	//boost::archive::text_iarchive iac(cifs);
	//iac >> c;
	//
	//// check
	//b.actionlog->push_back("111");

	int n, m;
	cin >> n >> m;
	vector<int>a;
	if (n % 2) {
		for (int i = 0; i < n / 2 + 1; ++i) {
			a.push_back(0);
			
				
			
		}
		for (int i = 0; i < n-(n / 2 + 1); ++i) {
			a.push_back(m);
		}
		

	}
	else {
		for (int i = 0; i < n / 2 + 1; ++i) {
			a.push_back(0);
		}
		for (int i = 0; i < n - (n / 2 + 1); ++i) {
			a.push_back(m);
		}
	}
	for (int i = 0; i < a.size(); ++i) {
		if (i != 0) {
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;

	return 0;

}

Measured memory_bytes: 1220
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    mn = min(a)
    while True:
        b = set()
        for e in a:
            if e % mn:
                b.add(e%mn)
            else:
                b.add(mn)
        a = list(b)
        mn = min(a)
        if len(a) == 1:
            print(mn)
            return
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

2 3 4 4
3 4 4
2 3 4
2 3 4
2 4 4


"""


Measured memory_bytes: 20404
n = gets.to_i
as = gets.split.map &:to_i
q = gets.to_i

bs = []
cs = []

q.times{
	b, c = gets.split.map &:to_i
	bs << b
	cs << c
}

sum = as.sum

as_map = Hash[as.group_by(&:itself).map {|k, v| [k, v.size] }]

q.times{ |i|
	count = as_map[bs[i]]
	
	if count != nil then
		as_map[bs[i]] = 0
		if as_map[cs[i]] == nil then
			as_map[cs[i]] = count
		else
			as_map[cs[i]] += count
		end

		sum += count * (cs[i] - bs[i])
	end
	
	puts sum
}


Measured memory_bytes: 33236
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int a[N];
int f[N];
int val[N<<2];
int query(int u,int l,int r,int x,int y){
	if (x<=l && r<=y){
		return val[u];
	}
	int mid=l+r>>1;
	int res=0;
	if (x<=mid) res=max(res,query(u<<1,l,mid,x,y));
	if (y>mid) res=max(res,query(u<<1|1,mid+1,r,x,y));
	return res;
}
void update(int u,int l,int r,int x,int v){
	if (l==r){
		val[u]=max(val[u],v);
		return;
	}
	int mid=l+r>>1;
	if (x<=mid) update(u<<1,l,mid,x,v);
	else update(u<<1|1,mid+1,r,x,v);
	val[u]=max(val[u<<1],val[u<<1|1]);
}
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	int maxn=0;
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		a[i]++;
		maxn=max(a[i],maxn);
	}
	int ans=0;
	for (int i=1;i<=n;i++){
		int tp;
		tp=query(1,1,maxn,max(a[i]-k,1),min(maxn,a[i]+k))+1;
		update(1,1,maxn,a[i],tp);
		ans=max(ans,tp);
	}
	printf("%d\n",ans);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()

using ll = long long;
constexpr ll INF = 10000000000;

using namespace std;

//fixed << setprecision(10)

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

int main() {
	string S; cin >> S;
	int n = S.length();

	int s = 0, t = 0, ans = 0;

	for (int i = 0; i < n; i++) {
		if (S[i] == 'S')s++;
		else {
			if (s)s--;
			else ans++;
		}
	}
	ans += s;
	cout << ans << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;
 
int main()
{
    int a;
  cin >> a;
  if(a == 1){
  cout << "Hello World" << endl;
  }
  else{
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	int ans=0;
	string str;
	cin>>str;
	str="000"+str;
	for(int i=str.size()-1;i>=0;i--){
		int curnumber=str[i]-48;
		if(curnumber>=10){
			str[i-1]++;
			curnumber-=10;
		}
		if(curnumber==5){
			ans+=5;
			if(str[i-1]>='5'){
				str[i-1]++;
			}
		}
		else
			if(curnumber>5){
				ans+=(10-curnumber);
				str[i-1]++;
			}
			else
				ans+=curnumber;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2308
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << (k == 1 ? 0 : n - k) << '\n';
}


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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

int main(void){
  int h, w;
  cin >> h >> w;
  arrst(a,h);

  vec s(26, 0);
  rep(i,h){
    rep(j,w){
      s[(a[i][j]-'a')]++;
    }
  }

  rep(i,26){
    s[i] %= 4;
  }

  //prtall(s);

  bool ok=true;
  if(h%2==0 && w%2==0){
    rep(i,26){
      if(s[i]>0) ok=false;
    }
  } else if(h%2==1 && w%2==1){
    bool odd=false;
    int even=0;
    rep(i,26){
      if(s[i]%2==1){
        if(odd){
          ok=false;
        }
        odd=true;
        s[i]--;
      }
      even+=s[i];
    }
    if(even>2*(h/2+w/2)) ok=false;
  } else {
    int mx;
    if(w%2==1){
      mx=h/2;
    } else {
      mx=w/2;
    }
    //prt(mx);
    int even=0;
    rep(i,26){
      if(s[i]%2==1){
        ok=false;
      }
      even+=s[i];
    }
    if(even>mx*2) ok=false;
  }

  prt(ok ? "Yes" : "No");

}


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

int A, B, C, D, P;
int main() {
  cin >> A >> B >> C >> D >> P;
  cout << min(A*P, B + (P<C ? 0 : (P-C)*D)) << "\n";
  return 0;
}

Measured memory_bytes: 3076
/*
* @author:  codancer
* @createTime:  2020-02-17, 09:39:06
*/
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
ll n,k;
ll a[200010];
bool check(ll x){
	ll cnt=0;// the number that less than x
	for(int i=1;i<=n;i++){
		ll num=0;
		if(a[i]==0){
			if(x>0) cnt+=n;
		}else{
			if(a[i]>0){
				ll h=x/a[i];
				if(x%a[i]&&(x>0)){
					++h;
				}
				num=lower_bound(a+1,a+n+1,h)-a-1;
			}
			else{
				ll h=x/a[i];
				if(x%a[i]&&(x>0)){
					h--;
				}
				ll great=upper_bound(a+1,a+n+1,h)-a-1;
				num=n-great;
			}
			cnt+=num;
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i]*a[i]<x) --cnt;
	}
	cnt/=2;
	return cnt<k;
}
ll l,r,ans;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	l=-1e18;
	r=1e18;
	// cout<<check(-6)<<endl;
	while(l<=r){
		ll mid=l+r>>1;
		if(check(mid)){
			 l=mid+1;
			 ans=mid;
		}
		else r=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
using namespace std;
int a[5],ok;
char op[4];
string s;
void dfs(int where,int sum)
{
	if(ok==0&&where<=5)
	{
		if(where==5)
		{
			if(sum==7)
			{
				ok=1;
				cout<<a[1]<<op[1]<<a[2]<<op[2]<<a[3]<<op[3]<<a[4]<<"=7"<<endl;
			}
		}
		else
		{
			op[where-1]='+';
			dfs(where+1,sum+a[where]);
		}
	}
	if(ok==0&&where<=5)
	{
		if(where==5)
		{
			
		}
		else
		{
			op[where-1]='-';
			dfs(where+1,sum-a[where]);
		}
	}
}
int main()
{
	cin>>s;
	for(int i=1; i<=4; i++) a[i]=s[i-1]-48;
	dfs(2,a[1]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    int main() {
    int a,b;
    char op;
while(1){
cin>> a >> op >> b ;
if (op == '*'){
cout << a*b << endl;
}
else if (op == '/'){
cout << a/b << endl;
}
else if (op == '-'){
cout << a-b << endl;
}
else if (op == '+'){
cout << a+b << endl;
}
else {break;
}
};
    return 0;
    }

Measured memory_bytes: 1160
import math
import itertools


N = int(input())
l = list(range(N))
p = itertools.permutations(l)
xy = [list(map(int, input().split())) for _ in range(N)]
s = 0
for pp in p:
    for i in range(1, N):
        pi, pj = pp[i - 1], pp[i]
        s += ((xy[pi][0] - xy[pj][0]) ** 2 +
              (xy[pi][1] - xy[pj][1]) ** 2) ** 0.5
ave = s / math.factorial(N)
print(ave)

Measured memory_bytes: 3064
extern crate proconio;
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: i64,
        mut b: i64,
        mut c: i64,
        s: [String; n],
    };

    let mut ans = vec![];
    for i in 0..n {
        let t = &s[i];
        if t == "AB" {
            if a < b || (a == b && i + 1 < n && s[i + 1] == "AC") {
                a += 1;
                b -= 1;
                ans.push("A");
            } else {
                a -= 1;
                b += 1;
                ans.push("B");
            }
        } else if t == "BC" {
            if b < c || (b == c && i + 1 < n && s[i + 1] == "AB") {
                b += 1;
                c -= 1;
                ans.push("B");
            } else {
                b -= 1;
                c += 1;
                ans.push("C");
            }
        } else {
            if c < a || (c == a && i + 1 < n && s[i + 1] == "BC") {
                c += 1;
                a -= 1;
                ans.push("C");
            } else {
                c -= 1;
                a += 1;
                ans.push("A");
            }
        }
        if a < 0 || b < 0 || c < 0 {
            println!("No");
            return;
        }
    }
    println!("Yes");
    println!("{}", ans.join("\n"));
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> P(M), Y(M), R(M);
    rep(i, M) cin >> P[i] >> Y[i];

    vector<pair<int, int>> L(M);
    rep(i, M) {
        L[i] = pair<int, int>(Y[i], i);
    }
    sort(L.begin(), L.end());
    map<int, int> mp;

    rep(i, M) {
        // R[i] = mp[P[i]];
        // mp[P[i]]++;
        int id = L[i].second;
        R[id] = mp[P[id]];
        mp[P[id]]++;
    }

    rep(i, M) {
        cout << std::setfill('0') << std::right << std::setw(6) << P[i] << std::setfill('0') << std::right << std::setw(6) << R[i]+1 << endl;
    }
}

Measured memory_bytes: 9592
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 2500000
ll MOD=1e9+7;



main(){
    int n=in(),d=in();
    d=d*2+1;
    cout<<(n+d-1)/d;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        bool gray = false;
        bool brown = false;
        bool green = false;
        bool lbule = false;
        bool bule = false;
        bool yellow = false;
        bool orange = false;
        bool red = false;
        var max = 0;
        var min = 0;
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] < 400)
            {
                if (!gray)
                {
                    max++;
                    min++;
                }
                gray = true;
            }
            else if (a[i] < 800)
            {
                if (!brown)
                {
                    max++;
                    min++;
                }
                brown = true;
            }
            else if (a[i] < 1200)
            {
                if (!green)
                {
                    max++;
                    min++;
                }
                green = true;
            }
            else if (a[i] < 1600)
            {
                if (!lbule)
                {
                    max++;
                    min++;
                }
                lbule = true;
            }
            else if (a[i] < 2000)
            {
                if (!bule)
                {
                    max++;
                    min++;
                }
                bule = true;
            }
            else if (a[i] < 2400)
            {
                if (!yellow)
                {
                    max++;
                    min++;
                }
                yellow = true;
            }
            else if (a[i] < 2800)
            {
                if (!orange)
                {
                    max++;
                    min++;
                }
                orange = true;
            }
            else if (a[i] < 3200)
            {
                if (!red)
                {
                    max++;
                    min++;
                }
                red = true;
            }
            else
            {
                max++;
            }

        }

        if (min == 0)
        {
            min++;
        }
        Console.WriteLine(min + " " + max);
    }
}


Measured memory_bytes: 13268
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

enum MOD = 10^^9 + 7;

void main() {
    int n, m;
    readf("%d %d\n", &n, &m);
    auto ng = new bool[100010];
    foreach (i; 0..m) {
        int a; readf("%d\n", &a);
        ng[a] = true;
    }

    auto dp = new int[n + 1];
    dp[0] = 1;
    foreach (i; 0..n) {
        int to1 = i + 1;
        if (to1 <= n && !ng[to1]) {
            dp[to1] += dp[i];
            dp[to1] %= MOD;
        }
        int to2 = i + 2;
        if (to2 <= n && !ng[to2]) {
            dp[to2] += dp[i];
            dp[to2] %= MOD;
        }
    }
    debug writeln(dp);
    writeln(dp[n]);
}

Measured memory_bytes: 2684
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <queue>

typedef long long ll;

using namespace std;


int main(){
    string s;
    int n;
    cin >> s >> n;
    int ch = 1;
    string f = "";
    string e = "";
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x == 1){
            if(ch){
                ch = 0;
            } else {
                ch = 1;
            }
            continue;
        }
        int a;
        string b;
        cin >> a >> b;
        if(a == 1){
            if(ch){
                f = f + b;
                //s = b + s;
            } else {
                e = e + b;
                //s = s + b;
            }
        } else {
            if(ch){
                e = e + b;
                //s = s + b;
            } else {
                f = f + b;
                //s = b + s;
            }
        }
    }
    if(ch){
        reverse(f.begin(), f.end());
        s = f + s + e;
        cout << s << endl;
    } else {
        reverse(e.begin(), e.end());
        reverse(s.begin(), s.end());
        s = e + s + f;
        cout << s << endl;
    }
}

Measured memory_bytes: 1596
n = int(input())
S = [int(i) for i in input().split()] + [0]
q = int(input())
T = [int(i) for i in input().split()]
c = 0

for i in T:
    S[n] = i
    j = 0
    while i != S[j]:
        j += 1
    if j != n:
        c += 1

print(c)

Measured memory_bytes: 8436
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005

// it's swapnil07 ;)

int ctd(int i){
    int ct = 0;
    while(i){
        i/=10;
        ct++;
    }
    return ct;
}

signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n; cin>>n;
    int ans = 0;
    For(i, 1, n+1){
        int x = ctd(i);
        if(x%2)
            ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int[] n = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt()};
        Arrays.sort(n);
        int count = 0;
        while (n[0] < n[1]) {
            n[0] += 2;
            count++;
        }
        if (n[0] != n[1]) {
            n[1]++;
            n[2]++;
            count++;
        }
        while (n[1] != n[2]) {
            n[1]++;
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 25684
/*GRATITUDE*/
//Arise Awake and Stop Not Till the Goal is reached. You are the greatest of all. Hare Krishna
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define ff              first
#define ss              second
#define uint            unsigned long long
#define int             long long
#define double           long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define vpii            vector<pii>
#define umpii           unordered_map<int,int>
#define ustii           unordered_set<int>   
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             10000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define all(x)             x.begin(), x.end()
#define all_r(x)           x.rbegin(), x.rend()
#define sortall(x)         sort(all(x))
#define sortall_r(x)       sort(all_r(x))  
#define tr(it, a)          for(auto it = a.begin(); it != a.end(); it++)
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("o.txt", "w", stdout);
#endif
}
/*************************************************************************************************/
//Write your functions here..............................
string to_string(char x) {
    string s(1,x);
    return s;
}

/***************************************************************************************************/
void solve() {
/*Write your code here*/
  int n; cin>>n; string res="";
    
    while(n!=0) {
        n--;
        res+=to_string(char('a'+n%26));
        n/=26;
    }
    reverse(all(res));
    cout<<res;

}
int32_t main()
{
ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;

map<string,int> mp;

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

int M = 0;

for(auto x : mp) {
    M = max(M,x.second);
}

vector<string> S = {};

for(auto x : mp) {
    if(x.second == M) S.push_back(x.first);
}

sort(all(S));
rep(i,S.size()) cout << S[i] << endl;

return 0;
}

Measured memory_bytes: 25584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 3000

int dp[MAX + 1][MAX + 1];

string getLCS(string& s, string& t, int len)
{
	string LCS;
	int i = 0, j = 0;
	while (len > 0)
	{
		if (s[i] == t[j])
		{
			LCS.push_back(s[i]);
			i++;
			j++;
			len--;
		}
		else
		{
			if (dp[i][j + 1] > dp[i + 1][j])
			{
				j++;
			}
			else
				i++;
		}
	}
	return LCS;
}

int lenLCS(string& s, string& t, int i, int j)
{
	if (i >= s.length() || j >= t.length())
		return 0;

	if (dp[i][j] != -1)
		return dp[i][j];

	if (s[i] == t[j])
		return dp[i][j] = 1 + lenLCS(s, t, i + 1, j + 1);
	else
	{
		return dp[i][j] = max(lenLCS(s, t, i, j + 1), lenLCS(s, t, i + 1, j));
	}
}

string solve(string s, string t)
{
	memset(dp, -1, sizeof(dp));
	int len = lenLCS(s, t, 0, 0);
	return getLCS(s, t, len);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s, t;
	cin >> s >> t;
	cout << solve(s, t);
}

Measured memory_bytes: 39260
#include <bits/stdc++.h>
using namespace std;
long long n;
string s;

int main(){
	cin>>n;
	s="";
	while(n--){
		s=s+char(n%26+'a');
		n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

#define N 100

int main() {
	static int aa[N];
	int n, m, x, i, j, c1, c2;

	scanf("%d%d%d", &n, &m, &x);
	for (j = 0; j < m; j++)
		scanf("%d", &aa[j]);
	c1 = 0;
	for (i = 1; i < x; i++)
		for (j = 0; j < m; j++)
			if (i == aa[j])
				c1++;
	c2 = 0;
	for (i = x + 1; i < n; i++)
		for (j = 0; j < m; j++)
			if (i == aa[j])
				c2++;
	printf("%d\n", c1 < c2 ? c1 : c2);
	return 0;
}


Measured memory_bytes: 128
N = int(input())
B = map(int,input().split())
mlen = 0
prev = 100000000000000000000
clen = 0
for i in B:
    if i <= prev:
        clen += 1
    else:
        clen = 1
    prev = i
    if clen > mlen:
        mlen = clen

print(mlen-1)

Measured memory_bytes: 64112
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
     int a ,b;
     cin>>a>>b;
     if(a>b){cout<<"safe";}
     else if(a<=b){ cout<<"unsafe";}
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] arr = new int[3][n];
        int[] swim = new int[n];
        int[] bugs = new int[n];
        int[] home = new int[n];

        for (int i=0;i<n;i++){
            int tmp = in.nextInt();
            swim[i]=tmp;
            tmp = in.nextInt();
            bugs[i] = tmp;
            tmp = in.nextInt();
            home[i] = tmp;
        }
        arr[0][0] = Math.max(Math.max(swim[0],bugs[0]),home[0]);
        arr[1][0] = arr[0][0];
        arr[2][0] = arr[0][0];

        for(int col=1;col<n;col++){
            arr[0][col] = Math.max(arr[1][col-1],arr[2][col-1]) + swim[col];
            arr[1][col] = Math.max(arr[0][col-1],arr[2][col-1]) + bugs[col];
            arr[2][col] = Math.max(arr[0][col-1],arr[1][col-1]) + home[col];
        }

        int ans = Math.max(Math.max(arr[0][n-1],arr[1][n-1]),arr[2][n-1]);
        System.out.println(ans);

    }
}


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

int eval(int& i,vector<string>& S){
    string s = S[i];
    i++;
    if(isdigit(s[s.size()-1])){
        return s[s.size()-1] - '0';
    }
    char op = s[s.size()-1];
    int res = (op == '*' ? 1 : 0);
    while(i < S.size()){
        if(s.size() >= S[i].size())break;
        if(op == '*'){
            res *= eval(i,S);
        }else{
            res += eval(i,S);
        }
    }
    return res;
}

int solve(int n){
    int i = 0;
    vector<string> s(n);
    for(auto &x:s)cin >> x;
    return eval(i,s);
}

int main(){
    int n;
    while(true){
        cin >> n;
        if(!n)return 0;
        cout << solve(n) << endl;
    }
}


Measured memory_bytes: 3036
import sys
#import math
#import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
N=str(input())
li=list(N)
i=0
for i in range(2):
  if(li[i]!=li[i+1]):
    print('Yes')
    sys.exit()
print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;


int D, G;
int p[20], c[20];


signed main(){
    cin >> D >> G, G/=100;
    rep(i, 0, D) cin >> p[i] >> c[i], c[i]/=100;

    int ans = INF;
    rep(i, 0, 1<<D){
        int s = 0;
        int cnt = 0;
        repr(j, D, 0){
            if(!((i>>j)&1)) continue;
            if(CEIL((G-s)/(j+1)) < p[j]) chmin(ans, cnt+CEIL((G-s)/(j+1)));
            else if(CEIL((G-(s+c[j]))/(j+1)) <= p[j]) chmin(ans, cnt+p[j]);
            else s += (j+1)*p[j]+c[j], cnt += p[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256