akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

class LCA
{
  int n, log_n;
  vector<vector<int>> parent;
  vector<int> depth;
  void dfs(const vector<vector<int>> &g, int v, int p, int d)
  {
    parent[0][v] = p;
    depth[v] = d;
    for (int i = 0; i < (int)g[v].size(); i++)
    {
      if (g[v][i] != p)
        dfs(g, g[v][i], v, d + 1);
    }
  }

public:
  LCA(const vector<vector<int>> &g, int root) : n(g.size()), log_n(0), depth(n, 0)
  {
    for (int v = n; v > 0; v /= 2)
      log_n++;
    parent.assign(log_n, vector<int>(n, 0));
    dfs(g, root, -1, 0);
    for (int k = 0; k < log_n - 1; k++)
    {
      for (int v = 0; v < n; v++)
      {
        if (parent[k][v] < 0)
          parent[k + 1][v] = -1;
        else
          parent[k + 1][v] = parent[k][parent[k][v]];
      }
    }
  }
  int query(int u, int v)
  {
    if (depth[u] > depth[v])
      swap(u, v);
    for (int k = 0; k < log_n; k++)
    {
      if (((depth[v] - depth[u]) >> k) & 1)
      {
        v = parent[k][v];
      }
    }
    if (u == v)
      return u;
    for (int k = log_n - 1; k >= 0; k--)
    {
      if (parent[k][u] != parent[k][v])
      {
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
};

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

    int n;cin>>n;
    vector<vector<int>> g(n);
    for(int i=0;i<n;i++){
        int k;cin>>k;
        for(int j=0;j<k;j++){
            int c;cin>>c;
            g[i].push_back(c);
        }
    }
    LCA lca(g,0);
    int q;cin>>q;
    for(int i=0;i<q;i++){
        int u,v;cin>>u>>v;
        cout<<lca.query(u,v)<<endl;
    }
}



Measured memory_bytes: 18444
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   string s;
   cin >> s;
   char p[] = {s[0], s[1], s[2]};
   sort(p, p+3);
   if (p[0]=='a' && p[1]=='b' && p[2]=='c') cout << "Yes" << endl;
   else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    int K=scan.nextInt();
    int Q=scan.nextInt();
    int[] A=new int[Q];
    int[] porson=new int[N];
    for(int i=0;i<Q;i++){
      A[i]=scan.nextInt();
    }
    for(int i=0;i<N;i++){
      porson[i]=K-Q;
    }
    for(int i=0;i<Q;i++){
          porson[A[i]-1]+=1;
    }
    for(int i=0;i<N;i++){
      if(porson[i]>0){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 59944
def sum_n(n,M):
    return n*(n+1)//2 % M

def cmb(n,k,M):
    max_sum,min_sum = sum_n(n,M)-sum_n(n-k,M),sum_n(k-1,M)
    return (max_sum - min_sum + 1) % M

N,K = map(int,input().split())
M = 10**9+7

ans = 0
for k in range(K,N+2):
    ans = (ans + cmb(N,k,M)) % M

print(ans)


Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <utility>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;cin>>s;
    set<char> st;
    REP(i,s.size()){
        st.insert(s[i]);
    }
    if(st.size()==2) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();
 
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif   */

    int n, m; cin >> n >> m;
    cout << ((n * (n - 1)) >> 1)  + ((m * (m - 1)) >> 1) << endl;

    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

typedef vector<int> VI;
typedef pair<int, int> PII;

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

int SEG[10] = {
	0x01111110,
	0x00110000,
	0x01101101,
	0x01111001,
	0x00110011,
	0x01011011,
	0x01011111,
	0x01110010,
	0x01111111,
	0x01111011
};

int t, n;
int d = 0;

void solve(int n)
{
	int s = SEG[n];
	REP(i, 7)
	{
		if((s&1) ^ (d&1)) cout << "1";
		else cout << "0";
		s >>= 4;
		d >>= 4;
	}
	cout << endl;
	d = SEG[n];
}

int main()
{
	while( 1 )
	{
		cin >> t;
		if(t==-1)
			break;

		d = 0;
		REP(i, t)
		{
			cin >> n;
			solve(n);
		}
	}
}

Measured memory_bytes: 0
#include <iostream>

using namespace std ;

int main(void){
    int s=0;
    int N, n;

    cin >> N;

    n = N;
    while(n != 0){
        s  += n % 10;
        n /= 10;
    }

    // cout <<  N << s << endl;
    if(N % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

#define ll long long
#define ln "\n"
#define fastio ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define mod 1e9 + 7
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main()
{
    fastio;

    int n;
    cin>>n;
    int a,b;
    int streak=0;
    vector<int>v;
    while (n--)
    {
        cin>>a;
        cin>>b;
        v.push_back(a);
        v.push_back(b);
    }
    for(int i=0; i<v.size(); i+=2){
        if(v[i]==v[i+1]){
            streak++;
        }
        if(streak>=3){
            break;
        }
        if(streak!=0 && v[i]!=v[i+1]){
            streak=0;
        }
    }
    if(streak>=3){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3660
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())

# i % i+1 = i が最善, あまりは 1 〜 N-1 
print(N*(N-1)//2)

Measured memory_bytes: 2940
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    w=parseInt(readline())
    for i in 1:w:length(s)
        print(s[i])
    end
end
main()

Measured memory_bytes: 108156
s = str(input().rstrip())
l = len(s)

judge = []
for i in range(l-2):
    temp = str(s[i]) + str(s[i+1]) + (s[i+2])
    base = int(temp)-753
    if base < 0:
        base = -base
    judge.append(base)
print(min(judge))

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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

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


vector<int> adj[200001];
vector<int> vis1(200001,0);
vector<int> vis(200001,0);

int len;
void dfs(int i){
	
	vis[i]=1;
	len++;
	for(auto j:adj[i]){
		if(!vis[j]){
		
		dfs(j);	
		}
	}
	
}


void solve() 
{
	int n;
	cin>>n;
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
	
	
		adj[a].push_back(b);
		adj[b].push_back(a);
		vis1[a]=1;
		vis1[b]=1;	
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
		len=0;
		dfs(i);
		ans=max(ans,len);	
		}
	}
	cout<<ans;
}



int  main(){
ll t;
//cin>>t;
t=1;
while(t--){
		solve();
	cout<<endl;
}
			
}

Measured memory_bytes: 21872
<?php
$n = trim(fgets(STDIN));

$i = 0;
while($i < $n){
list($a[$i],$b[$i]) = explode(" ",trim(fgets(STDIN)));
++$i;
}
$ans = 0;
--$i;
while($i >= 0){
$N = $a[$i] + $ans;
$d = $b[$i] * ceil($N / $b[$i]) - $N;
$ans += $d;
--$i;
}

echo $ans;
?>

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

#define what_is(x) cerr << #x << " is " << x << endl;

const ll LMAX = (1LL<<61);
const int IMAX = (1<<29);
const int BIG = 104206970;
const int PRIME = 104206969;

const int N = 100001;
const int MOD = 1e9+7;

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// cout.precision(9); cout << fixed;
	int n; cin >> n;
	pair<int,int> seg[n];
	for (int i = 0; i < n; i++) {
		int x, l; cin >> x >> l;
		seg[i] = {x+l, x-l};
	}
	sort(seg,seg+n);
	int ans = 0;
	int ptr = -MOD;
	for (int i = 0; i < n; i++) {
		if (ptr <= seg[i].second) {
			ans++;
			ptr = seg[i].first;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;

void solve() {  
    ll n;
    cin >> n;
    vector<ll> dp(n+1);
    for(int i=1;i<=n;i++) {
        for(int j=i;j<=n;j+=i) {
            dp[j]++;
        }
    }
    ll sum = 0;
    for(int i=1;i<=n;i++) {
        sum+=(dp[i]*i);
    }
    cout << sum << endl;
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 81328
using System;
class Atcoder_Templete
{
    static void Main(string[] args)
    {
        string[] input_string = Console.ReadLine().Split(' ');
        int A = int.Parse(input_string[0]);
        int B = int.Parse(input_string[1]);

        int result = -1;
        
        if(Judge(A)&& Judge(B))
        {
            result = A * B;
        }

        //出力
        Console.WriteLine(result);
    }

    public static bool Judge(int X)
    {
        bool a = 1 <= X;
        bool b = X <= 9;
        return a && b;
    }

}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <map>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;

ll exgcd(ll a,ll b,ll &x,ll &y)
{
    ll d=a;
    if(b!=0)
    {
        d=exgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }else{
        x=1;y=0;
    }
    return d;
}
ll a[maxn],b[maxn];
int main()
{
    ll t;
    //cout<<gcd(16,12);

        ll n,m;
        cin>>n>>m;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
            b[i]=a[i]/2;
        ll m1=a[0],yu=b[0],m2,flag=0;
        for(int i=1;i<n;i++)
        {
            ll x,y;
            m2=a[i];
            ll d=exgcd(m1,m2,x,y);
            ll r=b[i]-yu;
            /*cout<<d<<"  d"<<endl;
            cout<<m1<<"  m1"<<endl;
            cout<<m2<<"  m2"<<endl;
            cout<<x<<"  x"<<endl;
            cout<<y<<"  y"<<endl;*/
            if(r%d!=0||yu>m)
            {
                flag=1;
                break;
            }
            x=((r/d*x)%(m2/d)+(m2/d))%(m2/d);
            yu=x*m1+yu;
            m1=m1/d*m2;
        }
        if(flag||yu>m)
            cout<<"0"<<endl;
        else
            cout<<(m-yu)/m1+(yu==0?0:1)<<endl;
    return 0;
}
/*
3
10 3
1 2 3
0 1 2
100 7
3 4 5 6 7 8 9
1 2 3 4 5 6 7
10000 10
1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9
*/



Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

fn f(x: usize, y: usize, z: usize) -> usize {
    x * x + y * y + z * z + x * y + y * z + z * x
}

fn g(
    n: usize,
    x: usize,
    y: usize,
    z: usize,
    map: &mut HashMap<usize, HashSet<(usize, usize, usize)>>,
) {
    let v = f(x, y, z);
    if v > n {
        return;
    }
    let set = map.entry(v).or_insert(HashSet::new());
    if set.contains(&(x, y, z)) {
        return;
    } else {
        set.insert((x, y, z));
    }
    g(n, x + 1, y, z, map);
    g(n, x, y + 1, z, map);
    g(n, x, y, z + 1, map);
    g(n, x + 1, y + 1, z, map);
    g(n, x + 1, y, z + 1, map);
    g(n, x, y + 1, z + 1, map);
    g(n, x + 1, y + 1, z + 1, map);
}

#[fastout]
pub fn main() {
    input! {
        n: usize,
    }

    let mut map = HashMap::new();
    g(n, 1, 1, 1, &mut map);

    for i in 1..=n {
        let v = map.entry(i).or_insert(HashSet::new()).len();
        println!("{}", v);
    }
}


Measured memory_bytes: 13832
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
long long p10[10];
int main(){
	int a;scanf("%d",&a);
//	mod=b;
	p10[0]=1;
	for(int i=1;i<10;i++)p10[i]=p10[i-1]*10;
	long long ret=0;
	// 小さいの
	for(int i=1;i<=9;i++){
		for(int j=i;j<=9;j++){
			long long cur=0;
			for(int k=i+1;k<j;k++){
				cur+=k*(p10[k]-p10[k-1]);
			}
			if(cur>a)continue;
			if(i==j){
				if(a%i||(a/i)>p10[i]-p10[i-1])continue;
				ret=(ret+p10[i]-p10[i-1]-(a/i)+1)%mod;
	//			printf("%d %d: %lld\n",i,j,ret);
				continue;
			}
			for(int k=1;k<=p10[i]-p10[i-1];k++){
				long long t=a-cur-k*i;
				if(t<=0)break;
				if(t%j)continue;
				if(t/j<=p10[j]-p10[j-1])ret++;
			}
			ret%=mod;
	//		printf("%d %d: %lld\n",i,j,ret);
		}
	}
	// 8888888みたいなやつ
	int rem=(a-1)/9;
	for(int i=1;i*i<=a;i++){
		if(a%i==0){
			int S=i;
			int T=a/i;
			if(S>9){
				rem--;
		//		printf("%d\n",S);
				ret=(ret+pw(10,S)+mod-pw(10,S-1)+1+mod-T)%mod;
			}
			if(S==T)continue;
			if(T>9){
				rem--;
		//		printf("%d\n",T);
				ret=(ret+pw(10,T)+mod-pw(10,T-1)+1+mod-S)%mod;
			}
		}
	}
	//printf("%lld\n",ret);
	// 8888999みたいなやつ
	ret=(ret+rem)%mod;
	printf("%lld\n",ret);
}

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

const int INF = 1e9;
int h, w;
char grid[110][110];
int dp[110][110];

int main(){
  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> grid[i][j];
  rep(i, h) rep(j, w) dp[i][j] = INF;
  
  
  if(grid[0][0] == '#'){
    dp[0][0] = 1;
  }else{
    dp[0][0] = 0;
  }
  
  for(int i = 1; i < h; i++){
    dp[i][0] = dp[i - 1][0];
    if(grid[i][0] == '#' && grid[i - 1][0] == '.'){
      dp[i][0]++;
    }
  }
  for(int i = 1; i < w; i++){
    dp[0][i] = dp[0][i - 1];
    if(grid[0][i] == '#' && grid[0][i - 1] == '.'){
      dp[0][i]++;
    }
  }
  
  for(int i = 1; i < h; i++){
    for(int j = 1; j < w; j++){
      if(grid[i][j] == '#' && grid[i][j - 1] == '.'){
        dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
      }else{
        dp[i][j] = min(dp[i][j], dp[i][j - 1]);
      }
      
      if(grid[i][j] == '#' && grid[i - 1][j] == '.'){
        dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
      }else{
        dp[i][j] = min(dp[i][j], dp[i - 1][j]);
      }
    }
  }
  
  //rep(i, h) { rep(j, w) cerr << dp[i][j]; cerr << endl; }
  
  cout << dp[h - 1][w - 1] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
    long long n,m,a[1000],ans,num;
    cin >> n >> m;
        num=0;
        ans=0;
        if(n==0&&m==0)  break;
    for(int i=0;i<n;i++)    cin >> a[i];
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            num = a[i]+a[j];
            if(num<=m)
            ans = max(ans,num);
        }
    }
        if(ans==0)  cout <<"NONE"<<endl;
        else    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3084
import sys

n = input()

i = 0
if len(n) % 2 == 0:
    while True:
        if n[i] == 'h' and n[i+1] == 'i':
            if i == len(n) - 2:
                print('Yes')
                sys.exit()
        else:
            print('No')
            sys.exit()
        i += 2
else:
    print('No')
    sys.exit()


Measured memory_bytes: 2940
import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();

        int point[] = new int[n];
        for(int i = 0; i < n; i++){
            point[i] = 0;
        }
        for(int i = 0; i < q; i++){
            int a = sc.nextInt();
            point[a-1] += 1;
        }
        for(int i = 0;i < n;i++){
            if(k - (q - point[i]) > 0){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 74488
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



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

    int ans =0 ;
    rep(i,0,10){
	int ii = s.find('0'+i);
	if(ii == -1)continue;
	string ss = s.substr(ii+1);

	rep(j,0,10){
	    int jj = ss.find('0'+j);
	    if(jj == -1)continue;
	    string sss = ss.substr(jj+1);
	    
	    rep(k,0,10){
		int kk = sss.find('0'+k);
		if(kk == -1)continue;
		ans++;
		//	cout << i << j << k << endl;
	    }
	}
    }
    P(ans);
    return  0;
}


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

void Constraints(int a,int b,char op)
{
  if(!(0<=a&&a<=200000&&0<=b&&b<=200000&&(op=='+'||op=='-'||op=='*'||op=='/'||op=='?'))){
    printf("条件を満たす入力をしてください。\n");
    exit(0);
  }
}

int Operator(int a,int b,char op)
{
  switch(op)
  {
    case '+': return (a+b);
    break;
    case '-': return (a-b);
    break;
    case '*': return (a*b);
    break;
    case '/':
    if(b==0)
    {
      printf("0 による割り算はできません。");
      exit(0);
    }
    else{return a/b;}
    break;
    case '?': return NULL;
    break;
  }
}

int main(void)
{
  int a,b;
  char op=' ';
  while(op!='?')
  {
    scanf("%d %c %d",&a,&op,&b);
    Constraints(a,b,op);
    if(op=='?'){
      break;
    }
    printf("%d\n",Operator(a,b,op));
  }
  return 0;
}



Measured memory_bytes: 2104
N,M = map(int,input().split())
node = [] 
dic = {}
for _ in range(M):
  a,b = map(int,input().split())
  dic[a] = dic.get(a,0) + 1
  dic[b] = dic.get(b,0) + 1
for k in dic:
  if dic[k]%2==1:
    print("NO")
    break
else:
  print("YES")
  
  

Measured memory_bytes: 51288
#include <bits/stdc++.h>
using namespace std;
 
const int N = 3000 * 100 + 10, inf = 1e9;

long long t[N];
 
int main()
{
	int n, c, k;
	cin >> n >> c >> k;
	for (int i = 0; i < n; i++)
		cin >> t[i];
	sort(t, t + n);
	int ans = 0, time = 0, cur = 0, f = -1;
	for (int i = 0; i < n; i++)
	{
		if(f == -1)
		{
			ans++;
			time = t[i], cur = 1, f = i;
		}
		else
		{
			if(t[f] + k >= t[i] && cur < c)
			{
				time = t[i], cur++;
			}
			else
			{
				f = -1, i--;
				continue;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll a,b,c,sum=0;
  cin>>a>>b;
  c = b - a;
  for(int i=1;i<c;i++){
    sum += i;
  }
  cout<<sum-a<<"\n";
  return(0);
}

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

sList = []
for i in range(n-1):
  sList.append(tuple(map(int,input().split())))

#print("sLIst",sList)

for i in range(len(sList)):
  timeCount = sList[i][1]+sList[i][0] 
  for j in range(i+1,len(sList)):
    if timeCount < sList[j][1]:
      timeCount = sList[j][1]
      
    timeTmp = timeCount % sList[j][2]
    if timeTmp == 0:
      timeCount += sList[j][0]
    else:
      timeCount += sList[j][2] - timeTmp + sList[j][0]
  print(timeCount)

print(0)
 

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io
    
    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];

    ll ans=100100100100100;
    for(int j=-100;j<=100;j++) {
        ll cost=0;
        rep(i,n){
            cost+=(a[i]-j)*(a[i]-j);
        }
        ans=min(ans, cost);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    sort(s, s + n);
    // for(int i = 0; i < n; i++){
    //     cout << s[i] << '\n';
    // } 
    pair<int,string> p[n];
    p[0].first = 1;
    p[0].second = s[0];
    int num = 0;
    for(int i = 1; i < n; i++){
        if (p[num].second == s[i]) {
            p[num].first++;
        }else{
            p[num+1].second = s[i];
            p[num+1].first = 1;
            num++;
        }
    }
    int mx = 0;
    for(int i = 0; i <= num; i++){
        if (p[i].first > mx) {
            mx = p[i].first;
        }
    }
    for(int i = 0; i <= num; i++){
        if (p[i].first == mx) {
            cout << p[i].second << "\n";
        }
        
    }
    
}

Measured memory_bytes: 17408
P = 998244353

N, S = map(int, input().split())
A = list(map(int, input().split()))

dp0 = [[0]*(S+1) for _ in range(N)]
dp1 = [[0]*(S+1) for _ in range(N)]
dp2 = [[0]*(S+1) for _ in range(N)]

dp0[0][0] = 1
dp1[0][0] = 1
if A[0] <= S:
    dp1[0][A[0]] = 1

for i in range(1, N):
    dp0[i][0] = 1
    dp1[i][0] = dp1[i-1][0] + 1
    dp2[i][S] = dp2[i-1][S] + dp1[i-1][S]
    if A[i] == S:
        dp2[i][S] += dp1[i-1][0] + 1
        dp1[i][S] += dp1[i-1][0] + 1
    elif A[i] < S:
        dp1[i][A[i]] += 1 + dp1[i-1][0]
    for j in range(1, S+1):
        dp1[i][j] += dp1[i-1][j]
        if j + A[i] < S:
            dp1[i][j+A[i]] += dp1[i-1][j]
        elif j + A[i] == S:
            dp2[i][S] += dp1[i-1][j]
            dp1[i][S] += dp1[i-1][j]
        dp0[i][j] %= P
        dp1[i][j] %= P
        dp2[i][j] %= P

print(dp2[N-1][S])

Measured memory_bytes: 248460
#include <bits/stdc++.h>
using namespace std;
using Pi = pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<Pi, vector<Pi>, greater<Pi>> AB;
  for (int i = 0; i < N; ++i) {
    Pi p;
    cin >> p.first >> p.second;
    AB.push(p);
  }
  int ans = 0;
  priority_queue<int> can;
  for (int i = 1; i <= M; ++i) {
    while (!AB.empty() && AB.top().first <= i) {
      can.push(AB.top().second);
      AB.pop();
    }
    if (!can.empty()) {
      ans += can.top();
      can.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	long long int x, y,ans=0,tmp=0;
	cin >> x >> y;
	ans++;
	tmp = x * 2;
	while(tmp<=y){
		ans++;
		tmp = tmp * 2;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if((a != b && b != c && a != c) || (a == b && a == c && b == c)) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

/*
https://atcoder.jp/contests/abc177/tasks/abc177_e
http://tutuz.hateblo.jp/entry/2018/10/03/074039
*/

const int mx=1'000'100;

vector<ll> minfactor(1'000'100,-1);

//エラトステネスの篩,n以下の素数の列挙の時に
//primeはi番目の素数、適当に返却を変えて
template <class T>
void sieve(T n){
	vector<bool> is_prime(n+1,true);
	vector<ll> prime;
	is_prime[0]=false;
	is_prime[1]=false;
	T ret=0;
	FOR(i,2,n+1){
		if(is_prime[i]){
			prime.push_back(i);
			minfactor[i]=i;
			for(T j=2*i;j<=n;j+=i){
				is_prime[j]=false;
				if(minfactor[j]==-1) minfactor[j]=i;
			}
		}
	}
}

//素因数分解
template <class T>
vector<P> prime_factor(T x){
    vector<P> ret;
	while(x!=1){
		ll tmp=minfactor[x],cnt=0;
		while(x%tmp==0){ 
			x/=tmp;
            cnt++;
		}
        ret.push_back(P(tmp,cnt));
	}
    return ret;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll g=0;
	sieve(mx);
	vector<ll> cnt(mx,0);
	rep(i,n){
		ll a;
		cin>>a;
		g=gcd(g,a);
		for(auto [x,y]:prime_factor(a)){
			cnt[x]++;
		}
	}
	if(g!=1){
		cout<<"not coprime"<<endl;
		return 0;
	}
	for(auto x:cnt){
		if(x>=2){
			cout<<"setwise coprime"<<endl;
			return 0;
		}
	}
	cout<<"pairwise coprime"<<endl;
}

Measured memory_bytes: 19068
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<vector<int> > A;
const int MX = 1 << 21;
int dp[MX];
int N;
int solve(int a) {
	if (dp[a] == -1) {
		dp[a] = 0;
		int x = 0;
		for (int i = 0; i < N; i++) {
			if (a & (1 << i))x++;
		}
		for (int i = 0; i < N; i++) {
			if (A[x][i] == 1) {
				if ((a & (1 << i)) == 0) {
					dp[a] = (dp[a] + solve(a ^ (1 << i))) % MOD;
				}
			}
		}
	}
	return dp[a];
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	A.resize(N, vector<int>(N));
	int res = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < (1 << N); i++) {
		dp[i] = -1;
	}
	dp[(1 << N) - 1] = 1;
	cout << solve(0)<< endl;
}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<fixed<<(int)(ceil((double)n/x)*t)<<setprecision(6)<<"\n";
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
const int MAXN = 1e5 + 10;
int nums[MAXN], dp[MAXN], tree[MAXN<<1];
LL n;
int lowbit(int i) {
    return i&(-i);
}
LL query(int i) {
    LL ret = 0;
    while (i > 0) {
        ret += tree[i];
        i -= lowbit(i);
    }
    return ret;
}
void add(int i) {
    while (i < (MAXN<<1)) {
        tree[i]++;
        i += lowbit(i);
    }
}
LL solve(LL val) {
    for (int i = 1; i <= n; i++) {
        if (nums[i-1] >= val) dp[i] = 1;
        else dp[i] = -1;
    }
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        dp[i] += dp[i-1];
    }
    for (int i = 0; i <= n; i++) {
        dp[i] += MAXN;
    }
    memset(tree, 0, sizeof(tree));
    LL ret = 0;
    for (int i = 0; i <= n; i++) {
        ret += query(dp[i]);
        add(dp[i]);
    }
    return ret;
}



int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
#ifdef LOCAL
    freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    if (n == 1) {
        cout << nums[0] << endl;
        return 0;
    }
    LL a = 1, b = 1e9;
    LL tot = n * (n+1) / 2 + 1;

    while (a < b) {
        LL mid = (a+b + 1) >> 1;
        if (solve(mid) >= tot/2) a = mid;
        else b = mid - 1;
    }
    cout << a << endl;


/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
    return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 1792
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, mw;
	cin >> n >> mw;
	vector<long long> memo;
	memo.resize(n*1000 + 1, 2147483647);
	memo[0] = 0;
	for (int i = 0; i < n; i++) {
		int w, v;
		cin >> w >> v;
		for (int j = memo.size() - 1; j >= v; j--) {
			memo[j] = min(memo[j], memo[j - v] + w);
		}
	}
	for (int i = memo.size() - 1; i >= 0; i--) {
		if (memo[i] <= mw) {
			cout << i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	s, t := next(), next()
	if len(s)+1 != len(t) {
		fmt.Println("No")
		return
	}
	if !strings.Contains(t, s) {
		fmt.Println("No")
		return
	}

	if strings.Index(t, s) != 0 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll ret = 0;
string str;
stack<char> s;
char c;
char ne;

void input() {
  IN(str);
}

void solve() {
  REP(i, str.size()){
    if (s.size() == 0){
      s.push(str[i]);
    } else {
      c = s.top();
      ne = str[i];
      if(c != ne){
        s.pop();
        ret += 2;
      } else {
        s.push(ne);
      }
    }
  }
}

int main(void){
  input();
  solve();
  PRINT(ret);
}


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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');
    cout.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

int main(){
    nimble;
    int n;
    string s;
    cin>>s;
    n=_sz(s);
    n--;
    if(s[n]=='s')
        s+="es";
    else s+="s";
    cout<<s;
    return 0;
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

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

int main(void) {
    int n,m;
    int dp[100010]={};
    int count=0;

    cin>>n>>m;
    int l,r;
    FOR(i,1,m){
        cin>>l>>r;
        dp[l]++;
        dp[r+1]--;
    }
    FOR(i,0,100009) {
        dp[i+1]+=dp[i];
    }
    FOR(i,0,100009){
        if(dp[i]==m){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 768
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[2,4,5,7,9]
if n%10==3:
    print("bon")
elif n%10 in lis:
    print("hon")
else:
    print("pon")

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

using namespace std;

int main(){
    int N,count=0;
    string S;


    //入力
    cin >> N >> S;

    for(int i=1; i<N; i++){
        if(S[i] == S[i-1]) {
            count++;
        }
    }
    cout << N-count << endl; 

    return 0;
}

Measured memory_bytes: 512
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

int lsb(int x)
{
    int res=log2(x&-x);
    return res;
}

void solve()
{
    int n,m;
    cin>>n>>m;

    set<int> st;
    for(int i=0;i<n;++i)
    {
        int x;
        cin>>x;

        st.ins(x);
    }

    vi v;
    for(auto c:st)
        v.pb(c);
    n=sz(v);

    int arr[32]={0};
    for(int i=0;i<n;++i)
    {
        ++arr[lsb(v[i])];
    }

    for(int i=0;i<32;++i)
    {
        if(arr[i])
        {
            if(arr[i]!=n)
            {
                cout<<0;
                return;
            }

            break;
        }
    }

    int l=1;
    for(int i=0;i<n;++i)
    {
        l=lcm(l,v[i]);

        if(l/2>m)
        {
            cout<<0;
            return;
        }
    }

    int a=l/2;

    //cout<<pos<<" "<<a<<" "<<l<<"\n";

    m-=a;
    if(m<0)
        cout<<0;
    else
        cout<<m/l+1;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long n,ans,now=-1; 
int main()
{
	cin>>n;
	while(n)
	{
		n/=2;
		now++;
		ans+=pow(2,now);
	}
	cout<<ans;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem D

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    a_max = max(a)
    a.remove(a_max)
    a = sorted(a)

    # See:
    # https://www.youtube.com/watch?v=RwWljbtCrPA
    # https://img.atcoder.jp/arc095/editorial.pdf
    diff = float('inf')
    center = 0

    for ai in a:
        current_diff = abs(a_max / 2 - ai)

        if current_diff < diff:
            diff = current_diff
            center = ai

    print(str(a_max) + ' ' + str(center))


Measured memory_bytes: 14060
from collections import Counter
n = int(input())
s = [Counter(input()) for _ in range(n)]

ans = ""
for x in ([chr(i) for i in range(97, 97+26)]):
    tmp = 100
    for S in s:
        if x in S.keys():
            tmp = min(tmp, S[x])
        else:
            tmp = 100
            break
    if tmp != 100:
        ans += x * tmp

print(ans)

Measured memory_bytes: 3316