akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s.find('9') == string::npos) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

	vector<int> a(N+2);

	a[0] = 0;
	a[N + 1] = 0;

	REP(i, N) {
		cin >> a[i+1];
	}

	int sum = 0;

	REP(i, a.size()-1) {
		sum += abs(a[i] - a[i + 1]);
	}

	FOR(i, 1, N +1) {
		cout << sum - abs(a[i] - a[i + 1]) - abs(a[i] - a[i - 1]) + abs(a[i-1] - a[i + 1]) << endl;
	}
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int D = int.Parse(str[1]);
		int A = int.Parse(str[2]);
		int[][]B = new int[N][];
		for(var i=0;i<N;i++){
			string[] str2 = Console.ReadLine().Split();
			B[i] = new int[2]{int.Parse(str2[0]),int.Parse(str2[1])};
		}
		Array.Sort(B,(x,y)=>x[0]-y[0]);
		long ans = 0;
		var list = new List<long[]>();
		list.Add(new long[2]{B[0][0]+D,((B[0][1]-1)/A+1)*A});
		int a1 = 0;
		long m1 = B[0][1];
		ans += (B[0][1]-1)/A+1;
		m1 = ((B[0][1]-1)/A+1)*A;
		//Console.Error.WriteLine(ans+" "+m1);
		for(var i=1;i<N;i++){
			while(a1<list.Count){
				if(list[a1][0]<B[i][0]-D){
					m1 -= list[a1][1];
					a1++;
				} else {
					break;
				}
			}
			//Console.Error.WriteLine(m1);
			if(B[i][1]>m1){
				long c1 = ((B[i][1]-m1-1)/A+1)*A;
				ans += c1/A;
				m1 += c1;
				list.Add(new long[2]{B[i][0]+D,c1});
			}
			//Console.Error.WriteLine(ans+" "+m1);
		}
		Console.WriteLine(ans);
	}
}

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

int main(){
  int A,B;
  cin>>A>>B;
  if((A%3==0)||(B%3==0)||((A+B)%3==0)){
    cout<<"Possible"<<endl;
    return 0;
  }
  cout<<"Impossible"<<endl;
  return 0;
}


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

int main(){
    int A,B;
    cin >> A >> B;
    int K = (B+A)/2;
    if( (B+A)%2!=0 ){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << K << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))

leftA = [0]
tmp = A[0]
for a in A:
    tmp = max(tmp, a)
    leftA.append(tmp)
# print(leftA)

rightA = deque([0])
tmp = A[-1]
for a in reversed(A):
    tmp = max(tmp, a)
    rightA.appendleft(tmp)
rightA.appendleft(0)
# print(rightA)

for i in range(1, n+1):
    print(max(leftA[i-1], rightA[i+1]))


Measured memory_bytes: 16080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    ll ans=(n/500)*1000;
    n=n%500;
    ans+=(n/5)*5;
    cout<<ans;
    return 0;  
} 





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

