akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <cassert>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e3+5;
int n, m, g[N][N], d[N], a[N], b[N], u[N], v[N], f[N], tag[N], fa[N], s[N], dep[N];
void dfs(int x)
{
    for(int y = 1; y <= n; ++y) 
        if(g[x][y]&&fa[x] != y) dep[y] = dep[x]+1, fa[y] = x, dfs(y);
}
int lca(int x, int y)
{
    for( ; x != y; x = fa[x]) if(dep[x] < dep[y]) swap(x, y);
    return x;
}
int get(int x)
{
    int ret = 0;
    for(int y = 1; y <= n; ++y) 
        if(g[x][y]&&fa[x] != y) ret += get(y), s[x] += s[y];
    return ret+min(s[x], 2);
}
int main()
{
    n = read(), m = read();
    for(int i = 1; i < n; ++i)
    {
        int x = read(), y = read();
        g[x][y] = g[y][x] = 1, ++d[x], ++d[y];
    }
    dfs(1);
    for(int i = 1; i <= m; ++i) u[i] = a[i] = read(), v[i] = b[i] = read(), ++s[a[i]], ++s[b[i]], s[lca(a[i], b[i])] -= 2;
    for(int _ = 1, x, y; _ < n; ++_)
    {
        for(x = 1; x <= n&&d[x] != 1; ++x); assert(x != n+1);
        for(y = 1; y <= n&&(!d[y]||!g[x][y]); ++y); assert(y != n+1);
        int p = 0, q = 0; --d[x], --d[y];
        // printf("%d %d %d\n", _, x, y);
        for(int i = 1; i <= m; ++i)
            if((u[i] == x)^(v[i] == x)) p?q = i:p = i;
        // printf("%d %d\n", p, q);
        if(p&&q)
        {
            switch((u[p] == x)<<1|(u[q] == x))
            {
                case 3: u[p] = v[q], tag[q] = 1; break;
                case 2: u[p] = u[q]; break;
                case 1: v[p] = v[q]; break;
                case 0: v[p] = u[q], tag[q] = 1; break;
            }
            f[q] = p, u[q] = v[q];
            // printf("%d %d\n", u[p], v[p]);
        }            
        for(int i = 1; i <= m; ++i) 
            if((u[i] == x)^(v[i] == x)) u[i] == x?u[i] = y:v[i] = y;
    }
    printf("%d\n", get(1));
    for(int i = 1; i <= m; ++i) 
    {
        if(f[i]) tag[i] ^= tag[f[i]]; if(tag[i]) swap(a[i], b[i]);
        printf("%d %d\n", a[i], b[i]);
    }
    return 0;
}
/*
2 3
3 4
4 2
*/

Measured memory_bytes: 14976
import java.util.*;

