akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    int N, k, count = 0;
    cin >> N;
    vector<int> L(N);
    rep(i, N)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end(), greater<int>());
    rep(i, N-2)
    {
        repd(j, i+1, N-1)
        {
            k = j + 1;
            while(L[i] < L[j] + L[k])
            {
                count++;
                k++;
                if(k == N) break;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    vector<vector<int>> b(H, vector<int>(W));
    REP(i,H) REP(j,W) cin >> a[i][j];
    REP(i,H) REP(j,W) cin >> b[i][j];
    vector<vector<bitset<2*80*88>>> dp(H, vector<bitset<2*80*88>>(W));
    dp[0][0][abs(a[0][0]-b[0][0])+6400] = 1;
    REP(i,H) REP(j,W){
        if(i > 0){
            dp[i][j] |= (dp[i-1][j] << abs(a[i][j] - b[i][j]));
            dp[i][j] |= (dp[i-1][j] >> abs(a[i][j] - b[i][j]));
        }
        if(j > 0){
            dp[i][j] |= (dp[i][j-1] << abs(a[i][j] - b[i][j]));
            dp[i][j] |= (dp[i][j-1] >> abs(a[i][j] - b[i][j]));
        }
    }
    int ans = INF;
    REP(i,2*80*88){
        if(dp[H-1][W-1][i]){
            chmin(ans, abs(6400-i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
int dfs(vector<int>v[],int s,bool vis[],int dp[])
{
    if(vis[s])return dp[s];
    vis[s]=1;
    vector<int>temp=v[s];
    for(int i=0;i<temp.size();i++)
    {
        int x=dfs(v,temp[i],vis,dp);
        dp[s]=max(dp[s],x+1);
    }return dp[s];
}
int main()
{
    int n,m,x,y;
    cin>>n>>m;
    vector<int>v[n];
    while(m--)
    {
        cin>>x>>y;
        v[x-1].push_back(y-1);
    }
    bool vis[n]={0};
    int dp[n]={0};
    for(int i=0;i<n;i++)
    {
        if(!vis[i])dp[i]=dfs(v,i,vis,dp);
    }int maxi=0;
    for(int i=0;i<n;i++)maxi=max(dp[i],maxi);
    cout<<maxi<<endl;
}


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

int main() {
  int N, A, a;
  int f = 0;
  cin >> N;
  
  for (int i=0; i < N; i++) {
    cin >> A;
    int j=0;
    a = A/2;
    while (A == a*2) {
      A = a;
      a = A/2;
      j++;
      
      if (i==0)
        f = j;
      else if (f < j)
        break;
    }
    if (f > j)
      f = j;
  }
  cout << f << endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		HashMap<Long,Integer> num = new HashMap<Long,Integer>();
		for(int i = 0;i < N;i++) {
			long a = scn.nextLong();
			if(num.containsKey(a)) {
				num.replace(a, num.get(a)+1);
			}else {
				num.put(a, 1);
			}
		}
		long ans = 0;
		Set<Long> s = num.keySet();
		for(long a:s) {
			if(a > num.get(a)) {
				ans+=num.get(a);
			}
			if(num.get(a) > a) {
				ans += num.get(a) - a;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 63500
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;
int a[MAX];
int b[MAX], t[VMAX+1];

int main(){

  int n;
  cin >> n;
  int s = VMAX;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    s = min(s, a[i]);
  }
  int ans = 0;
  bool v[MAX];
  for(int i = 0; i < n; i++){
    b[i] = a[i];
    v[i] = false;
  }
  sort(b, b+n);
  for(int i = 0; i < n; i++) t[b[i]] = i;
  for(int i = 0; i < n; i++){
    if(v[i]) continue;
    int cur = i;
    int ss = 0, an = 0;
    int m = VMAX;
    while(true){
      v[cur] = true;
      an++;
      m = min(m, a[cur]);
      ss += a[cur];
      cur = t[a[cur]];
      if(v[cur]) break;
    }
    ans += min(ss + (an - 2) * m, m + ss + (an + 1) * s);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3168
n=int(input())
l=[input().split() for i in range(n)]
l_new=[[l[x][0],int(l[x][1]),x+1] for x in range(n)]
l_new=sorted(l_new,reverse=True,key=lambda x:x[1])
l_new=sorted(l_new,key=lambda x:x[0])
for i in range(n):
    print(l_new[i][-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
void solve(){
	double r;
	cin>>r;
	double ans=2*PI*r;
	cout<<setprecision(10)<<fixed<<ans<<endl;
	
	
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    
 

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

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

int main(){
    int a, b; cin >> a >> b;
    ll ans = lcm(a,b);
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    map<pair<int, int>, int> ans;
    vector<pair<int, int>> ord;
    vector<vector<int>> g(n, vector<int>());
    int a, b;
    REP(i, n - 1) {
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        ans.emplace(make_pair(a, b), i);
        ord.emplace_back(a, b);
    }
    int t = -1;
    REP(i, n) {
        if (sz(g[i]) == 1) {
            t = i;
            break;
        }
    }

    int mx = 0;
    function<void(int, int, int)> dfs = [&](int c, int p, int k) {
        if (p != -1 && sz(g[c]) == 1) return;
        int l = 1;
        for (int x : g[c]) {
            if (x == p) continue;
            if (l == k) l++;
            ans[make_pair(min(c, x), max(c, x))] = l;
            chmax(mx, l);
            dfs(x, c, l);
            l++;
        }
    };

    dfs(t, -1, 0);
    cout << mx << EOL;
    for (auto q : ord) cout << ans[q] << EOL;
}


Measured memory_bytes: 14968
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        s: Chars,
    }

    let mut a = vec![0; s.len()+1];

    for i in 0..s.len() {
        if s[i] == '<' {
            a[i+1] = std::cmp::max(a[i+1], a[i]+1);
        }
    }

    for ri in (0..s.len()).rev() {
        if s[ri] == '>' {
            a[ri] = std::cmp::max(a[ri], a[ri+1] + 1);
        }
    }

    println!("{}", a.iter().sum::<usize>());
}

fn main() {
    solve()
}


Measured memory_bytes: 8580
N = int(input())

AC=0
WA=0
TLE=0
RE=0
for i in range(N):
    ans = input()
    
    if ans == 'AC':
        AC += 1
    elif ans == 'WA':
        WA += 1
    elif ans == 'TLE':
        TLE += 1
    elif ans == 'RE':
        RE += 1

print('AC x ' + str(AC))
print('WA x '+ str(WA))
print('TLE x '+ str(TLE))
print('RE x '+ str(RE))

Measured memory_bytes: 9036
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int calc(vector<int> &v, int pos){
  int n = v.size();
  if(n == pos){
    return 0;
  }else{
    if(v[pos] == 0) return calc(v, pos + 1);
    
    int res = INF;
    int dif = v[pos];

    REP2(i, pos, n){
      v[i] = (v[i] - dif + 10) % 10;
      res = min(res, calc(v, pos + 1) + 1);
    }
    
    REP2(i, pos, n){
      v[i] = (v[i] + dif + 10) % 10;
    }
    return res;
  }
}

int main(){
  int n;
  string s1, s2;
  
  while(cin >> n && n){
    cin >> s1 >> s2;
  
    vector<int> v(n);
    REP(i, n) v[i] = (s1[i] - s2[i] + 10) % 10;
    cout << calc(v, 0) << endl;
  }
  

  return 0;
}

Measured memory_bytes: 1200
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    string S;
    cin>>S;
    int N=S.size();
    auto dp=make_vec<ll>(N+1,13);

    REP(i,13){
        dp[0][i]=0;
    }
    dp[0][0]=1;

    REP(i,N){
        if(S[i]=='?'){
            REP(j,10){
                dp[i+1][j%13]+=dp[i][0];
                dp[i+1][(j+10)%13]+=dp[i][1];
                dp[i+1][(j+7)%13]+=dp[i][2];
                dp[i+1][(j+4)%13]+=dp[i][3];
                dp[i+1][(j+1)%13]+=dp[i][4];
                dp[i+1][(j+11)%13]+=dp[i][5];
                dp[i+1][(j+8)%13]+=dp[i][6];
                dp[i+1][(j+5)%13]+=dp[i][7];
                dp[i+1][(j+2)%13]+=dp[i][8];
                dp[i+1][(j+12)%13]+=dp[i][9];
                dp[i+1][(j+9)%13]+=dp[i][10];
                dp[i+1][(j+6)%13]+=dp[i][11];
                dp[i+1][(j+3)%13]+=dp[i][12];
            }
        }else{
            int j=S[i]-'0';
            dp[i+1][j%13]+=dp[i][0];
            dp[i+1][(j+10)%13]+=dp[i][1];
            dp[i+1][(j+7)%13]+=dp[i][2];
            dp[i+1][(j+4)%13]+=dp[i][3];
            dp[i+1][(j+1)%13]+=dp[i][4];
            dp[i+1][(j+11)%13]+=dp[i][5];
            dp[i+1][(j+8)%13]+=dp[i][6];
            dp[i+1][(j+5)%13]+=dp[i][7];
            dp[i+1][(j+2)%13]+=dp[i][8];
            dp[i+1][(j+12)%13]+=dp[i][9];
            dp[i+1][(j+9)%13]+=dp[i][10];
            dp[i+1][(j+6)%13]+=dp[i][11];
            dp[i+1][(j+3)%13]+=dp[i][12];
        }
        REP(j,13){
            dp[i+1][j]%=MOD;
        }
    }
    cout<<dp[N][5]<<endl;

}

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

int main() {
	ll a,b,c,A,B,ans=0;
	cin>>a>>b>>c>>A>>B;
	c*=2;
	if(c<=a+b){
		ll D=min(A,B);
		A-=D;B-=D;
		ans+=D*c;
	}
	if(c<=a){
		ans+=A*c;		
		A-=A;
	}
	if(c<=b){
		ans+=B*c;
		B-=B;
	}
	cout << ans+A*a+B*b;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {            
  
  public static void main(String[] args) {                                
    
    Scanner sc = new Scanner(System.in);      
           
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    if(A == B){
        System.out.println(C);
        return;
    }else if(B == C){
        System.out.println(A);
        return;
    }else if(C == A){
        System.out.println(B);
        return;
    }
                                    
  }    
}
        

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

using ll = long long int;

ll gcd(ll x, ll y){
    if(y==0) return x;
    else return gcd(y, x%y);
}

ll lcm(ll x, ll y){
    return x/gcd(x,y)*y;
}

int main(){
    int n, ans = 0;
    cin >> n;
    vector<ll> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    for(int S=1;S<(1<<n);S++){
        bool ok = true;
        ll l = 1;
        for(int i=0;i<n;i++){
            if((S>>i)&1) l = lcm(l, p[i]);
        }
        for(int i=0;i<n;i++){
            if(((S>>i)&1)==0 && l%p[i]==0) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}




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


#define int long long 



const int inf = 1e15, N = 3e5;
pair <int, int> p[N];



struct RMQ {
        vector <int> t;
        int n;
        RMQ(int n) : n(n) {
                t.resize(n << 1, -inf);
        }
        
        void modify(int p, int v) {
        		v = max(v, t[p + n]);
                for(t[p += n] = v; p > 1; p >>= 1) t[p >> 1] = max(t[p], t[p ^ 1]);
        }
        int query(int l, int r) { int res = -inf;
                for(l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
                        if(l & 1) res = max(res, t[l++]);
                        if(r & 1) res = max(res, t[--r]);
                }
                return res;
        }
};

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++) cin >> p[i].first >> p[i].second;
	sort(p + 1, p + n + 1);
	vector <int> v;
	for(int i = 1; i <= n; i++) v.push_back(p[i].second);
	sort(v.begin(), v.end());
	map <int, int> mp; int ptr = 0;
	for(int x: v) if(!mp[x]) mp[x] = ++ptr;

	int ans = -inf;

	RMQ st1(ptr + 7), st2(ptr + 7);

	for(int i = 1; i <= n; i++) {
		ans = max(ans, p[i].first + p[i].second + st1.query(1, mp[p[i].second]));
		ans = max(ans, p[i].first - p[i].second + st2.query(mp[p[i].second], ptr));
		st1.modify(mp[p[i].second], -p[i].first - p[i].second);
		st2.modify(mp[p[i].second], -p[i].first + p[i].second);
	}

	cout << ans << endl;
}

Measured memory_bytes: 26600
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

int main()
{
	int n, m;
	cin >> n >> m;
	int ans = 0;
	vector<ll> h(n);
	vector<bool> once(n); //true
	rep(i, n) once[i] = true;
	rep(i, n) cin >> h[i];
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		if (h[a - 1] > h[b - 1]) {
			once[b - 1] = false;
		}
		else if (h[a - 1] < h[b - 1]) {
			once[a - 1] = false;
		}
		else {
			once[a - 1] = false;
			once[b - 1] = false;
		}
	}
	rep(i, n) {
		if (once[i])
			ans++;
	}

	cout << ans;
}



Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  int c = a + b - 1;
  int sum = ( b + c ) * a / 2;
  if ( c < 0 ) {
    sum -= c;
  } else if ( 0 < b ) {
    sum -= b;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

vector<vector<ll>> pascal;

void init_pascal(int n) {
    pascal.resize(n + 1);
    
    rep(i, n + 1) {
        pascal[i].resize(i + 1, 1);
        
        if (i < 2) {
            continue;
        }
        
        reps(ii, 1, i) {
            pascal[i][ii] = pascal[i - 1][ii - 1] + pascal[i - 1][ii];
        }
    }
}

ll combination(int n, int r) {
    if (n < r) {
        return 0;
    }
    
    return pascal[n][r];
}

string get_average(ll sum, int n) {
    ll l = sum / n;
    double d = (double)(sum % n) / n;
    char ds[10];
    char res[30];
    snprintf(ds, sizeof(ds), "%.6f", d);
    snprintf(res, sizeof(res), "%lld%s", l, ds + 1);
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v), greater<ll>());
    ll sum = 0, ans = 0;
    int acnt = 0, gcnt = 0;
    init_pascal(50);
    
    rep(i, a) {
        sum += v[i];
    }
    
    rep(i, n) {
        if (v[i] == v[a - 1]) {
            acnt++;
        }
        else if (v[i] > v[a - 1]) {
            gcnt++;
        }
    }
    
    if (acnt == 1) {
        ans = 1;
    }
    else {
        if (gcnt == 0) {
            reps(i, a, b + 1) {
                ans += combination(acnt, i - gcnt);
            }
        }
        else {
            ans += combination(acnt, a - gcnt);
        }
    }
    
    cout << get_average(sum, a) << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=gets.to_i
s=gets.split.map!{|i|i.to_i}
ans=0
pen=0
for i in 0..n-1
  if s[i]%2==0
    if s[i]%3==0 || s[i]%5==0
      ans=1
    else
      pen=1
    end
  end
end
if ans==1 && pen==0 || ans==0 && pen==0
  puts "APPROVED"
else
  puts "DENIED"
end


Measured memory_bytes: 14364
import math
while 1:
    N = int(input())
    if N == 0:
        break
    xs = list(map(int, input().split()))
    avg = 0
    for x in xs:
        avg += x
    avg /= len(xs)
    var = 0
    for x in xs:
        var += (x - avg) ** 2
    var /= len(xs)
    print(math.sqrt(var))


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

#define int long long
signed main(){
    int inf = 1000000000+7;
    int n,m;
    cin >> n >> m;
    int x;
    int ans1=0;
    int ans2=0;
    for(int i=1;i<=n;i++){
        cin >> x;   
        ans1 = (ans1+(n - 2*i +1)*x)%inf;
    }
    for(int i=1;i<=m;i++){
        cin >> x;   
        ans2 = (ans2 +(m - 2*i +1)*x)%inf;
    }
    cout << (ans1*ans2)%inf;
    return 0;
    
}

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

int k;
string s;

int main()
{
	ios::sync_with_stdio(0);
	cin >> k >> s;
	int len = s.size();
	if(k >= len) cout << s;
	else cout << s.substr(0, k) << "...";
//	system("pause");
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
vector<i64> ls;
int main() {
  cin >> s;
  i64 n = s.size();
  ls.push_back(1);
  for (i64 i = 1; i < n; ++i) {
    if (s[i - 1] == s[i]) ls.back()++;
    else ls.push_back(1);
  }
  for (i64 x : ls) cerr << x << ' ';
  cerr << endl;
  vector<i64> res(n);
  for (i64 i = 0, j = 0; i < ls.size(); ++i) {
    bool left = i % 2;
    if (!left) {
      j += ls[i];
      res[j] += ls[i] / 2;
      res[j - 1] += ls[i] - ls[i] / 2;
    } else {
      res[j - 1] += ls[i] / 2;
      res[j] += ls[i] - ls[i] / 2;
      j += ls[i];
    }
  }
  for (i64 x : res) cout << x << ' ';
  cout << endl;
  return 0;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
 int n;
 cin>>n;
 int maxi=0,cnt=0;
 vector<int> h(n);
 r(i,n){
   cin>>h.at(i);
   if(maxi<=h.at(i))cnt++;
   maxi=max(maxi,h.at(i));
 }

 cout<<cnt<<endl;

return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    ll ans = 0;
    for (int b = k + 1; b <= n; b++) {
        ans += n / b * (b - k) + max((n % b - k + 1), 0LL);
        // cout << "b " << b << ' ' << ans << '\n';
    }
    if (k == 0) ans -= n;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
using System;

namespace A_CirclePond
{
    class Program
    {
        static void Main(string[] args)
        {
            var hankei = int.Parse(Console.ReadLine().Split(' ')[0]);
            double ensyu = hankei * 2 * 3.14;
            decimal ensyudesi = Convert.ToDecimal(ensyu);

            Console.WriteLine(ensyudesi.ToString());
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 18144
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

void hora(int tc) {
	int n, k;
	cin>>n>>k;
	int tot = 0;
	while(n) {
		tot++;
		n /= k;
	}
	cout<<tot<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll mod = 1000000007;
const int INF = 1<<29;

using Graph = vector<vector<int>>;
int main(){
  int N, X, Y; cin >> N >> X >> Y;
  X--; Y--;

  Graph G(N);
  for (int i = 0; i < N - 1; ++i){
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[X].push_back(Y);
  G[Y].push_back(X);


  vector<int> dist(N, -1);
  queue<int> que;
  //map<P, int> depth; //<深さ, 個数>
  vector<vector<int>> depth(N, vector<int>(N, 0));
  for (int v = 0; v < N; ++v){ //どこから探索するか
    dist.assign(N, -1);
    dist[v] = 0;
    que.push(v);
    //cout << "=====" << endl;
    while (!que.empty()){
      int u = que.front();
      que.pop();
      depth[v][u] = dist[u];
      //cout << depth[v][u] << endl;
      for (auto nu: G[u]){
        if (dist[nu] == -1){
          dist[nu] = dist[u] + 1;
          que.push(nu);
        }
      }
    }

  }
  map<int, int> depth_cnt;
  for(int i = 0; i < N; ++i){
    for (int j = i + 1; j < N; ++j){
      depth_cnt[depth[i][j]]++;
    }
  }

  //cout << "==result==" << endl;
  for (int i = 1; i < N; ++i){
    cout << depth_cnt[i] << endl;
  }
}


Measured memory_bytes: 16128
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int n[26] = { 0 }, f = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		n[s[i] - 'a']++;
	for (int i = 0; i < 26; i++)
		if (n[i] % 2 != 0)
			f = 1;
	cout << (f == 0 ? "Yes" : "No") << endl;
	return 0;
}

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

struct Point{
	int h,w;
	Point(){};
	Point(int h_,int w_){
		h=h_,w=w_;
	};
};

Point operator+(const Point& a,const Point& b){return Point(a.h+b.h,a.w+b.w);}

struct Board{

	int H,W;
	vector<string>s ;
	vector<Point>near;
	queue<Point> que;
	vector<vector<int>> dist;
	vector<vector<bool>> visited;
	int ans;
	int bk;
	int wt;

	Board(){};
	Board(int h_,int w_){
		H=h_,W=w_;
		s.resize(H);
		near={{-1,0},{1,0},{0,-1},{0,1}};
		init_dist();
		init_visited();
	};

	bool in_board(Point p){if(0<=p.h && p.h<H && 0<=p.w && p.w<W)return true;else return false;} 
	char get_char(Point p){return s[p.h][p.w];}
	vector<Point> get_near(Point p){vector<Point>ret;for(auto&& u:near)ret.emplace_back(p+u);return ret;}

	int  get_dist(Point p){return dist[p.h][p.w];}
	int  set_dist(Point p,int i){dist[p.h][p.w]=i;}
	void init_dist(){dist.assign(H,vector<int>(W,-1));}

	int  is_visited(Point p){return visited[p.h][p.w];}
	int  set_visited(Point p,bool i){visited[p.h][p.w]=i;}
	void init_visited(){visited.assign(H,vector<bool>(W,false));}


	void dfs(Point p){
		if(is_visited(p))return;
		set_visited(p,true);
		for(auto&& u:get_near(p)){
		if(in_board(u) && !is_visited(u) && get_char(p)!=get_char(u)){
				 
				if(get_char(u)=='.'){wt++;}
				else if(get_char(u)=='#'){bk++;}
				dfs(u);
		}
		}
	}

	int do_all_dfs(){
		ans=0;
		init_visited();
		for (int i;i<H;i++)for(int j=0;j<W;j++){
		wt=0,bk=0;
		Point p(i,j);
		if(get_char(p)=='#' && ! is_visited(p)){
		bk++;
	//		cout<<"b "<<p.h<<" "<<p.w<<endl;
		dfs(p);
		ans+=bk*wt;
		}}
		return ans;
	}

	void bfs(){
		while(! que.empty()){
		Point p=que.front();que.pop();	
		for(auto&& u:get_near(p)){
		if(in_board(u) &&get_dist(u)==-1){
			set_dist(u,get_dist(p)+1);
			if(get_char(u)=='.')ans++;
			que.push(u);
		}}
		}}

	void do_all_bfs(){for (int i;i<H;i++)for(int j=0;j<W;j++){
		Point p(i,j);
		if(get_dist(p)==-1){
			que.push(p);bfs();
		}
	}
	}
	

};


signed main(){
	int h,w;cin>>h>>w;
	Board bd(h,w);
	for(auto&& u:bd.s)cin>>u;
//	for(auto&& u:bd.s)cout<<u<<endl;
	cout<<bd.do_all_dfs()<<endl;
}


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

int main(){
    char p[200], s[101], p_copy[200];
    scanf("%s", p);
    scanf("%s", s);
    strcpy(p_copy, p); 	
    p_copy[strlen(s)] = '\0';
    strcat(p, p_copy);
  	if(strstr(p, s) != NULL)printf("Yes\n");
  	else printf("No\n");
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>

int main() {
  int H, W;

  while (true) {
    std::cin >> H >> W;
    if (H == 0 && W == 0) {
      break;
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
          std::cout << "#";
        } else {
          std::cout << ".";
        }
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3104
a, b = map(str, input().split())
n = int(a+b)

flag = 0
i = 4
while i**2 <= n:
    if i**2 == n:
        flag = 1
        break
    else:
        i += 1
if flag == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K,Q;
  cin>>N>>K>>Q;
  map<int,int>M;
  for(int i=1;i<=N;i++)
    M[i]=0;
  for(int i=0;i<Q;i++){
  int x;
    cin>>x;
      M.at(x)++;
  }for(int i=1;i<=N;i++){
  if(0<K-Q+M.at(i))
    cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  
 }
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

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

map<ll, ll> prime_factorize(ll N) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}

void Main() {
    ll A, B;
    cin >> A >> B;
    ll num = gcd(A, B);
    if (num == 1) {
        cout << 1 << '\n';
        return;
    }
    auto primes = prime_factorize(num);
    ll cnt = (ll) primes.size() + 1;
    cout << cnt << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

string s;

int main() {
    ios::sync_with_stdio(false);
    cin >> s;
    int idx = s.length() - 1;
    long long sum = 0;
    for (int i = (int)s.length() - 1 ; i >= 0; i--) {
        if (s[i] == 'B') {
            sum += (idx - i);
            idx--;
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main() {

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

  int n, m;
  cin >> n >> m;

  long long sum = 0;
  for (int i = 0, x; i < m; ++i) {
    cin >> x;
    sum += x;
  }

  if (sum > n) cout << -1 << '\n';
  else cout << n - sum << '\n';
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;

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

    ll N;
    string temp;
    cin >> N; 
    map<string, ll> lot;
    ll type = 0;
    //while (cin >> temp) {
    for(int i = 0; i < N; i++){
        cin >> temp;
        if (!lot[temp]) {
            lot[temp] = 1;
            type++;
        }
    }
    cout << type << endl;
    return 0;
}

Measured memory_bytes: 19248
#include <cstdio>

int main(void)
{
    int n, m, f, e;

    scanf("%d %d", &n, &m);

    for (f = 1, e = m; f < e; f++, e--)
        printf("%d %d\n", f, e);
    for (f = m + 1, e = 2 * m + 1; f < e; f++, e--)
        printf("%d %d\n", f, e);
    return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

template<typename T>
struct BIT{
    int n;
    vector<T> dat;
    BIT(int n) : n(n), dat(n+1,0){}
    void add(int x, T val){
        for(int i = x+1; i <= n; i += (i & -i)) dat[i] += val;
    }
    T sum(int x){
        T ret = 0;
        for(int i = x+1; i > 0; i -= (i & -i)) ret += dat[i];
        return ret;
    }
    T sum(int a, int b){
        return sum(b) - sum(a-1);
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,k; cin >> n >> k;
    vi a(n);
    rep(i,n) cin >> a[i];

    rep(_,k){
        auto bit = BIT<int>(n+1);
        rep(i,n){
            int l = max(0, i-a[i]);
            int r = min(n-1, i+a[i]);
            bit.add(l, 1);
            bit.add(r+1, -1);
        }
        rep(j,n) a[j] = bit.sum(j);
        if(a[0] == n) break;
    }
    cout << join(a, " ") << endl;
    return 0;
}

Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,m;
char t[500005];
int c[30][500005]; //??????????

int lowbit(int x){
    return x&(-x);
}

void updata(int i,int k,int cha){    //?i????k
    while(i <= n){
        c[cha][i] += k;
        i += lowbit(i);
    }
}

int getsum(int i,int cha){        //?A[1 - i]??
    int res = 0;
    while(i > 0){
        res += c[cha][i];
        i -= lowbit(i);
    }
    return res;
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	string s;
	cin>>s;
	for(int i=1;i<=n;i++)
	{
		updata(i,1,s[i-1]-'a'+1);
		t[i]=s[i-1];
	}
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		int op;
		cin>>op;
		if(op==1)
		{
			int a;
			char b;
			cin>>a>>b;
			updata(a,-1,t[a]-'a'+1);
			t[a]=b;
			updata(a,1,t[a]-'a'+1);
		}
		else
		{
			int l,r;
			cin>>l>>r;
			int ans=0;
			for(int j=1;j<=26;j++)
				if(getsum(r,j)>getsum(l-1,j))
					ans++;
			cout<<ans<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 52764
import math

n = int(input())


ans = 10000000

for a in range(1, int(math.sqrt(n)+1)):
    if n % a != 0:
        continue

    b = n //a
    
    ka = len(str(a))
    kb = len(str(b))

    if max(ka, kb) < ans:
        ans = max(ka, kb)


print(ans)


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

int main()
{
  int n, k;
  cin >> n >> k;
  int l[n];
  for (int i = 0; i < n; i++) cin >> l[i];
  sort(l, l + n);
  reverse(l, l + n);
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += l[i];
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
long long M = 1e9+7;
long long power(long long a, long long p)
    {
        if(p==0) return 1;
        long long ans= power(a,p/2);
        ans =(ans * ans) % M;
        if(p%2) ans = (ans*a) % M;
        return ans;
    }

    bool isPrime(long long n)
    {
        if (n <= 1)
            return false;
        for (long long i = 2; i < n; i++)
            if (n % i == 0)
                return false;
        return true;
    }
    long long SieveOfEratosthenes(long long n, long long a)
    {
        bool prime[n+1];
        memset(prime, true, sizeof(prime));
        for (long long p=2; p*p<=n; p++)
        {
            if (prime[p] == true)
            {
                for (long long i=p*p; i<=n; i += p)
                    prime[i] = false;
            }
        }
        for (long long p=2; p<=n; p++)
           if (prime[p])
           {
               if(a%p==0)
               {
                   return (a-p);
               }
           }
    }
    long long nCr(int n, int r)
    {
        if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
        long long ans = 1;
        int i;
        for(i = 1; i <= r; i++) {
            ans *= n - r + i;
            ans /= i;
        }
        return ans;
    }
int main()
{
    IOS;
    long long a,b,c,d,e,h,n,t,f,m,f1=0,flag=0,flag1=0,co=0,co1=0,co2=0,arr1[100001]={0},sum=0,sum1=0,ma=0,ma1=0,mi=1000000000000000001;
    long long g,co3=0,co4=0,co5=0,co6=0,co7=0,co8=0,mul=1,sum2=0,sum3=0,mu=1,mu1=1;
    long long a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,b6;
    double pi=2 * acos (0.0);
    string str,str1,str2,str3,str4,str5,str6;
    char ch,ch1;
    //vector<long long>v; //vector<long long> v(n+1);
    //vector<long long>v1;
    // vector<string>vs;
    // vector<string>vs1;
    vector<char>vc;
    //map<long long,long long>mp;
    map<char,int>mp1;
    //set<long long>s;
    set<long long>s1;
    queue<long long> q;
    //stack<long long> stk;
    //vector< pair<long long,long long> >v3;
    //map<long long,long long>::iterator it;
    //map<string,string>::iterator it;
    // vector<pair<char, pair<int,int> > > v3;
    //vector< pair<char,int > > v1;
    int x[]={1,1,1,0,0,-1,-1,-1};
    int y[]={0,1,-1,1,-1,1,-1,0};
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a;
        ma=max(ma,a);
        mi=min(mi,a);
    }
    cout<<abs(ma-mi)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

 int main(){
 int a,b,c,d;
 
 scanf("%d %d %d",&a,&b,&c);
  
 if(a > b) {
    d = a;
      a = b;
      b = d;
  } if(b > c) {
    d = c;
    c = b;
    b = d;
 
  } if(a > b) {
    d = a;
    a = b;
    b = d;
  }
  printf("%d %d %d\n",a ,b ,c);
 
 
 
  return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<cmath>
using namespace std ;
int main()
{
	int n ;
	float dp[ 30 ] ;
	while( cin >> n , n )
	{
		dp[ 0 ] = 1 ;
		dp[ 1 ] = 2 ;
		dp[ 2 ] = 4 ;
		for( int i = 3 ; i < n ; i++ )
		{
			dp[ i ] = dp[ i - 1 ] + dp[ i - 2 ] + dp[ i - 3 ] ;
		}
		n-- ;
		cout << ceil( dp[ n ] / 3650 ) << endl ;
	}
	return 0 ;
}

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

#define int long long

#define X first
#define Y second
#define eb emplace_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb emplace_back
#define all(v) v.begin(),v.end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP rep
using vint=vector<int>;
typedef long long ll;
typedef ll LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> inline bool MX(T&l, const T&r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T&l, const T&r){return l>r?l=r,1:0;}
LL N,M;
LL p;
const LL SIZE=1e6;
LL A[SIZE],B[SIZE],x[SIZE];
vector<pll> edges[SIZE];
bool reached[SIZE];
LL sum[SIZE];
LL power(LL x,LL r){
  if(r==0) return 1;
  LL ans=power(x,r/2);
  ans*=ans;
  ans%=p;
  if(r%2) ans*=x;
  return ans%p;
}
LL gyaku(int x){
  return power(x,p-2);
}
bool dfs(int from){
  queue<LL> qu;
  reached[from]=true;
  qu.push(from);
  while(!qu.empty()){
    int now=qu.front();
    qu.pop();
    for(auto ne:edges[now]){
      LL next=ne.first;
      if(reached[next]){
        if(sum[next]==(sum[now]*ne.second%p));
        else return false;
      }
      else{
        sum[next]=sum[now]*ne.second%p;
        qu.push(next);
        reached[next]=true;
      }
    }
  }
  return true;
}
LL solve(){
  REP(i,N) reached[i]=false;
  REP(i,N) edges[i].clear();
  REP(i,N) sum[i]=1;
  REP(i,M){
    edges[A[i]].pb(B[i],x[i]);
    edges[B[i]].pb(A[i],gyaku(x[i]));
  }
  REP(i,N){
    if(!reached[i]){
      if(!dfs(i)){
        return false;
      }
    }
  }
  return true;
}
signed main(){
  cin >> N >> M;
  REP(i,M){
    cin >> A[i] >> B[i] >> x[i];
    A[i]--;
    B[i]--;
  }
  const LL ii9=1000000000;
  vint v={ii9+7,ii9+9,ii9+87,ii9+93,ii9+97};
  bool ans=true;
  REP(i,v.size()){
    p=v[i];
    ans&=solve();
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 35096
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define MAXN
#define MAXM
using namespace std;
int n,m;

int main()
{
	int ans=0;
	scanf("%d%d",&n,&m);
	if (n>=m)
	{
		ans+=n;
		n--;
	}
	else
	{
		ans+=m;
		m--;
	}
	if (n>=m)
	{
		ans+=n;
	}
	else
	{
		ans+=m;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
/* Madar Bozorg migoft : "dorost mishavad"
va hamishe badash b aseman negah mikard o mikhandid
hatm daram k chiz haii ""DARBARE KHODA"" midanest
k ma az an bi khabar budim :) */
//RTn_E
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define _file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define ll long long
#define ld long double
#define sp setprecision
#define pb push_back
#define F first
#define S second
#define mk make_pair
#define pii pair < int , int >
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 100;
const ll inf = 1e18;

//Main CODE :/\

int main() {
    ios_base :: sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
    string a;
    cin >> a;
    for (int i = 0; i < a.size(); i++){
        for (int j = i; j < a.size(); j++){
            string tmp = "";
            for (int k = 0; k < i; k++)
                tmp += a[k];
            for (int k = j + 1; k < a.size(); k++)
                tmp += a[k];
            if (tmp == "keyence")
                return cout << "YES\n" , 0;
        }
    }
    if (a == "keyence")
        return cout << "YES\n" , 0;
    cout << "NO\n";
    return 0;
}
//The_End
//Game Over :D


Measured memory_bytes: 256