akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if(s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    int x, y, cc = 0, c = 0, d = 0;
    bool ww = 0, e[2][18004] = {}, f[2][18004] = {};
    vector<int> a, b;
    cin >> s >> x >> y; s += 'T';
    fr(s.length()) {
        if (s[i] == 'T') {
            if (ww) b.push_back(cc), c += cc;
            else a.push_back(cc), d += cc;
            cc = 0;
            ww = !ww;
        } else cc++;
    }
    //fr(a.size()) cout << a[i] << ' '; cout << '\n';
    //fr(b.size()) cout << b[i] << ' '; cout << '\n';
    int g = 0, h = 0;
    e[0][9000] = f[0][9000] = 1;
    for (int i = 0; i < a.size(); i++) {
        for (int j = a[i]; j <= 18000 - a[i]; j++) {
            if (e[0][j]) {
                if (i) e[1][j - a[i]] = 1;
                e[1][j + a[i]] = 1;
            }
        }
        fr(18001) e[0][i] = e[1][i], e[1][i] = 0;
    }
    for (int i = 0; i < b.size(); i++) {
        for (int j = b[i]; j <= 18000 - b[i]; j++) {
            if (f[0][j]) f[1][j - b[i]] = f[1][j + b[i]] = 1;
        }
        fr(18001) f[0][i] = f[1][i], f[1][i] = 0;
    }
    //for (int i = 7990; i <= 8010; i++) cout << e[0][i] << ' ' << f[0][i] << '\n';
    if (e[0][9000 + x] && f[0][9000 + y]) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector< vector<int> > a;
	a = vector< vector<int> >(2, vector<int>(n));
	
	for(int i = 0; i < 2; i++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> a[i][j];
		}
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		int tmp_ans = a[0][0];
		
		int tmp_i1 = i;
		while(tmp_i1 != 0)
		{
			tmp_ans += a[0][tmp_i1];
			tmp_i1--;
		}
		
		int tmp_i2 = i;
		while(tmp_i2 != n)
		{
			tmp_ans += a[1][tmp_i2];
			tmp_i2++;
		}
		
		if(ans < tmp_ans)
		{
			ans = tmp_ans;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
//½{·Ìa
#include<stdio.h>
#include<string.h>
#define N 10000

void mpStr2Num(char *str,int *num)//ñð½{·®É
{
    char *ss;
    int  *nn;
    int  k;
    int  x;

    while (*str == ' ' || *str == '\t') str++;
    while (*str == '0') str++;
    ss = str;
    while (*ss >= '0' && *ss <= '9') ss++;

    if (ss == str) {
        *num = 0;
        return;
    }

    x = 0;
    k = 1;
    nn = num;
    do {
        x += (*--ss - '0') * k;
        k *= 10;
        if (k == N || ss == str) {
            *++nn = x;
            x = 0;
            k = 1;
        }
    } while (ss != str);

    *num = nn - num;
}

void mpNum2Str(int *num,char *str)//½{·®ðñÉ
{
    int  i, j;
    char *ss;
    int  x;

    if (*num == 0) {
        *str++ = '0';
        *str = '\0';
        return;
    }

    ss = str - 1;
    for (i = *num; i > 0; i--) {
        x = *++num;
        for (j = 1; j < N; j *= 10) {
            *++ss = x % 10 + '0';
            x /= 10;
        }
    }
    while (*ss == '0') ss--;

    *(ss + 1) = '\0';    
    while (str < ss) {
        x = *str;
        *str++ = *ss;
        *ss-- = x;
    }
}

void mpAdd(int *ret, int *a, int *b)
{
    int  i;
    int  lr, la, lb;
    int  *rr;
    int  x;

    la = *a;
    lb = *b;
    lr = (la >= lb) ? la : lb;

    rr = ret;
    x = 0;
    for (i = 1; i <= lr; i++) {
        if (i <= la) x += *++a;
        if (i <= lb) x += *++b;
        if (x < N) {
            *++rr = x;
            x = 0;
        } else {
            *++rr = x - N;
            x = 1;
        }
    }
    *++rr = x;
    *ret = lr + x;
}

int main(void){
	int s[30],a[30],b[30];
	char ss[100],aa[100],bb[100];
	int n,cnt,i;

	scanf("%d ",&n);
	while(n--){
		cnt=0;

	fgets(aa,100,stdin);
	mpStr2Num(aa,a);

	fgets(bb,100,stdin);
	mpStr2Num(bb,b);

	mpAdd(s,a,b);
	mpNum2Str(s,ss);

	for(i=0;i<81;i++){
		if(ss[i]!='\0'){
			cnt++;
		}
		if(cnt>80){
			printf("overflow\n");
			cnt=-6;
			break;
		}
	}
	
	if(cnt>=0){
	printf("%s\n",ss);
	}
	}
	return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  cout<<max(0LL,a-2*b)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e18
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b,ll m){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % m;  a = (a * a) % m;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e4 + 2;
ll i,n,x,y,z,cnt;
string s[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n + 1){
        cin>>s[i];
        if(s[i][s[i].length() - 1] == 'A'){
            if(s[i][0] == 'B') x += 1;
            else
                y += 1;
        }
        else{
            if(s[i][0] == 'B') z += 1;
        }
        for(ll j = 0;j < s[i].length() - 1;j += 1) if(s[i][j] == 'A' && s[i][j + 1] == 'B') cnt += 1;
    }
    cnt += x + min(y,z);
    if(x > 0 && y + z == 0) cnt -= 1;
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 768
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; 
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
 
template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;
 
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'
 
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 
 
const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
 
int N, o, t, r, a;
double DP[305][305][305];

double dp(int i, int j, int k){
    if (i < 0 || j < 0 || k < 0) return 0.0;
    if (DP[i][j][k] != -1.0) return DP[i][j][k];
    if (i == 0 && j == 0 && k == 0) return DP[i][j][k] = 0.0;
    DP[i][j][k] = 1.0;
    DP[i][j][k] += (k *dp(i,j+1,k-1) / N + j * dp(i+1,j-1,k)/N + i * dp(i-1,j,k)/N);
    DP[i][j][k] *= (1.0 * N / (i + j + k));
    return DP[i][j][k];
}



int main(){ FAST
    //ifstream cin("/Users/konwoo/input.txt");
    //ofstream cout("/Users/konwoo/output.txt");

    cin >> N;
    F0R(i,N){
        cin >> a;
        if (a == 1) ++o;
        if (a == 2) ++t;
        if (a == 3) ++r;
    }
    F0R(i,N+1) F0R(j,N+1) F0R(k,N+1) DP[i][j][k] = -1.0;
    cout << setprecision(10) << dp(o,t,r) << newl;




    



 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}


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

int main() {
  long h,w,m,ans;
  cin >> h >> w >> m;
  vector<long> vh(m),vw(m);
  set<long> hw;
  vector<pair<long,long>> hmx,wmx;
  map<long,long> hmp,wmp;
  for(long i=0;i<m;i++) {
    cin >> vh[i] >> vw[i];
    hmp[vh[i]]++;
    wmp[vw[i]]++;
    hw.insert(vh[i]*100000000+vw[i]);
  }
  for(auto itr=hmp.begin();itr!=hmp.end();itr++) {
    hmx.push_back({(*itr).second,(*itr).first});
  }
  for(auto itr=wmp.begin();itr!=wmp.end();itr++) {
    wmx.push_back({(*itr).second,(*itr).first});
  }
  sort(hmx.begin(),hmx.end());
  reverse(hmx.begin(),hmx.end());
  sort(wmx.begin(),wmx.end());
  reverse(wmx.begin(),wmx.end());
  ans=hmx[0].first+wmx[0].first;
  bool imp=true;
  for(long i=0;i<hmx.size()||imp;i++) {
    if(hmx[0].first!=hmx[i].first) break;
    for(long j=0;j<wmx.size()||imp;j++) {
      if(wmx[0].first!=wmx[j].first) break;
      if(!(hw.count(hmx[i].second*100000000+wmx[j].second))) {
        imp=false;
        break;
      }
    }
  }
  
  if(imp) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 76540
import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, K = mi()
    A = list(mi())
    c = 0
    d = 0

    for i in range(N-1):
        for j in range(i+1, N):
            if A[i] > A[j]:
                c += 1
    
    for i in range(N):
        for j in range(N):
            if A[i] < A[j]:
                d += 1

    ans = (K*(K-1)//2)%MOD
    ans *= d
    ans %= MOD
    ans += (K*c)%MOD
    ans %= MOD

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9708
#include<stdio.h>

int main(void)

{

int a,b;

scanf("%d",&a);

scanf("%d",&b);

if(a<b)

{

printf("a < b\n");
}

if(a>b)

{

printf("a > b\n");

}

if(a==b)

{

printf("a == b\n");

}
return 0;

}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    vector<int> W(N);

    int w = 0;
    int x = 0;
    Rep(i,N){
        Scd(W[i]);
        w += W[i];
    }

    int ans = 1111111;
    Rep(i,N){
        w -= W[i];
        x += W[i];
        ans = min( ans, abs(w-x) );
    }

    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();
		if(N==1)
	    {
	        if(A==B)
	           System.out.println(1);
	        else
	          System.out.println(0);
	    }
	    else 
	    {
	        if(A>B)
	            System.out.println(0);
	        else
	           System.out.println((long )(B-A)*(N-2)+1);;
	    }
//		if (start > end) {
//			System.out.println(0);
//		} else {
//			if (n == 1 && start != end) {
//				System.out.println(0);
//			} else {
//				System.out.println((long)(start + end * (n - 1)) - (long)(end + start * (n - 1)) + 1);
//			}
//
//		}
		//int max=Math.max(0,(start + end * (n - 1)) - (end + start * (n - 1)) + 1);
		//System.out.println(max);
	}

}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<bitset>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
bitset<2010>f[2010],g[2010],p[2010];
char ss[2010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read();
    for(int i=2;i<=n;i++)
    {
    	scanf("%s",ss+1);
    	for(int j=1;j<i;j++)
    	{
    		if(ss[j]=='0')p[j][i]=1;
    		else p[i][j]=1;
    	}
    }
    for(int i=1;i<=n;i++)f[i][i]=1,g[i][i]=1;
    for(int d=2;d<=n;d++)
    {
    	for(int l=1;l+d-1<=n;l++)
    	{
    		int r=l+d-1;
    		g[r][l]=(g[r]&f[l+1]&p[l]).any();
    		f[l][r]=(f[l]&g[r-1]&p[r]).any();
    	}
    }
    pr2((g[n]&f[1]).count());
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	LL n,m,ans=0,SUM=0;
	cin>>n>>m;
	vector<LL> a1,a2,b1,b2,c1,c2,sum;
	for(LL i=0;i<n;i++){
		LL a,b,c;
		cin>>a>>b>>c;
		a1.push_back(a);
		b1.push_back(b);
		c1.push_back(c);
		a2.push_back(a*-1);
		b2.push_back(b*-1);
		c2.push_back(c*-1);
		sum.push_back(0);
	}
	for(int i=0;i<2;i++){
		vector<LL> a;
		if(i) a=a2;
		else a=a1;
		for(int j=0;j<2;j++){
			vector<LL> b;
			if(j) b=b2;
			else b=b1;
			for(int k=0;k<2;k++){
				vector<LL> c;
				if(k) c=c2;
				else c=c1;
				for(int l=0;l<n;l++){
					sum[l]=a[l]+b[l]+c[l];
				}
				sort(sum.begin(),sum.end());
				SUM=0;
				for(int i=0;i<m;i++) SUM+=sum[n-1-i];
				ans=max(ans,SUM);
			}
		}
	}
	cout<<ans;
	return 0;
}


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

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


Measured memory_bytes: 3080
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto l = readln.chomp.to!double;
  auto a = l / 3;
  writefln("%.12f", a * a * a);
}


Measured memory_bytes: 256
import collections

N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(N))

a = [0 for _ in range(40)]
start = 0
for i in range(8):
    a[start:start+(i+2)] = [i+1 for _ in range(i+2)]
    start = start + (i+2)

ans = 0
for i in list(c.values()):
    ans += a[i-1]

print(ans)

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

int main()
{
  cout<<fixed<<setprecision(20);
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  double theta=abs(m*6-0.5*(h*60+m))*M_PI/180;
  if(theta==0||theta==2*M_PI||theta==4*M_PI) cout<<abs(a-b);
  else if(theta==M_PI||theta==3*M_PI||theta==5*M_PI) cout<<a+b; 
  else cout<<sqrt(a*a+b*b-2*a*b*cos(theta));
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end() 
 

ll mod_pow(ll x,ll n,ll mod) {
ll res=1;
  while(n>0) {
if(n&1) {
res=res*x%mod;
}
   x=x*x%mod;
    n>>=1;
  }
return res;
}


int main() {
  ll n,a,b;
  cin>>n>>a>>b;
  ll mod=1000000007;
ll  ans=mod_pow(2,n,mod);

  ans--;
  ll A=1;
  ll B=1;
  for(ll i=0;i<a;i++) {
A*=(n-i);
    A%=mod;
  }
  for(ll i=0;i<b;i++) {
B*=(n-i);
    B%=mod;
  }
  
  for(ll i=2;i<=a;i++) {
A*=mod_pow(i,mod-2,mod);
    A%=mod;
  }
  
  for(ll i=2;i<=b;i++) {
B*=mod_pow(i,mod-2,mod);
    B%=mod;
  }
  
  
  ans-=(A+B);
  
  if(ans<0) {
while(ans<0) {
ans+=mod;
}
  }
  
  
  cout<<ans<<endl;
}
  
  
  
  

  
  
  
  
  
  
  
  
  

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e9
#define PI (acos(-1))
int main() {
    ll n;
    cin>>n;
    ll min=n+1;
    REP(i,sqrt(n)){
        if(n%(i+1)==0){
            chmin(min,n/(i+1)+(i+1));
        }
    }
    cout<<min-2<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
N, M = map(int, input().split())
C = [list(map(int, input().split())) for i in range(M)]

def bfs(room, now):
    # print(room, now)
    plan = deque([])
    # for r in room:
    #     plan.append(r)
    plan.append(now)
    # print(plan)
    visited[1][0] = True
    while plan:
        now = plan.popleft()
        # print(now, plan)
        for i in PATH[now]:
            if visited[i][0] == True:
                # print('true')
                continue
            else:
                # for r in PATH[next]:
                #     plan.append(r)
                plan.append(i)
                # print(plan)
                visited[i][0] = True
                visited[i][1] = now

if __name__ == '__main__':
    PATH = [deque([]) for i in range(N+1)]
    
    for i in range(M):
        PATH[C[i][0]].append(C[i][1])
        PATH[C[i][1]].append(C[i][0])
    # print(PATH)
    visited = [[False,0] for i in range(N+1)]
    bfs(PATH[1], 1)
    # print(visited)
    print("Yes")
    for i in range(2,N+1):
        print(visited[i][1])


Measured memory_bytes: 118640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;
const ll INF = ll(1e18)+1;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll l = -INF, r = INF; //[l, r)
    while(l+1 < r){ //隣り合ったら終わり
        ll x = (l+r)/2; //x未満は何個？
        bool ok = [&]{
            ll cnt = 0; //条件を満たす個数
            for(int i = 0; i < n; i++){
                if(a[i] < 0){
                    int l = -1, r = n;
                    while (l+1 < r){
                        int c = (l+r)/2;
                        if(a[c]*a[i] < x) r = c;
                        else l = c;
                    }
                    cnt += n-r;
                }
                else{
                    int l = -1, r = n;
                    while(l+1 < r){
                        int c = (l+r)/2;
                        if(a[c]*a[i] < x) l = c;
                        else r = c;
                    }
                    cnt += r;
                }
                if(a[i]*a[i] < x) cnt--;
            }
            cnt /= 2; //ひっくり返したのも数えてるので
            return cnt < k;
        }();
        
        if(ok) l = x;
        else r = x;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 1792
package main

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

func main() {
	N := getStdinInt()
	a := getStdinIntArr()
	cnt := 0
	for i := 0; i < N; i++ {
		if a[i]%2 == 1 && (i+1)%2 == 1 {
			cnt++
		}
	}
	fmt.Printf("%d\n", cnt)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];
  
  int count = 0;
  for (int i = 1; i <= 100; i++) {
    for (int j = 0; j < N; j++) {
      if (h[j] >= i) {
        if (j == 0 || h[j-1] < i) count++;
      }
    }
  }
  cout << count << endl;  
}

Measured memory_bytes: 256
n=int(input())
if n<10:
    print(n)
else:
    if n<100:
        print(9)
    else:
        if n<1000:
            print(n-90)
        else:
            if n<10000:
                print(909)
            else:
                if n<100000:
                    print(909+n-9999)
                else:
                    print(90909)

Measured memory_bytes: 38384
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        i: [(usize, usize); m],
    }
    let mut one_to_i = vec![false; n];
    let mut i_to_n = vec![false; n];
    for a in 0..m {
        if i[a].0 == 1 {
            one_to_i[i[a].1 - 1] = true;
        } else if i[a].1 == n {
            i_to_n[i[a].0 - 1] = true;
        }
    }
    for j in 0..n {
        if one_to_i[j] == true && i_to_n[j] == true {
            println!("POSSIBLE");
            return;
        }
    }
    println!("IMPOSSIBLE");
}


Measured memory_bytes: 7796
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  int N, M; cin >> N >> M;

  vector <bool> bridge(N - 1);

  vector < pair <int, int> > AB(M);
  for (int i = 0; i < M; i++){
    int a, b; cin >> a >> b;
    a--; b--;
    AB[i].first = a;
    AB[i].second = b;
  }
  
  sort(AB.begin(), AB.end(), greater< pair<int, int> >());

  int ans = 0;
  for (int i = 0; i < M; i++){
    
    bool flag = false;

    int A = AB[i].first, B = AB[i].second;
    for (int j = A; j < B; j++){
      if (bridge[j] == true){
        flag = true;
        break;
      }
    }

    if (flag == false){
      bridge[A] = true;
      ans++;
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
const int mo=1e9+7;

struct Node
{
	int key,act,t;
	Node(int _key=0,int _act=0,int _t=0):key(_key),act(_act),t(_t){}
};

struct Node_Less
{
	bool operator() (const Node &a,const Node &b) const {return a.act>b.act || (a.act==b.act && a.t>b.t);}
};

tree<Node,null_type,Node_Less,rb_tree_tag,tree_order_statistics_node_update> T;
map<int,string> NS;
map<int,int> tn,ta;
map<string,int> HASH;int HASHcnt;

int Hash(string s)
{
	long long xx=1;
	int res=0;
	for (int i=0;i<(int)s.length();i++)
	{
		res=(res+xx*s[i])%mo;
		xx=xx*19390702%mo;
	}
	return res;
	return HASH[s]?HASH[s]:HASH[s]=++HASHcnt;
}

int n;

void Init()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for (int i=1;i<=n;i++)
	{
		string s;
		int x;
		cin >> s;
		cin >> x;
		NS[Hash(s)]=s;
		T.insert(Node(Hash(s),x,i));
		tn[Hash(s)]=i;
		ta[Hash(s)]=x;
	}
}

void Solve()
{
	int m,cnt=n;
	cin >> m;
	for (int t=n+1;t<=n+m;t++)
	{
		char ch;
		string s;
		int x;
		cin >> ch >> s;
		NS[Hash(s)]=s;
		if (ch=='+') cin >> x;
		if (ch=='+')
		{
			tn[Hash(s)]=t;
			ta[Hash(s)]=x;
			if (cnt<=4)
			{
				cnt++;
				T.insert(Node(Hash(s),x,t));
				int tmp=T.order_of_key(Node(Hash(s),x,t));
				if (cnt < 5 || tmp > 0) cout << s << " is not working now." << endl;
				if (cnt == 5) cout << NS[T.find_by_order(0)->key] << " is working hard now." << endl;
			}
			else
			{
				auto tmp=T.find_by_order(cnt/5-1);
				cnt++;
				T.insert(Node(Hash(s),x,t));
				if (cnt%5==0)
				{
					if ((int)T.order_of_key(Node(Hash(s),x,t)) <= cnt/5-1)
					{
						cout << s << " is working hard now." << endl;
					}
					else
					{
						cout << s << " is not working now." << endl;
						cout << NS[T.find_by_order(cnt/5-1)->key] << " is working hard now." << endl;
					}
				}
				else
				{
					if ((int)T.order_of_key(Node(Hash(s),x,t)) <= cnt/5-1)
					{
						cout << s << " is working hard now." << endl;
						cout << NS[tmp->key] << " is not working now." << endl;
					}
					else
					{
						cout << s << " is not working now." << endl;
					}
				}
			}
		}
		else
		{
			auto tmp=T.find_by_order(cnt/5-1);
			string tmps=NS[tmp->key];
			T.erase(Node(Hash(s),ta[Hash(s)],tn[Hash(s)]));
			cnt--;
			if (s==tmps)
			{
				if (cnt%5==4) continue;
				if (cnt>4) cout << NS[T.find_by_order(cnt/5-1)->key] << " is working hard now." << endl;
			}
			else
			{
				if (cnt%5==4)
				{
					if ((int)T.order_of_key(*tmp)>cnt/5-1)
					{
						cout << NS[tmp->key] << " is not working now." << endl;
					}
				}
				else
				{
					if (cnt<5) continue;
					if (T.find_by_order(cnt/5-1)->key == tmp->key) continue;
					cout << NS[T.find_by_order(cnt/5-1)->key] << " is working hard now." << endl;
				}
			}
		}
	}
}

int main()
{
	Init();
	Solve();
	return 0;
}

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

int main(void)
{
  int a,b,sum=0;
  double t;
  cin>>a>>b>>t;

  for(int i=1;i*a<(double)(t+0.5);i++){
    sum+=b;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
Module Module1
  Sub main()
    Dim a As Integer = Console.ReadLine()
    Dim b As Integer = Console.ReadLine()
    Dim c As Integer = Console.ReadLine()
    Dim d As Integer = Console.ReadLine()
    Dim train As Integer
    Dim bus As Integer
    If a < b Then
      train = a
    Else
      train = b
    End If
    If c < d Then
      bus = c
    Else
      bus = d
    End If
    Dim ans As Integer = train + bus
    Console.WriteLine(ans)
  End Sub
End Module

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

int main()
{
    int N;
    vector<int> as;
    cin >> N;
    copy_n(istream_iterator<int>(cin), N, back_inserter(as));

    sort(as.begin(), as.end());
    reverse(as.begin(), as.end());

    int alice = 0, bob = 0;
    bool alice_turn = true;
    for (auto a : as)
    {
        if (alice_turn)
        {
            alice += a;
        }
        else
        {
            bob += a;
        }

        alice_turn = !alice_turn;
    }

    cout << (alice - bob) << endl;
    return 0;
}


Measured memory_bytes: 256
cnt = 0
def dfs(g , start,N):
    global cnt
    visited = [False for i in range(N)]
    stack =[]
    stack.append(start)

    while stack:
        v = stack.pop()
        visited[v] = True

        for i in range(N):
            if g[v][i] == 1 and visited[i] ==False:
                stack.append(i)

    for i in range(N):
        if visited[i] == False:
            cnt += 1
            break


N,M = map(int,input().split())
g = [ [0 for i in range(N)] for j in range(N)]
a,b = [0] * M,[0] * M

for i in range(M):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

for i in range(M):

    g[a[i]][b[i]] -= 1
    g[b[i]][a[i]] -= 1

    dfs(g,0,N)

    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int gap(int a,int b) {
    if(a>b) swap(a,b);
    b-=a;
    return min(b,24-b);
}
signed main() {
    int N;
    cin>>N;
    vector<int> D(N+1);
    D[0]=0;
    REP(i,N) {
        cin>>D[i+1];
        D[i+1]=min(D[i+1],24-D[i+1]);
    }
    sort(ALL(D));
    int ans=INF;
    vector<int> E(N+1);
    E[0]=0;
    REPF(i,1,N+1) {
        int tmp=INF;
        REP(j,i) {
            chmin(tmp,gap(E[j],D[i]));
        }
        
        int tmp2=INF;
        REP(j,i) {
            chmin(tmp2,gap(E[j],24-D[i]));
        }

        if(tmp<tmp2) {
            E[i]=24-D[i];
        } else {
            E[i]=D[i];
        }
        chmin(ans,max(tmp,tmp2));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;


int main(){
	int inf=INT_MAX;
	int dp[1<<16];
	int n;
	while(cin>>n,n){
		for(int i=0;i<(1<<n);i++){
			dp[i]=inf;
		}
		int t[20][20];
		vector<int> vt;
		REP(i,0,n){
			REP(j,0,n+1){
				cin>>t[i][j];
			}
		}
		dp[0]=0;
		for(int i=0;i<(1<<n);i++){//all
			if(dp[i]==inf)continue;
			REP(j,0,n){//
				if((i>>j)&1) continue;
				int mint=t[j][0];
				REP(k,0,n){
					if((i>>k)&1) mint=min(mint,t[j][k+1]);
				}
				dp[i|(1<<j)]=min(dp[i|(1<<j)],dp[i]+mint);
			}
		}

		cout<<dp[(1<<n)-1]<<endl;
	}


	return 0;
}

Measured memory_bytes: 3340
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
typedef long long int llint;

int main(void){
  std::string n;

  std::cin >> n;

  if(n.find_first_of("7") != std::string::npos) std::cout << "Yes"<< std::endl;
  else                       std::cout << "No" << std::endl;
  
  return 0;
}


Measured memory_bytes: 3592
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };



int main() {
    string SS, T;
    cin >> SS >> T;
    int n = SS.size();
    int k = T.size();
    string S = SS;
    bool frag;
    for (int i = n - k; i >= 0;i--) {
        frag = true;
        rep(j, k) {
            if (SS[i + j] != T[j] && SS[i+j]!='?') frag = false;
        }
        if (frag) {
            rep(j, k) {
                S[i + j] = T[j];
            }
            break;
        }
    }
    if (frag) {
        rep(i, n) {
            if (S[i] == '?') S[i] = 'a';
        }
        cout << S << endl;
    }
    else cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
/* ITP1_8_D */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String s = br.readLine();
      String p = br.readLine();
      int s_len = s.length();
      int p_len = p.length();
      if(s_len < p_len) return;

      String ss = s + s;
      boolean judge = false;

      // CHECK
      for(int i = 0; i < s_len; i++){
        if(s.charAt(i) == p.charAt(0)){
          if(p.equals(ss.substring(i, i + p_len))){
            judge = true;
            break;
          }
        }
      }
      // OUTPUT
      if(judge)
        System.out.println("Yes");
      else
        System.out.println("No");
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24372
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;

int main(void)
{
    int k,n,i;
    int array1[50];

    cin>>n>>k;
    for(i = 0;i<n;i++)
        cin>>array1[i];

    sort(array1,array1+n);

    int sum = 0;

    for(i = n-1;i>=n-k;i--)
        sum += array1[i];

        cout<<sum<<endl;


    return 0;
}





Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]

li_ans = []
ans = 0

for j in range(min(a), max(a)):
    for k in a:
        ans += abs(k - j) ** 2
    else:
        li_ans.append(ans)
        ans = 0

if len(li_ans) == 0:
    print(0)
else:
    print(min(li_ans))

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
using namespace std;
int dp[2][5001][2];/* 今いる位置、切った長さ、ここで切ったか */
int N;
int t[10010];
int ans = 1 << 30;
int main(){
    cin >> N;
    for(int i = 1; i < N; i++){
        cin >> t[i];
    }
    for(int i = 0; i <= 1; i++){
        for(int j = 1; j <= N / 2; j++){
            for(int k = 0; k <= 1; k++){ 
                dp[i][j][k] = 1 << 30;
            }
        }
    }
    dp[1][1][0] = 0;
    for(int i = 1; i < N; i++){
        for(int j = 1; j <= N / 2; j++){
            for(int k = 0; k < 2; k++){
                int to = (i + 1) & 1;
                dp[to][j + 1][0] = min(dp[to][j + 1][0], dp[i & 1][j][0]);
                dp[to][j][1] = min(dp[to][j][1], dp[i & 1][j][0] + t[i]);
                dp[to][j + 1][0] = min(dp[to][j + 1][0], dp[i & 1][j][1] + t[i]);
                dp[to][j][1] = min(dp[to][j][1], dp[i & 1][j][1]);
            }
        }
        for(int j = 1; j <= N / 2; j++){
            for(int k = 0; k < 2; k++){
                dp[i & 1][j][k] = 1 << 30;
            }
        }
    }
    ans = min(dp[N & 1][N / 2][1], dp[N & 1][N / 2][0]);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int n, k;
int odp = 0;

void dfs(int akt, vector< vector<int> >& T, vector<int>& ojciec, vector<int>& d)
{
    for (int i = 0; i < T[akt].size(); ++i)
        dfs(T[akt][i], T, ojciec, d);
    if (akt == 0)
        return;
    if (T[akt].size() == 0)
        d[akt] = 0;
    else
    {
        int maxi = -1;
        for (int i = 0; i < T[akt].size(); ++i)
            maxi = max(maxi, d[T[akt][i]]);
        ++maxi;
        if (maxi == k - 1 && ojciec[akt] != 0)
        {
            ++odp;
            d[akt] = -1;
        }
        else
            d[akt] = maxi;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    vector<int> ojciec(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> ojciec[i];
        --ojciec[i];
    }
    if (ojciec[0] != 0)
        ++odp;
    ojciec[0] = -1;
    vector< vector<int> > T(n);
    for (int i = 1; i < n; ++i)
        T[ojciec[i]].push_back(i);
    if (k == 1)
    {
        cout << (n - 1) - T[0].size() + odp;
        return 0;
    }
    vector<int> d(n);
    dfs(0, T, ojciec, d);
    cout << odp;
    return 0;
}


Measured memory_bytes: 15872
def countingsort(A,n):
    k=max(A)
    
    B=[0 for i in range(n)]
    C=[0 for i in range(k+1)]
    
    for i in range(n):
        C[A[i]]+=1
        
    for i in range(1,k+1):
        C[i]=C[i]+C[i-1]
    
    for j in range(n-1,-1,-1):
        B[C[A[j]]-1]=A[j]
        C[A[j]]-=1
    
    print(*B)
    
n=int(input())
A=list(map(int,input().split()))

countingsort(A,n)

Measured memory_bytes: 233736
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 510;
int n,a[N][N];
ll b[N][N],c[N][N],dp[N][N];

inline ll calc1(int l,int r){
	if (l>r) return 0;
	assert(b[r][r]-b[l-1][r]-b[r][l-1]+b[l-1][l-1]>=0);
	return b[r][r]-b[l-1][r]-b[r][l-1]+b[l-1][l-1];
}
inline ll calc2(int x,int y,int z){
	return c[y][n]-c[x][n]-c[y][z-1]+c[x][z-1];
}

int main(){
	n=read();
	For(i,0,n+1) For(j,0,n+1) dp[i][j]=1e15;
	For(i,1,n) For(j,1,n) if (i!=j) a[i][j]=read();
	For(i,1,n) For(j,1,n){
		int x=(i<j)?a[i][j]:0;
		b[i][j]=b[i][j-1]+b[i-1][j]-b[i-1][j-1]+x;
	}
	For(j,1,n) For(i,1,n){
		int x=(i>j)?a[i][j]:0;
		c[j][i]=c[j][i-1]+c[j-1][i]-c[j-1][i-1]+x;
	}
	dp[0][0]=0;
	For(i,1,n) dp[0][i]=calc1(1,i);
	For(i,0,n) For(j,i+1,n) For(k,j+1,n){
		dp[j][k]=min(dp[j][k],dp[i][j]+calc1(j+1,k)+calc2(i,j,k+1));
	}
	ll ans=1e15;
	For(i,0,n-1) ans=min(ans,dp[i][n]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 10772
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> data[100000];
    int group[100000] = {0}, id = 1;
    rep(i, m)
    {
        int l, r;
        cin >> l >> r;
        data[l].push_back(r);
        data[r].push_back(l);
    }
    queue<int> que;
    rep(i, n)
    {
        que.push(i);
        if (group[i] == 0)
            group[i] = id;
        while (!que.empty())
        {
            int foo = que.front();
            que.pop();
            rep(i, data[foo].size())
            {
                if (group[data[foo][i]] == 0)
                {
                    group[data[foo][i]] = id;
                    que.push(data[foo][i]);
                }
            }
        }
        id++;
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        int a, b;
        cin >> a >> b;
        if (group[a] == group[b])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 8988
//  Created by liszt on 2019/07/15.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int N,Q; cin>>N >>Q;
    string S; cin>>S;
    int T[N];
    T[0]=0;
    for(int i=0;i<N-1;i++){
        T[i+1]=T[i];
        if(S.substr(i,2)=="AC")T[i+1]++;
    }
    
    for(int i=0;i<Q;i++){
        int l,r; cin>>l >>r;
        cout<<T[r-1]-T[l-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int a=max({A,B,C});
  int b=min({A,B,C});
  int c=(A+B+C-a-b);
  int ans=a-c+c-b;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
n = int(input())
s = [input() for i in range(n)]

ans = 0
d = {}
for i in s:
    a = [c for c in i]
    a.sort()
    a = "".join(a)
    if a in d:
        ans+= d[a]
        d[a] +=1
    else:
        d[a] = 1
print(ans)


Measured memory_bytes: 24976
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int a[3][3];rep(i,3)rep(j,3)cin>>a[i][j];
  int n;cin>>n;
  vector<vector<bool>> ok(3,vector<bool>(3,false));
  rep(i,n){
    int b;cin>>b;
    rep(j,3)rep(k,3)if(a[j][k] == b)ok[j][k] = true;
  }

  bool ans = false;
  bool tmp1 = true;
  bool tmp2 = true;
  rep(i,3){
    if(ok[i][0] && ok[i][1] && ok[i][2])ans = true;
    if(ok[0][i] && ok[1][i] && ok[2][i])ans = true;
    tmp1 &= ok[i][i];
    tmp2 &= ok[i][2-i];
  }

  if(ans || tmp1 || tmp2)print("Yes");
  else print("No");
  return 0;
}



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


int main(){
    int a=1000000,n;
    cin>>n;
    vector<int> x(n);
    rep(i,n){
        cin>>x[i];
    }
    rep(i,100){
        int b=0;
        rep(j,n){
            b+=(x[j]-i-1)*(x[j]-i-1);
        }
        a=min(a,b);
    }
    cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 256
loop{
	h,w=gets.chomp.split(" ").map{|i| i.to_i}
	break if h==0 && w==0
	map=Array.new(h,Array.new(w))
	pos=Array.new[0,0]

	for i in 0..h-1
		map[i]=gets.chomp.split("").map{|i|i.to_s}
	end

	x=0
	y=0
	loop{
		case map[y][x]
		when ">"
			x+=1
		when "<"
			x-=1
		when "^"
			y-=1
		when "v"
			y+=1
		when "."
			puts "#{x} #{y}"
			break
		end
		pos << [x,y]
		if 	pos.size != pos.uniq.size
			puts "LOOP"
			break
		end
	}
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	
	int answer = 0;
	for (int i = 0; i < N; i++)
	{
		// 3倍操作は何回でもいいが、2で割る操作は1回は行う必要があります。
		// A[i]に対して2で割る操作を何回行うことができるのかの回数を計算します。
		while(A[i] % 2 == 0)
		{
			A[i] /= 2;
			answer++;
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int len = s.length();
		
		System.out.println(s.substring(0, 1) + (len-2) + s.substring(len-1, len));
		
		sc.close();
	}
}

Measured memory_bytes: 21716