public class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		HashSet<String>h=new HashSet<>();
		String v=s.next();
		h.add(v);
		for(int i=1;i<n;++i) {
			String w=s.next();
			if(v.charAt(v.length()-1)!=w.charAt(0)||!h.add(w)) {
				System.out.println("No");
				return;
			}
			v=w;
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 22740
#include<iostream>
#include <math.h>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    int arrayX[n] = {};
    int arrayY[n] = {};
    for (int i = 0; i < n; i++) {
        cin >> arrayX[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> arrayY[i];
    }
    for (int x = 1; x < 5; x++) {
        double sum = 0;
        if (x == 4) {
            double lowest = 0;
            for (int i = 0; i < n; i++) {
                if (abs(arrayX[i] - arrayY[i]) > lowest) {
                    lowest = abs(arrayX[i] - arrayY[i]);
                }
            }
            cout << fixed << setprecision(10) << lowest << endl;

        } else {
            for (int i = 0; i < n; i++) {
                sum += pow(abs(arrayX[i] - arrayY[i]), x);
            }
            sum = pow(sum, (1.0 / x));
            cout << fixed << setprecision(10) << sum << endl;
        }

    }
}


Measured memory_bytes: 3448
N, X = map(int, input().split())
a = [1]
b = [1]
for i in range(50):
  a += [2*a[-1]+3]
  b += [2*b[-1]+1]
  
def ans(N, X):
  if N == 0 : return X
  if X == 1 : return 0
  if X == a[N]: return b[N]
  if X == (a[N]+1)//2 : return 1 + b[N-1]
  if X < (a[N]+1)//2:
    return ans(N-1, X-1)
  else:
    return 1+b[N-1] + ans(N-1, X-(a[N]+1)//2)

print(ans(N,X))

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF (ll)1e18

char S[202020];
ll Sn;
ll i, j, k;
vector<ll> anss;

int main(){
    scanf("%s", S);
    Sn = strlen(S);
    fornum(i,0,Sn){
        if(S[i]=='?'){
            printf("D");
        }else{
            printf("%c", S[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define prf pair<ld,ld>
#define vct vector<ll>
#define vpt vector<pr>
#define vcf vector<ld>
#define vpf vector<prf>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for(i = 0; i < (1LL*n); i++)
#define Fr(i, n) for(i = n - 1; i >= 0; i--)
 
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
 
void prv(vct v){for (ll i=0;i<v.size();i++)cout<<v[i]<<" ";cout << "\n";}
void prn(ll n){cout<<n<<"\n";}
void prs(string n){cout<<n<<"\n";}
void deb(string s, ll n){cout<<s<<" : "<<n<<"\n";}
void prmt(mat m){for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);}
 
mat getRzMat(ll m,ll n, ll ini=0){mat mt;mt.assign(m,vector<ll>(n,ini));return mt;}
 
ll poww(ll x, ll y, ll m){
    ll res = 1;
    while (y){
        if (y%2 == 0){x = (x * x) % m;y = y / 2;}
        else{res = (res * x) % m;y--;}
    }
    return res;
}
 
vct divsors(ll n){
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++){if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
mat mt;
ll n, k, m, l, r, x, y, z;//ll ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c, d, w;
ll mod = 1000000007;
ld epi = 0.00000001;
ll cas=0;

void solve(){
    cin>>n;
    vct vi(n);
    vct ci(n);
    F(i,n)cin>>vi[i];
    F(i,n)cin>>ci[i];

    ll vn=0,cn=0;
    F(i,n){
        if(vi[i]>ci[i]){
            vn+=vi[i];
            cn+=ci[i];
        }
    }
    prn(vn-cn);
    
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout<<fixed<<setprecision(10);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    while (t--){
        solve();
        cas++;
    }
    return 0;
}
 

Measured memory_bytes: 3676
import numpy as np
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
p_sum=[0]
for i in p:p_sum.append(p_sum[-1]+i)
max_sum_val = 0
for j in range(len(p_sum) - K):
    max_sum_val = max(p_sum[K+j]-p_sum[j], max_sum_val)
print((max_sum_val + K)/2)

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

int main()
{
  int N ;
  cin>>N ;
  vector<int>a(N) ;
  for(int i=0;i<N;i++) cin>>a.at(i) ;
  sort(a.begin(),a.end()) ;
  reverse(a.begin(),a.end()) ;
 
  if(N==2){
    cout<<a.at(0)<<" "<<a.at(1)<<endl ;
    return 0 ;
  }
  int center ;
  int m,n ;
  if(a.at(0)%2==0) center=a.at(0)/2 ;
  else center=(a.at(0)+1)/2 ;
  int min_dif=1e9 ;
  for(int i=1;i<N;i++){
    if((a.at(0)%2==0&&a.at(i)==center)||(a.at(0)%2!=0&&(a.at(i)==center||a.at(i)==center-1))){
      cout<<a.at(0)<<" "<<a.at(i)<<endl ;
      return 0 ;
    }else{
      int dif ;
      if(a.at(0)%2==0){
        dif=(a.at(i)>center?a.at(i)-center:center-a.at(i)) ;
        if(min_dif>dif){
          min_dif=dif ;
          n=a.at(i) ;
        }
      }else{
        dif=(a.at(i)>center?a.at(i)-center:center-a.at(i)) ;
        if(min_dif>dif){
          min_dif=dif ;
          n=a.at(i) ;
        }
      }
    }
  }
  m=a.at(0) ;
  cout<<m<<" "<<n<<endl ;
  
  return 0 ;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 200005
vector<int> pre_G[MAX_N];
vector<int> G[MAX_N];
int par_[MAX_N];
int flag_netsukigi[MAX_N];
void make_netsukigi(int r){
    rep(i,MAX_N){
        G[i].clear();
        par_[i] = 0;
        flag_netsukigi[i] = 0;
    }
    queue<int> que;
    que.push(r);
    flag_netsukigi[r] = 1;
    par_[r] = -1;

    while(que.size() > 0){
        int x = que.front();
        que.pop();
        flag_netsukigi[x] = 1;
        rep(i,pre_G[x].size()){
            if(flag_netsukigi[pre_G[x][i]] == 0){
                par_[pre_G[x][i]] = x;
                G[x].push_back(pre_G[x][i]);
                que.push(pre_G[x][i]);
            }
        }
    }
}

int main() {
    string fileNameIfs = "1_10.txt";
    const char* cstrIfs = fileNameIfs.c_str();
    ifstream ifs(cstrIfs);
    int n;
    if(!ifs.is_open()){ // 標準入力する
        cin >> n;

        rep(i,n-1){
            int a, b;
            scanf("%d%d", &a, &b);
            pre_G[a].push_back(b);
            pre_G[b].push_back(a);
        }
    }else{ // ファイル入力する
        ifs >> n;

        rep(i,n-1){
            int a, b;
            ifs >> a >> b;
            pre_G[a].push_back(b);
            pre_G[b].push_back(a);
        }
    }
    
        
    int start = -1;
    rep(i,n){
        if(pre_G[i].size()>2){
            start = i;
            break;
        }
    }

    if(start == -1){
        cout << 1 << endl;
        return 0;
    }

    make_netsukigi(start);
    int ans = 0;

    queue<int> que;
    int ari[n] = {};
    int son[n] = {};
    int nashi[n] = {};
    rep(i,n){
        son[i] = G[i].size();
        if(i == start) continue;
        if(son[i] == 0){
            que.push(i);
        }
    }

    while(que.size()){
        int x = que.front();
        que.pop();
        if(G[x].size()>=2){
            ans += max(0, nashi[x]-1);
            ari[x] = 1;
        }
        if(x == start)break;
        son[par_[x]]--;
        if(son[par_[x]] == 0) que.push(par_[x]);
        if(ari[x] == 0) nashi[par_[x]]++;
        if(ari[x] == 1) ari[par_[x]] = 1;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21584
import sys
import math
import bisect
from collections import defaultdict, deque
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    return


# B
def B():
    return


# C
def C():
    n = I()
    for i in range(int(n ** 0.5), 0, -1):
        if n % i == 0:
            print(i + n // i - 2)
            return
    return


# D
def D():
    a, b, x = LI()
    if (x <= a * a * b / 2):
        print(math.degrees(math.atan(a * b * b / x / 2)))
    else:
        print(math.degrees(math.atan(2 * (a * a * b - x) / a ** 3)))
    return


# E
def E():
    n, k = LI()
    a = LI()
    f = LI()
    a.sort()
    f.sort(reverse=True)
    left = 0
    right = 0
    for a_i, f_i in zip(a, f):
        right = max(a_i * f_i, right)
    while (left != right):
        mid = (left + right) >> 1
        score = 0
        for i in range(n):
            if a[i] * f[i] > mid:
                score += a[i] - mid // f[i]
        if score <= k:
            right = mid
        else:
            left = mid + 1
    print(left)
    return


# F
def F():
    return


# Unittest
def resolve():
    E()
    return


# Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 105292
#include<bits/stdc++.h>
using namespace std;
vector<long long>v;
void dfs(int now,int back,long long num) {
	if(now==11) return;
	v.push_back(num);
	if(back>0) dfs(now+1,back-1,num*10+back-1);
	dfs(now+1,back,num*10+back);
	if(back<9) dfs(now+1,back+1,num*10+back+1);
}
int main() {
	int k;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>k;
	v.push_back(0);
	for(int i=1;i<=9;i++) dfs(1,i,i);
	sort(v.begin(),v.end());
	cout<<v[k]<<endl;
	return 0;
}


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

constexpr long long mod{1000000007};

using vl = std::vector<long long>;
using vvl = std::vector<vl>;
int n;
vvl multi(vvl, vvl);

int main()
{
	long long k;
	scanf("%d%lld", &n, &k);
	vvl edge(n, vl(n));
	for (int i{}; i < n; i++)
		for (int j{}; j < n; j++)
			scanf("%lld", &edge[i][j]);
	vvl mat(n, vl(n));
	for (int i{}; i < n; i++)
		mat[i][i] = 1;
	while (k)
	{
		if (k & 1)
			mat = multi(edge, mat);
		edge = multi(edge, edge);
		k >>= 1;
	}
	long long ans{};
	for (int i{}; i < n; i++)
		for (int j{}; j < n; j++)
		{
			ans += mat[i][j];
			ans %= mod;
		}
	printf("%lld\n", ans);

	return 0;
}

vvl multi(vvl a, vvl b)
{
	vvl ret(n, vl(n));
	for (int r{}; r < n; r++)
		for (int c{}; c < n; c++)
			for (int l{}; l < n; l++)
			{
				ret[r][c] += a[r][l] * b[l][c];
				ret[r][c] %= mod;
			}
	return ret;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,m;
    cin >> n >> m;
    map<int, int> mp;
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        if(a == 0){
            mp[b]++;
        }
        else if(b == n-1) mp[a]++;
    }    
    bool flag = false;
    for(auto p:mp){
        if(p.second > 1) flag = true;
    }
    if(flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[100003],dp[100003];
int main()
{
  ll n,k,i,j,mini;
  cin>>n>>k;
  for(i=0;i<n;i++)
    cin>>a[i];
  //memset(dp,INT_MAX,sizeof(dp));
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(i=2;i<n;i++)
  {
    j=i-1;
    mini=INT_MAX;
    while(j>=i-k && j>=0)
    {
      mini=min(mini,dp[j]+abs(a[j]-a[i]));
      j--;
    }
    dp[i]=mini;
   }
   cout<<dp[n-1]<<endl;
 }
                


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
ll a, b, c, i, j, k, n, m, t, arr[200005], ar[200005];
int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        int r,c;
        scanf("%d %d",&r,&c);
        int sh[r+1][c+1];
        for(int i=0;i<r;i++){
                int t=0;
                for(int j=0;j<c;j++){
                        scanf("%d",&sh[i][j]);
                        t+=sh[i][j];
                }
                sh[i][c]=t;
        }
        for(int i=0;i<c+1;i++){
                int t=0;
                for(int j=0;j<r;j++){
                        t+=sh[j][i];
                }
                sh[r][i]=t;
        }
        for(int i=0;i<r+1;i++){
                for(int j=0;j<c+1;j++){
                        if(j!=c){
                                printf("%d ",sh[i][j]);
                        }else{
                                printf("%d\n",sh[i][j]);
                        }
                }
        }
        return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const int MOD2 = 1e9 + 9;
const int INF = 5e18;
 
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = result*a;
 
        b >>= 1;
        a = a*a;
    }
    return result;
}

void solve(){
    int a,b,n;
    cin>>a>>b>>n;
    int x = min(b-1,n);
    cout<<(a*x)/b - a*(x/b)<<endl;
}
main(){
    fastio; 
    int x=0;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1) {
    a = 14;
  }
  if (b == 1) {
    b = 14;
  }
  if (a > b) {
    cout << "Alice" << endl;
  } else if (b > a) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
  return 0;
}


Measured memory_bytes: 3012
#include <iostream>
using namespace std;
int main()
{
    char kiroku[26] = {};
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        kiroku[s[i]-'a'] = 1;
    }
    for(int i = 0; i < 26; i++){
        if(kiroku[i] == 0){
            cout << s + (char)(i + 'a') << endl;
            return 0;
        }
    }
    for(int i = 25; i > 0; i--){
        if(s[i-1] < s[i]){
            for(int j = 25; j >= 0; j--){
                if(s[i-1] < s[j]){
                    s[i-1] = s[j];
                    break;
                }
            }
            s.erase(s.begin() + i, s.end());
            cout << s << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cmath>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    int con = 1;

    while(con < b){
        con--;
        con += a;
        cnt++;
    }


    cout << cnt << endl;
}   

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

int main() {
  string str;
  int n;
  cin >> str;
  cin >> n;
  string cmd;
  int a, b;
  string p;
  for (int i = 0; i < n; i++) {
    cin >> cmd;
    if (cmd ==  "print") {
      cin >> a >> b;
      cout << str.substr(a, b - a + 1) << endl;
    } else if (cmd == "replace") {
      cin >> a >> b >> p;
      str = str.substr(0, a) + p + str.substr(b + 1);
    } else {
      cin >> a >> b;
      reverse(str.begin() + a, str.begin() + b + 1);
    }
  }
}



Measured memory_bytes: 3184
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let s: String = scan(tokens);
    let modulo: usize = 1_000_000_007;
    let mut dp = vec![0; 13];
    dp[0] = 1;
    let mut tmp = vec![0; 13];
    for b in s.bytes() {
        if b == b'?' {
            for i in 0..13 {
                tmp[i] = 0;
            }
            for i in 0..13 {
                for b in 0..10 {
                    tmp[(i * 10 + b) % 13] += dp[i];
                }
            }
            for i in 0..13 {
                tmp[i] %= modulo;
            }
        } else {
            let b = (b - b'0') as usize;
            for i in 0..13 {
                tmp[(i * 10 + b) % 13] = dp[i];
            }
        }
        std::mem::swap(&mut dp, &mut tmp);
    }
    println!("{}", dp[5]);
}


Measured memory_bytes: 4476
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();
      long a = sc.nextLong();
      long b = sc.nextLong();
      if(a>b||(n==1&&a!=b))System.out.println(0);
      else System.out.println(b*(n-2)-a*(n-2)+1);
    }
}


Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int a[30];
int main()
{
	int n;
	long long total = 1;
	char s[100000];
	scanf("%d%s", &n, s);
	for(int i = 0; i < n; ++i)
	{
		++a[s[i] - 'a'];
	}
	for(int i = 0; i < 26; ++i)
	{
		(total *= a[i] + 1) %= 1000000007;
	}
	printf("%d\n", total - 1);
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
  int N;
  long long int ans, R=0, G=0, B=0;
  cin >> N;
  char S[N+1];
  for(int i=1; i<N+1; i++) cin >> S[i];
  for(int i=1; i<N+1; i++){
    if(S[i] == 'R') R++;
    if(S[i] == 'G') G++;
    if(S[i] == 'B') B++;
  }
  ans = R*G*B;
  for(int i=1; i <= N; i++){
    for(int j=1; i+2*j<=N; j++){
      if(S[i] != S[i+j] && S[i+j] != S[i+2*j] && S[i+2*j] != S[i]) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int d[1000];
int t[1000];
int f[1000];
char s[64];
pair<int,int> event[1000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		map<string,int> m;
		for(int i=0;i<1000;i++)f[i]=0;
		for(int i=0;i<a;i++){
			scanf("%s%d%d",s,d+i,t+i);
			t[i]=t[i]%100+t[i]/100*60;
			string S=s;
			m[S]=i;
		}
		int b;
		scanf("%d",&b);
		for(int i=0;i<b;i++){
			scanf("%s",s);
			string S=s;
			f[m[S]]=1;
		}
		for(int i=0;i<a;i++){
			event[i]=make_pair(d[i]*1440+t[i],i);
		}
		std::sort(event,event+a);
		int ret=0;
		bool dame=false;
		int last=-99999999;
		for(int i=0;i<a;i++){
		//	printf("%d %d\n",event[i].first,f[event[i].second]);
			if(last+30>event[i].first)continue;
			bool ok=true;
			for(int j=i+1;j<a;j++){
				if(event[i].first+30>event[j].first){
					if(f[event[j].second]){
						ok=false;
						break;
					}
				}
				else break;
			}
			if(ok){
				ret++;
				last=event[i].first;
			}else{
				if(f[event[i].second])dame=true;
			}
		}
		if(dame)printf("-1\n");
		else printf("%d\n",ret);
	}
}

Measured memory_bytes: 1148
import math
N = int(input())
sqN = math.floor(math.sqrt(N))
ansdict = {i+1:0 for i in range(N)}

for z in range(1, sqN+1):
  for y in range(1, sqN+1):
    for x in range(1, sqN+1):
      try:
        ansdict[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
      except KeyError:
        continue

for num in ansdict.values():
  print(num)
        

Measured memory_bytes: 75052
N, M, K = map(int, input().split())
MOD = 998244353

fac = [1, 1] # 元テーブル
facinv = [1, 1] #逆元テーブル
inv = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    fac.append( ( fac[-1] * i ) % MOD )
    inv.append( ( -inv[MOD % i] * (MOD//i) ) % MOD )
    facinv.append( (facinv[-1] * inv[-1]) % MOD )

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return fac[n] * facinv[r] * facinv[n-r] % MOD

sum = 0
for k in range(K+1):
    sum += M * pow(M-1,N-1-k, MOD) * cmb(N-1,k) % MOD
    sum %= MOD

print(sum % MOD)


Measured memory_bytes: 33164
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;
vector<double> X,Y;

bool input() {
  return true;
}

void solve(){
}

int main() {
  cin >>N;
  X.assign(N, 0); rep(i, N) cin >>X[i];
  Y.assign(N, 0); rep(i, N) cin >>Y[i];
  for (int p=1; p<=4; p++){
    double res = 0;
    rep(i, N){
      double xy = X[i] - Y[i];
      if (p == 1) res += abs(xy);
      if (p == 2) res += xy * xy;
      if (p == 3) res += xy * xy * abs(xy);
      if (p == 4) res = max(res, abs(xy));
    }
    if (p == 2) res = sqrt(res);
    if (p == 3) res = cbrt(res);
    cout <<fixed <<setprecision(12) <<res <<endl;
  }
}


Measured memory_bytes: 3412
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

pair <int, int> f[20];

int g[20];
int a[20];
int b[20];
int n,ans;

int getbit(int x, int i)
{
    return (x >> i) & 1;
}

void solve(int mask)
{
    vector <int> val(0);
    for (int i = 0; i < n; i++)
    {
        g[i] = getbit(mask, i);
        if (g[i]) f[i] = mp(b[i], i);
        else f[i] = mp(a[i], i);
        val.push_back(f[i].fi);
    }
    sort(val.begin(), val.end());
    int res = 0;
    for (int cur = 0; cur < n; cur++)
    {
        int x = val[cur];
        bool found = false;
        for (int i = cur; i < n; i++)
        {
            int num = f[i].fi;
            int id = f[i].se;
            if (num == x && (i - cur) % 2 == g[id])
            {
                found = true;
                for (int j = i; j - 1 >= cur; j--)
                {
                    swap(f[j], f[j - 1]);
                    g[f[j].se] ^= 1;
                    res++;
                }
                break;
            }
        }
        if (!found) return;
    }
    ans = min(ans, res);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("file.inp","r",stdin);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    ans = (int) 1e9;
    for (int i = 0; i < (1 << n); i++)
    {
        solve(i);
    }
    if (ans == (int) 1e9) cout << -1;
    else cout << ans;
    return 0;
}


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

int n;
std::vector<int> vec;

int main() {
    std::cin >> n;
    vec.assign(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> vec[i];
    }
    std::sort(vec.begin(), vec.end());
    int ans = vec[vec.size()/2] - vec[vec.size()/2-1];
    std::cout << ans << std::endl;
}


Measured memory_bytes: 640
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
//const int MOD = 1000000007;
const int MOD = 998244353;
//int MOD = 1000000007;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

//約数の列挙O(√n)
vector<int> divisor(int n){
    vector<int> res(0);
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}



void solve(){
  string S;
  cin >> S;
  if(S == "AAA" || S == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}


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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())
#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int N, M, K;
int A[200000+1];
int B[200000+1];

int
main()
{
  scanf("%d %d %d", &N, &M, &K);
  REP(i, N) { scanf("%d", &A[i]); }
  REP(i, M) { scanf("%d", &B[i]); }

  int ans = 0;
  int sum = 0;
  for (int i = 0; i < N && sum + A[i] <= K; i++) {
    sum += A[i]; 
    ans++;
  }
  int max = ans;
  int a_num = ans;
  for (int j = 0; j < M; j++) {
    while (sum + B[j] > K && a_num > 0) {
      sum -= A[a_num - 1];
      ans--;
      a_num--;
    }
    if (sum + B[j] <= K) {
      sum += B[j];
      ans++;
      if (max < ans) max = ans;
    } else {
      break;
    }
  }

  printf("%d\n", max);
  
  return 0;
}


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

int main() {
  cin.tie(0);
  int A, B;
  char op;
  cin >> A >> op >> B;
  int ans;
  if(op=='+') ans = A + B;
  else ans = A - B;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    double a, b;
    cin >> a >> b;
    cout << a / b << endl;
    return 0;
}

Measured memory_bytes: 764
<?php

$nm = explode(' ',trim(fgets(STDIN)));
$n = $nm[0];
$m = $nm[1];

$roads = [];
for ($i=0; $i<$m; $i++){
  $l = explode(' ',trim(fgets(STDIN)));
  array_push($roads,$l[0],$l[1]);
}

for ($i=1; $i<=$n; $i++){
  	if ($i !== 1) echo "\n";
  
  	$count = 0;
  	for ($j=0; $j<count($roads); $j++){
      if ($roads[$j] == $i) $count++;
	}
  
  	echo $count;
}


?>

Measured memory_bytes: 4604
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  string str[h];
  for(int i=0;i< h;i++){
    cin >> str[i];
  }
  int a[h+2][w+2];
  for(int i=0;i<=h+1;i++){
    for(int j=0;j<=w+1;j++){
      a[i][j] = 0;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(str[i][j] == '#'){
        for(int k=0;k<3;k++){
          for(int l=0;l<3;l++){
            a[i+k][j+l] ++;
          }
        }
      }
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(str[i][j] == '#'){
        cout << '#';
      }else{
        cout <<a[i+1][j+1];
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
int main(){

        int A,B,C,K;
        cin >> A >> B >> C >> K;
        int maxnum = max(max(A,B),C);
        cout << maxnum * pow(2,K) + A+B+C-maxnum << endl;
        return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


int main(void) {

  string s;
  cin >> s;

  ll n[1001000] = {};
  int m = s.size();
  rep(i, m) {
    int k = (int)s[m - 1 - i] - (int)'0';
    n[i] = k;
  }

  ll dp[3][2];
  dp[0][0] = n[0]; dp[0][1] = 10LL - n[0];
  
  for (int i = 1; i < m + 1; i++) {
    dp[i & 1][0] = dp[(i + 1) & 1][0] + n[i];
    if (n[i] + 1 < 10) dp[i & 1][0] = min(dp[i & 1][0], dp[(i + 1) & 1][1] + n[i] + 1LL);
    dp[i & 1][1] = min(dp[(i + 1) & 1][0] + 10LL - n[i], dp[(i + 1) & 1][1] + 9LL - n[i]);
  }

  cout << dp[m & 1][0] << endl;

  return 0;
}

  


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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

const int N = 100005;

int n, m;
vector<pair<int,int>> g[N];
int was[N];
int dist[N];

void die() {
	cout << "No\n";
	exit(0);
}

void dfs(int v, int d = 0) {
	was[v] = 1;
	dist[v] = d;
	for (auto& item : g[v]) {
		int to = item.first;
		int c = item.second;
		if (!was[to]) {
			dfs(to, d + c);
		} else {
			if (dist[to] != d + c) {
				die();
			}
		}
	}
}

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

	cin >> n >> m;
	REP(i, m) {
		int x, y, c;
		cin >> x >> y >> c;
		--x; --y;
		g[x].emplace_back(y, c);
		g[y].emplace_back(x, -c);
	}
	REP(i, n) if (!was[i]) dfs(i);
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

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

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=1e6;
int n,x,a[N+5],b[N+5],p[N+5],t[N+5];
bool bo,bz[N+5],bz1[N+5];
int gcd(int a,int b){return a%b==0?b:gcd(b,a%b);}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=2;i<=N;i++)
	{
		if (!bz[i]) p[++p[0]]=i,t[i]=i;
		for (int j=1;j<=p[0] && p[j]*i<=N;j++)
		{
			bz[i*p[j]]=1,t[i*p[j]]=p[j];
			if (i%p[j]==0) break; 
		}
	}
	for (int i=1;i<=n;i++)
	{
		x=a[i];
		while (x>1)
		{
			if (bz1[t[x]])
			{
				bo=1;
				break;
			}
			x/=t[x];
		}
		if (bo) break;
		x=a[i];
		while (x>1)
		{
			bz1[t[x]]=1;
			x/=t[x];
		}
	}
	if (!bo)
	{
		printf("pairwise coprime");
		return 0;
	}
	x=a[1];
	for (int i=2;i<=n;i++) x=gcd(x,a[i]);
	if (x==1) printf("setwise coprime"); else printf("not coprime");
	return 0;
} 

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int a,b,c,d,e,f;
	int water;int sugar;int sugarwater;
	int maxsugarwater=-1;
	int maxsugar=-1;
	int watsug=0;
	cin >> a >> b >>c >>d>>e>>f;
	//scanf("%d %d %d %d %d %d ",&a,&b,&c,&d,&e,&f);
	
	for(int i=0;100*i*a <=f;i++)
		for(int j=0;100*b*j+100*i*a<=f;j++){
			water=100*i*a+100*b*j;
			//int k=0,l=0;
			for(int k=0;k*c<=((i*a+b*j)*e);k++)
				for(int l=0;l*d+k*c<=(i*a+b*j)*e;l++){
					
					sugar=k*c+l*d;
					if(sugar+water !=0 && sugar+water <= f){
					//sugarwater=(100*sugar)/(water+sugar);
					//printf("%d %d %d %d %d %d\n",i,j,k,l,sugarwater,sugar );
					if(sugar *(watsug) > (water+sugar)*maxsugar){
						//maxsugarwater=sugarwater;
						maxsugar=sugar;
						watsug=water+sugar;
					}
					}
				}

		}
	cout << watsug << " " <<maxsugar;

	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
vector <int> length;
int main() {
    scanf("%d", &N);
    for (int i=0; i<N; i++){
        int a;
        scanf("%d", &a);
        length.push_back(a);
    }
    sort(length.begin(), length.end());
    long long tot = 0;
    for (int i=0; i<N; i++){
        for (int j=i+1; j<N; j++){
            int k = lower_bound(length.begin(), length.end(), length[i]+length[j]) - 1 - length.begin();
            tot += k-j;
        }
    }
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

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

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    using P = pair<int, int>;
    int N;
    cin >> N;
    vector<P> X(N);
    cin >> X;
    if (N == 1) {
        cout << 1 << endl; return 0;
    }
    map<P, int> m;

    REP(i, N) {
        REP(j, N) {
            if (i == j) continue;
            m[{ X[i].first - X[j].first, X[i].second - X[j].second }]++;
        }
    }

    int ans = INF;
    for (auto&& a : m) { chmin(ans, N - a.second); }

    cout << ans << endl;
    return 0;
}

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

int main()
{
	long long int n, k, q, i;
	scanf("%lld %lld %lld", &n, &k, &q);
	
	long long int a[q];
	long long int player_point[n] = {0};
	
	for (i = 0; i < q; ++i)
	{
		scanf("%lld", &a[i]);
		player_point[a[i]-1]++;
	}
	
	for (i = 0; i < n; ++i)
	{
		if (player_point[i] > q-k)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2176
#include "bits/stdc++.h" // {{{
using namespace std; typedef long long ll; typedef pair<int,int> pii;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define repr(i,h,l) for(int i=(h); i >= (int)(l); --i)
#define reps(i,s,t) for(int i=(s); i <= (int)(t); ++i)
#define ALL(x)      begin(x), end(x)
#define UNQ(x)      (x).erase(std::unique(ALL(x)), end(x))
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#define YDK(f,a,b)  ((f)? (a):(b))
#ifdef  DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t\t= " << (x) << '\n'
#define show2(x,y)  clog << '(' << #x << ',' << #y << ")\t\t= " << '(' << (x) << "\t, " << (y) << ")\n"
#define LN()        fputs("\n--------------------------------\n", stderr)
struct NullPointer{};
#else
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
struct NullPointer{ NullPointer(){cin.tie(0);ios::sync_with_stdio(false);} };
#endif
#define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; }
template<class T> struct Ordered
{ virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); };
#undef def
namespace {
  constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL; ostringstream _oss;
  TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
  { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
  TMPLT(T,U) inline bool chmax(T &a, const U &b){return b>a ? a=b,1 : 0;}
  TMPLT(T,U) inline bool chmin(T &a, const U &b){return b<a ? a=b,1 : 0;}
  TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
  template<class T>   string toString(const T &x){ _oss.str(""); _oss << x; return _oss.str(); }
  template<class Itr> string mkString(Itr begin, Itr end, const char *sp = " ") {
    _oss.str(""); for(Itr i=begin; i != end; ++i) { if(i != begin)_oss << sp; _oss << *i; }
    return _oss.str();
  }
  // }}}

constexpr int MX = ten(5) + 10;

void Xx_main_xX(const vector<char*> &args)
{
  long ans = 0;
  long a, b, c;
  cin >> a >> b >> c;
  long tmp = min(b,c);
  ans += 2 * tmp;
  c -= tmp;
  b -= tmp;

  tmp = min(a, c);
  c -= tmp;
  ans += tmp;
  if (c) ++ans;


  cout << ans+b << endl;


}

} // {{{
signed main(signed argc, char *argv[]) {
  NullPointer Exception;
  cout << fixed << setprecision(9); Xx_main_xX(vector<char*>(argv, argv+argc)); return 0;
} // }}}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> gate(m);
  for(int i = 0; i < m; i++)
  {
    int l, r;
    cin >> l >> r;
    gate[i] = {l - 1, r - 1};
  }
  pair<int, int> result = gate[0];
  for(int i = 1; i < m; i++)
  {
    if(gate[i].first >= result.first && gate[i].first <=result.second){
      result.first = gate[i].first;
    }
    if(gate[i].second <= result.second && gate[i].second >= result.first){
      result.second = gate[i].second;
    }
    if(gate[i].first > result.second){
      result = {1, 0};
      break;
    }
  }
  cout << result.second - result.first + 1 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll ;
typedef vector<int> ve ;
typedef pair <int , int> pr ;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MAX INT_MAX
#define MIN (-1 * INT_MAX)
#define rep(i,a,b) for(ll i = a ; i< b ; ++i)
#define repp(i,a,b) for(i = a ; i< b ; ++i)
#define reppp(i,a) for( ll i = a ; i >= 0 ; --i)
#define loop(i , arr)  for(auto i : arr)
#define endl '\n'
ve    vec  , vec2  , vec3  , vec4 , v , p;
ll t , n , k , m , sum , cnt;
map<int,vector<int>> graph ;
vector<ve> sv ;
vector<bool>visited ;
priority_queue<ll> pq ;
map< ll , ll> mp ,  mpp ,mpc ;
bool sortBylength(pair <string , int> &a,pair <string , int>  &b)
{
    return a.first.length() > b.first.length() ;

}
ll power(ll x, unsigned long long int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
const int mod = 1e9+7 ;
char ch[100001];
const int sss = 1e6+1 ;
const int sss2 = 1e5+2 ;
int arrr[sss2] = {0} ;
vector <int> alls(6) ;
vector<int>pa ;
map<int , int> mps , mps2r ;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n ;
    cnt = 0 ;
    float ss = 0.0f ;
    rep(i , 1, n+1){
     cnt += !(i%2) ? 0 :1 ;
    }
    ss = (float) cnt/ n ;
    printf("%f" , ss) ;

}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc057_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

/**
 * ceil loga(x)
 */
int loga(ll x, ll a) {
  if (x == 0) return 0;
  int cnt = 0;
  while (x != 0) {
    x /= a;
    cnt++;
  }
  return cnt;
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N;
  cin >> N;

  ll ans = INF;
  ll tmp = 1;
  repi(i, 1, sqrt(N) + 1) {
    if (N % i != 0) continue;
    ll res = N / i;
    ll f = max(loga(tmp, 10), loga(res, 10));
    ans = min(ans, f);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256