akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/abc042/tasks/arc058_a
# C - こだわり者いろはちゃん / Iroha's Obsession
import copy

N, K = list(map(int, input().split()))
d_list = list(map(int, input().split()))

# 一番上の桁から見ていく
use_list = list(set(range(10)) - set(d_list))
n_list = [int(x) for x in list(str(N))]

# 各桁ごとに、使える数字を使っているかどうか洗い出す
keta_list = [x in use_list for x in n_list]

def can_update(old_n):
    kouho_n_list = [x for x in use_list if x > old_n]
    if kouho_n_list:
        return True
    else:
        return False

# 一番左に出てくるFalseの桁
k_index = keta_list.index(False) if False in keta_list else -1

if k_index != -1:
    is_ok = False

    for index in range(k_index, -1, -1):
        # 途中桁の場合
        old_n = n_list[index]
        # その桁で使用可能な数字があるか
        if can_update(old_n):
            # その桁で使用可能な数字がある
            kouho_n_list = [x for x in use_list if x > old_n]
            new_n = min(kouho_n_list)
            new_n_list = n_list[:index] + [new_n]
            # 当該桁以降は、使用可能な最小値で構成する
            if index < len(keta_list):
                new_n_list += [min(use_list)] * (len(keta_list) - (index+1))
            ans = int(''.join([str(x) for x in new_n_list]))
            is_ok = True
            break

        if not is_ok:
            # 最大桁を更新する
            new_n = sorted(use_list)[1] if min(use_list) == 0 else min(use_list)
            # 残りの桁を全て、使用可能な最小値で置き換える
            new_n = str(new_n) + str(min(use_list)) * len(keta_list)
            ans = int(new_n)

else:
    # 使える数字だけで構成されているので、そのままでOK
    ans = N

