akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
#define d(x) (1 << x - 1)
using namespace std;
typedef long long ll;
typedef double db;
const int N = 16, M = 1 << N, mod = 1000000007;
int n, m, sn, a[N][N], g[M], f[N][M], sum;
int main()
{
	scanf ("%d%d", &n, &m);
	Rep(i, 1, m) {
		int x, y, z;
		scanf ("%d%d%d", &x, &y, &z);
		a[x][y] = a[y][x] = z;
		sum += z;
	}
	sn = (1 << n) - 1;
	Rep(p, 1, sn) {
		Rep(j, 1, n) if (d(j) & p) {
			Rep(k, j + 1, n) if (d(k) & p) {
				g[p] += a[j][k];
			}
		}
		if (!(d(1) & p)) continue ;
		f[1][p] = g[p];
		Rep(j, 1, n) if (d(j) & p) {
			for(int q = p & (p - 1); q; q = (q - 1) & p) if ((d(1) & q) && !(d(j) & q)) {
				Rep(k, 1, n) if ((d(k) & q) && a[j][k] && (k == 1 || f[k][q])) {
					f[j][p] = max(f[j][p], f[k][q] + a[j][k] + g[p - q]);
				}
			}
		}
	}
//	cout << f[n][sn]<<endl;
	printf("%d\n", sum - f[n][sn]);

	return 0;
}


Measured memory_bytes: 3456
n,d = gets.split.map(&:to_i)

x = []
n.times{x << gets.split.map(&:to_i)}

