akhauriyash/Code-Regression huggingface dataset:
a={1,3,5,7,8,10,12}
b={4,6,9,11}
c={2}

nums=[None]*12
for i in a:
  nums[i-1]="a"
for i in b:
  nums[i-1]="b"
for i in c:
  nums[i-1]="c"
x,y=map(int,input().split())
if nums[x-1]==nums[y-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

ll MOD = 998244353;
ll FAC_MAX = 2 * 1e5;

ll mpow(ll a, ll n) {  // a^n (mod MOD)
    // 二分累乗法 O(log n)
    ll ans = 1;
    while (n != 0) {
        if (n & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ans;
}

vi fac_vec;
ll fac(ll n) {  // n! (mod MOD)
    if (fac_vec.empty()) {
        fac_vec = vi(FAC_MAX + 10);  // (FAC_MAX+10)! まで対応
        fac_vec[0] = 1;
        for (ll i = 1; i < fac_vec.size(); i++) {
            fac_vec[i] = (fac_vec[i - 1] * i) % MOD;
        }
    }
    return fac_vec[n];
}

vi ifac_vec;
ll ifac(ll n) {  // (n!)^(-1) (mod MOD)
    // フェルマーの小定理より、k^(-1)≡k^(MOD-2) なので、
    // (n!)^(-1)≡(n!)^(MOD-2)
    if (ifac_vec.empty()) {
        ifac_vec = vi(FAC_MAX + 10);  // {(FAC_MAX+10)!}^(-1) まで対応
        ifac_vec[0] = 1;
        for (ll i = 1; i < ifac_vec.size(); i++) {
            ifac_vec[i] = (ifac_vec[i - 1] * mpow(i, MOD - 2)) % MOD;
        }
    }
    return ifac_vec[n];
}

ll comb(ll a, ll b) {  // aCb (mod MOD)
    // aCb = a! * (b!)^(-1) * {(a-b)!}^(-1)
    if (a < b || a < 0 || b < 0) return 0;
    return (fac(a) * ifac(b) % MOD) * ifac(a - b) % MOD;
}

ll dupc(ll a, ll b) {  // aHb (mod MOD) 重複あり組み合わせ
    // aHb = (a+b-1)Cb
    return comb(a + b - 1, b);
}

int main() {
    ll N, M, K, ans = 0;
    cin >> N >> M >> K;
    for (ll i = 0; i <= K; i++) {
        // 色の順列 M*(M-1)^(N-i-1)
        ll x = (M * mpow(M - 1, N - i - 1)) % MOD;
        // i個の分け方 comb(N-i, i)
        ll y = dupc(N - i, i);
        ans += (x * y) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6384
#include<stdio.h>

int main() {
	long long int a, b, c, d, n, m = 0, result = 1000000, w[350000] = {}, e[350000] = {};
	char str[340000];
	scanf("%lld%s", &n,str);
	for (int i = 0; i < n;i++) {
		if (str[i] == 'W') { w[i + 1] = w[i] + 1; e[i + 1] = e[i];}
		else { e[i + 1] = e[i] + 1; w[i + 1] = w[i]; }
	}
	for (int i = 1; i <= n; i++) {
      
		if(result>e[n]-e[i]+w[i-1]){ result = e[n] - e[i] + w[i - 1] - w[0];}
     
	}
	printf("%lld", result);
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
    using namespace std;
         
    #define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define pb push_back
    #define ll long long
    #define ld long double
    #define vll vector<long long>
    #define infl LONG_LONG_MAX
    #define infd LDBL_MAX
    #define F first
    #define S second
    #define pll pair<ll,ll> 
    #define G(a,b) get<a>(b)
    #define ALL(v) v.begin(),v.end()
    #define MP make_pair
    #define MT make_tuple
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define fi(i,a,b) for(ll i=(b-1);i>=a;i--)    
    #define endl "\n"
    #define nl cout<<"\n";
    #define pr(x) cout<<x;
    #define pr1(x) cout<<x<<" ";
    #define pr2(x,y) cout<<x<<" "<<y;

    ll p=1e9+7;
      
    ll modpro(ll x,ll y,ll z=1)
    {
      x%=p;
      y%=p;
      z%=p;
      ll res=(x*y)%p;
      res=(res*z)%p;
      return res;
    }
     
    ll modadd(ll x,ll y,ll z=0)
    {
      x%=p;
      y%=p;
      z%=p;
      ll res=(x+y)%p;
      res=(res+z)%p;
      return res;
    }
    
    const ll N=2e5+5;
    ll col[N],dp[N],cnt[N];

    void func()
    {
       ll n;
       cin>>n;

       f(i,1,n+1) cin>>col[i];
       col[0]=infl;

       dp[0]=1;
       f(i,1,n+1)
       {
         if(col[i]==col[i-1]) dp[i]=dp[i-1];
         else 
         {
            dp[i]=modadd(dp[i-1],cnt[col[i]]);
            cnt[col[i]]=modadd(cnt[col[i]],dp[i-1]);
         }
       }

       pr(dp[n]) nl
    }     
     
     
    int main() 
    {
        fast
        //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //#endif // ONLINE_JUDGE
        
     
        ll ntc=1;
        //cin>>ntc;
     
        f(i,1,ntc+1)
        {
          //cout<<"Case #"<<i<<": ";
          func();
        }
     
        return 0;
    }

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    int ans = 0, l = s.size();
    string t, p = "";
    rep(i, l) {
        t += s[i];
        if(t == p) continue;
        p = t;
        t = "";
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
N, L = list(map(int, input().split()))

s = sum(range(L, L+N))
LL = L + N - 1
if L >= 0:
    print(s - L)
elif L < 0 and LL >= 0:
    print(s)
elif L < 0 and LL < 0:
    print(s - LL)


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#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 debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;

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

  LL ans;
  int N;
  cin >> N;

  LL L[100] = {};
  L[0] = 2;
  L[1] = 1;

  FOR(i, 2, N + 1) { L[i] = L[i - 1] + L[i - 2]; }

  cout << L[N] << '\n';

  return 0;
}

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

class Program
{
    public Program() { }


    Scanner cin;

    long[] All;
    long[] Pate;

    void myon()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int x = cin.nextInt();

        if(x == 1 || x == 2 * N - 1)
        {
            Console.WriteLine("No");
            return;
        }

        Console.WriteLine("Yes");

        int step = 1;
        for (int i = 0; i < N - 2; i++)
        {
            while (step >= x - 1 && step <= x + 1) { step++; }
            Console.Write(step + " ");
            step++;
        }
        Console.Write((x - 1) + " ");
        Console.Write((x - 0) + " ");
        Console.Write((x + 1) + " ");

        for (int i = 0; i < N - 2; i++)
        {
            while (step >= x - 1 && step <= x + 1) { step++; }
            Console.Write(step + " ");
            step++;
        }
    }

    static void Main(string[] args)
    {
        new Program().myon();
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

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

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

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

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

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

}


Measured memory_bytes: 16452
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int n;
vvi G;
pii dfs(int a){
	if(G[a].size()==0)return pii(0,0);
	int out=0;
	int de=0;
	vi tmp;
	rep(i,G[a].size()){
		pii b=dfs(G[a][i]);
		de=max(de,b.second+1);
		tmp.pb(-b.first-1);
	}
	sort(all(tmp));
	out=-tmp[0];
	int q=0;
	for(int i=tmp.size()-2;i>=0;i--){
		if(tmp[i]==tmp[i+1])q++;
		else{
			q-=tmp[i+1]-tmp[i]-1;
			if(q<0)q=0;
		}
	}
	out+=q;
	//if(-tmp[0]-i<-tmp[i])out++;
//	cout<<a<<" "<<out<<" "<<de<<endl;
//	rep(i,tmp.size())cout<<" "<<-tmp[i];cout<<endl;
	return pii(out,de);
}
int main(){
	cin>>n;
	G=vvi(n);
	rep(i,n-1){
		int a;
		cin>>a;
		G[a-1].pb(i+1);
	}
	cout<<dfs(0).first<<endl;
}










Measured memory_bytes: 15104
#include <stdio.h>

int main(void)
{
	int total;
	int book[9];
	int sum;
	int i;
	
	while (1){
		scanf("%d", &total);
		if (total == 0){
			break;
		}
		
		sum = 0;
		for (i = 0; i < 9; i++){
			scanf("%d", &book[i]);
			sum += book[i];
		}
		printf("%d\n", total - sum);
	}
	
	return (0);
}

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

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

    vector<long long> A(N);
    for (int i = 0; i < A.size(); i++)
    {
        cin >> A.at(i);
        if (A.at(i) == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    long long result = 1;
    long long max = 1000000000000000000;
    for (int i = 0; i < N; i++)
    {
        if (result > max / A.at(i))
        {
            result = -1;
            break;
        }
        else
        {
            result = result * A.at(i);
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 4000
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;

    ll K; cin >> K;
    ll A[N], B[M]; F0R(i, N) cin >> A[i];
    F0R(i, M) cin >> B[i];

    ll as = 0; F0R(i, N) as += A[i];
    ll bs = 0;
    int bp = 0;
    int ans = 0;
    F0Rd(i, N+1) {
        if (i < N) as -= A[i];
        if (as <= K) {
            while (bp < M && as + bs + B[bp] <= K) {
                 bs += B[bp]; bp++;
            }
            ckmax(ans, i + bp);
        }
//        cout << as << " " << bs << " " << bp << nl;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 6740
A, B = [int(_) for _ in input().split()]


def make(o, x, p):
    #文字列oが1個、xがp個
    #1列に50個まで
    lines = p // 50
    r = p % 50
    return [o * 100] + [(x + o) * 50, o * 100] * lines + [(x + o) * r +
                                                          (o + o) *
                                                          (50 - r), o * 100]


ans = make('.', '#', B - 1) + make('#', '.', A - 1)
print(len(ans), 100)
for s in ans:
    print(s)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int mod = int(1e+9) + 7;


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

  int f = 0;
  auto r = s.size() - 1;

  int ans = 0;
  while (f < r) {
    if (s[f] == s[r]) {
      f++;
      r--;
    } else if (s[f] == 'x') {
      f++;
      ans++;
    } else if (s[r] == 'x') {
      r--;
      ans++;
    } else if (f == r) {
      break;
    } else {
      ans = -1;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	
	int sum = 0;
	int koka[] = {1, 5, 10, 50, 100, 500};

	for(int i = 0; i < 6; i++){
		int c;
		cin >> c;
		sum += c * koka[i];
	}

	cout << (sum >= 1000 ? "1" : "0") << endl;

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int isSubstring(string s1, string s2) 
{ 
    int M = s1.length(); 
    int N = s2.length(); 
    for (int i = 0; i <= N - M; i++) { 
        int j; 
        for (j = 0; j < M; j++) 
            if (s2[i + j] != s1[j]) 
                break; 
        if (j == M) 
            return i; 
    } 
    return -1; 
} 
int main()
{
    rkc;
    /*string s,t;
    cin>>s>>t;
    if(s.length()==t.length())
    {
        int c=0;
        sort(s.begin(),s.end());
        sort(t.begin(),t.end());
        fl(i,0,s.length())if(s[i]==t[i])c++;
        if(c==t.length())cout<<"array";
        else cout<<"need tree";
    }
    else
    {
        int res=isSubstring(s,t),res1=isSubstring(t,s);
        if(res!=-1||res1!=-1)
        cout<<"automaton";
        else
        {
                sort(s.begin(),s.end());
                sort(t.begin(),t.end());
                if(isSubstring(s,t)||isSubstring(t,s))cout<<"both";
                else cout<<"need tree";
        }
    }*/
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1]=s[k-1]+32;
    cout<<s;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static String s = "";

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int ans = 0;

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] kurai = new int[N];
		for(int i=0; i<N; i++) {
			kurai[i] = -1;
		}

		for(int i=0; i<M; i++) {
			int s = sc.nextInt();
			int c = sc.nextInt();

			if(kurai[s-1] == -1) {
				kurai[s-1] = c;
			}else {
				if(kurai[s-1] != c) {
					ans = -1;
					break;
				}
			}
		}


		if(N == 1) {
			if(kurai[0] == -1) {
				kurai[0] = 0;
			}
		}
		else {
			for(int i=0; i<N; i++) {
				if(kurai[i] == -1) {
					if(i == 0)
						kurai[i] = 1;
					else
						kurai[i] = 0;
				}
			}
		}

		if(ans == -1 || (N != 1 && kurai[0] == 0))
			ans = -1;
		else {
			int j = 0;
			for(int i=N-1; i>=0; i--) {
				ans += kurai[i] * Math.pow(10, j);
				j++;
			}
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 25172
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var a = o.a();
  var b = o.a();
  return 6-a-b;
}

Measured memory_bytes: 21064
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n; scanf("%d",&n);
	ll a=1,b=1;
	while (n--) {
		ll x,y;
		scanf("%lld%lld",&x,&y);
		ll na,nb,lu;
		//if (y>x) na=(a+x-1)/x*x,nb=na/x*y;
		//else nb=(b+y-1)/y*y,na=nb/y*x;
		na=(a+x-1)/x; nb=(b+y-1)/y; lu=na>nb?na:nb;
		na=lu*x; nb=lu*y;
		a=na;b=nb;
		//printf("%lld %lld\n",a,b);
	}
	printf("%lld",a+b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long f(int n)
{	long long ans=1;
	
	for(int i=1;i<=n;i++)
	ans=ans*i;
return ans;
}
int main()
{
	int n,a[10],b[10];
	cin>>n;
	int sum=n-1;
	long long ans1=0,ans2=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
	}
	for(int i=1;i<=n;i++)
	{	sum=a[i]-1;
		for(int j=1;j<i;j++)
		
			
		if(a[j]<a[i])
		{
			sum--;
		}
		//cout<<sum<<endl;
		ans1+=sum*f(n-i);
	}
	//cout<<ans1<<endl;
	for(int i=1;i<=n;i++)
	{	sum=b[i]-1;
		for(int j=1;j<i;j++)
		if(b[j]<b[i])
		{
			sum--;
		}
		ans2+=sum*f(n-i);
	}
	//cout<<ans2<<endl;
	long long ans=fabs(ans1-ans2);
	cout<<ans<<endl;
 } 

Measured memory_bytes: 256
sub f{my$p=$h[my$c=$c[$_]-=my$r=$s=$v[++$_]=1];$v[$_--]or$a[$c]-=-$s*(-$s+($s=($r+=&f)-$h[$c]+$p))for@$_;$a[$c]+=$s*(@a-($h[$c]+=$s))+1;$r}@a=(0)x<>;@c=glob<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f;print"@a"

Measured memory_bytes: 516656
import java.util.Scanner;
import java.math.BigDecimal;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			BigDecimal in[] = new BigDecimal[8];
			for(int j = 0; j < 8; j++) {
				in[j] = sc.nextBigDecimal().setScale(BigDecimal.ROUND_UNNECESSARY);
			}

			/*
			for(int j = 0; j < in.length; j++) {
				System.out.println(in[j]);
			}
			// */

			BigDecimal m[] = new BigDecimal[2];
			for(int j = 0; j < 2; j++) {
				m[j] = in[2+4*j].subtract(in[0+4*j]).multiply(in[3+4*((j+1)%2)].subtract(in[1+4*((j+1)%2)]));
		//		System.out.println(m[j]);
			}

			if(m[0].equals(m[1]))
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23268
n = int(input())
num = float("inf")
for i in range(n + 1):
    rec = 0
    k = i
    while k > 0:
        rec += k % 6
        k = k // 6
    k = n - i
    while k > 0:
        rec += k % 9
        k = k // 9
    num = min(num, rec)

print(num)

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

int main () {
  char c;
  cin >> c;
  if (c !='a' && c != 'e' && c != 'i'
      && c != 'o' && c != 'u') cout << "consonant" << endl;
  else cout << "vowel" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    vector<int> s(N), t(N), c(N);
    vector<int> sum(100001, 0);
    for(int i=0; i<N; i++) cin >> s[i] >> t[i] >> c[i];

    for(int ch=1; ch<=C; ch++){

        vector<int> acm(100001, 0);
        for(int i=0; i<N; i++) if(c[i] == ch) acm[s[i]]++, acm[t[i]+1]--;
        for(int i=1; i<100001; i++) acm[i] = acm[i-1] + acm[i];
        for(int i=0; i<100001; i++) if(acm[i]) sum[i]++;

    }

    int ans = 0;
    for(int i=1; i<100001; i++) ans = max(ans, sum[i]);
    cout << ans << endl;
}

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

int main(void){
  int N;
  cin >> N;
  int x=0;
  bool flag=true;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  while(flag){
  	for(int i=0;i<N;i++){
      if(A[i]%2==0)A[i] /= 2;
      else{
      	flag=false;
	  }
  	}
  	if(flag==true){
	  x++;
    }
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define repins(a,n) vector<string> a(n);rep(i,n){cin>>a[i];}
#define repind(a,n) vector<double> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template<class T>
inline void out(T a){cout<<a<<endl; }
inline void out(double a){ printf("%.10f\n", a);} 
#define all(x) (x).begin(),(x).end()
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)
using vell = vector<ll>;
using ves = vector<string>;
using ved = vector<double>;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main()
{
	in(a);
	in(b);
	rep(i,1010){
		if(((ll)(i*0.08))==a&&((ll)(i*0.1))==b){
			out(i);
			return 0;
		}
	}
	out(-1);
}

Measured memory_bytes: 384
N = int(input())
li = [ int(it) for it in input().split() ]

sss = 0

for i in range(10000000):
  ma = max(li)
  if (ma==0):
    break
  ind = li.index(ma)

  l = ind
  for i in range(ind,N):
    if ( li[i] != ma ):
      break
    else:
      l = i
  r = ind
  for i in range(ind,-1,-1):
    if ( li[i] != ma ):
      break
    else:
      r = i
  l,r=r,l
  nma = 0
  if (l>0):
    nma = max(nma,li[l-1])
  if (r<N-1):
    nma = max(nma,li[r+1])

  sss += ma-nma
  for i in range(l,r+1):
    li[i]-=ma-nma
print (sss)

Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に

int main()
{
    string S;
    cin >> S;
    map<string, int> count;
    rep(i,S.size()){
        if(S.at(i)=='a'){
            count["a"]++;
        }
        else if(S.at(i)=='b'){
            count["b"]++;
        }
        else{
            count["c"]++;
        }
    }
    int d1=abs(count["a"]-count["b"]);
    int d2=abs(count["a"]-count["c"]);
    int d3=abs(count["b"]-count["c"]);
    if(d1<=1 && d2<=1 && d3<=1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int n,ans=0;
  cin>>n;
  int m=n;
  while(n>0){ans+=n%10;n=n/10;}
  if(m%ans==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
  
  
}

Measured memory_bytes: 3600
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans, cnt = 1, [0, 0, 0]
for i in a:
    ans = ans * cnt.count(i) % mod
    for j in range(3):
        if cnt[j] == i:
            cnt[j] += 1
            break
print(ans)


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

typedef long long ll;

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b,a);
    if (b == 0) return a;
    else return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}

ll f(ll x, ll c, ll d) {
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c,d);
    return res;
}

int main() {
    ll a, b;
    ll c, d;
    cin >>a >>b >>c >>d;
    ll ans = f(b, c, d) - f(a-1, c, d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int d;

vector<int> c;
vector<vector<int>> s;
vector<int> t;

int last(int d, int i) {
  int j;

  for (j=d; j>=0; j--) {
    if (t[j] == i) return d-j;
  }
  return d+1;
}

int cdiff(int, int);

int main()
{
  int i, j;

  c.resize(26);
  cin >> d;
  for(i=0; i<26; i++) {
    cin >> c[i];
  }

  s.resize(d);
  for (i=0; i<d; i++) {
    s[i].resize(26);
    for (j=0; j<26; j++) {
      cin >> s[i][j];
    }
  }
  t.resize(d);

  for (i=0; i<d; i++) {
//    t[i] = i%26;
    t[i] = 0;
  }
  int conf = 0;

  for (i=0; i<d; i++) {
    conf += s[i][t[i]];
//printf("+ %d\n", s[i][t[i]]);
    for (j=0; j<26; j++) {
      int cm;
      cm = c[j] * last(i, j);
      conf -= cm;
//printf("- %d\n", cm);
    }
  }

//printf("conf = %d\n", conf);

  int maxconf;
  maxconf = conf;

  for (int loop=0; loop<10; loop++) {

    for (i=0; i<d; i++) {
      int oc;
      int mc;
      oc = t[i];
      mc = oc;
//printf("t[%d] = %d conf = %d\n", i, oc, conf);
      for (j=(oc+1)%26; j!=oc; j=(j+1)%26) {
        conf += cdiff(i, j);
//printf("t[%d] = %d conf = %d\n", i, t[i], conf);
        if (conf > maxconf) {
          maxconf = conf;
          mc = j;
//printf("%d %d %d\n", i, j, conf);
        }
      }
      t[i] = mc;
      conf = maxconf;
    }
//printf("maxconf = %d\n", maxconf);
  }

  for (i=0; i<d; i++) {
    printf("%d\n", t[i]+1);
  }
  return 0;
}
int cdiff(int xd, int xq) {
  int rdiff;
  int oq;
  int j;

  oq = t[xd];

  rdiff = s[xd][xq] - s[xd][oq];
//printf("s[%d][%d] = %d -> s[%d][%d] = %d\n", xd ,oq, s[xd][oq], xd, xq, s[xd][xq]);

  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==oq) break;
    rdiff += c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
  }
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==xq) break;
    rdiff += c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
  }

  t[xd] = xq;
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==oq) break;
    rdiff -= c[oq] * last(j, oq);
//printf("c[%d] * last(%d, %d) = %d\n", oq, j, oq, c[oq] * last(j, oq));
  }
  for (j=xd; j<d; j++) {
    if (j>xd && t[j]==xq) break;
    rdiff -= c[xq] * last(j, xq);
//printf("c[%d] * last(%d, %d) = %d\n", xq, j, xq, c[xq] * last(j, xq));
  }
  return rdiff;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define loop(times) for(int i=0;i<(times);i++)

using namespace std;

int main() {
    while(1<2){
    int n;
    long long max;
    cin>>n;
    if(n==0)break;
    int a[n];
    int s[n];

    loop(n)cin>>a[i];
    max=a[0];
    s[0]=a[0];
        
    loop(n)s[i+1]=s[i]+a[i+1];
    for(int k=0;k<n;k++){
     loop(n-k){
         if(max<=s[k+i]-s[k-1])max=s[k+i]-s[k-1];   
    }
    }
    cout<<max<<endl;
    }
}


Measured memory_bytes: 3020
#include<stdio.h>
int main(){
int n[1006]={0},m[1006]={0},k=0,i,N,M;
while(scanf("%d%d",&N,&M)!=0){
k=0;
if(M==0)break;
for(i=0;i<N;i++)scanf("%d",&n[i]);
for(i=0;i<M;i++)scanf("%d",&m[i]);
for(i=0;;i++){
k+=m[i];
k+=n[k];
if(k>=N-1)break;
}
printf("%d\n",i+1);
}
exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

int main()
{
    int A, B;
    std::cin >> A >> B;

    int ans = 0;
    for (int i = A; i <= B; i++) {
        std::string s = std::to_string(i);
        int h = s.length()/2;
        bool r = true;
        for (int j = 0; j < h; j++) {
            if (s[j] != s[s.length()-j-1]) {
                r = false;
                break;
            }
        }
        if (r) {
            ans++;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
al = [int(a) for a in input().split()]
a_dic = {}
for a in al:
    num = a_dic.get(a, 0)
    a_dic[a] = num + 1

min_X = min(al)
max_X = max(al)
ans = 0
for X in range(min_X, max_X + 1):
    num = a_dic.get(X-1, 0) + a_dic.get(X, 0) + a_dic.get(X+1, 0)
    if num > ans:
        ans = num

print(ans)


Measured memory_bytes: 93388
#include<stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a[100005], b[100005];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (i = 0; i < n; i++)
        scanf("%d", &b[i]);
    int d[100005];
    for (i = 0; i < n; i++)
        d[i] = a[i] - b[i];
    qsort(d, n, sizeof(int), asc);
    double sum = 0;
    for (i = 0; i < n; i++)
        sum += d[i];
    if (sum < 0)
    {
        printf("-1\n");
        return 0;
    }
    int ans = 0;
    sum = 0;
    i = 0;
    while (d[i] < 0)
    {
        ans++;
        sum += d[i];
        i++;
    }
    i = n - 1;
    while (sum < 0)
    {
        ans++;
        sum += d[i];
        i--;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>
#include <stack>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

constexpr lli mod197 = 1000000007LL;
constexpr lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}



int main(void) {

	string s;
	cin >> s;

	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]) {
			COUT(i + 1 << " " << i + 2);
			return 0;
		}
	}
	for (int i = 0; i < s.size() - 2; i++) {
		if (s[i] == s[i + 2]) {
			COUT(i + 1 << " " << i + 3);
			return 0;
		}
	}

	COUT(-1 << " " << -1);

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MOD 1000000007

using namespace std;

int main() {


	string str; cin >> str;

	for (int i = 0; i < str.size(); i++) {
		if (i % 2 == 0) {
			cout << str[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<map>
using namespace std;
int k;
struct pa{
    int x,y;
};
deque<pa>p;
bool vis[10000000];
void bfs(){
    while(p.size())
    {
        pa n=p.front();p.pop_front();
        if(vis[n.x])
        {
            continue;
        }
        vis[n.x]=1;
        if(!n.x)
        {
            cout<<n.y;
            return;
        }
        pa a;
        a.x=n.x*10%k;a.y=n.y;
        p.push_front(a);
        a.x=(n.x+1)%k;a.y=n.y+1;
        p.push_back(a);
    }
}
int read()
{
    int x=0,f=1;
    char ch;
    while((ch=getchar())<'0'||ch>'9')
    {
        if(ch=='-')
        {
            x=-1;
        }
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-48;
        ch=getchar();
    }
    return x*f;
}
int main()
{
    k=read();
    pa b;
    b.x=1;b.y=1;
    p.push_front(b);
    bfs();
    return 0;
}

       



Measured memory_bytes: 1152
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> W(N);
    for (ll i = 0; i < N; i++) {
        cin >> W[i];
    }

    ll ans = INT_MAX;
    for (ll T = 0; T < N - 1; T++) {
        ll S1 = 0, S2 = 0;
        for (ll i = 0; i < N; i++) {
            if (i <= T) {
                S1 += W[i];
            } else {
                S2 += W[i];
            }
        }
        ans = min(ans, abs(S1 - S2));
    }

    cout << ans << endl;
}

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

int main() {
    double r;
    cin >> r;
    double pi = 3.1415926535;
    cout << 2 * pi * r << endl;
    
}

Measured memory_bytes: 3784
s=input()
n=len(s)
ans=n
for i in range(97, 97+26):
    x=chr(i)
    cnt=s.count(x)
    if cnt==n:
        ans=0
        break
    if cnt!=0:
        t=list(s)
        for j in range(n-1):
            u=[""]*(n-1-j)
            for k in range(n-1-j):
                if t[k]==x or t[k+1]==x:
                    u[k]=x
                else:
                    u[k]=t[k]
            if u.count(x)==n-1-j:
                ans=min(ans,j+1)
                break
            else:
                t=u
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(0,min(b,d)-max(a,c))<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	while(1){
		double D,E,ans=100000;
		cin >> D >> E;
		if(!D&&!E)	break;
		for(double x=0;x<=D;x++){
			ans = min(ans,abs(sqrt(x*x+(D-x)*(D-x))-E));
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    vector<int> b(n);

    if(n%2==0){
        for(int i=0;i<n/2;i++){
            b.at(i)=a.at(n-1-2*i);
        }
        for(int i=0;i<n/2;i++){
            b.at(i+n/2)=a.at(2*i);
        }
        for(int i=0;i<n-1;i++){
            cout<<b.at(i)<<" ";
        }
        cout<<b.at(n-1)<<endl;
    }
    else{
        for(int i=0;i<n/2;i++){
            b.at(i)=a.at(n-2-2*i);
        }
        for(int i=0;i<n/2;i++){
            b.at(i+n/2)=a.at(2*i);
        }
        b.at(n-1)=a.at(n-1);
        for(int i=0;i<n-1;i++){
            cout<<b.at(n-1-i)<<" ";
        }
        cout<<b.at(0)<<endl;
    }

    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
using namespace std;
int main()
{
	int n, t, c;
	while (cin >> n && n)
	{
		c = 0;
		t = n;
		while (t != 1)
		{
			if (!(t%2))	t /= 2;
			else		t = t * 3 + 1;
			c++;
		}
		cout << c << endl;
	}
}

Measured memory_bytes: 0
from collections import deque
import sys
input = sys.stdin.readline

mod = 10**9 + 7
INF = float("inf")

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

edges = [[] * N for _ in range(N)]
for _ in range(N - 1):
    # 頂点の番号を0-indexに直す
    a, b = map(lambda x: int(x) - 1, input().split())
    edges[a].append(b)
    edges[b].append(a)

# 0をrootとする
dq = deque([0])

# color[i] = i番目の頂点を塗ることが可能な色の数
# visitedの管理も兼ねている（別にvisited配列を作っても特に問題はない）
# 後述するように負の値が入ることを許しているので、-1や0などで初期化するのはNG
color = [INF] * N
color[0] = K

"""
root = 0 から末端に向かって調べる

子1, 子2, 子3, ...と複数の「未着色」の子がある場合、塗ることが出来る色の数は
K-1, K-2, K-3,... (p==0 の場合)
K-2, K-3, K-4,... (p!=0 の場合)　のようになる

子が十分多い場合、どこかで「0」になるので、ans = 0　となる
故に、色の数が負になっても答えには影響しない
"""

while dq:
    # 親となる頂点
    p = dq.popleft()
    # 親をpとした時の、「未着色」な子の数
    cnt = 0
    for c in edges[p]:
        if color[c] == INF:
            if p == 0:
                color[c] = (K - 1 - cnt) % mod
            else:
                color[c] = (K - 2 - cnt) % mod
            cnt += 1
            dq.append(c)

ans = 1
for i in range(N):
    ans = (ans * color[i]) % mod

print(ans)


Measured memory_bytes: 90512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
ll fre[1000006], n, a[10004];
ll pwr(ll b, ll e)
{
	ll ans = 1;
	while (e)
	{
		if (e & 1)
			ans = (ans * b) % mod;
		e >>= 1;
		b = (b * b) % mod;
	}
	return ans;
}
int main(int argc, char const *argv[])
{
	fast;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		ll num = a[i];

		for (ll j = 2; j * j <= num ; ++j)
		{
			ll cv = 0;
			while (num % j == 0)
			{
				cv ++;
				num /= j;
			}
			fre[j] = max(fre[j], cv);
		}
		if (num > 1)
			fre[num] = max(fre[num], 1ll);
	}
	ll pro = 1;
	for (int i = 1; i <= 1000000; ++i)
	{
		pro = (pro * pwr(i, fre[i])) % mod;
	}
	// db(pro);
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans = (ans + (pro * pwr(a[i], mod - 2)) % mod) % mod;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

//例えば、a < bとしたとき昇順ソートとなる
bool cmp(const P &a, const P &b){
    return a.second < b.second;
}

int main()
{
    int n;
    cin >> n;
    vector<P> range(n);
    rep(i, n){
        int x, l;
        cin >> x >> l;
        range[i].first = x-l;
        range[i].second = x+l;
    }
    //secondが最も小さいものを選ぶ
    sort(range.begin(), range.end(), cmp);

    int hand = -MOD;
    int ans = 0;
    rep(i, n){
        if ( hand <= range[i].first ){
            hand = range[i].second;
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define CYES cout << "Yes" \
                  << "\n"
#define CNO cout << "No" \
                 << "\n"
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const string MM = " ";

int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    int max_n = 0;
    for (auto& p : m) {
        if (p.second >= max_n) {
            max_n = p.second;
        }
    }
    for (auto& p : m) {
        if (p.second == max_n) {
            cout << p.first << "\n";
        }
    }
}

Measured memory_bytes: 26240
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define INF 1000000007
 
ll f[100001];
ll a[200005];

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD; 
 	b /= 2;
 	}
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}


int main(){
    int n, k;
    f[0] = 1;
	for(int i = 1 ; i <= 100000 ; i++)
		f[i] = (f[i-1]*i)%INF;
    cin >> n >> k;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    sort(a+1,a+n+1);
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        if((n-i) >= (k-1))
            ans = (ans - (1ll*a[i] * C(1ll*(n-i), 1ll*(k-1), INF)) % INF + INF) % INF;
        if(i >= k)
            ans = (ans + (1ll*a[i] * C(1ll*(i-1), 1ll*(k-1), INF)) % INF + INF) % INF;
    }
    cout << ans;
}

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

int main(){
  int N, K; string S;
  cin >> N >> K >> S;

  int L = S.length();
  S.push_back('2');

  vector<int> A; int tmp = 1;
  for(int i=1; i <= L; i++){
    if(S[i] == S[i-1]){
      tmp++;
    } else {
      if(S[i-1] == '1'){
        A.push_back(tmp);
      } else {
        A.push_back(-tmp);
      }
      tmp = 1;
    }
  }

  int M = A.size();
  vector<int> sum(100010,0);
  sum[0] = 0;
  for(int i=1; i<=M; i++){
    sum[i] = sum[i-1]+abs(A[i-1]); 
  } 
  
  int ans = 0; 
  for(int i=0; i<M; i++){
    int cur = 0;
    if(A[i] > 0){
      ans = max(ans, sum[i+min(2*K+1, M-i)] - sum[i]);
    } else {
      ans = max(ans, sum[i+min(2*K, M-i)] - sum[i]);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;

int main() {
    cin >> n;
    int m = 1;
    if (n <= 2) {
        cout << "No" << endl;
        return 0;
    }
    while (2*m-1 <= n) {
        m *= 2;
    }
    if (m == n) {
        cout << "No" << endl;
        return 0;
    }
    m--;
    cerr << m << endl;
    cout << "Yes" << endl;
    rep(i,m-1) cout << i+1 << " " << i+2 << endl;
    cout << m << " " << n+1 << endl;
    rep(i,m-1) cout << n+i+1 << " " << n+i+2 << endl;
    int pos = 1;
    for (int i = m+1; i <= n; i++) {
        if (i == m+1) {
            cout << i << " " << 1 << endl;
            cout << i+1 << " " << i << endl;
            cout << pos << " " << n+i+1 << endl;
            cout << n+i+1 << " " << n+i << endl;
            i++;
        } else {
            cout << i << " " << n+i-1 << endl;
            cout << pos << " " << n+i << endl;
        }
        pos++;
    }
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int x, t;
    cin>>x>>t;
    cout<<max(x - t, 0)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int solve(int k) {
    int sum = 0;
    while (k) {
        sum += k % 10;
        k /= 10;
    }
    return sum;
}
int main() {
    int n;
    cin >> n;
    int ans = INT_MAX;
    for (int i = 1; i < n; i++) {
        ans = min(ans, solve(i) + solve(n - i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

template<class T>
T sqr(const T & a) {
	return a * a;
}

ll f(ll b, ll n) {
	if(n < b) return n;
	return f(b, n/b) + n % b;
}

int main() {
	ll n, s;
	ll b = -1;
	cin >> n >> s;
	if(n == s) b = n+1;
	for(ll i = 2; sqr(max(i-10,0ll)) <= n; i++) {
		if(f(i, n) == s) {
			b = i;
			break;
		}
	}
	if(n-s > 0) for(ll i = 1; sqr(max(i-10,0ll)) <= n; i++) {
		if((n-s) % i == 0) {
			ll bb = (n-s) / i + 1;
			if(n/bb == i && n / bb < bb) {
				if(b < 0) b = bb;
				b = min(b, bb);
			}
		}
	}
	cout << b << endl;
	return 0;
}


Measured memory_bytes: 256