print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int ans = INF;
    for (int i = 0; i + m <= n; i++){
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            if (s[i + j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,m,x,t,s=0,i,res;
  cin >> n >> m >> x;
  for(i=0;i<m;i++){
    cin >> t;
    if(t<x) s++;
  }
  res=min(s,m-s);
  cout << res << endl;
  return 0;
}

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

arr=[]

for i in range(n):
    x,l = map(int,input().split())
    arr.append([x,l,x-l,x+l])
arr.sort(key=lambda x: x[3])

#print(arr)

ans = 0
start=-100000
fin=-1000

start = arr[0][2]
fin=arr[0][3]

for a,b,c,d in arr[1:]:
    if c < fin:
        ans+=1
        pass
    elif c >= fin:
        start=c
        fin = d

print(n-ans)


Measured memory_bytes: 65368
#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
#include <chrono>
#include <iomanip>
#include <vector>
#include <utility>
#include <time.h>
#include <set>
#include <unordered_set>
#include <list>
#include <iterator>
#include <time.h>
#include <chrono>
#include <deque>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <climits>
#include <tuple>
#include <map>
using namespace std;

#define ll long long
#define ldb long double

ll mod(ll a, ll b)
{
	return (b + (a % b)) % b;
}

ll subMod(ll a, ll b, ll M)
{
	return mod((mod(a, M) - mod(b, M)), M);
}

ll dayofweek(ll d, ll m, ll y)
{
	static ll t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
	y -= m < 3;
	return (y + y / 4 - y / 100 +
		y / 400 + t[m - 1] + d) % 7;
}

void test()
{

}


void solve()
{
	ll n;
	cin >> n;
	vector<ll> x(n);

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

	int left = -100, right = 100;
	int mid = (left + right) / 2;

	while (left <= right)
	{
		mid = (left + right) / 2;
		
		int sum = 0;
		int sum2 = 0;
		int sum3 = 0;

		for (int i = 0; i < n; i++)
		{
			sum += (x[i] - mid) * (x[i] - mid);
			sum2 += (x[i] - mid - 1) * (x[i] - mid - 1);
			sum3 += (x[i] - mid + 1) * (x[i] - mid + 1);
		}

		if (sum2 < sum)
		{
			left = mid + 1;
		}
		else if(sum3 < sum)
		{
			right = mid - 1;
		}
		else
		{
			break;
		}
	}

	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		ans += (x[i] - mid) * (x[i] - mid);
	}

	cout << ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//test();

	solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//#define kk
#define int long long
#define FOR(i, n) for(int i=1; i<=n; i++)
#define ff first
#define ss second
#define ll int
#define inf 1000000000
#define pb push_back
#define mod 1000000007
 
const long long INF=1e18+5;
typedef pair<int, int> pi;

int arr[3001];
int dp[3001][3001];

int get(int i, int j){
	if(i>j) return 0;
	if(i==j) return arr[i];
	if(dp[i][j]!=-1) return dp[i][j];
	
	return dp[i][j]=max(arr[i]-get(i+1, j), arr[j]-get(i, j-1));
}

void solve(){
	int n;
	cin>>n;
	
	for(int i=1; i<=n; i++){
		cin>>arr[i];
	}
	memset(dp, -1, sizeof dp);
	cout<<get(1, n)<<endl;
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cout<<fixed<<setprecision(10);
	
	#ifdef kk
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	int T=1;
	//cin>>T;
	
	while(T--){
		solve();
	}
}


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

int main(){
    int A, B;
    cin >> A >> B;
    int count = 0;
    for (int i = A; i <= B; i++){
        vector<int> I;
        int use_i;
        use_i = i;
        while(use_i != 0){
            I.push_back(use_i % 10);
            use_i /= 10;
        }
        if (I.at(0) == I.at(4) && I.at(1) == I.at(3)){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
n = input()
a = list(map(int, input().split()))
#b = list(map(int, input().split()))
#c = list(map(int, input().split()))
m = 0
c = 0
for i in range(1, len(a)):
    if a[i] <= a[i-1]:
        c += 1
        m = max(m, c)
    else:
        c = 0
print(m)

Measured memory_bytes: 14224
import math

s=input()
l=len(s)
ans1=0
r="10"*(l//2)+"1" 
if l%2==1:
  r+="1"
  
for i in range(l):
    if s[i]!=r[i]:
	    ans1+=1
		
r="01"*(l//2)+"0" 
if l%2==1:
  r+="1"
ans2=0
for i in range(l):
    if s[i]!=r[i]:
	    ans2+=1
		
print(min(ans1,ans2))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ROOT 0
#define INTERNAL 1
#define LEAF 2
#define REP(asd, fgh) for(int asd = 0; asd < fgh; asd++)

int n;

class Node{
  public:
  int p;
  int depth;
  string type;
};

vector<Node> ans;
vector< vector<int> > t;

void dfs(int ind, int prev, int depth){
  ans[ind].p = prev;
  ans[ind].depth = depth;
  if(t[ind].size() == 0 && ans[ind].type != "root"){
    ans[ind].type = "leaf";
    return;
  }
  for(int i = 0; i < t[ind].size(); i++){
    dfs(t[ind][i], ind, depth+1);
  }
}

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

  cin >> n;
  ans = vector<Node>(n);
  t = vector< vector<int> >(n, vector<int>(0));
  int root;
  REP(i, n){
    int id; cin >> id;
    ans[id].type = "internal node";
    int k;
    cin >> k;
    REP(j, k){
      int c; cin >> c;
      t[id].push_back(c);
    }
  }
  //ans[0].p = -1;
  //ans[0].depth = 0;
  vector<bool> used(n, false);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < t[i].size(); j++){
      used[ t[i][j] ] = true;
    }
  }
  for(int i = 0; i < n; i++){
    if(used[i] == false){
      root = i;
      break;
    }
  }
  ans[root].type = "root";
  dfs(root, -1, 0);

  for(int i = 0; i < n; i++){
    cout << "node " << i << ": parent = " << ans[i].p << ", depth = " << ans[i].depth << ", " << ans[i].type;
    cout << ", [";
    for(int j = 0; j < t[i].size(); j++){
      if(j != 0)
        cout << ", ";
      cout << t[i][j];
    }
    cout << "]" << endl;
  }

  return 0;
}

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

using namespace std;

int main()
{
    int i;
    string a;
    long long sum=0;
    cin>>a;
    int len = a.length();
    for(i=0;i<len;i++)
    {
       int l= (int)a[i]-48;
       sum = sum+l;
    }
    if(sum%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3764
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
s = [a for a in "1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51".split(",") if a != ""]
print(s[int(input())-1])

Measured memory_bytes: 4464
from scipy.ndimage import distance_transform_cdt
h,w = map(int, input().split())
grid = [[i=="." for i in input()] for _ in range(h)]
print(distance_transform_cdt(grid, metric='taxicab').max())

# reference : https://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.ndimage.morphology.distance_transform_bf.html

Measured memory_bytes: 40000
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

long long gcd(long long N, long long M){
    while (true){
        if (min(N,M)==0){
            return max(N,M);
        }else if (N>M){
            N%=M;
        }else{
            M%=N;
        }
    }
}

vector<long long> primes(0);
void prime_number(int N){
    vector<int> tmp(N+1,1);
    tmp[0]=tmp[1]=0;
    for(int i=2; i<=N; i++){
        if(tmp[i]==1){
            primes.push_back(i);
            for(long long j= (long long) i*i; j<=N; j+=i){
                tmp[j]=0;
            }
        }
    }
}

vector<int> factorize(long long x){
    vector<int> ret(primes.size(),0);
    for(int i=0; i<primes.size(); i++){
        long long p=primes[i];
        while(x%p==0){
            x/=p;
            ret[i]++;
        }
    }
    if (x!=1){
        primes.push_back(x);
        ret.push_back(1);
    }
    return ret;
}

int main(){
    long long A, B;
    cin >> A >> B;

    long long N=gcd(A,B);

    prime_number(1000000);

    vector<int> vec=factorize(N);

    int cnt=1;
    for(int i=0; i<(int) vec.size(); i++){
        if(vec[i]>0){
            cnt++;
        }
    }
    cout << cnt << endl;

}

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

const long long INF = 1LL << 60;

int main() {
  int N;
  cin >> N;
  
  vector<int> h(N);
  for(int n=0; n<N; n++) cin >> h[n];
  
  vector<int> dp(N, INF);
  dp[0] = 0;
  dp[1] = dp[0] + abs(h[1]-h[0]);

  for(int n=2; n<N; n++) dp[n]=min(
    dp[n-2] + abs(h[n] - h[n-2]),
    dp[n-1] + abs(h[n] - h[n-1])
  );
  
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	ll x, y;
	cin >> x >> y;
	ll dc = c*2;
	ll ans = 0;
	if(dc <= a + b){
		if(x < y){
			ans += dc * x;
			if(dc <= b) ans += dc * (y-x);
			else ans += b * (y-x);
		}else{
			ans += dc * y;
			if(dc <= a) ans += dc * (x-y);
			else ans += a * (x-y);
		}
	}else{//dc > a+b
		ans += a * x;
		ans += b * y;
	}
	cout << ans << endl;
	return 0;
}

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

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

void solve(void) {
  ll N; cin >> N;
  vector<ll> vec(N);
  rep(N, i) cin >> vec[i];

  ll res = 0;
  ll tmp_min = vec[0];
  rep(N, i) {
    if (tmp_min >= vec[i]) res++;

    tmp_min = min(tmp_min, vec[i]);
  }
  cout << res << endl;
}

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

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 0 , 1 } ;
const int dy[] = { 0 , -1 , 1 , 0 } ;

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n , q ;
    cin >> n >> q ;

    string s ; cin >> s ;
    s = 'B' + s ; n ++ ;

    vi pref ( n + 1 ) ;
    for ( int i=2 ; i < n ; i++ )
    {
        if ( s[i-1] == 'A' && s[i] == 'C' )
            pref[i] ++ ;

        pref[i] += pref[i-1] ;
    }

    while ( q-- )
    {
        int l , r ;
        cin >> l >> r ;

        int ans = pref[r] - pref[l-1] ;

        if ( s[l-1] == 'A' && s[l] == 'C' ) ans -- ;
        cout << ans ; line
    }

}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 1388
N, K = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
ans = N
psum = 0
for i in range(N-1, -1, -1) :
    if psum+a[i] < K :
        psum += a[i]
    else :
        ans = min(ans, i)

print(ans)

Measured memory_bytes: 3572
/*
 * 17-06-21_ARC076_C.cpp
 *
 *  Created on: 2017/06/24
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;

const int MOD = 1e9+7;

ll solve(int x,int y){
	if(x<y)
		swap(x,y);
	if(x-y>=2)
		return 0;
	ll res=1;
	for(int i=1;i<=y;i++){
		res = (res*i)%MOD;
	}
	res = res*res%MOD;
	if(x-y==1){
		res = (res*x)%MOD;
	}else{
		res = res*2%MOD;
	}
	return res;
}

int N,M;
int main(){
	cin >> N >> M;
	cout << solve(N,M)<<endl;
	return 0;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solvePriorityQueue(N, M, A));
    }


    private static long solvePriorityQueue(int N, int M, int[] A) {
        PriorityQueue<Integer> que = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer integer, Integer t1) {
                return t1 - integer ;
            }
        });

        for (int i=0; i<N; i++) {
            que.add(A[i]);
        }

        for (int i=0; i<M; i++) {
            int top = (int)que.poll();
            que.add(top/2);
        }

        long sum = 0;
        while(!que.isEmpty()) {
            sum += que.poll();
        }

        return sum;
    }
}

Measured memory_bytes: 52240
#include <bits/stdc++.h>
#define MAX 10000007
#define PI acos(-1)
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cout<<x<<endl;
#define endl "\n"
#define MEM(a,x) memset(a,x,sizeof(a))

using namespace std;
typedef long long ll ;
const int INF= 1e9+7;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<long long,null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
*/
/*
bool sortbysec(const pair<int,int>&a, const pair<int,int>&b)
{
    return (a.second<b.second);
}
*/
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.tie(NULL);
    string s;
    cin>>s;

    int n=s.length();
    int num=0;

    int ans=MAX;

    for(int i=0;i<n-2;i++)
    {
        int temp=100;
        for(int j=i;j<i+3;j++)
        {
            num=num + (s[j]-'0')*temp;
            temp/=10;
        }

        ans=min(ans,abs(num-753));
        num=0;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // get value from StandardIn
    int n = Integer.parseInt(sc.next());
    if(n%2==0){
      System.out.println(n/2);
    }else{
      System.out.println(n/2+1);
    }
    // System.out.println(n);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
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 namespace std;

int N;
double dp[3010][3010];
double p[3010],q[3010];
signed main(){
    cin>>N;
    rep(i,N){
        cin>>p[i];
        q[i]=1-p[i];
    }
    dp[0][0]=1;
    rep(i,N){
        rep(j,N+1){
            if(j==0) dp[i+1][j]=dp[i][j]*q[i];
            else dp[i+1][j]=dp[i][j]*q[i]+dp[i][j-1]*p[i];
        }
    }
    double ans=0.00;
    for(int i=(N+1)/2; i<=N; i++){
        ans+=dp[N][i];
    }
    cout<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 141696
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
tf = True
for i,j in zip(s[:-1], s[1:]):
    if i == j:
        tf = False

print("Good" if tf else "Bad")

Measured memory_bytes: 3064
/**
*    author:  yuya1234
*    created: 02.08.2020 21:00:20
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int x;
  cin>>x;

  if(x>=30)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	string S;
	cin >> S;
	
	if (S[0] == S[S.size() - 1]) {
		if (S.size() % 2) co("Second");
		else co("First");
	}
	else {
		if (S.size() % 2) co("First");
		else co("Second");
	}

	Would you please return 0;
}

Measured memory_bytes: 512
//Colorful Leaderboard

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    nvarep(n,a);
    int red = 0;
    set<int>s;
    rep(i,0,n){
        if(a[i]>=3200)red++;
        else s.insert(a[i]/400);
    }
    if(s.size()==0){
        cout<<1;
    }else{
        cout<<s.size();
    }
    cout<<" ";
    cout<<s.size()+red<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define sd second
#define ll long long
#define pli pair<ll,int>

using namespace std;

const int maxn = 500010;
const int maxk = 5010;
const ll oo = 1e9+7;

int m,n,a[maxn],s[maxn],num[maxn],id[maxn];

int cmp (int x,int y) {
    return a[x] < a[y];
}

int main() {
   // freopen("in.txt","r",stdin);
    cin>>n;
    int mx = 0;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        mx = max(mx,a[i]);
    }
    cout<<mx<<" ";
    int pv = mx;
    mx =0;
    for (int i=1;i<=n;i++)
        if (a[i] <= pv/2 ) mx = max(mx,a[i]);
    mx = pv - mx;
    bool use = false;
    for (int i=1;i<=n;i++)
        if (a[i] >= pv/2 && a[i] < mx) {
            mx = min(mx,a[i]);
            use = true;
        }
    if (use) cout<<mx;
    else cout<<pv-mx;

}


Measured memory_bytes: 2432
#include<stdio.h>

const int nMax = 367;

int main() {
  int n, x[nMax], y[nMax], b[nMax], p[nMax];
  int i, ans, normalTicket, setTicket;

  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
    scanf("%d", &b[i]);
    scanf("%d", &p[i]);
  }

  for(i=0; i<n; i++) {
    if(b[i]>=5 && p[i]>=2) { // 割引条件に適合したものを買うならば一発で計算できる
      ans = (x[i]*b[i]+y[i]*p[i])*0.8;
    }
    else {
      normalTicket = x[i]*b[i]+y[i]*p[i]; // 単純に毎数分だけ買った値
 
     if(b[i]<5) {
	b[i] = 5;
      }
      if(p[i]<2) {
	p[i] = 2;
      }
      setTicket = (x[i]*b[i]+y[i]*p[i])*0.8;

      if(normalTicket < setTicket) {
	ans = normalTicket;
      }
      else {
	ans = setTicket;
      }
    }
    printf("%d\n", ans);
  }
return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#include<stdlib.h>

int main(void){
	int n;
	scanf("%d",&n);
	int *a;
	a=malloc(n*sizeof(int));
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	long long int max=a[0];
	long long int sum=0;
	
	for(int i=1;i<n;i++){
		if(max>a[i]){
			sum+=(max-a[i]);
		}else{
			max=a[i];
		}
	}
	printf("%lld",sum);
	free(a);
}

Measured memory_bytes: 2244
n = int(input().strip())
st = []
for i in range(n):
    st.append(input().split())
x = input().strip()

num = 0
for i in range(n):
    if st[i][0] == x:
        num = i
ans = 0
for i in range((num + 1), n, 1):
    ans += int(st[i][1])
print(ans)


Measured memory_bytes: 38384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "map"

using namespace std;
const long long int MOD = 1000000007;

int N,M;
int dp[1000][10];
list <int>edge[10];
int s, e;
queue<int>Q;
int ans;

int Check(int a, int b);

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> s >> e;
		edge[s].push_back(e);
		edge[e].push_back(s);
	}
	for (int i = 0; i < 1000; i++) {
		for (int j = 2; j < 10; j++) {
			dp[i][j] = -1;
		}
	}
	dp[1][1] = 1;
	for (int i = 2; i <= N; i++) {
		ans += Check((int)pow(2, N) - 1, i);
	}
	cout << ans << endl;
	return 0;
}

int Check(int a, int b) {
	//cout << a << " " << b << endl;
	if (b == 1)return dp[a][b];
	if (dp[a][b] > -1)return dp[a][b];
	dp[a][b] = 0;
	for (auto i = edge[b].begin(); i != edge[b].end(); ++i) {
		//cout << a%(int)pow(2, *i) << " " << (int)pow(2, (*i) - 1) << endl;
		if (a % (int)pow(2, *i) >= (int)pow(2, (*i) - 1)) {
			dp[a][b] += Check(a - (int)pow(2, b - 1), *i);
		}
	}
	return dp[a][b];
}

Measured memory_bytes: 512
#整数を文字列で入力し、１文字ずつに分解し、数値に戻す
nums = gets.chars.map(&:to_i)
#配列の中に１がいくつあるか数える
count = 0
i = 0
3.times do |i|
  count += 1 if nums[i] == 1
end
#出力
puts count


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

using namespace std;

typedef long long ll;

ll MOD = 1e9+7;

int n;
ll h[110];

ll power(ll a, ll n) {
    if (n<0) return 0;
    if (!n) return 1;
    ll t = power(a,n/2);
    return t*t%MOD*((n&1)?a:1)%MOD;
}

ll D[110][110];
ll ch[110];
vector<ll> comp;
int main() {
    int i, j;

    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%lld",&h[i]);
    for (i=0;i<n;i++) comp.push_back(h[i]);
    comp.push_back(0);
    sort(comp.begin(),comp.end());
    comp.erase(unique(comp.begin(),comp.end()),comp.end());
    for (i=0;i<n;i++) ch[i] = lower_bound(comp.begin(),comp.end(),h[i])-comp.begin();
    for (j=0;j<comp.size();j++) {
        if (j==0) D[0][j] = power(2,h[0]);
        else if (j<=ch[0]) D[0][j] = power(2,h[0]-comp[j]+1);
        else D[0][j] = 0;
    }
    for (i=1;i<n;i++) {
        ll p = min(ch[i-1],ch[i]);
        for (j=0;j<comp.size();j++) {
            if (j<=p) D[i][j] = (D[i-1][j]+D[i-1][p])*power(2,h[i]-comp[p])%MOD;
            else D[i][j] = D[i-1][p]*2*power(2,h[i]-comp[j])%MOD;
        }
    }
    printf("%lld\n",D[n-1][0]);

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; ++i) {
		cin >> C[i];
		for (int j = 0; j < M; ++j) {
			cin >> A[i][j];
		}
	}

	int ans = -1;

	for (int mask = 0; mask < (1 << N); ++mask) {
		int total = 0;
		vector<int> v(M, 0);
		for (int i = 0; i < N; ++i) {
			if (mask & (1 << i)) {
				total += C[i];
				for (int j = 0; j < M; ++j) {
					v[j] += A[i][j];
				}
			}
		}
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			if (v[j] < X) {
				ok = false;
				break;
			}
		}
		if (ok) {
			if (ans < 0 || total < ans) {
				ans = total;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
n, t = map(int,input().split())
a = list(map(int, input().split()))

result = {}
m = 0
checker = []
for i in range(1, n):
    if m<a[-i]:
        m = a[-i]
    checker.append(m)
checker = checker[::-1]
for i in range(n-1):
    s = checker[i]-a[i]
    if s in result:
        result[s] += 1
    else:
        result[s] = 1
x = max(result.items())
print(x[1])

Measured memory_bytes: 21856
#include <bits/stdc++.h>
        #define endl '\n'
        #define modulo 1000000007
        #define int long long
        //#define __int128 long long
        #pragma GCC optimize("-Ofast")
        #define float double
        #define PI 3.141592653589793238462643383279502884
        #define sinDegrees(x) sin((x) * PI / 180.0)
        #define tanDegrees(x) tan((x) * PI / 180.0)
        #define atanDegrees(x) atan(x)* 180.0 / PI
        #define f first
        #define s second
        using namespace std;
        int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x*temp%m)*temp%m)%m;
        }
        int inv(int x)
        {
        return (power(x,modulo-2,modulo))%modulo;
        }
        bool comp(int a,int b)
        {
            return a>b;
        }
        ///Solution created by:Ahmadsm2005
        int32_t main()
        {
            //freopen("output.txt","w", stdout);
            //freopen("input0.txt","r", stdin);
            //iostream::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            int requiredred,requiredgreen,red,green,colorless;
            cin>>requiredred>>requiredgreen>>red>>green>>colorless;
            vector<int>redder;
            vector<int>greener;
            int arr[red],arr2[green],arr3[colorless];
            for(int i=0;i<red;i++){
            cin>>arr[i];
            }
            for(int i=0;i<green;i++)
            cin>>arr2[i];
            for(int i=0;i<colorless;i++)
            cin>>arr3[i];
            sort(arr,arr+red,comp);
            sort(arr2,arr2+green,comp);
            sort(arr3,arr3+colorless,comp);
            for(int i=0;i<requiredred;i++)
            redder.push_back(arr[i]);
            for(int i=0;i<requiredgreen;i++)
            greener.push_back(arr2[i]);
            reverse(redder.begin(),redder.end());
            reverse(greener.begin(),greener.end());
            int i=0,l=0,x=0;
            while(1){
            if(x>=colorless)
            break;
            int miner1=(int)1e15,miner2=(int)1e15;
            if(i<redder.size()){
            miner1=redder[i];
            }
            bool flag=0;
            if(l<greener.size())
            miner2=greener[l];
            if(miner1==(int)1e15&&miner1==miner2)
            break;
            if(miner1<miner2&&arr3[x]>miner1){
            redder[i]=arr3[x];
            i++;
            flag=1;
            }
            else if(arr3[x]>miner2){
            greener[l]=arr3[x];
            l++;
            flag=1;
            }
            if(!flag)
            break;
            x++;
            }
            int counter=0;
            for(int i=0;i<redder.size();i++)
            counter+=redder[i];
            for(int i=0;i<greener.size();i++)
            counter+=greener[i];
            cout<<counter;
            return 0;
        }


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

long long int a,b,c,d;
long long int fon(long long int k)
{
	return k/c+k/d-k/(d*c/__gcd(d,c));
}
int main()
{
	cin >> a >> b >> c >> d;
	cout <<  b - a +1 - (fon(b) - fon(a-1))<< endl;

}

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


int main() {
  
  int a,b,c,d;
  cin >>a >>b >> c >> d;
  
  for(int i=0;i<100;i++){
    c=c-b;
    if(c<=0){
      cout<<"Yes"<<endl;
      break;
    }
    a=a-d;
    if(a<=0){
      cout<< "No"<<endl;
      break;
    }
  }
}
  

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,last,now; 
int main()
{
	cin>>a;
	for(int s=1;s<=a;s++)
	{
		cin>>b;
		if(b==last)now++;
		else
		{
			c+=now/2;
			now=1;
		}
		last=b;
	}
	cout<<now/2+c<<endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;

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

            int n = int.Parse(Console.ReadLine());

            List<List<string>> abs = new List<List<string>>();
            
            for (int i = 0; i < n; i++)
            {
                List<string> ab = new List<string>();
                ab.Add(Console.ReadLine().PadLeft(88, '0'));
                ab.Add(Console.ReadLine().PadLeft(88, '0'));
                abs.Add(ab);
            }

            foreach (List<string> ab in abs)
            {

                if (ab[0].TrimStart('0').Length > 80 || ab[1].TrimStart('0').Length > 80)
                {
                    Console.WriteLine("overflow");
                    continue;
                }

                List<string> a = new List<string>();
                List<string> b = new List<string>();
                List<string> results = new List<string>();

                for (int i = 0; i < 11; i++)
                {
                    a.Add(ab[0].Substring(i * 8, 8));
                }

                for (int i = 0; i < 11; i++)
                {
                    b.Add(ab[1].Substring(i * 8, 8));
                }

                string kuri = "0";

                for(int i = 10; i >= 0; i--)
                {
                    int r = int.Parse(a[i]) + int.Parse(b[i]) + int.Parse(kuri);
                    if (r.ToString().Length > 8)
                    {
                        kuri = r.ToString().Substring(0, r.ToString().Length - 8);
                        results.Add(r.ToString().Substring(r.ToString().Length - 8, 8));
                    }
                    else 
                    {
                        results.Add(r.ToString().PadLeft(8,'0'));
                        kuri = "0";
                    }
                    
                }
                string resultsStr = "";
                
                results.Reverse();

                foreach (string result in results)
                {
                    resultsStr += result;
                }

                if (resultsStr.TrimStart('0').Length > 80)
                {
                    Console.WriteLine("overflow");
                    continue;
                }

                if (resultsStr.TrimStart('0') == "")
                {
                    Console.WriteLine("0");
                }
                else 
                {
                    Console.WriteLine(resultsStr.TrimStart('0'));
                }
                
               
            }

        }
    }
}

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

int main() {
    int n, y;
    cin >> n >> y;
    for(int i=n; i>=0; i--){
        for(int j=n-i; j>=0; j--){
            if(10000*i + 5000*j + 1000*(n-i-j) == y){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

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

vector<int> dis;

int main()
{
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int64_t> p(a);
	for (int i = 0; i < a; i++) {
		cin >> p.at(i);
	}
	vector<int64_t> q(b);
	for (int i = 0; i < b; i++) {
		cin >> q.at(i);
	}
	priority_queue<int64_t> pq_r;
	for (int i = 0; i < c; i++) {
		int64_t r_in;
		cin >> r_in;
		pq_r.push(r_in);
	}

	sort(p.begin(), p.end());
	reverse(p.begin(), p.end());
	sort(q.begin(), q.end());
	reverse(q.begin(), q.end());

	int64_t ans = 0;
	priority_queue<int64_t, vector<int>, greater<int>> pq_pq;
	for (int i = 0; i < x; i++) {
		ans += p.at(i);
		pq_pq.push(p.at(i));
	}
	for (int i = 0; i < y; i++) {
		ans += q.at(i);
		pq_pq.push(q.at(i));
	}

	int64_t diff = 0;
	while (pq_pq.size() > 0 && pq_r.size() > 0) {
		int64_t pq = pq_pq.top();
		int64_t r = pq_r.top();
		if (pq < r) {
			diff += r - pq;
			pq_pq.pop();
			pq_r.pop();
		} else {
			break;
		}
	}
	ans += diff;

	cout << ans << endl;
}



Measured memory_bytes: 4084
/////////package Educ_DP;

import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        s.nextLine();
        String[]l=s.nextLine().split(" ");
        int[] list=new int[l.length];
        for (int i=0;i<list.length;i++){
            list[i]=Integer.parseInt(l[i]);
        }
        int[] dp=new int[list.length];
        dp[dp.length-1]=0;
        dp[dp.length-2]=Math.abs(list[list.length-1]-list[list.length-2]);
        for (int i=dp.length-3;i>=0;i--){
            dp[i]=Math.min(dp[i+2]+Math.abs(list[i]-list[i+2]),dp[i+1]+Math.abs(list[i]-list[i+1]));
        }
        System.out.println(dp[0]);
    }
}


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
//}}}


int solve(){
  int a,b;cin>>a>>b;

  rep(c, 1, 4){
    if ((a*b*c)%2==1){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

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

    for (int i = 1; i < n + 1;++i){
        cout << a[i] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 4372
main :: IO ()
main = do
    [a,b,c,d] <- getLine
    let fs = read [a,b]
    let sn = read [c,d]
    let res = case (betw fs, betw sn) of
                (True,True) -> "AMBIGUOUS"
                (True,False) -> "MMYY"
                (False,True) -> "YYMM"
                _ -> "NA"
    putStrLn res

betw :: Int -> Bool 
betw x= x>0 && x<13



Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> lengths(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> lengths[i];
  }

  int max = *std::max_element(lengths.begin(), lengths.end());
  int total = std::accumulate(lengths.begin(), lengths.end(), 0);

  std::cout << ((total - max) > max ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final char[] s = scanner.nextLine().toCharArray();
        long result = 0;
        long whiteCount = 0;
        for (int i = s.length - 1; i >= 0; i--) {
            if (s[i] == 'W') {
                whiteCount++;
            } else {
                result += whiteCount;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 26552
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>

using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
typedef pair<long long int,long long int> pll;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



long long int N,M;
pll XL[100005],XL2[100005];
int main() {
	cout << fixed << setprecision(18);
    cin>>M>>N;
    for(int i=0;i<N;i++){
        cin>>XL[i].first>>XL[i].second;
        XL[i]={XL[i].second,XL[i].first};
    }
    sort(XL,XL+N);
    long long int now=-INF,res=0;
    for(int i=0;i<N;i++){
        if(now<=XL[i].second){
            now=XL[i].first;
            res++;
        }
    }
    cout<<res<<endl;
} 


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        
        int l = sn.nextInt();
        int r = sn.nextInt();
        int d = sn.nextInt();
        int cnt = 0;
        
        for(int i = l; i <= r; i++) {
            if(i % d == 0) {
                cnt++;
            }
        }
        
        System.out.print(cnt);
    }
}


Measured memory_bytes: 35372
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 N, K;
  cin >> N >> K;
  vector<i64> A(N);
  for (auto& x : A) cin >> x;

  const i64 M = 1LL << 42;

  vector<i64> lower_sum(45), eq_sum(45);
  int k = 1;
  for (i64 d = M; d > 0; d >>= 1, ++k) {
    i64 cnt = 0;
    REP(i, N) {
      if (A[i] & d) cnt++;
    }
    if (K & d) {
      eq_sum[k] = eq_sum[k - 1] + (N - cnt) * d;
      lower_sum[k] = max(eq_sum[k - 1] + cnt * d,
                         (lower_sum[k - 1] == 0)
                             ? 0
                             : lower_sum[k - 1] + max(cnt, N - cnt) * d);
    } else {
      eq_sum[k] = eq_sum[k - 1] + cnt * d;
      if (lower_sum[k - 1] != 0) {
        lower_sum[k] = lower_sum[k - 1] + max(cnt, N - cnt) * d;
      }
    }
  }
  i64 ans = max(lower_sum[k - 1], eq_sum[k - 1]);
  cout << ans << endl;
}

Measured memory_bytes: 3948
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.TreeMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPowersOfTwo solver = new BPowersOfTwo();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPowersOfTwo {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // input
            int n = in.nextInt();
            TreeMap<Integer, Integer> mp = new TreeMap<>(Comparator.naturalOrder());
            for (int i = 0; i < n; i++) {
                mp.merge(in.nextInt(), 1, Integer::sum);
            }
            int ans = 0;
            while (!mp.isEmpty()) {
                int use = mp.lastKey();
                mp.merge(use, -1, Integer::sum);
                if (mp.get(use) == 0) {
                    mp.remove(use);
                }
                int target = 1;
                while (target <= use) {
                    target *= 2;
                }
                target -= use;
                if (mp.containsKey(target)) {
                    mp.merge(target, -1, Integer::sum);
                    if (mp.get(target) == 0) {
                        mp.remove(target);
                    }
                    ans++;
                }


            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 103152
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

struct P { double x, y; };

int main() {
	P p1, p2;
	cin >> p1.x >> p1.y >> p2.x >> p2.y;
	int q;
	cin >> q;
	while (q-->0) {
		P p, h;
		cin >> p.x >> p.y;
		double t = ((p2.x - p1.x) * (p.x - p1.x) + (p2.y - p1.y) * (p.y - p1.y)) / (pow(p2.x - p1.x, 2) + pow(p2.y - p1.y, 2));
		h.x = p1.x + t * (p2.x - p1.x);
		h.y = p1.y + t * (p2.y - p1.y);
		cout << fixed << setprecision(12) << h.x << " " << h.y << endl;
	}
	return 0;
}

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

struct dor {
	dor *l, *r;
	int b;

	void pp() {
		b = (l == NULL ? 0 : l->b) | (r == NULL ? 0 : r->b);
	}
} *rt;

int n, q;
string s;

int si;
char ch;
void gnk(int l, int r, dor *&t) {
	if(t == NULL) t = new dor();
	if(l == r) {
		t->b = (1 << ((int)(ch - 'a')));
		return;
	}
	if(si <= (l + r) / 2) gnk(l, (l + r) / 2, t->l);
	else gnk((l + r) / 2 + 1, r, t->r);
	t->pp();
}

int sl, sr;
int sgb(int l, int r, dor *&t) {
	if(l > sr || r < sl || t == NULL) return 0;
	if(l >= sl && r <= sr) return t->b;
	return sgb(l, (l + r) / 2, t->l) | sgb((l + r) / 2 + 1, r, t->r);
}

int sb(int l, int r) {
	sl = l, sr = r;
	return sgb(1, n, rt);
}

void gk(int i, char c) {
	si = i, ch = c;
	gnk(1, n, rt);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> s >> q;
	for(int i = 0; i < s.size(); ++i) {
		gk(i + 1, s[i]);
	}
	for(int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		if(x == 1) {
			char z;
			cin >> z;
			gk(y, z);
		} else {
			int z;
			cin >> z;
			cout << __builtin_popcount(sb(y, z)) << "\n";
		}
	}
	return 0;
}


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

int main() {
    ll r, D, x;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; i++)
    {
        x = r * x - D;
        cout << x << endl;
    }
    
    
  return 0;
}


Measured memory_bytes: 256