ans = 0
(0..n-1).to_a.combination(2) do |arr|
    a = 0.0
    d.times do |j|
        a += (x[arr[0]][j] - x[arr[1]][j]) ** 2
    end
    ans += 1 if Math.sqrt(a).denominator == 1
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
using namespace std;
long long INF = 1e10;
int main(){
  int n,i,j,k;
  cin >> n >> k;
  long long h[n+1],dp[n+1];
  for(i=1;i<=n;i++)cin >> h[i];
  for(i=0;i<=n;i++)dp[i]=INF;
  dp[1]=0;
  for(i=1;i<n;i++){
    for(j=1;j<=k && j+i<=n;j++)dp[i+j]=min(dp[i]+abs(h[i]-h[i+j]),dp[i+j]);
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

typedef long long int lli;
lli left[100005];
lli right[100005];
lli A[100005];
int N;

int main(){
	scanf("%d", &N);
	for(int i=1; i<=N; ++i)
		scanf("%lld", A+i);
	left[N] = right[N] = 2;
	A[0] = 1;
	if(A[N] != 2){
		printf("-1\n");
		return 0;
	}
	for(int i=N; i>0; --i){
		left[i-1] = ((left[i] - 1) / A[i-1] +1) * A[i-1];
		right[i-1] = (right[i] + A[i] - 1) / A[i-1] * A[i-1];
		if(left[i-1] > right[i-1]){
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld %lld\n", left[0], right[0]);
}




Measured memory_bytes: 2560
#include <stdio.h>
 int main()
{
double h, v, y, t;
int i;
while (scanf("%lf", &v) != EOF){
t = v / 9.8;
y = 4.9 * t * t;
i = 1;
while (1){
if (5 * i - 5 >= y){
break;
}
else {
i++;
}
}
printf("%d\n", i);
}
return 0;
}

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

int n , k;
int arr[105];
int dp[100005];

int mex(vector <int> v){
    sort(v.begin() , v.end());
    int j = 0;
    for(int i = 0; i < (int)v.size(); i++){
        if(v[i]!=j){
            return j;
        }
        j++;
    }
    return (j);
}

int grundy(int i){
    if(i==0){
        return 0;
    }
    if(i < 0){
        return -1;
    }
    if(dp[i] != -1){
        return dp[i];
    }
    vector <int> v;
    for(int j = 0; j < n; j++){
        if(i - arr[j] < 0){
            break;
        }
        int x = grundy(i - arr[j]);
        v.push_back(x);
    }
    return(dp[i] = mex(v));
    v.clear();
    
}

int main(){
    memset(dp , -1 ,sizeof(dp));
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr , arr + n);
    int ans = grundy(k);
    if(ans){
        cout << "First\n"; return 0;
    }
    cout << "Second\n";
}

Measured memory_bytes: 13184
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    string S[N];
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }
    
    int alst = 0;
    int bfir = 0;
    int cnt = 0;
    int both = 0;
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(S[i][0] == 'B' && S[i][S[i].size()-1] == 'A') both++;
        else{
            if(S[i][0] == 'B'){
                bfir++;
            }
            if(S[i][S[i].size()-1] == 'A') alst++;
        }
        for(int j = 1; j < S[i].size(); j++){
            if(S[i][j]=='B' && S[i][j-1]=='A'){
                cnt++;
            }
        }
        
        
    }
    
    ans += cnt;
    if(both==0){
        ans += min(alst, bfir);
    } else {
        if(alst + bfir == 0){
            ans += (both-1);
        } else {
            ans += both;
            ans += min(alst, bfir);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>

typedef long long ll;
#define rep(i,n) for(ll i = 0; i < n; i++)

using namespace std;

int main(){
	/****input****/
	int l;
	cin >> l;

	/****calc****/
	double ans;
	ans = (l/3.0)*(l/3.0)*(l/3.0);

	/****output****/
	std::cout << std::fixed;
	std::cout << std::setprecision(12) << ans;
    return 0;
}


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

int main() {
  int h, w;
  string a, x;
  cin >> h >> w;

  for (int i = 0; i < w + 2; i++) x += "#";
  cout << x << endl;
  while (h--) cin >> a, cout << "#" << a << "#" << endl;
  cout << x << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int h,w;
int n;
int a[10010];
int pointer;
int x,y;
int ans[110][110];
int main(){
	scanf("%d %d",&h,&w);
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	while(x<h&&y<w){
		//printf("%d %d %d\n",x,y,pointer);
		if(y%2){
			ans[x][y] = pointer;
			a[pointer]--;
			if(!a[pointer]) pointer++;
			if(x==0) y++;
			else x--;
		} else {
			ans[x][y] = pointer;
			a[pointer]--;
			if(!a[pointer]) pointer++;
			if(x==h-1) y++;
			else x++;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%d ",ans[i][j]+1);
		}
		puts("");
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
#include <queue>
using namespace std;
const int N=1e5+10,INF=0x3f3f3f3f;
typedef pair<int,int>P;
typedef vector<int>::iterator ive;
long long step[N];
int k;
map<int,vector<int> >m;
map<P,int>mmp;
void bfs(){
    queue<int>q;
    q.push(k);
    step[k]=0;
    while(!q.empty()){
        int now=q.front();
        q.pop();
        for(ive it=m[now].begin();it!=m[now].end();it++){
            if(step[now]+mmp[P(max(*it,now),min(*it,now))]<step[*it]){
                step[*it]=step[now]+mmp[P(max(*it,now),min(*it,now))];
                q.push(*it);
            }
        }
    }
}
int main()
{
    int n,a,b,c,q,x,y;
    while(~scanf("%d",&n)){
        memset(step,INF,sizeof(step));
        m.clear();
        mmp.clear();
        n--;
        while(n--){
            scanf("%d%d%d",&a,&b,&c);
            m[a].push_back(b);
            m[b].push_back(a);
            mmp[P(max(a,b),min(a,b))]=c;
        }
        scanf("%d%d",&q,&k);
        bfs();
        while(q--){
            scanf("%d%d",&x,&y);
            printf("%lld\n",step[x]+step[y]);
        }
    }
    return 0;
}

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


int main(){
    IOS;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool one=1;
    while(a>0 && c>0){
        if(one){
            c-=b;
            one=0;
        }
        else {
            a-=d;
            one=1;
        }
    }
    if(a<=0)cout<<"No";
    else cout<<"Yes";
    return 0;  
} 





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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    string s;
    cin >> s;
    if(s == "SAT")cout << 1;
    if(s == "FRI")cout << 2;
    if(s == "THU")cout << 3;
    if(s == "WED")cout << 4;
    if(s == "TUE")cout << 5;
    if(s == "MON")cout << 6;
    if(s == "SUN")cout << 7;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define INF 2147483647
using namespace std;

int n,query[300000];

void init(int n_){
	n = 1;
	while(n < n_) n *= 2;
	for(int i = 0;i < n * 2 - 1;i++) query[i] = INF;
}

void update(int a,int x){
	a += n - 1;
	query[a] = x;
	while(a){
		a = (a - 1) / 2;
		query[a] = min(query[a * 2 + 1],query[a * 2 + 2]);
	}
}

int find(int s,int t,int k,int l,int r){
	if(t <= l || s >= r) return INF;
	if(l >= s && r <= t) return query[k];
	else return min(find(s,t,k * 2 + 1,l,(r + l) / 2),find(s,t,k * 2 + 2,(r + l) / 2,r));
}

int main(){
	int q;
	cin >> n >> q;
	init(n);
	for(int i = 0;i < q;i++){
		int a,b,c;
		cin >> a >> b >> c;
		if(a == 0){
			update(b,c);
		}
		else{
			cout << find(b,c + 1,0,0,n) << endl;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

int N;
vi A;

signed main() {
    cin >> N;
    A = vi(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] -= (i + 1);
    }

    sort(ALL(A));
    int h = A.size() / 2;
    int mid = A[h];
    if (A.size() % 2 == 0) {
        mid = (A[h - 1] + A[h]) / 2;
    }

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += abs(A[i] - mid);
    }

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

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

int main() {
  int a, b;
  
  cin >> a >> b;

  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <fstream>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
#define INF (1LL<<60)-1
using namespace std;
 
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*ll t,tcitr;
    cin>>t;
    tcitr=0;
    while(tcitr<t)
    {*/
        //cout<<"Case #"<<tcitr+1<<": ";
        ll n,i,j,k;
        cin>>n;
        ll a[n];
        ll prod=1;
        ll prm[1000001]={};
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            prm[a[i]]++;
        }
        ll gd=gcd(a[0],a[1]);
        for(i=2;i<n;i++)
        {
            gd=gcd(gd,a[i]);
        }
        if(gd!=1)cout<<"not coprime\n";
        else
        {
            bool flg=false;
            for(i=2;i<=1000000;i++)
            {
                for(j=2*i;j<=1000000;j+=i)
                {
                    prm[i]+=prm[j];
                }
                if(prm[i]>1)
                {
                    flg=true;
                    break;
                }
            }
            (flg)?cout<<"setwise coprime\n":cout<<"pairwise coprime\n";
        }
        /*tcitr++;
    }*/
    return 0;
}

Measured memory_bytes: 19252
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

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

ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}


//入力
int a, b;


int main(){

    cin >> a >> b;

    if(a <= 5){
        cout << 0 << endl;
        return 0;
    }

    if(a <= 12){
        cout << b / 2 << endl;
        return 0;
    }

    cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
/*
	*	Created By: 'Present_Sir'
	*	Created On: Friday 21 August 2020 10:54:23 AM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int n;
    cin>>n;
    int a1[] = { 2, 4, 5, 7, 9 };
    int a2[] = { 0, 1, 6, 8 };
    
    for(int i=0; i<5; ++i){
        if(n%10 == a1[i]){
            cout<<"hon"<<endl;
            return;
        }
    }

    for(int i=0; i<4; ++i){
        if(n%10 == a2[i]){
            cout<<"pon"<<endl;
            return;
        }
    }
    cout<<"bon"<<endl;
    return;
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>

long long k[1000001] = {};

int main()
{
    long long n, p, i, ori_p;
    scanf("%lld %lld", &n, &p);

    if (n == 1)
    {
        printf("%lld\n", p);
        return 0;
    }
    ori_p = p;
    for (i = 2; i <= (long long)sqrt(ori_p); i++)
        while (p % i == 0)
        {
            k[i]++;
            p /= i;
        }

    long long sum = 1;
    for (i = 2; i <= (long long)sqrt(ori_p); i++)
        if (k[i] >= n)
            sum *= (long long)pow(i, (k[i] / n));
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vector<string> W(N);
    REP(i, N) cin >> W[i];

    bool f = true;
    set<string> s;

    REP(i, N){
        if(s.count(W[i]) > 0) f = false;
        if(i > 0 && W[i][0] != W[i - 1][W[i - 1].size() - 1]) f = false;
        s.insert(W[i]);
    }

    if(f){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
W, H, x, y = tuple([int(s) for s in input().split()])
S = W * H / 2
flag = 1 if (W % 2 == 0 and H % 2 == 0 and W // 2 == x and H // 2 == y) else 0
print("{0} {1}".format(S, flag))

Measured memory_bytes: 2940
from collections import defaultdict
N = int(input())

cnt = defaultdict(int)

for a in range(1, N + 1):
    cnt[(str(a)[0], str(a)[-1])] += 1

ans = 0
for head in range(1, 10):
    for tail in range(1, 10):
        ans += cnt[(str(head), str(tail))] * cnt[(str(tail), str(head))]

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
 
 
int dfs(int i, vector<int> &dp, vector<vector<int>> &adj){
    if(dp[i])return dp[i];

    dp[i]=1;
    int ans=0;
    for(auto child: adj[i]){
        ans=max(ans,dfs(child,dp,adj));
    }
    dp[i]+=ans;

    // cout<<i<<' '<<dp[i]<<endl;
    
    return dp[i];
}


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

    vector<vector<int>> adj(n+1);
    vector<int> dp(n+1);

    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
    }

    // for(auto x:adj){
    //     for(auto y:x)cout<<y<<' ';
    //     cout<<endl;
    // }

    int ans=0;
    for(int i=1;i<=n;i++){
        if(!dp[i])dfs(i,dp,adj);
        ans=max(ans,dp[i]);
    }
    cout<<ans-1<<endl;
}



int main()
{   
    // int n;
    // cin>>n;

    // while(n--)
    solve();

    return 0;
}

Measured memory_bytes: 8832
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  string S, T;
  cin >> S >> T;
  T += S;
  cout << T << endl;
}

Measured memory_bytes: 256
import bisect


_, _, k = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
A.insert(0, 0)
B.insert(0, 0)

for i in range(1, len(A)):
    A[i] = A[i - 1] + A[i]

for i in range(1, len(B)):
    B[i] = B[i - 1] + B[i]


res = 0
for i in range(len(A)):
    if k < A[i]:
        break

    j = bisect.bisect_left(B, k - A[i])
    if j == len(B) or B[j] > k - A[i]:
        j -= 1


    cnt = i + j
    res = max(res, cnt)
print(res)


Measured memory_bytes: 123792
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int[] a;

    private void solve() {

        int min = (int)1e9 + 7;
        int max = 0;
        a = new int[3];
        for(int i = 0;i < 3;i++) {
            a[i] = nextInt();

            min = Math.min(min, a[i]);
            max = Math.max(max, a[i]);
        }

        out.println(max - min);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int memo[10][10] = {0};
int wl[10][3] = {0};
int n, m, x, y, ans = 0, hal;

void solve(int now, int riv);
void check();
int main() {
  int i, j;
  while(1) {
    cin >> n;
    if(n == 0) break;
    for(i = 1; i <= n; i++)
      for(j = 0; j < 2; j++) wl[i][j] = 0;
    for(i = 1; i <= n; i++)
      for(j = 1; j <= n; j++) memo[i][j] = 0;
    cin >> m;
    for(i = 0; i < m; i++) {
      cin >> x >> y;
      memo[x][y] = 1;
      memo[y][x] = 2;
      wl[x][0]++;
      wl[y][1]++;
    }
    hal = (n - 1) / 2;
    ans = 0;
    // check();
    solve(1, 2);
    cout << ans << endl;
    ;
  }
  return 0;
}

void solve(int now, int riv) {
  int nnow, nriv;
  if(now == n && riv == n + 1) {
    check();
    return;
  }
  if(riv < n) {
    nnow = now;
    nriv = riv + 1;
  }
  else {
    nnow = now + 1;
    nriv = nnow + 1;
  }
  if(now == riv || memo[now][riv] != 0)
    solve(nnow, nriv);
  else {
    if(hal > wl[now][0]) {
      ++wl[now][0];
      ++wl[riv][1];
      memo[now][riv] = 1;
      memo[riv][now] = 2;
      solve(nnow, nriv);
      --wl[now][0];
      --wl[riv][1];
    }
    if(hal > wl[now][1]) {
      ++wl[now][1];
      ++wl[riv][0];
      memo[now][riv] = 2;
      memo[riv][now] = 1;
      solve(nnow, nriv);
      --wl[now][1];
      --wl[riv][0];
    }
    memo[now][riv] = 0;
    memo[riv][now] = 0;
  }
}

void check() {
  int i, j;
  /*for(i = 1; i <= n; ++i) {
    for(j = 1; j <= n; ++j) cout << memo[i][j] << " ";
    cout << endl;
  }
  cout << "wl";
  for(i = 1; i <= n; ++i) cout << " " << wl[i][0];
  cout << endl << endl;*/
  for(i = 1; i <= n; ++i)
    if(wl[i][0] != hal || wl[i][1] != hal) return;

  ++ans;
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  int D = max({A, B, C}), E = max({A, B, C});
  for (int i = 0; i < K; i++) D *= 2;

  cout << A + B + C + D - E << endl;
}

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

using P = pair<long long, int>;

struct edge {
    int to; 
    long long cost;
};

const long long INF = 1ll << 60;
const int MAX_V = 100000;
int V;
vector<edge> G[MAX_V + 1];
long long d[MAX_V + 1];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    V = n;
    for (int i = 0; i < m; i++) {
        int l, r;
        long long c;
        cin >> l >> r >> c;
        l--; r--;
        G[l].push_back(edge{r, c});
    }
    for (int i = 0; i < n - 1; i++) {
        G[i + 1].push_back(edge{i, 0});
    }

    dijkstra(0);

    if (d[n - 1] == INF) cout << -1 << endl;
    else cout << d[n - 1] << endl;
}

Measured memory_bytes: 9340
from math import sqrt
def calc(x1, y1, rr1, x2, y2, rr2):
    rr0 = (x2 - x1)**2 + (y2 - y1)**2
    xd = x2 - x1
    yd = y2 - y1
    cv = (rr0 + rr1 - rr2)
    if 4*rr0*rr1 < cv**2:
        return tuple()
    if 4*rr0*rr1 == cv**2:
        return ((x1 + cv*xd/(2.*rr0), y1 + cv*yd/(2.*rr0)),)
    sv = sqrt(4*rr0*rr1 - cv**2)
    return (
        (x1 + (cv*xd - sv*yd)/(2.*rr0), y1 + (cv*yd + sv*xd)/(2.*rr0)),
        (x1 + (cv*xd + sv*yd)/(2.*rr0), y1 + (cv*yd - sv*xd)/(2.*rr0)),
    )

def solve(mid):
    ps = []
    for i in xrange(n):
        x1, y1, l1 = P[i]
        if l1 < mid:
            return 0
        rr1 = l1**2 - mid**2
        for j in xrange(i):
            x2, y2, l2 = P[j]
            rr2 = l2**2 - mid**2
            if (x1 - x2)**2 + (y1 - y2)**2 > (sqrt(rr1)+sqrt(rr2))**2:
                return 0
            ps.extend(calc(x1, y1, rr1, x2, y2, rr2))
        ps.append((x1, y1))
    if n == 1:
        return 1
    for px, py in ps:
        if all((px-x)**2 + (py-y)**2 < l**2 - mid**2 + 1e-8 for x, y, l in P):
            return 1
    return 0

while 1:
    n = input()
    if n == 0:
        break
    P = [map(int, raw_input().split()) for i in xrange(n)]

    left = 1.; right = min(l for x, y, l in P)+1e-8
    while left+1e-8 < right:
        mid = (left + right) / 2.
        if solve(mid):
            left = mid
        else:
            right = mid
    print "%.08f" % left

Measured memory_bytes: 6500
#include <bits/stdc++.h>
using namespace std;
// #define  int long long
class Node{
	public:
	long long leftvalue,rightvalue,val = 0;
	Node *left,*right;
	
	Node(int l,int r){
		leftvalue = l,rightvalue = r;
		left = right = NULL;
	}
};


long long max(long long a,long long b){
	if(a<b) return b;
	return a;
}

class SegmentTree{
    public:
	Node *root = NULL;							//SEGMENT TREE ROOT NODE
    
    // //INORDER HELPER FUNCTION
    // void showinorder(Node *p){
	// 	if(p!=NULL){
	// 		showinorder(p->left);
	// 		cout<<p->val<<" LEFT VALUE"<<p->leftvalue<<" RIGHT VALUE"<<p->rightvalue<<endl;
	// 		showinorder(p->right);
	// 	}
	// }

	// //SHOW TREE IN INORDER FORM
    // void show(){
    //     showinorder(root);
    // }
    
	//BUILD SEGMENT TREE HELPER FUNCITON
	Node* build(int l,int r){
		Node *temp = new Node(l,r);
		if(l == r){
			temp->val = 0;
		}
		else
		{
			int mid = (l+r)>>1;
			temp->left = build(l,mid);
			temp->right = build(mid+1,r);
			temp->val = max(temp->right->val,temp->left->val);
		}
		return temp;
	}
	//BUILD SEGMENT TREE
	void buildtree(){
        root =  build(0,200005);
	}

	//UPDATE SEGMENT TREE HELPER FUCNTION
	Node* update(Node* p,int ind,long long value){
		if(p->leftvalue == p->rightvalue and p->leftvalue == ind){
			p->val = value;
		}
		else if(p->leftvalue<=ind and p->rightvalue>=ind)
		{
			p->left = update(p->left,ind,value);
			p->right = update(p->right,ind,value);
			p->val = max(p->left->val,p->right->val);
		}
		return p;
		
	}
	//UPDATE SEGMENT TREE
	void updatetree(int ind,long long value){
		root = update(root,ind,value);
	}

	//QUERY FUNCTION HELPER
	long long query(Node* p,int l,int r){
		if(p->leftvalue>=l and p->rightvalue<=r){ return p->val; }
		else if(p->leftvalue>r or p->rightvalue<l){ return 0; }
		else{ 
			long long a = query(p->left,l,r),b = query(p->right,l,r);
			return max(a,b);
		}
	}

	//QUERY FUNCTION
	long long queryst(int l,int r){ return query(root,l,r); }
};


vector <int> h(200005),a(200005);

int main(){
	int n;
	cin>>n;
	// h.clear();
	// a.clear();
	for(int i = 0;i<n;++i) cin>>h[i];
	for(int i = 0;i<n;++i) cin>>a[i];

	SegmentTree st;
	st.buildtree();
	long long int ans = 0,curr = 0;
	for(int i = 0;i<n;++i){
		curr = st.queryst(0,h[i]);
		curr += a[i];
		ans = max(ans,curr);
		st.updatetree(h[i],curr);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 20608
import collections
import heapq
import math
import random
import sys
input = sys.stdin.readline
sys.setrecursionlimit(500005)
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
rs = lambda: input().rstrip()

n = ri()
a = rl()
N = 1000000
f = [0] * (N + 10)
for v in a:
    f[v] += 1
for i in range(N, 0, -1):
    if f[i] == 0:
        continue
    j = i * 2
    while j <= N:
        f[j] += f[i]
        j += i
cnt = sum(f[i] == 1 for i in a)
print(cnt)



Measured memory_bytes: 131452
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}

int main()
{
    int n;
    cin >> n;
    int a[n];
    cn(a, n);
    sort(a, a + n);
    ll ans = a[n - 1];
    for (int i = 2; i <= (n + 1) / 2; i++)
    {
        ans += 2 * a[n - i];
    }
    if (n % 2 != 0)
    {
        ans -= a[n - (n + 1) / 2];
    }
    cout << ans;
}

Measured memory_bytes: 4392
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhijeetkns
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BYYMMOrMMYY solver = new BYYMMOrMMYY();
        solver.solve(1, in, out);
        out.close();
    }

    static class BYYMMOrMMYY {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int val1 = Integer.parseInt(s.substring(0, 2));
            int val2 = Integer.parseInt(s.substring(2, 4));
            if ((val1 >= 1 && val1 <= 12) && (val2 >= 1 && val2 <= 12)) out.println("AMBIGUOUS");
            else if ((val1 >= 1 && val1 <= 12)) out.println("MMYY");
            else if (val2 >= 1 && val2 <= 12) out.println("YYMM");
            else out.println("NA");
        }

    }
}



Measured memory_bytes: 23764
Sa = list(input())
Sb = list(input())
Sc = list(input())
i = 0
n = "a"
ai = 0
bi = 0
ci = 0

while True:
    if n =="a":
        if len(Sa) == ai:
            print("A")
            break
        n = Sa[ai]
        ai += 1

    elif n =="b":
        if len(Sb) == bi:
            print("B")
            break
        n = Sb[bi]
        bi+= 1

    elif n =="c":
        if len(Sc) == ci:
            print("C")
            break
        n = Sc[ci]
        ci+=1


Measured memory_bytes: 3064
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N,a[22];
double dp[22][200010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N)cin>>a[i];
	rep(i,N+1)rep2(j,1,200001)dp[i][j] = i ? INF : 0;
	rep(i,N)rep2(j,1,200001){
		for(int k = j; k <= 200000; k += j){
			dp[i+1][k] = min(dp[i+1][k], max(dp[i][j], fabs(a[i] - k)/a[i]));
		}
	}
	double ans = INF;
	rep2(j,1,200001)ans=min(ans,dp[N][j]);
	cout<<fixed<<setprecision(16)<<ans<<endl;
}

Measured memory_bytes: 34080
n, k = list(map(int, input().split()))

s = 0

if k == 0:
    print(n ** 2)
else:
    for i in range(k+1, n+1):
        if n % i < k:
            s += n // i * (i - k)
        else:
            s += n // i * (i - k) + n % i - (k-1)
        
    print(s)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	int len = a.length(),b=0;
	for(int i = 1;i<len-1;i++){
		b++;
	}
	cout<<a[0]<<b<<a[len-1];


	return 0;
}


Measured memory_bytes: 256
S=input()
if len(S)%2!=0:
  print("No")
  exit()
for i in range(int(len(S)/2)):
  if S[i*2]!="h":
    print("No")
    exit()
  if S[i*2+1]!="i":
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		COMinit(N + 1);
		for (int i = 1; i <= K; i++) {
			if (N - K < i - 1) {
				System.out.println(0);
				continue;
			}
			System.out.println((COM(N - K + 1, i) * COM(K - 1, i - 1)) % MOD);
		}
	}

	static int MOD = 1000000007;

	static long[] fac;
	static long[] finv;
	static long[] inv;

	// テーブルを作る前処理
	static void COMinit(int N) {
		fac = new long[N];
		finv = new long[N];
		inv = new long[N];
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < N; 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;
		}
	}

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

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23892
#include<cstdio>
using namespace std;
int main(void)
{
	int hyou[8][8]={{0,0,0,0,0,0,0,0},
					{0,0,300,500,600,700,1350,1650},
					{0,6,0,350,450,600,1150,1500},
					{0,13,7,0,250,400,1000,1350},
					{0,18,12,5,0,250,850,1300},
					{0,23,17,10,5,0,600,1150},
					{0,43,37,30,25,20,0,500},
					{0,58,52,45,40,35,15,0}};
	int ic1,ic2,h1,h2,m1,m2,i,j,wk,t1,t2,kin;
	
	while(1)	{
		scanf("%d",&ic1);
		if(ic1==0)	break;
		scanf("%d %d",&h1,&m1);
		scanf("%d",&ic2);
		scanf("%d %d",&h2,&m2);
		if(ic1>ic2)	{
			wk=ic1;
			ic1=ic2;
			ic2=wk;
		}
		t1=h1*60+m1;
		t2=h2*60+m2;
		if(((t1>=17*60+30 && t1<=19*60+30) || (t2>=17*60+30 && t2<=19*60+30)) && hyou[ic2][ic1]<=40)	{
			if(hyou[ic1][ic2]%100!=0)	{
				kin=(hyou[ic1][ic2]+50)/2;
			}
			else {
				kin=hyou[ic1][ic2]/2;
			}
		}
		else {
			kin=hyou[ic1][ic2];
		}
		printf("%d\n",kin);
	}
	return 0;
}


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