int main(void)
{
    // bits/stdc++.h をincludeしているときは定数M_PIが使えます
    const double PI=3.14159265358979323846;
    double a,b,x;
    cin >> a >> b >> x;
    double s = x / a;
    double ans = 0;
    double a2 = 0;
    // コーナーケース
    if ( s == a * b) {
        ans = 0;
    } else {
        if (s > b * a / 2) {
            // 台形の時
            // 上底bu
            double bu = 2 * s / a - b;
            s -= a * bu;
            b -= bu;
            a2 = 2 * s / b;    // a2 = a とするとコーナーケースを考慮する必要がなくなる
        } else {
            // 三角形の時
            a2 = 2 * s / b;
        }
        // アークタンジェント計算(結果はラジアン)
        double r = atan(b/a2);
        // ラジアン-角度変換
        ans = r * (180.0 / PI); 
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };





ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll X[301][4];
int main() {
int N,A,B;
cin>>N>>A>>B;
ll ans=(N-A+1)*(N-B+1);
cout<<ans<<endl; 
}


Measured memory_bytes: 256
/*input
100000
*/

#include <iostream>

using namespace std;

int main()
{

	int N;
	cin >> N;

	long long power = 1;

	for(int i=1;i<=N;i++){
		power *= i;
		power %= 1000000007;
	}

	cout << power << endl;

	return 0;
}


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

int main() {
  int a, b;

  cin >> a >> b;

  int ans = 0;

  while (++ans) {
    if (floor(ans * 0.08) > a && floor(ans * 0.1) > b) {
      cout << "-1";
      return 0;
    } else if (floor(ans * 0.08) == a && floor(ans * 0.1) == b) {
      cout << ans;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

ma = max(a, b)
mi = min(a, b)
ans = []
if ma == mi:
    ans.append(ma)
    
for i in range(ma // 2, 0, -1):
    if ma % i == 0 and mi % i == 0:
        ans.append(i)
ans.append(1)
print(ans[k - 1])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
    int m, n, x, y;
    cin >> n >> m;
    int a[n][m] = {};
    int c[n]={};
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            cin >> x;
            a[i][j] = x;
        }
    }
    for (int k=0; k<m; k++) {
        cin >> y;
        for (int l=0; l<n; l++) {
            a[l][k] = a[l][k] * y;
        }
    }
     
    for (int o=0; o<n; o++) {
        for (int p=0; p<m; p++) {
            c[o] += a[o][p];
        }
        cout << c[o] << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
//#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <cmath>

using namespace std;

class Dice
{
public:
	Dice(int num[6]);
	int Play(char c);
	int T;
private:
	int NS[4],EW[4];
	int NS_p,EW_p;
};

//?????????????????????
Dice::Dice(int num[6])
{
	NS_p = 0;
	EW_p = 0;
	NS[0] = num[0];
	NS[1] = num[1];
	NS[2] = num[5];
	NS[3] = num[4];
	EW[0] = num[0];
	EW[1] = num[3];
	EW[2] = num[5];
	EW[3] = num[2];
	T = num[0];
}

int Dice::Play(char c){

	if (c == 'N' || c == 'S'){
		if(c == 'N') NS_p = (NS_p + 1) % 4;
		else {
			if (NS_p == 0) NS_p = 3;
			else NS_p--;
		}
		EW[EW_p] = NS[NS_p];
		EW[(EW_p+2)%4] = NS[(NS_p+2)%4];
	}
	else if (c == 'E' || c == 'W'){
		if (c == 'E') EW_p = (EW_p + 1) % 4;
		else {
			if (EW_p == 0) EW_p = 3;
			else EW_p--;
		}
		NS[NS_p] = EW[EW_p];
		NS[(NS_p + 2) % 4] = EW[(EW_p + 2) % 4];
	}
	T = NS[NS_p];
	
	return 1;
}


int main(){

	int num[6];
	char c;

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

	Dice d1(num);

	while (cin >> c){
		d1.Play(c);
	}

	cout << d1.T << endl;

	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        var R = new List<Tuple<string, int>>();
        var D = new Dictionary<string, int>();
        for (int i = 0; i < N; i++)
        {
            string s = cin.nextString();
            int p = cin.nextInt();
            R.Add(Tuple.Create(s, p));
            D.Add(string.Format("{0}-{1}", s, p), i + 1);
        }

        R.Sort((a, b) =>
            {
                int ret1 = a.Item1.CompareTo(b.Item1);
                if (ret1 != 0)
                {
                    return ret1;
                }
                return b.Item2 - a.Item2;
            });

        for (int i = 0; i < N; i++)
        {
            Console.WriteLine(D[string.Format("{0}-{1}", R[i].Item1, R[i].Item2)]);
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
const int MOD=1e9+7;
const int MAXN=1e6+7;

int ans=0;
int n,m,k,q;
string s;
list<char> lst;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>s>>q;
    bool rev=false;
    for(char c:s)lst.push_back(c);
    FOR(i,0,q){
        int t;
        cin>>t;
        if(t==1){
            rev=!rev;
        }else{
            int f;
            cin>>f;
            char c;
            cin>>c;
            if(f==1^rev){
                lst.push_front(c);
            }else{
                lst.push_back(c);
            }
        }
    }
    if(rev){
        for(list<char>::const_iterator it=lst.end();it!=lst.begin();){
            --it;
            cout<<*it;
        }
    }else{
        for(list<char>::const_iterator it=lst.begin();it!=lst.end();++it){
            cout<<*it;
        }
    }
    cout<<"\n";
    return 0;
}



Measured memory_bytes: 10064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,k; cin >>n>>k;
    string s; cin >> s;
    if(s[k-1] == 'A') {
        s[k-1] = 'a';
    } else if(s[k-1] == 'B') {
        s[k-1] = 'b';
    } else if(s[k-1] == 'C') {
        s[k-1] = 'c';
    } 

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let height: usize = sc.read();
    let width: usize = sc.read();
    let h: usize = sc.read();
    let w: usize = sc.read();
    if height % h == 0 && width % w == 0 {
        println!("No");
        return;
    }
    println!("Yes");
    if width % w != 0 {
        let row = construct(w, width);
        for _ in 0..height {
            for j in 0..width {
                print!("{} ", row[j]);
            }
            println!();
        }
    } else {
        let column = construct(h, height);
        for i in 0..height {
            for _ in 0..width {
                print!("{} ", column[i]);
            }
            println!();
        }
    }
}

fn construct(w: usize, width: usize) -> Vec<i64> {
    let mut sum = vec![0; width + 1];
    for i in 0..width {
        if i >= w {
            sum[i] = sum[i - w] - 1;
        }
    }
    sum[width] = 1;
    let mut cur = width;
    while cur >= w {
        cur -= w;
        sum[cur] = sum[cur + w] + 1;
    }
    let mut a = vec![0; width];
    for i in 0..width {
        a[i] = sum[i + 1] - sum[i];
    }
    a
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 5372
#include <iostream>
using namespace std;
int main(){
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if(w >= x && h >= y){
		if(x+r <= w && x-r >= 0 && y+r <= h && y-r >= 0){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

struct CmpSort {
	bool operator ()(const string &s1, const string &s2) {
		if (s1.size() == s2.size()) {
			return s1 < s2;
		}
		return s1.size() < s2.size();
	}
};

int main() {
	int n, num;
	string name;
	map<string, int, CmpSort> productionInfo;
	map<string, int>::iterator pos;

	productionInfo.clear();
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> name >> num;
		productionInfo[name] += num;
	}
	for (pos = productionInfo.begin(); pos != productionInfo.end(); ++pos) {
		cout << pos->first << " " << pos->second << endl;
	}

	return 0;
}


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

int main(){
    int a,b,ans;
    cin >>a>>b;
    float x,y;
    x=ceilf((float)a/0.08);
    y=ceilf((float)b/0.1);
    if(x<y){
        ans=y;
    }else{
        ans=x;
    }
    //out <<ans<<endl;
    //cout << ans*0.08<< " "<< ans*0.1<<endl;
    if((int)(ans*0.08)==a && (int)(ans*0.1)==b){
        cout <<ans<<endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<ll> D(100005, 0);
	vector<ll> sum(100005, 0);
	rep(i, 0, n - 1)
	{
		ll d; cin >> d;
		++D[d];
	}
	int cnt = 0;
	rep(i, 0, 100000)
	{
		sum[i + 1] = sum[i] + D[i];
		if (sum[i + 1] == n / 2)++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int N=105;

ll n, m, k, u, v, x, y, t, a, b, ans, mod;
ll C[N][N];
ll tav[N][N];
ll dp0[N][N][N]; // b=a
ll dp1[N][N][N]; // b=a+1

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m>>k>>mod;
	for (int i=0; i<N; i++){
		C[i][0]=C[i][i]=1;
		for (int j=1; j<i; j++) C[i][j]=(C[i-1][j-1] + C[i-1][j])%mod;
	}
	for (int x=0; x<N; x++){
		tav[x][0]=1;
		for (int y=1; y<N; y++) tav[x][y]=tav[x][y-1]*x%mod; // :|
	}
	
	dp0[0][0][0]=1;
	for (int a=0; a<k; a++){
		// b=a
		for (int x=0; x<=n; x++) for (int y=0; y<=m; y++) if (dp0[a][x][y]){
			ll val=tav[k-a][y]*(tav[a+1][m-y]-tav[a][m-y])%mod, mul=1;
			for (int xx=x; xx<=n; xx++){
				dp1[a][xx][y]=(dp1[a][xx][y] + dp0[a][x][y]*mul%mod*C[n-x][xx-x])%mod;
				mul=mul*val%mod;
			}
		}
		
		// b=a+1
		for (int x=0; x<=n; x++) for (int y=0; y<=m; y++) if (dp1[a][x][y]){
			ll val=tav[a+1][n-x]*(tav[k-a][x]-tav[k-a-1][x])%mod, mul=1;
			for (int yy=y; yy<=m; yy++){
				dp0[a+1][x][yy]=(dp0[a+1][x][yy] + dp1[a][x][y]*mul%mod*C[m-y][yy-y])%mod;
				mul=mul*val%mod;
			}
		}
	}
	ans=dp0[k][n][m];
	if (ans<0) ans+=mod;
	cout<<ans<<"\n";
	
	return 0;
}
/*
2 2 1 998244353
1 2 2 998244353
2 1 2 998244353

*/

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

int main()
{	
	int y, m, d;
	char c;

	cin >> y >> c >> m >> c >> d;

	if(y < 2019 || (y == 2019 && m < 5))
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;

	return 0;
}


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

res = 0
dp = [[0]*(n+1) for _ in range(n+1)]
for i in reversed(range(n)):
    for j in reversed(range(i+1,n)):
        if s[i] == s[j]:
            dp[i][j] = dp[i+1][j+1] + 1
        cres = min(j-i, dp[i][j])
        res = max(res, cres)

print(res)            

Measured memory_bytes: 231816
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define dash 12
#endif

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Extra --------------------------------------------------------------------

#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    string a,b;
    std::cin>>a>>b;

    if(b.size()) {
        b.pop_back();
    }
    cout<<((a==b) ? "Yes" : "No")<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

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

    int t = 1;
    loop(Case,1,t+1)
    {
        d(Case);
        solve(Case);
    }
    return 0;
}

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

enum {
  B10 = 10000, B5 = 5000, B1 = 1000
};

inline bool isCorrect(int x10, int x5, int x1, int n, long y){
    bool isPositive = ((x10 >= 0) && (x5 >= 0) && (x1 >=0));
    bool isCorrectN = (n == x10 + x5 + x1);
    bool isCorrectY = (y - B10*x10 - B5*x5 - B1*x1 == 0);

    return isPositive && isCorrectN && isCorrectY;
}

// O(n^2)
void simplyAns(int& x10, int& x5, int& x1, int n, long y){
    for(x10 = 0; x10 <= n; x10++){
        for(x5 = 0; x5 <= n - x10; x5++){
            x1 = n - x5 - x10;
            if(isCorrect(x10, x5, x1, n, y)) return;
        }
    }
}

int main(){
    int  n; cin >> n;
    long y; cin >> y;

    int x10 = -1, x5 = -1, x1 = -1;
    simplyAns(x10, x5, x1, n, y);

    if(isCorrect(x10, x5, x1, n, y)){
        cout << x10 << " " << x5 << " " << x1 << endl; 
    } else {
        cout << "-1 -1 -1" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <map>
using namespace std;

int main()
{
	int N;
	long long K;
	cin >> N >> K;
	vector<pair<int,int>> number(N);
	
	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		number[i] = make_pair(a,b);
	}
	sort(number.begin(), number.end());
	long long looking = 0;
	for (int i = 0; i < N; i++)
	{
		looking += number[i].second;
		if (K <= looking)
		{
			cout << number[i].first<<endl;
			break;
		}
	}
	return 0;

}


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

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			int[]A = new int[N];
			for(int i = 0;i<N;i++)A[i] = scan.nextInt();
			
			Arrays.sort(A);
			
			int ke = A[0];
			int kenum = 0;
			
			
			while(true) {
			
			
			int count = 0;
			for(int i = 0;i<N;i++) {
				
				if(i==kenum)continue;
				
				if(A[i]==0) { 
					count++;
				}else {
					A[i] = A[i]%ke;
					if(A[i]<ke&&A[i]!=0) {
						ke=A[i];
						kenum=i;
					
					}
				
				}
			}
			
			if(count==N-1)break;
			}
			
			
			System.out.println(ke);
		}
		
		
	}
		
	

}


Measured memory_bytes: 48568
#include <iostream>

using namespace std;

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

    int ans = 0;
    int palindromic;
    for ( int i=1; i<=9; i++ ) {
        for ( int j=0; j<=9; j++ ) {
            for ( int k=0; k<=9; k++ ) {
                palindromic = 10001 * i + 1010 * j + 100 * k;
                if ( A <= palindromic && palindromic <= B )
                    ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
using namespace std;

int main(void) {
	int A[200000] ,sortedA[200000] = { 0 };
	int N,lmid=0,rmid=0,ans=0;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		sortedA[i] = A[i];
	}
	sort(sortedA, sortedA + N);
	lmid = sortedA[N / 2 - 1];
	rmid = sortedA[N / 2];

	for (int i = 0;i < N;i++) {
		if (A[i] <= lmid)
			ans = rmid;
		else if (A[i] >= rmid)
			ans =lmid;
		cout << ans << endl;
	}
	return 0;
}

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

const int MAXN = 2e5+4;
int a[MAXN];
const int MAXM = 1e6;
bool flag[MAXM+4];

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

	sort(a+1, a+n+1);

	int ans = 0;
	for (int i=1; i<=n; i++) {
		if (false==flag[a[i]]) {
			if (a[i]!=a[i+1]) {

				ans++;
			}

			for (int j=1; a[i]*j<=MAXM; j++) {
				flag[a[i]*j] = true;
			}
		}
	}

cout<<ans<<"\n";


}

Measured memory_bytes: 5352
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<math.h>
#include<map>
#include<stack>
#include<set>
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#include<bits/stdc++.h>
typedef long long LL;
using namespace std;
int a[100010];
map<char, int>mp;
signed main()
{
	IOS;
	int n,x,t;
	cin >> n>>x>>t;
	int ans = (ceil(n*1.0 / x)*t);
	cout << ans << endl;
}


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

int main()
{
    ll a;
    double b;
    cin >> a >> b;
    ll b2 = b * 100 + 0.1;
    ll ans = a * b2;
    cout << ans / 100 << endl;
    return 0;
}


Measured memory_bytes: 3728
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	defer stdout.Flush()
	s := readString()
	K := readInt()

	m := map[string]bool{}

	for i := 1; i <= len(s) && i < 2*K; i++ {
		for j := 0; j+i <= len(s); j++ {
			m[s[j:j+i]] = true
		}
	}

	ss := make([]string, len(m))

	i := 0
	for t := range m {
		ss[i] = t
		i++
	}

	sort.Strings(ss)

	println(ss[K-1])
}

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;


int main(){
    using P = pair<int,int> ;
    int N;cin>>N;
    vector<P> A(N,make_pair(0,0));
    int left=0,right=0;
    REP(i,N){
        string s;cin>>s;
        REP(j,s.size()){
            if(s[j]=='(') A[i].second++;
            else{
                if(A[i].second>0) A[i].second--;
                else A[i].first++;
            }
        }
        if(A[i].first==0) left+=A[i].second;
        if(A[i].second==0) right+=A[i].first;
    }
    vector<P> f,g;
    REP(i,N) if(A[i].first&&A[i].second){
        if(A[i].second - A[i].first >=0) f.push_back(P(A[i].first,A[i].second-A[i].first));
        else g.push_back(P(A[i].first,A[i].second-A[i].first)); 
    }
    sort(All(f));
    REP(i,f.size()){
        if(f[i].first<=left) left+=f[i].second;
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    REP(i,g.size()){
        if(g[i].first<=left) left+=g[i].second;
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(left==right) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 11088
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,v,w,t;
  cin>>a>>v>>b>>w>>t;
  int x=abs(a-b);
  int y=v-w;
  if(y*t >= x){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;
}


Measured memory_bytes: 3648
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;
#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL <class T = int> inline T IN() { T x; cin >> x; return x; }
TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> vector<T> make_v(size_t a) { return vector<T>(a); }
TPL<TNM T, TNM... Ts> auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }

TPL<TNM T> using vec2 = decltype(make_v<T>(0, 0));
TPL<TNM T> using vec3 = decltype(make_v<T>(0, 0, 0));
TPL<TNM T> using vec4 = decltype(make_v<T>(0, 0, 0, 0));
TPL<TNM T> using vec5 = decltype(make_v<T>(0, 0, 0, 0, 0));

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int main(void) {
	ll N;
	cin >> N;
	vector<ll> X(N);

	REP(i, N) {
		X[i] = IN();
	}

	auto _X = X;
	sort(ALL(_X));
	ll b = _X[N / 2];
	REP(i, N) {
		if (X[i] == b) {

		}
		if (X[i] >= b) {
			OUT(_X[N / 2 - 1]);
		}
		else OUT(b);
	}

	return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
double bmidist(double h, double w);
int main()
{
    int i,n,id,h,w,bestid;
    double d;

    while(1){
        scanf("%d",&n);
        if(n==0) break;
        double best=100;
        for(i=0;i<n;i++){
            scanf("%d %d %d",&id,&h,&w);
            d = bmidist(h,w);
            if(best > d){
                best = d;
                bestid = id;
            }
        }
        printf("%d\n" ,bestid);
    }
    return 0;
}

double bmidist(double h, double w) {
    double result;
    h /= 100;
    result = w / (h*h);
    result = 22 - result;
    if(result < 0) result *= -1;
    return result;
}

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

using namespace std;

main(){
    int n;
    scanf("%d" , &n);

    int d = 1;
    int ans = 0;
    for(int i = 1 ; i <= 10 ; i ++){
        if(d*10 > n){
            if(i&1)ans += n - d + 1;
            break;
        }
        if(i&1)ans += d*10 - d;
        d *= 10;
    }

    printf("%d\n" , ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VVI vector<vector<ll>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define lb(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define ub(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define pb push_back
#define pf push_front
#define m_p make_pair
#define fi first
#define se second
#define sz size()
#define sort(v) sort(v.begin(),v.end())
ll n,m;
VVI gp;
int main()
{   cin>>n>>m;
    vector<vector<char>>mat(n+1,vector<char>(m+1));
    lf(i,1,n)
        lf(j,1,m)
            cin>>mat[i][j];
    ll dp[n+1][m+1]={-1};
    memset(dp,0,sizeof(dp));
    lf(i,1,n)
    {   lf(j,1,m)
        {   if(i==1 && j==1)
            {   dp[i][j]=1;
            }
            else if(mat[i][j]!='#')
            {   ll sum=0;
                sum+=dp[i-1][j];
                sum+=dp[i][j-1];
                dp[i][j]=(sum)%mod;
            }
        }
    }
    cout<<dp[n][m]<<endl;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> V(N);
  REP(i, 0, N) {
    ll a, b;
    cin >> a >> b;
    V[i] = pair<ll, ll>(a, b);
  }
  sort(V.begin(), V.end(), less<>());

  ll cost = 0;
  ll remain = M;
  REP(i, 0, V.size()) {
    if (remain > V[i].second) {
      remain -= V[i].second;
      cost += V[i].second * V[i].first;
    } else {
      cost += V[i].first * remain;
      cout << cost << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
unordered_map<int,int> um;
unordered_set<int> us;
set<int> s;
// v.front() gives the first element of vector 
// v.back()  gives the last element of vector
// insert erase substr
//g++ -o Legendary-Grandmaster Legendary-Grandmaster.cpp&Legendary-Grandmaster.exe 
//cd C:\Users\158si\Desktop\Algorithim\codeForces\elite
// for-bash cd C:/Users/158si/Desktop/Algorithim/codeForces/elite

int main(){
	int H,A;
	cin >> H  >> A;
	int x = H/A;
	if(H%A==0){
		cout << x;
	}else{
		cout << x+1;
	}
	
	return 0;
}

























Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
ll rec(int n, ll x){
    if(n==0) return 1;
    ll len = (1LL<<(n+1))-3;
    ll num = (1LL<<n)-1;
    if(x==1){
        return 0;
    }
    else if(x<=len+1) return rec(n-1,x-1);
    else if(x==len+2) return num+1;
    else if(x<=(len+1)*2) return num+1+rec(n-1,x-len-2);
    else return num*2+1;
}
int main(){
    int n;
    ll x;
    cin>>n>>x;
    cout<<rec(n,x)<<endl;
    return 0;
}



Measured memory_bytes: 256
import heapq
import math

n,m = list(map(int,input().split()))
a = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(a)

for i in range(m):
	tmp = heapq.heappop(a)
	tmp = (math.floor(-tmp/2)) * (-1)
	heapq.heappush(a, tmp)

print(sum(a) * -1)

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

#define ll long long
#define INF 1.0e+15;

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 1; i < N; i++) a[i] += a[i - 1];

	ll ans = INF;

	for (int i = 0; i < N - 1; i++) {
		ans = min(ans, abs(2 * a[i] - a[N - 1]));
	}
	cout << ans << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N, K;
    cin >> N >> K;
    int H[N];
    for(int i = 0; i < N; i++) cin >> H[i];
    sort(H, H + N);
    ll sum = 0;
    for(int i = N - 1 - K; i >= 0; i--) sum += H[i];
    
    cout << sum;
    return 0;
}


Measured memory_bytes: 1024
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$K) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
//$H = explode(" ",trim(fgets(STDIN)));

$a = str_split($N);
$c = array_count_values($a);
$stotal = 0;
$len = count($a);
for($i=0;$i<$len;$i++) {
  if ($a[$i]=='B') {
    $stotal += $i;
  }
}
$total = 0;
$len = $len -1;
for($i=0;$i<$c['B'];$i++) {
  $total += $len-$i;
}
printf("%d\n",$total-$stotal);


Measured memory_bytes: 38700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

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

}

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

int main() {
  int N, temp;
  std::cin >> N;
  
  std::vector<int> L;
  while (std::cin >> temp) {
    L.push_back(temp); 
  }
  std::sort(L.begin(), L.end(), std::greater<>());
  
  int ans = 0;
  
  for (int i=0; i<N-2; ++i) {
    if (L.at(i) >= L.at(i+1) + L.at(i+2)) 
      continue;
    
    for (int j=i+1; j<N-1; ++j) {
      auto l = j+1;
      auto r = N;
      
      while (l < r) {
        auto mid = l + (r - l) / 2;
        if (L.at(i) >= L.at(mid) + L.at(j)) {
          r = mid;
        } else {
          l = mid + 1;
        }
      }
      ans += l - j - 1;
    }
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 main(){
    string s;
    cin>>s;
    reverse(ALL(s));
    int i=0;
    string ss[4]={"dream","dreamer","erase","eraser"};
    rep(i,4){
        reverse(ALL(ss[i]));
    }
    string tmp="";
    while(i<s.size()){
        tmp+=s[i];
        rep(i,4){
            if(ss[i]==tmp){
                tmp="";
            }
        }
        i++;
    }
    if(tmp==""){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

int n;

void input() {
    cin >> n;
}

void solve() {
    int count;
    if( n < 10) {
        count = n;
    } else if (n >= 10 && n < 100) {
        count = 9;
    } else if (n >= 100 && n < 1000) {
        count = n - 99 + 9;
    } else if (n >= 1000 && n < 10'000) {
        count = 909;
    } else if (n >= 10'000 && n < 100'000) {
        count = n - 9999 + 909;
    } else if (n == 100'000) {
        count = 90909;
    }
    cout << count << endl;

}



int main() {
    input();
    solve();

}


Measured memory_bytes: 256
S = [19,29,59,79,89,109,139,149,179,199,229,269,349,359,379,389,409,419,439,449,479,499,509,569,599,619,659,709,719,739,769,809,829,839,859,919,929,1009,1019,1039,1049,1069,1109,1129,1229,1249,1259,1279,1289,1319,1459,1489,1499,1549,1559,1609,1619,1949,1999,2029]
N = int(input())

for i in range(N):
  print(S[i], end=" ")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	vector<vector<int>> A(N, vector<int>(20));
	for (int i = 0; i < N; i++) {
		ll a; cin >> a;
		for (int j = 0; a > 0; j++) {
			A[i][j] = a % 2;
			a /= 2;
		}
	}
	vector<int> bit(20);
	ll ans = 0, right = 0;
	
	for (int i = 0; i < N; i++) {
		bool flag = true;
		for (int j = 0; j < 20; j++) {
			if (A[i][j] == 1 && bit[j] == 1) flag = 0;
		}
		
		if (flag) {
			ans += (i - right + 1);
			for (int k = 0; k < 20; k++) {
				bit[k] = (bit[k] + A[i][k]) % 2;
			}

		}
		else {
			for (int k = 0; k < 20; k++) {
				bit[k] = (bit[k] + A[right][k]) % 2;
			}
			right++, i--;
		}
	}
	cout << ans << endl;
}


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

vector<int> enumDiv(int n) {
  vector<int> ret;
  for(int i = 1 ; i*i <= n ; ++i) {
    if (n%i == 0) {
      ret.push_back(i);
      if (i != 1 && i*i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}

int main() {
  int n, c = 0;
  cin >> n;
  for (int i = 1; i <= n; i+=2) {
    if (enumDiv(i).size() == 7) ++c;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256