akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

#include <string>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <math.h>



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

	unsigned n = s1.size();

	for( int i=0 ; i<n/2 ; i++ )
	{
		if( s1[ i ] == s1[ n -1 -i ] )
		{
			continue;
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}


	auto s2 = s1.substr( 0, ( n-1 ) /2 );
	auto s3 = s1.substr( ( n+3 ) /2 -1 );

	n = s2.size();

	for( int i=0 ; i<n/2 ; i++ )
	{
		if( s2[ i ] == s2[ n -1 -i ] )
		{
			continue;
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}

	n = s3.size();

	for( int i=0 ; i<n/2 ; i++ )
	{
		if( s3[ i ] == s3[ n -1 -i ] )
		{
			continue;
		}
		else
		{
			cout << "No" << endl;
			return 0;
		}
	}


	cout << "Yes" << endl;
		
	return 0;
}

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

int main()
{
    int n,m,i,a[100],sum=0,count=0;
    double b;
    cin>>n>>m;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        sum=sum+a[i];
    }
    b=sum/(4.0*m);
    for(i=0;i<n;i++){
        if(a[i]>=b)
            count++;
    }
    if(count>=m){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut 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,
    b: i32
  }
  if a * b % 2 == 0 {
    println!("No");
  } else {
    println!("Yes");
  }
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b , x;

int main()
{
    _FastIO;

    cin >> a >> b;
    if(max(a , b) > 8){
        cout << ":(" << endl;
    }
    else
        cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 3636
//#include    <bits/stdc++.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define N  500005
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f
#define MOD 998244353
#define Mod 1e9 + 7
template<typename T> inline T max(T a,T b,T c){
    return max(a,max(b,c));
}
template<typename T> inline T min(T a,T b,T c){
    return min(a,min(b,c));
}
template<typename T> inline T max(T a,T b,T c,T d){
    return max(a,max(b,c,d));
}
template<typename T> inline T min(T a,T b,T c,T d){
    return min(a,min(b,c,d));
}
const int  dx[]={0,1,0,-1,0,1,-1,1,-1};
const int  dy[]={0,0,1,0,-1,1,-1,-1,1};
typedef long long ll;
using namespace std;
int main(){
    int a[5];
    int ans=0;
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    int t1,t2;
    t1=a[2]-a[0];
    t2=a[2]-a[1];
    if (t1%2&&t2%2) ans+=t1/2+t2/2+1;
    else if (t1%2&&!(t2%2)) ans+=(t1+1)/2+t2/2+1;
    else if (!(t1%2)&&(t2%2)) ans+=t1/2+(t2+1)/2+1;
    else ans+=t1/2+t2/2;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <functional>
const int INF =1e5;
const int MOD = 1e9 + 7;
using namespace std;
typedef pair<int,int> P;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define pb push_back

int main(){
    int n;
    cin>>n;
    cout<<n/3<<endl;
    return 0;

}


Measured memory_bytes: 256
while True:
    try:
        y, m, d = (int(x) for x in input().split())
        ymd = 10000 * y + 100 * m + d
        ans = "heisei" + " " + str(y - 1988) + " " + str(m) + " " + str(d)
        if ymd < 18680908:
            ans = "pre-meiji"
        elif ymd < 19120730:
            ans = "meiji" + " " + str(y - 1867) + " " + str(m) + " " + str(d)
        elif ymd < 19261225:
            ans = "taisho" + " " + str(y - 1911) + " " + str(m) + " " + str(d)
        elif ymd < 19890108:
            ans = "showa" + " " + str(y - 1925) + " " + str(m) + " " + str(d)
        print(ans)
    except:
        break


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

typedef long long LL;

int n;

void work(){
  scanf("%d",&n);
  LL ans=0;
  for (int i=1;i<=n;++i)
	for (int j=1;i*j<n;++j) ++ans;
  printf("%lld\n",ans);
}

int main(){
  int T=1;
  for (;T--;) work();
  return 0;
}

Measured memory_bytes: 3824
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//キーボード入力メソッド
		Scanner sc = new Scanner(System.in);

		//変数宣言
		int H = 1;
		int W = 1;

		while(true) {
			//HとWを手動入力
			H = sc.nextInt();
			W = sc.nextInt();

			//HとWがともに0のとき、処理を抜ける
			if(H == 0 && W == 0) {
				break;
			}

			//図形作成
			for(int i=1; i<H+1; i++) {
				if(i%2==0) {//偶数行目(2で割り切れる行数)の時
					for(int j=1; j<W+1; j++) {
						if(j%2==0) {//偶数列目(2で割り切れる列数)の時
							System.out.print("#");
						}else {//奇数列目(2で割り切れる列数)の時
							System.out.print(".");
						}
					}
					System.out.println();
				}else {//奇数行目(2で割り切れない行数)の時
					for(int j=1; j<W+1; j++) {
						if(j%2==0) {//偶数列目(2で割り切れる列数)の時
							System.out.print(".");
						}else {//奇数列目(2で割り切れる列数)の時
							System.out.print("#");
						}
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
}



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

int main() {
  int N,D;
  cin >> N >> D;
  int M=2*D+1;
  if(N%M==0){
    cout << N/M << endl;
  }
  else{
    cout << N/M + 1 << endl;
  }
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint i,j,n,x,s,ans=1;cin>>n>>s;
	vector<int>d(n);
	for(i=1;i<n;i++){
		cin>>x;
		d[x]++;
	}
	if(s!=0||d[0]>0){cout<<0<<endl;return 0;}
	d[0]=1;
	for(i=1;i<n;i++){
		for(j=0;j<d[i];j++){ans*=d[i-1];ans%=mod;}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double EPS=1e-9;
const long long INF = 100001000010000100ll;

template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

int N, L;

int d[100000+10];
int memo[100000+10];

vector<pii>order;

int rec(int n){
	if(memo[n]!=-1)
		return memo[n];

	if(d[n] > d[n-1] && d[n] > d[n+1]){
		return memo[n]=L-d[n];
	}else if(d[n] <= d[n-1] && d[n] > d[n+1] ){
		return memo[n]=L-d[n]+rec(n-1);
	}else if(d[n] > d[n-1] && d[n] <= d[n+1] ){
		return memo[n]=L-d[n]+rec(n+1);
	}else if(d[n] <= d[n-1] && d[n] <= d[n+1] ){
		return memo[n]=L-d[n]+max(rec(n-1), rec(n+1));
	}
	return inf;

}

int main(){
	cin >> N >> L;
	rep(i, N){
		cin >> d[i+1];
		order.pb(mp(d[i+1], i+1));
	}
	int ans=-1;
	sort(all(order), greater<pii>());
	memset(memo, -1,sizeof(memo));
	rp(i, order){
		ans = max(ans, rec(order[i].second));
	}
	cout << ans << endl;


}

Measured memory_bytes: 2832
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int sum = a + b;
	if (sum < 10) {
		cout << sum << endl;
	} else {
		cout << "error" << endl;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	char S[100];
	cin>>S;
	for(int i=0;i<strlen(S)-8;i++){
		cout<<S[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll ans = 1LL << 60, sum = a[0];
  ll tmp = 0;

  if(a[0] < 0){
    tmp = abs(a[0])+1;
    sum = 1;
  }

  if(sum == 0){
    tmp++;
    sum++;
  }
  
  srep(i, 1, n) {
    sum += a[i];
    if (sum == 0) {
      tmp++;
      if (sum - a[i] > 0)
        sum--;
      else
        sum++;
    }
    if (sum - a[i] >= 0 && sum >= 0) {
      tmp += sum + 1;
      sum = -1;
    } else if (sum - a[i] <= 0 && sum <= 0) {
      tmp += abs(sum) + 1;
      sum = 1;
    }
  }
  mins(ans, tmp);
  tmp = 0;
  sum = a[0];
  if(a[0] > 0){
    tmp = a[0]+1;
    sum = -1;
  }
  if(sum == 0){
    tmp++;
    sum--;
  }
  srep(i, 1, n) {
    sum += a[i];
    if (sum == 0) {
      tmp++;
      if (sum - a[i] > 0)
        sum--;
      else
        sum++;
    }
    if (sum - a[i] >= 0 && sum >= 0) {
      tmp += sum + 1;
      sum = -1;
    } else if (sum - a[i] <= 0 && sum <= 0) {
      tmp += abs(sum) + 1;
      sum = 1;
    }
  }
  mins(ans, tmp);
  print(ans);
  return 0;
}

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

int main() {
  int count=0;
  string S,T;
  cin >> S >> T;
  
  for (int i=0; i<S.size(); i++) {
    if (S.at(i)==T.at(i)) count++;
  }
  
  if (S.size()==count) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>
 
int main() {
	int n = 0, x = 0, y = 0;
	int fx = 0, fy = 0, ft = 0;
	int time = 0;
	bool yn = true;
	std::cin >> n;
	std::cin >> ft >> fx >> fy;
	if (n != 1) {
		for (int i = 0; i < n - 1; i++) {
			std::cin >> time >> x >> y;
			if (std::abs(x - fx) == std::abs(y - fy)) {
				if ((time - ft) % 2 == 0) {
					continue;
				}
				else {
					std::cout << "No" << std::endl;
					return 0;
				}
			}else if (std::abs(x - fx) + std::abs(y - fy) > time - ft) { yn = false; }
			ft = time;
			fx = x;
			fy = y;
		}
	}
	else {
		if (fx + fy > ft) { yn = false; }
		else { yn = true; }
	}
	if (yn == true) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

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

using namespace std;

void get_value(vector <int> &L, string &S, char given_ch)
{
    int current_segment = 0;
    for(int i = 0; i < S.size(); i++)
    {
        if(S[i] == given_ch)
        {
            current_segment++;
        }
        else if(current_segment != 0 && S[i] != given_ch)
        {
            L.push_back(current_segment);
            current_segment = 0;
        }

        if(S[i] == given_ch && i + 1 == S.size())
        {
            L.push_back(current_segment);
        }
    }
}

int main()
{
    int length, max_flips;
    string S;
    cin >> length >> max_flips >> S;

    vector <int> zero_segments;
    get_value(zero_segments, S, '0');

    vector <int> one_segments;
    get_value(one_segments, S, '1');

    int max_length = 0, current_0_length = 0, current_1_length = 0,left_segment = 0;

    for(int i = 0; i < zero_segments.size() || i < one_segments.size(); i++)
    {
        if(i < zero_segments.size())
        {
            current_0_length += zero_segments[i];
        }

        if(i < one_segments.size())
        {
            current_1_length += one_segments[i];
        }

        if(i >= max_flips)
        {
            current_0_length -= zero_segments[left_segment];
            current_1_length -= one_segments[left_segment];

            left_segment++;
        }

        int extra = 0;

        if(S[0] == '0' && left_segment != 0)
        {
            extra = one_segments[left_segment - 1];
        }

        if(S[0] == '1' && i + 1 < one_segments.size())
        {
            extra = one_segments[i + 1];
        }

        int current_length = current_0_length + current_1_length + extra;

        max_length = max(max_length, current_length);
    }

    cout << max_length;
    return 0;
}


Measured memory_bytes: 1020
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)

int main()
{
    int A, B;
    cin >> A >> B;
    if (A < 6)
    {
        cout << 0;
    }
    else if (A < 13)
    {
        cout << B / 2;
    }
    else
    {
        cout << B;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
#define N 1000006
#define mod 1000000007
using namespace std;
int n, k;
char s[N];
ll p25[N], p26[N];
int pw(int x, int y){
	int sum=1;
	while(y){
		if(y&1) sum=(ll)sum*x%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return sum;
}
int main(){
    scanf("%d", &k);
    p25[0]=p26[0]=1;
    for(int i=1; i<=k; ++i) p25[i]=p25[i-1]*25%mod, p26[i]=p26[i-1]*26%mod;
    scanf("%s", s);
    n=strlen(s);
    ll ans=0, c=1;
    for(int i=0; i<=k; ++i){
    	if(i) c=c*(n-1+i)%mod*pw(i,mod-2)%mod;
    	ans=(ans+p26[k-i]*p25[i]%mod*c)%mod;
	} 
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 18304
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M, *A = map(int, read().split())
 
MOD = 10**9 + 7
 
dp = [0] * (N + 10)
dp[0] = 1
is_broken = [False] * (N + 1)
 
for x in A:
    is_broken[x] = True
 
for n in range(1, N + 1):
    if is_broken[n]:
        continue
    x = dp[n - 1] + dp[n - 2]
    if x >= MOD:
        x -= MOD
    dp[n] = x
 
answer = dp[N]
print(answer)


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


int dp[200010];
int preid[200010];
char prec[200010];
bool can[200010];
int nxtid[200010];
char nxtc[200010];

vector<int> idx[26];

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

	string A;
	cin >> A;
	int N = A.size();
	for(int i = 0; i < N; i++) {
		idx[A[i] - 'a'].push_back(i + 1);
	}
	for(int i = 0; i < 26; i++) {
		idx[i].push_back(N + 1);
	}

	const int INF = 1 << 28;
	fill((int*)begin(dp), (int*)end(dp), INF);
	dp[0] = 0;
	for(int i = 0; i < N + 1; i++) {
		if(dp[i] == INF) continue;
		for(int j = 0; j < 26; j++) {
			int nxt = *lower_bound(idx[j].begin(), idx[j].end(), i + 1);
			if(dp[nxt] > dp[i] + 1) {
				dp[nxt] = dp[i] + 1;
				preid[nxt] = i;
				prec[nxt] = 'a' + j;
			}
			else if(dp[nxt] == dp[i] + 1 && prec[nxt] > 'a' + j) {
				preid[nxt] = i;
				prec[nxt] = 'a' + j;
			}
		}
	}

	can[N + 1] = true;
	for(int i = N - 1; i >= 0; i--) {
		if(dp[i] == INF) continue;
		for(int j = 0; j < 26; j++) {
			int nxt = *lower_bound(idx[j].begin(), idx[j].end(), i + 1);
			if(can[nxt] && dp[i] + 1 == dp[nxt]) {
				can[i] = true;
				nxtc[i] = 'a' + j;
				nxtid[i] = nxt;
				break;
			}
		}
	}

	string ans;
	for(int i = 0; i < N + 1;) {
		ans += nxtc[i];
		i = nxtid[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4372
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef map<string,int> msi;
const int INF=2<<25;
msi p;
int n,m,price[100];
vector<vector<int> > recipe[100];
int search(int x,bool used[100]){
	int minim=price[x];
	if(used[x])
	return INF;
	else
	used[x]=true;
	for(int i=0;i<recipe[x].size();i++){
		int sum=0;
		for(int j=0;j<recipe[x][i].size();j++)
			sum+=search(recipe[x][i][j],used);
		minim=min(minim,sum);
	}
	used[x]=false;
	return minim;
		
}
int main() {
	string s,sb;
	while(cin >> n && n!=0){
		for(int i=0;i<n;i++){
			cin >> s >> price[i];
			p.insert(msi::value_type(s,i));
		}
		cin >> m;
		int num;
		for(int i=0;i<m;i++){
			vector<int> material;
			cin >> s >> num;
			for(int j=0;j<num;j++){
			cin >> sb; 
			material.push_back(p[sb]);
			}
			recipe[p[s]].push_back(material);
		}
		cin >> s;
		bool used[100]={};
		cout << search(p[s],used) << endl;
		for(int i=0;i<100;i++){
			recipe[i].clear();
			price[i]=0;
		}
		p.clear();
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main(){
	fast;
	ll a,b;
	cin>>a>>b;
	cout<<a*a-b;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int main(){
  int n;cin>>n;
  vector<int> v(n);
  rep(i,n)cin>>v[i];
  vector<int> dp(n+10);
  dp[0]=0;
  dp[1]=abs(v[1]-v[0]);
  FOR(i,0,n-2){
    dp[i+2]=min(dp[i]+abs(v[i+2]-v[i]),dp[i+1]+abs(v[i+2]-v[i+1]));
  }
  //rep(i,n)cout<<dp[i]<<endl;
  cout<<dp[n-1];
}

Measured memory_bytes: 3980
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        long[] a = new long[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i] = scanner.nextInt();
        }
        Set<Long> divisors = divisors(sum);
        for (long d : divisors) {
            long[] b = new long[n];
            long m = 0;
            for (int i = 0; i < n; i++) {
                m += b[i] = a[i] % d == 0 ? 0 : a[i] / d * d + d - a[i];
            }
            Arrays.sort(b);
            long cost = 0;
            m /= d;
            for (int i = n - 1; i >= 0; i--) {
                if (--m < 0) {
                    break;
                }
                cost += d - b[i];
            }
            if (cost <= k) {
                System.out.println(d);
                return;
            }
        }
    }

    static Set<Long> divisors(long n) {
        Set<Long> divisors = new TreeSet<>(Comparator.reverseOrder());
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                divisors.add(i);
                divisors.add(n / i);
            }
        }
        return divisors;
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 28188
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll n,a[200005],ma1=0,ma2=0;
bool l=false;
int main() {
	cin>>n;
	rep(i,0,n){
		cin>>a[i];
		if(a[i]%2==1)l=true;
	}
	if(l)cout<<"first"<<endl;
	else cout<<"second"<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int a,b,h,w;
char g[110][110];

int main(){
    cin>>a>>b;

    int c=0;
    for(int i=0;i<100;++i){
        for(int j=0;j<50;++j){
            if(i%2==0&&j%2==0&&c<a-1){
                g[i][j]='.';
                c++;
            }
            else g[i][j]='#';
        }
    }
    c=0;
    for(int i=0;i<100;++i){
        for(int j=0;j<50;++j){
            if(i%2==1&&j%2==1&&c<b-1){
                g[i][j+50]='#';
                c++;
            }
            else g[i][j+50]='.';
        }
    }
    cout<<100<<" "<<100<<endl;
    for(int i=0;i<100;++i){
        for(int j=0;j<100;++j){
            cout<<g[i][j];
        }
        cout<<'\n';
    }

    return 0;
}

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

using namespace std;
int N;
int sum;
int s[101];
int main() {
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> s[i];
    sum += s[i];
  }

  sort(s,s+N);

  if(sum % 10 != 0) {
    cout << sum <<endl;
    return 0;
  }
  else {
    int i = 0;
    while(i < N) {
      if(s[i] % 10 != 0) {
	sum -= s[i];
	cout << sum <<endl; return 0;
      }
      i++;
     
    }
  }
  cout <<"0"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <array>
#include <set>
#include <map>
#include <queue>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
 
struct Timer {

    double CYCLE_PER_SEC = 2400000000.0;
    unsigned long long BEGIN_CYCLE = 0;

    Timer() {}
    Timer(double cycle) : CYCLE_PER_SEC(cycle) {}

    unsigned long long int getCycle() {
        unsigned int low, high;
        __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
        return ((unsigned long long int)low) | ((unsigned long long int)high << 32);
    }

    void start(void) {
        BEGIN_CYCLE = getCycle();
    }

    double get_time(void) {
        return (double)(getCycle() - BEGIN_CYCLE) / CYCLE_PER_SEC;
    }

};

struct XorShift {
    unsigned int x;
    XorShift () : x(2463534242U) {}
    unsigned int rand() {
        x ^= (x << 13);
        x ^= (x >> 17);
        x ^= (x << 5);
        return x;
    }
};

XorShift Random;

constexpr double TIME_LIMIT = 1.00;
constexpr double TEMP_START = 2.00;
constexpr double TEMP_END   = 0.30;
constexpr double TEMP_DIFF  = (TEMP_START - TEMP_END) / TIME_LIMIT;

bool prob(int diff, double cur_time) {
    if (diff >= 0) return true;
    double temp = TEMP_START - TEMP_DIFF * cur_time;
    double P = exp((double) diff / temp) * 4294967295.0;
    return Random.rand() < P;
}

int main() {
 
    int N; cin >> N;
    vector < int > D(N);
    REP(i,N) cin >> D[i];

    if (N == 1) {
        cout << D[0] << endl;
        return 0;
    }

    int atmost = 1e9;
    REP(i,D.size()) atmost = min(atmost, D[i]);

    Timer timer;
    timer.start();

    int BestScore = 0;
    int preScore = 0;
    while (true) {
        double cur_time = timer.get_time();
        int idx1 = Random.rand() % N;
        D[idx1] = 24 - D[idx1];
        int diff = 1e9;
        REP(i,D.size()) REP(j,D.size()) {
            if (i != j) {
                diff = min(diff, abs(D[i] - D[j]));
            }
        }
        diff = min(diff, atmost);
        int d = diff - preScore;
        if (prob(d, cur_time)) {
            preScore += d;
            if (preScore > BestScore) {
                BestScore = preScore;
            }
        } else {
            D[idx1] = 24 - D[idx1];
        }
        if (cur_time > TIME_LIMIT) break;
    }
 
    cout << BestScore << endl;

    return 0;
}


Measured memory_bytes: 768
N = int(input())
X = list(map(int,input().split()))

mod = 10**9 + 7

n_pow = 1
for i in range(2,N):
    n_pow*=i
    n_pow%=mod

n_s1 = [(n_pow*pow(i,mod-2,mod))%mod for i in range(1,N)]

n_s2 = [n_s1[0]]

s = n_s1[0]

for i in range(1,N-1):
    s+=n_s1[i]
    s%=mod
    n_s2.append(s)

ans = 0

for i in range(N-1):
    ans += (X[i+1]-X[i])*n_s2[i]
    ans %= mod

print(ans)



Measured memory_bytes: 66456
#include<stdio.h>

int main(void){
  int n,cm;
  int count = 0;
  scanf("%d %d",&n,&cm);
  int a[n];
  for(int i = 0;i < n;i++)
    scanf("%d",&a[i]);
  for(int i = 0;i < n;i++){
    if(a[i] >= cm)
      count++;
  }
  printf("%d",count);
  return 0;
}
  
  


Measured memory_bytes: 512
#include <iostream>
#include<string>
#include<list>
#include<algorithm>
#include<cstdio>
using namespace std;


int main(){
    
    int n,t;
    scanf("%d",&n);
    list<int> V;
    string com;
    for(int i=0;i<n;i++){
        
        cin>>com;
        
        if(com[0]=='i'){
            scanf("%d",&t);
            V.push_front(t);
            
        }else if(com[6]=='F'){
                V.pop_front();
                //deleteLast
        }else if(com[6]=='L'){
                V.pop_back();
        }else if(com[0]=='d'){
                scanf("%d",&t);
                for(list<int>::iterator it = V.begin();it!=V.end();it++){
                    if(*it==t){
                        V.erase(it);
                        break;
                    }
                }
            }
    }
    int i=0;

    for(list<int>::iterator it = V.begin();it != V.end();it++){
       if(i++) printf(" ");
        printf("%d",*it);
        }
        
    
    printf("\n");




return 0;
}


Measured memory_bytes: 34404
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

n,x=map(int,input().split())
A=list(map(int,input().split()))
if A[0]>x:
    count+=A[0]-x
    A[0]=x
for i in range(n-1):
    if A[i]+A[i+1]>x:
        count+=A[i+1]-(x-A[i])
        A[i+1]=x-A[i]
        # print(x-A[i],i)
print(count)


Measured memory_bytes: 14660
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    H = I()
    W = I()
    N = I()

    if H > W:
        print(int(math.ceil(N / H)))
    else:
        print(int(math.ceil(N / W)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4020
N,M = map(int,input().split())
Ls = []
Rs = []
for _ in range(M):
	L,R = map(int,input().split())
	Ls.append(L)
	Rs.append(R)	

num = min(Rs) - max(Ls) + 1

if num < 0:
	num = 0

print(num)

Measured memory_bytes: 55896
num = gets.to_i
arr = gets.split.map(&:to_i)
endi = num - 1
count = 0

loop do
  while endi >= 1 do
    break if arr[endi] < arr[endi - 1]
    endi -= 1
  end

  break if endi == 0

  while endi >= 1 do
    if arr[endi] < arr[endi - 1]
      arr[endi], arr[endi - 1] = arr[endi-1], arr[endi]
      count += 1
      endi -= 1
    else
      break
    end
  end
  endi = num - 1
end

puts arr.join(" ")
puts count



Measured memory_bytes: 6872
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N;
  cin >> N;
  int ans = (N + 999) / 1000 * 1000 - N;
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

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


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

    vector<char> result(26,0);

    rep(i,w.size()){
        result[w[i]-'a']++;
    }

    rep(i,result.size()){
        if(result[i] % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;

}


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

#define F first
#define S second
#define x1 privet1
#define x2 privet2
#define y1 privet3
#define y2 privet4
#define left privet6

using namespace std;
typedef long long ll;

const int max_n = 200011, log_n = 32, max_m = 111, mod = 1000000007, inf = 1000111222;

ll n, a[55];

ll check(int k) {
    /*for (int i = 0; i < n; ++i) {
        cout << a[i] << " ";
    }
    cout << endl;*/
    if (k == n - 1) {
        ll b = (a[0] - (n - 1));
        b = max(b, 0LL);
        for (int i =0 ; i < n; ++i) {
            a[i] -= b;
        }
        b *= n;
        /*for (int i = 0; i < n; ++i) {
            cout << a[i] << " ";
        }
        cout << endl;*/
        while (true) {
            if (a[n - 1] < n) {
                return b;
            }
            ++b;
            a[n - 1] -= n;
            for (int i = 0; i < n - 1; ++i) {
                ++a[i];
            }
            sort(a, a + n);
        }
    }
    ll b = min((a[k] - a[k + 1]) / (n + 1), a[0] / (n - k));
    for (int i = 0; i < n; ++i) {
        if (i <= k) {
            a[i] -= b * (n - k);
        } else {
            a[i] += b * (k + 1);
        }
    }
    sort(a, a + k + 2);
    return b * (k + 1) + check(k + 1);
}

int main() {
    // freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    cout << check(0) << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ans=100000
for i in range(n):
  if abs(a-(t-h[i]*0.006)) < ans:
    ans=abs(a-(t-h[i]*0.006))
    k=i
print(k+1)

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

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

  string ans = "yes";
  for(int i=0; i<s.size(); i++) {
    char c = s[i];
    for(int j=i+1; j<s.size(); j++) {
      char c2 = s[j];
      if(c == c2) {
        ans = "no";
        break;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int m=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    m=max(m,a[i]);
  }
  int g=a[0];
  for(int i=0;i<n;i++){
    g=gcd(g,a[i]);
  }
  if(k<=m&&k%g==0){
    cout << "POSSIBLE" << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 640
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	vector<vector<int>> edges(N);
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		edges[u].emplace_back(v);
		edges[v].emplace_back(u);
	}

	vector<int> ans(N), lis(N, INF);
	auto dfs = [&](auto &&f, int now) -> void {
	
		auto idx = lower_bound(lis.begin(), lis.end(), a[now]) - lis.begin();
		auto val = lis[idx];
		lis[idx] = a[now];

		ans[now] = lower_bound(lis.begin(), lis.end(), INF) - lis.begin();

		for (const auto &e : edges[now]) if(!ans[e]) f(f, e);

		lis[idx] = val;

	};

	dfs(dfs, 0);

	for (const auto &e : ans) cout << e << "\n";

	return 0;
}

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

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

    int N, K;
    int counter = 0;

    cin >> N >> K;

    while(N>0)
    {
        N /= K;
        ++counter;
    }

    cout << counter;

    return 0;
}


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

public class Main {

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

		    int n = sc.nextInt();
		    double[] v = new double[n];
		    for(int i=0;i<n;i++) {
		    	v[i] = sc.nextDouble();
		    }
		    Arrays.sort(v);
		    double ans = v[0];
		    for(int i=1;i<n;i++) {
		    	ans = (v[i]+ans)/2;
		    }
		    System.out.println(ans);


		    sc.close();
	}
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	auto S=vecin(N);
	S.erase(unique(ALL(S)),S.end());

	N=S.size();
	REP(i,N-1){
		cout << S[i] << ' ';
	}
	out(S[N-1]);
	return 0;
}


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

int main() {
    long int N,K;
    scanf("%d%d",&N,&K);
    long int h[N];
    long int dp[N];
    for (int i = 0; i <= N; i++) {
        scanf("%d",&h[i]);
    }
    for (int i = 0; i <= N; i++) {
        dp[i] = INFINITY;
    }
        dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int t = 1; (t <= K)&&(i + t <= N); t++) {
          if(dp[i + t] > dp[i] + abs(h[i] - h[i + t])){
                dp[i + t] = dp[i] + abs(h[i] - h[i + t]);
          }
        }
    }
    
    printf("%d",dp[N-1]);
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

struct UnionFind {
    vector<int> d;

    UnionFind(int N=0) : d(N, -1){} 

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x); 
        y = find(y); 
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x; 
        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x){
        return -d[find(x)];
    }
};

int main(){

    int N,M; cin >> N >> M;
    UnionFind uf(N);
    rep(i,M){
        int A, B; cin >> A >> B;
        A--;
        B--;
        uf.unite(A,B);
    }

    int ans = 0;
    rep(i,N){
        ans = max(ans,uf.size(i));
    }
    cout << ans << endl;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int ans=0;

  int n; cin >> n;
  vector<int> c(100010, 0);
  for (int i=0; i<n; i++) {
    int a; cin >> a;
    c[a]++;
  }
  for (int i=1; i<100010-1; i++) {
    ans = max(ans, c[i-1]+c[i]+c[i+1]);
  }

  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 640
# C - Sum of gcd of Tuples (Easy)

import math

K = int(input())
ans = 0

for a in range(1, K + 1):
	for b in range(1, K + 1):
		ab = math.gcd(a, b)
		
		for c in range(1, K + 1):
			ans += math.gcd(ab, c)

print(ans)

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

#define MAX 10000007

int n;
vector<pii> v;

ll dp[2007][2007];

ll solve(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];


    ll atual = v[l+n-r-1].F;
    int idx = v[l+n-r-1].S;

    if(l==r){
        return atual*abs(idx-l);
    }

    ll a1 = solve(l+1, r) + atual*abs(idx-l);
    ll a2 = solve(l, r-1) + atual*abs(idx-r);

    return dp[l][r] = max(a1, a2);

}

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

    memset(dp, -1, sizeof(dp));

	cin >> n;
    v.resize(n);
    FOR(i, n) cin >> v[i].F, v[i].S = i;

    sort(rall(v));


    cout << solve(0, n-1) << '\n';

	return 0;
}


Measured memory_bytes: 35164
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()

    ans = N-1

    for i in range(2, N):
        for j in range(1, N):
            if i*j > N-1:
                break
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10012
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int W = in.nextInt();
		int H = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		int r = in.nextInt();
		if((x-r >= 0 && x+r <= W) && (y-r >= 0 && y+r <=H)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26156