int main(){
  string S,T;
  cin>>S>>T;
  
  if(S.length()<T.length()){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  
  string ans="";
  for(int i=S.length()-T.length();i>=0;i--){
    ans=S;
    //cout<<"i:"<<i<<endl;
    for(int j=0;j<T.length();j++){
      if(S.at(i+j)==T.at(j) || S.at(i+j)=='?'){
        ans.at(i+j)=T.at(j);
        //cout<<"ans:"<<ans<<endl;
      }else{
        break;
      }
      if(j==T.length()-1){
        for(int k=0;k<S.length();k++){
          if(ans.at(k)=='?'){
            ans.at(k)='a';
          }
        }
        cout<<ans<<endl;
        return 0;
      }
    }
  }
  
  cout<<"UNRESTORABLE"<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	double ans = 0.0;
	REP(i, n) {
		double a;
		cin >> a;
		string s;
		cin >> s;
		if (s == "JPY") {
			ans += a;
		}
		else {
			ans += (double)380000.0*a;
		}
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#include<stdio.h>

int main (){

  int x,y,a,d,gcd;

  scanf("%d%d",&x,&y);
  if(x>y){
    a = y;
    y = x;
    x = a;
  }
  
  while(y%x != 0){
    d = y%x;
    y = x;
    x = d;
  }
  printf("%d\n",x);

  return 0;
}

Measured memory_bytes: 592
#include<cstdio>
using namespace std;
int a[200005];
int main(){
	int n,i,j=1;
	long long sum,ans=0;
	int yhs;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	yhs=a[1];
	sum=a[1];
	for(i=1;i<=n;i++){
		while(j<=n&&yhs==sum){
			ans+=j-i+1;
			j++;
			sum+=a[j];
			yhs^=a[j];
		}
		sum-=a[i];
		yhs^=a[i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 896
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 2000000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
long long a[26];
int main(){
	ios_base::sync_with_stdio(false);
	long long i,j,ans,n;
	string s;
	cin>>s;
	n=s.size();
	ans=n*(n-1)/2;
	for(i=0;i<n;i++) a[s[i]-'a']++;
	for(i=0;i<26;i++){
		ans-=(a[i]*(a[i]-1))/2;
	}
	cout<<++ans;
	return 0;
}



Measured memory_bytes: 720
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		TreeMap<String, List<Integer>> map = new TreeMap<String, List<Integer>>();

		for(int i = 0; i < q; i++) {
			int query = sc.nextInt();

			switch(query) {
			case 0:  //insert
				String key = sc.next();
				int x = sc.nextInt();
				if(map.get(key) == null) {
					map.put(key, new ArrayList<Integer>());
				}
				map.get(key).add(x);
				break;

			case 1:  //get
				key = sc.next();
				if(map.get(key) != null) {
					for(int num : map.get(key)) {
						System.out.println(num);
					}
				}
				break;

			case 2:  //delete
				key = sc.next();
				if(map.get(key) != null) {
					map.remove(key);
				}
				break;

			case 3:  //dump
				String first = sc.next();
				String last = sc.next();
				//map.subMap(first, true, last , true).forEach((color, value) -> {
				for(String color : map.subMap(first, true, last, true).keySet()) {
					for(int num : map.subMap(first, true, last, true).get(color)) System.out.println(color + " " + num);
				}
			}
		}
	}

}



Measured memory_bytes: 198244
#include <iostream>

using namespace std;

const int N = 100010;
typedef long long ll;

int n,m;
int mod = 1e9+7;
int a[N],b[N];

int main()
{
   ll num;
   ll sum1 = 0,sum2 = 0;
   cin >> n >> m;
   for (int i = 1; i <= n; i ++ )
    {
    cin >> num;
    sum1 += (i-1)*num-(n-i)*num;
    sum1 %= mod;
   }
   for (int i = 1; i <= m; i ++ )
   {
    cin >> num;
    sum2 += (i-1)*num-(m-i)*num;
    sum2 %= mod;
   }
   cout << (sum1 * sum2) % mod << endl;
   return 0;
}


Measured memory_bytes: 384
#ifdef local_mode
#include <cstdio>
    #include <cassert>
#endif
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
#ifdef local_mode
    //#define FILENAME "test" ← defined via command line
    assert(freopen(FILENAME ".in", "r", stdin));
    assert(freopen(FILENAME ".out", "w", stdout));
#endif
    ios_base::sync_with_stdio(0), cin.tie(0);

    int n,m;
    cin >> n >> m;
    if (n == 1 && m == 1) {
        cout << 1;
    } else if (n == 1 || m == 1) {
        cout << max(n, m) - 2;
    } else {
        cout << ((ll)(n - 2)) * (m - 2);
    }

    return 0;
}







































Measured memory_bytes: 256
//ABC0117A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	double t, x;
	cin >> t >> x;
	double ans = 0.0;
	ans = t/x;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// header {{{
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
using namespace std;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}

template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
// }}}

// init {{{
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {


	i64 ans = 0;
	string ANS;
	int N, M;

	cin >> N >> M;
	vector<i64> vec(N);
	for (i64 i = 0; i < N; i++) {
		cin >> vec.at(i);

	}

	std::sort(vec.begin(), vec.end());
	for (i64 i = 0; i < N - M; i++) {
		ans += vec.at(i);

	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
//15:36:00 start

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace  std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int x=0;
	int tmp=n;
	while(tmp)
	{
		x+=tmp%10;
		tmp/=10;
	}
	if(n%x)cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}








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

using namespace std;

//#define FILE_IO

typedef long long LL;

LL N;
LL dp[205][2];
LL cnt[205];
vector <int> ans;

void solve(LL N)
{
    if(N == 1)  return;
    if(N == 2)  { ans.push_back(1); return; }

    if(N % 2 == 1)
    {
        solve(N - 1);
        int val = ans.size() + 1;
        ans.insert(ans.begin(), val);
    }
    else
    {
        solve(N / 2);
        int val = ans.size() + 1;
        ans.push_back(val);
    }
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%lld", &N);
    solve(N + 1);

    printf("%d\n", 2 * ans.size());
    for(auto x: ans)
        printf("%d ", x);
    for(int i = 1; i <= ans.size(); i++)
        printf("%d ", i);

    return 0;
}


Measured memory_bytes: 256
import itertools
N, M = list(map(int, input().split(" ")))

switches = []
for _ in range(M):
    l = list(map(int, input().split(" ")))
    switches.append(l[1:])


points = list(map(int, input().split(" ")))
# スイッチの数はN個。このkonおスイッチにon/offの状態があるので2^N
# これの全部の組み合わせを出して、条件を全て満たせる組み合わせがあればクリア
count = 0
for i in range(2**N):
    for j, switch in enumerate(switches):
        n = 0
        for k in switch:
            # print(i, k, i >> (k - 1))
            n += i >> (k - 1)
        # print("========")
        if n % 2 == points[j]:
            continue
        else:
            break
    # breakによって抜けなかった時
    else:
        count += 1
print(count)


Measured memory_bytes: 39920