akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	int **f1 = new int*[n], **f2 = new int*[n], **f3 = new int*[n];
	for (int i = 0; i < n; ++i) {
		f1[i] = new int[10];
		f2[i] = new int[100];
		f3[i] = new int[1000];
		for (int j = 0; j < 10; ++j) {
			f1[i][j] = (i == 0) ? 0 : f1[i - 1][j];
		}
		for (int j = 0; j < 100; ++j) {
			f2[i][j] = (i == 0) ? 0 : f2[i - 1][j];
		}
		for (int j = 0; j < 1000; ++j) {
			f3[i][j] = (i == 0) ? 0 : f3[i - 1][j];
		}
		int x = s[i] - '0';
		f1[i][x] = 1;
		if (i == 0) {
			continue;
		}
		for (int y = 0; y < 10; ++y) {
			if (f1[i - 1][y]) {
				f2[i][y * 10 + x] = 1;
			}
			for (int z = 0; z < 10; ++z) {
				if (f2[i - 1][y * 10 + z]) {
					f3[i][y * 100 + z * 10 + x] = 1;
				}
			}
		}
	}
	int res = 0;
	for (int i = 0; i < 1000; ++i) {
		if (f3[n - 1][i]) {
			++res;
			//print(i);
		}
	}
	cout << res << endl;
	return 0;

}

Measured memory_bytes: 132224
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  ll N,M;
  cin >> N >> M;
  ll ans=0;
  if(N*2<=M){
    ans += N;
    M -= N*2;
    ans += M/4;
  }else{
    ans += M/2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int sum=0, mx=0, v;

int main(){
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &v);
        if(v > mx)
            mx = v;
        sum += v;
    }
    sum = sum - mx +(mx/2);
    printf("%d\n", sum);
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(n*a,b) << endl;
	return 0;
}

Measured memory_bytes: 256
// AOJ 2575
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(void)
{
	string str;
	cin >> str;

	string s = "AIDUNYAN";
	map <char, int> m, tmp;
	for (int i = 0; i < s.length(); i++){
		m[s[i]]++;
	}
	
	string ret;
	for (int i = 0; i < str.length(); i++){
		string a = str.substr(i, 8);
		tmp.clear();
		for (int j = 0; j < 8; j++) tmp[a[j]]++;
		if (tmp == m){
			ret += "AIZUNYAN";
			i += 7;
		}
		else {
			ret += str[i];
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 3e5+5;

int main(){
	int n; cin >> n;
	int a, sum = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			a = __gcd(i, j);
			for(int k = 1; k <= n; k++) sum += __gcd(a, k);
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3636
/*input
7
1 1 1 1 1 1 1
*/

#include <bits/stdc++.h>
#include <unistd.h>

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e18
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,_;
	ll n;
	cin>>n;
	ll a[n];
	rep(i,0,n)cin>>a[i];
	sort(a,a+n,[](ll &a,ll & b){
		return a>b;
	});
	ll ans=0;
	ans+=a[0];
	i=1;
	n-=2;
	while(n>1)ans+=2*a[i],i++,n-=2;
	if(n)ans+=a[i];
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(0);
 	cin.tie(0);
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}




Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int,int> pii;
const int mod = (int) 1000000007;
const int inf = (int) 2e18;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
  	int n, x, t;
  	cin >> n >> x >> t;
  	cout << ((n + x - 1) / x) * t << "\n";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin>>N>>D;
  vector<vector<int>> A(N,vector<int>(D));
  for(int i=0;i<N;i++)
    for(int j=0;j<D;j++)
      cin>>A[i][j];
  int ans=0;
  for(int i=0;i<N;i++)
    for(int j=i+1;j<N;j++){
      int l=0;
      for(int k=0;k<D;k++)
        l+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
      if(pow(l,0.5)==(int)pow(l,0.5))
        ans++;
    }
  cout<<ans<<endl;
}

Measured memory_bytes: 4056
def check():
    N, Y = [int(i) for i in input().split(' ')]
    if Y % 1000 != 0:
        return '-1 -1 -1'
    else:
        sen = Y // 1000
        sub = sen - N
        count9 = sub // 9
        for num9 in range(count9+1):
            sub1 = sub - num9*9
            if sub1 % 4 == 0 and num9+sub1//4 <= N:
                return '{} {} {}'.format(num9, sub1//4, sen-num9*10-sub1*5//4)
        return '-1 -1 -1'
print(check())

Measured memory_bytes: 3064
"JAG模擬予選練習会"
while True:
    N, M = map(int, input().split())  # 問題の数N, 難易度の幅M
    if N == 0 and M == 0:
        break

    max_value = {}
    for i in range(1, M+1):
        max_value[i] = 0

    for i in range(N):
        d, v = map(int, input().split())
        max_value[d] = max(max_value[d], v)

    ans = sum(max_value.values())
    print(ans)



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

int DIVISOR(int num1, int num2, int num3) {
	int TIMES = 0;
	for (int i = num1; i <= num2; i++) {
		if (num3 % i == 0) {
			TIMES++;
		}
	}
	return TIMES;
}

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


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

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

    int c = op == '+' ? 1 : -1;

    cout << a + b * c << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int a[100010],q[100010];
ll dp[100010],ma[100010];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,E,T;scanf("%d%d%d",&n,&E,&T);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);a[0]=0;
	dp[0]=0;ma[0]=-a[1]*2;int f=1,r=1,k=0;q[1]=0;
	for (int i=1;i<=n;i++)
	{
		while (2*(a[i]-a[k+1])>T)
		{
			if (q[f]==k) f++;
			k++;
		}
		dp[i]=dp[q[f]]+a[q[f]+1]-a[q[f]]+T+a[i]-a[q[f]+1];
		if (k) dp[i]=min(dp[i],ma[k-1]+ll(a[i])*3);
		ma[i]=min(ma[i-1],dp[i]-a[i]-a[i+1]-a[i+1]);
		while (f<=r&&dp[q[r]]-a[q[r]]>=dp[i]-a[i]) r--;
		q[++r]=i;
	}
	cout<<dp[n]+E-a[n]<<endl;
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>

using namespace std;

int main()
{
    int n;
    char tmp;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> tmp;
        if(tmp == 'Y'){
            cout << "Four";
            return 0;
        }
    }
    cout << "Three";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,n) for(int i =0;i<n;i++)
#define REP(n) rep(i,n)

const int maxw = 510;
const int maxh = 510;

int w,h;
char tile[maxw][maxh];
int width[maxw][maxh];

int main()
{
    while(cin >> w >> h && (w&&h))
    {
        memset(width,0,sizeof(width));
        rep(j,h)rep(i,w) cin >> tile[i][j];
    
        rep(j,h)for(int i=w-1;i>=0;i--)
        {
            if(tile[i][j] == '*')width[i][j] = 0;
            else width[i][j] = width[i+1][j]+1;
        }
        /*rep(j,h)
        {
            rep(i,w)
            {
                cout << width[i][j] << " " ;
            }
            cout << endl;
        }*/


        int ans = 0;
        rep(j,h)rep(i,w)
        {
            int maxwidth = width[i][j];
            for(int maxhaight = 1;maxhaight <= h-j; maxhaight++)
            {
                maxwidth = min(maxwidth,width[i][j+maxhaight]);   
                ans = max(ans, maxwidth *( maxhaight + 1));
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}

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

using namespace std;

int main() {
	vector<int> p;
	int dp[101][10001];
	for (int i = 0; i < 10001; i++)dp[0][i] = 0;
	int n;
	cin >> n;
	int maxp = 0;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		maxp += t;
		p.push_back(t);
	}

	//dp
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= maxp; j++) {
			if (j - p[i - 1] >= 0) {
				dp[i][j] = max(dp[i - 1][j], dp[i-1][j - p[i - 1]] + p[i - 1]);
			}
			else dp[i][j] = dp[i - 1][j];
		}
	}

	int res = 0;
	for (int i = 0; i <= maxp; i++) {
		if (dp[n][i] % 10 == 0)continue;

		if (dp[n][i] > res)res = dp[n][i];
	}

	cout << res << endl;
	return 0;
}

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

typedef long long ll;
bool ldp[5005][5005], rdp[5005][5005];
int n, k;
int a[5005];

// 二分探索判定条件 O(k^2)
bool C(int id){
    for(int i = 0; i < k; ++i){
        for(int j = 0; j < k; ++j){
            if((ldp[id][i]&rdp[id + 1][j]) && ((i+j)>=k-a[id]&&(i+j)<k)){
                return true;
            }
        }
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    
    sort(a, a + n);
    
    ldp[0][0] = true;
    rdp[n][0] = true;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < k; ++j){
            if(j - a[i] >= 0){
                ldp[i + 1][j] |= ldp[i][j] | ldp[i][j - a[i]];
            }
            else{
                ldp[i + 1][j] |= ldp[i][j];
            }
        }
    }
    for(int i = n - 1; i >= 0; --i){
        for(int j = 0; j < k; ++j){
            if(j - a[i] >= 0){
                rdp[i][j] |= rdp[i + 1][j] | rdp[i + 1][j - a[i]];
            }
            else{
                rdp[i][j] |= rdp[i + 1][j];
            }
        }
    }
    
    int lb = -1, ub = n;
    while(ub - lb > 1){     // 二分探索 O(logn)
        int mid = (lb + ub) / 2;
        if(C(mid))  ub = mid;
        else        lb = mid;
    }
    
    cout << ub << endl;
}

Measured memory_bytes: 49152
N,K = map(int,input().split())
A = list(map(int,input().split()))

Bit = 0
while(True):
    if((1<<(Bit+1))>K):  
        break
    else:
        Bit += 1
X = 0
for b in range(Bit,-1,-1):
    X_ = X+(1<<b)
    if(X_ > K):
        continue
    Sum = sum([X^a for a in A])
    Sum_ = sum([X_^a for a in A])
    if(Sum_ > Sum):
        X = X_
print(sum([X^a for a in A]))


Measured memory_bytes: 14248
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() -1; i++) {
		if (s.at(i) != s.at(s.size() - 1 - i)) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < (s.size() - 1)/2; i++) {
		if (s.at(i) != s.at((s.size() - 1) / 2 - i-1)) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = (s.size() + 1) / 2; i < s.size() - 1; i++) {
		if (s.at(i) != s.at(s.size() - 1 - i)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

int main(void)
{
  char c;

  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else 
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
a = [0]*110
a[1:] = list(map(int,input().split()))
MOD = 10**9+7
dp = [[0]*110000 for _ in range(110)]
dp_sum = [[0]*110000 for _ in range(110)]
dp[0][0] = 1
for i in range(K+1):
    dp_sum[0][i] = 1

for i in range(1,N+1):
    for j in range(K+1):
        dp[i][j] = dp_sum[i-1][j]
        if j - a[i]-1 >= 0:
            dp[i][j] -= dp_sum[i-1][j-a[i]-1]

        if j-1 >= 0:
            dp_sum[i][j] = dp_sum[i][j-1] + dp[i][j]
        else:
            dp_sum[i][j] = dp[i][j]
        dp[i][j] %= MOD
        dp_sum[i][j] %= MOD
print(dp[N][K])
# for i in range(N+1):
#     print(dp[i])

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

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long;
using pll = pair<ll, ll>;

int main()
{
    ll N, X, T;
    cin >> N >> X >> T;

    const auto n = (N / X) + (N % X ? 1 : 0);
    cout << n * T << endl;

    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str=sc.nextLine();
		System.out.println(isIncludeCf(str));
	}
	
	public static String isIncludeCf(String str){
		if(str.indexOf("C")<str.lastIndexOf("F")&&str.indexOf("C")>=0){
			return "Yes";
		}
		return "No";
	} 
}

Measured memory_bytes: 9680
N,M = map(int,input().split())
MOD = 10**9+7
ans = 1
if abs(N-M) > 1:
    ans = 0
else:
    for i in range(1,N+1):
        ans *= i
        ans %= MOD
    for i in range(1,M+1):
        ans *= i
        ans %= MOD
    if N == M:
        ans *= 2
        ans %= MOD

print(ans)


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

int main() {
  string S;
  cin >> S;
  
  if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
} 

Measured memory_bytes: 256
N = int(input())
L = [int(l) for l in input().split()]
counter = 0
for i in range(N):
    a = L[i]
    for j in range(i+1,N):
        b = L[j]
        for k in range(j+1,N):
            c = L[k]
            if a+b>c and b+c>a and c+a>b and a != b and b!= c and c!= a:
                counter += 1
print(counter)


Measured memory_bytes: 68288
import java.util.Scanner;

class Main
{
    public static void main(String[] args)
    {
      //入力
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] h = new int[110000];
      for (int i=0; i<n; i++) h[i] = sc.nextInt();
      
      //移動
      int count;
      int max = 0;
      for(int start=0;start<n-1;start++) {
        if(max>=n-start) break;
        count = 0;
        for(int now=start;now<n-1;now++) {
          if(h[now]>=h[now+1]) count++;
          else break;
        }
        max = Math.max(max,count);
      }
      
      //出力
      System.out.println(max);
      
    }
      
}



Measured memory_bytes: 52728
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static String line;

	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		line = sc.next();
		return true;
	}
	static void solve(){
		int countK = 0,
			 countU = 0,
			 countP = 0,
			 countC = 0;
		for(int i = 0; i < line.length(); i++){
			char word = line.charAt(i);
			if(word == 'K'){
				countK++;
			}else if(word == 'U'){
				countU++;
			}else if(word == 'P'){
				countP++;
			}else if(word == 'C'){
				countC++;
			}
		}
		int res = Math.min(Math.min(countK, countU),Math.min(countP, countC) );
		System.out.println(res);
	}
}

Measured memory_bytes: 12000
/* 
 * ???????????§??????????´? Test.java
 *
 * Copyright(C) 2016 Nagasaki Team All Rights Reserved.
 */
/**
 * 
 *
 * @author Chikara
 * @version 1.00
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{
	/* main???????????? */
	public static void main(String[] args) throws IOException{
		String str = null;
		int count = 1;
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		str = br.readLine();
		
		while(!str.equals("0")){
			System.out.println("Case "+ count +": " + str);
			count++;
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 31448
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
#define N 1000000007
ll fact[500001];
ll inv[500001];
ll mypower(ll a, ll b, ll mod)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2 == 1)
            ans = (ans*a)%mod;
        a = (a*a)%mod;
        b = b/2;
    }
    return ans;
}
void pre()
{
    ll i;
    fact[0] = 1;
    for(i=1;i<500001;i++)
        fact[i] = (i*fact[i-1])%N;
    inv[500000] = mypower(fact[500000], N-2, N);
    for(i=(500000-1);i>=0;i--)
        inv[i] = (inv[i+1]*(i+1))%N;
}
ll comb(ll n, ll k)
{
    return (fact[n]*((inv[k]*inv[n-k])%N))%N;
}
int main() {
    pre();
    ll n,k;
    cin >> n >> k;
    ll sum = 0;
    int r;
    ll ans = 0;
    for(r=0;r<=min(n-1, k);r++)
    {
        ans = ans + (comb(n,r)*comb(n-1,r))%N;
        ans = ans%N;
    }
    ans = (ans+N)%N;
    cout << ans << '\n';
}

Measured memory_bytes: 8064
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var t = 1;
        for (int i = 0; i < seqA.Length; ++i)
        {
            if (seqA[i] != t)
            {
                continue;
            }

            ++t;
        }
        var k = n - t + 1;
        Console.WriteLine(k >= n ? -1 : k);
    }
}


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

double nb(int n) {
	double d = 1.;
	for (int i = 1; i <= n; ++i){
		d *= (double)i;
	}
	return d;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	vector<int> v;
	rep(i, n)
		v.push_back(i);
	sort(v.begin(), v.end());

	double sum = 0;		
	do {
		rep(k, n - 1) {
			int i = v[k], j = v[k + 1];
			int dd = pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2);
			sum += sqrt(double(dd));
		}
	} while(next_permutation(v.begin(), v.end()));

	printf("%.9f\n", sum / nb(n));
	return 0;
}


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 10;
char s[N][N];

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    for (int i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }
    int res = 0;
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < (1 << m); j++) {
            int cnt = 0;
            for (int u = 0; u < n; u++) {
                for (int v = 0; v < m; v++) {
                    if (((1 << u) & i) || ((1 << v) & j)) continue;
                    if (s[u][v] == '#') cnt++;
                }
            }
            res += cnt == k;
        }
    }
    printf("%d", res);
    return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

ll ruisekiwa[NUM+1];
ll table[NUM+1];


int main(){

	for(int i = 0; i <= NUM; i++){
		table[i] = 0;
	}

	ruisekiwa[0] = 0;
	ruisekiwa[1] = 1;

	for(int i = 2; i <= NUM; i++){
		ruisekiwa[i] = i;
		ruisekiwa[i] += ruisekiwa[i-1];
	}

	ll left,right,mid,tmp;
	int max_add;

	for(ll i = 1; i <= NUM; i++){

		left = 0,right = NUM-i,mid = (left+right)/2;

		while(left <= right){
			tmp = ruisekiwa[i+mid]-ruisekiwa[i-1];

			if(tmp <= NUM){
				max_add = mid;
				left = mid+1;
			}else{
				right = mid-1;
			}
			mid = (left+right)/2;
		}

		for(int add = 0; add <= max_add; add++){

			table[ruisekiwa[i+add]-ruisekiwa[i-1]]++;
		}
	}

	ll S;

	scanf("%lld",&S);

	ll ans = 0;

	for(ll i = 1; i <= S; i++){
		if(S%i != 0)continue;

		ans += table[i]*table[S/i];
	}

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

	return 0;
}



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

int main(){
    int A, B;
    cin >> A >> B;
    int sum = 0;
    for(int i=A; i<=B; i++){
        int v = i;
        int s = v % 10;
        v /= 10;
        int t = v % 10;
        v /= 100;
        int u = v % 10;
        v /= 10;
        int k = v % 10;
        if(s==k && t == u) ++sum;

    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using L = long long;
 
#define FOR(i, l, r) for(int i = l; i <= r; ++i)
#define REP(i, n) FOR(i, 0, n - 1)
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	int n, W;
	cin >> n >> W;
	vector<L> dp(W + 1), prev_dp(W + 1);
	while(n --> 0) {
		int w, v;
		cin >> w >> v;
		FOR(i, w, W)
			dp[i] = max(dp[i], prev_dp[i - w] + v);
		FOR(i, 1, W)
			dp[i] = max(dp[i], dp[i - 1]);
		prev_dp = dp;
	}
	cout << dp.back() << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cout << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define lSOne(x)(x&-x)
#define EPS 1e-20
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 2e6 + 7;

ll x; vii vec;

int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> x ; vec.resize(x);
    for ( ll& i : vec ) cin >> i;

    for ( int i = x-2; i > -1; --i ){
        if ( vec[i] > vec[i + 1] ){
            if ( vec[i]-1 <= vec[i + 1] ){
                vec[i]--;
            }
            else{
                return cout << "No" ,0 ;
            }
        }
    }
    cout << "Yes";
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long input[] = new long[n];
		long ball[] = new long[200001];
		

		for(int i = 0; i < n; i++){
			input[i] = scan.nextLong()-1;
		}
		
		Arrays.fill(ball, 0);
		for(int i = 0; i < n; i++){
			ball[(int)input[i]] ++;
		}
		
		long sum = 0;
		
		for(int i = 0; i < 200001; i++){
			long x = ball[i];
			sum += (x*(x-1))/2; 
		}

		for(int i = 0; i < n; i++){
			long x = input[i];
			long y = ball[(int) x];
			long z = Math.max(y - 1, 0);
			System.out.println(sum - ((y * (y - 1))/2) + ((z * (z - 1))/2));
		}
	}
}

Measured memory_bytes: 93176
import numpy as np

N = int(input())
F = np.array([list(map(int, input().split(' '))) for _ in range(N)])
P = np.array([list(map(int, input().split(' '))) for _ in range(N)])

ans = - (10 ** 11)

for n in range(1, 1024):
    bits = np.array(list(map(int, list('{:010b}'.format(n)))))
    dup = np.sum(F * bits, axis=1)
    ans = max(ans, np.sum(P[range(N), dup]))

print(ans)


Measured memory_bytes: 27352
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


//for(i=0; i<N; i++) cin >> a[i];





int main(void) {
  ll i, j, k;
  
  ll K;
  cin >> K;
  
  map<ll, ll> mp;
  
  ll r=7%K;
  mp[r]++;
  for(i=1; r!=0; i++) {
    r=(r*10+7)%K;
    
    mp[r]++;
    if(mp[r]>1) {
      pt(-1);
      return 0;
    }
    
    
  }
  
  pt(i);
  
  
}




Measured memory_bytes: 66076
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		for(;;){
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			
			int[] data = new int[n];
			for(int i = 0; i < n ; i++){
				data[i] = sc.nextInt();
			}
			Arrays.sort(data);
			
			int value = 0;
			for(int i = 1; i < n-1;i++){
				value += data[i];
			}
			System.out.println(value / (n-2));
		}
	}
	
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
int q, n, c;
int main() {
	scanf("%d", &q);
	while(q--) {
		scanf("%d", &n);
		for(int i = 1; i * i < n; i++) {
			if(n % (2 * i + 1) == i) {
				c--; break;
			}
		}
		c++;
	}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 2732
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main(void)
{
        int n;
        cin >> n;
        int a[200010];
        REP(i,n) cin >> a[i];
        int ans[200010];
        int it1 = (n-1)/2;
        int it2 = it1;
        ans[it1] = a[0];

        if(n == 1){
                cout << a[0] << endl;
                return 0;
        }

        if(n%2){
                it2 = it1;
                it1--;
                ans[it1] = a[1];
        }else{
                it2 = it1;
                it1++;
                ans[it1] = a[1];
        }

        int temp;
        for(int i = 2; i < n-1; i++){
                if((n-i)%2){
                        temp = it2+1;
                        it2 = it1;
                        it1 = temp;
                }else{
                        temp = it2-1;
                        it2 = it1;
                        it1 = temp;
                }
                ans[it1] = a[i];
        }
        ans[n-1] = a[n-1];

        REP(i,n/2) swap(ans[i], ans[n-i-1]);

        REP(i,n) cout << ans[i] << ' ';

        return 0;
}

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

int root(int r[], int x)
{
  if(r[x] == x)
    return x;
  else
  {
    return r[x] = root(r, r[x]);
  }
}

bool same(int r[], int x, int y)
{
  return (root(r, x) == root(r, y));
}

void punion(int r[], int x, int y)
{
  if(same(r,x,y))
    return;
  r[root(r,x)] = root(r,y);
}

int main()
{
  int n, k, l;
  cin >> n >> k >> l;
  int rd[n];
  int rw[n];
  REP(i, n)
  {
    rd[i] = i;
    rw[i] = i;
  }
  
  REP(i, k)
  {
    int p, q;
    cin >> p >> q;
    p--; q--;
    punion(rd, p, q);
  }
  REP(i, l)
  {
    int p, q;
    cin >> p >> q;
    p--; q--;
    punion(rw, p, q);
  }
  
  pair<int, int> q[n];
  map<pair<int, int>, int> ans;
  REP(i, n)
  {
    q[i] = make_pair(root(rd, i), root(rw, i));
    ans[q[i]]++;
  }
  REP(i, n) cout << ans[q[i]] << " ";
  return 0;
}

Measured memory_bytes: 17984
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

int main(){
    ll N; cin>>N;
    ll ans=0;
    REP(i,1,N+1) ans+=i*(N+1-i);
    rep(i,N-1){
        ll a,b; cin>>a>>b;
        if(a>b) swap(a,b);
        b--;
        ans-=a*(N-b);
    }
    cout<<ans<<endl;
}

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

const ll INF = 1LL << 60;

ll N, K;
vector<ll> v;
int main() {
    cin >> N >> K;
    v.resize(N);
    rep(i, N) cin >> v[i];

    bool zero_exist = false;
    rep(i, N) {
       if (v[i] == 0) {
           zero_exist = true;
       }
    }

    ll ans = INF;
    if (!zero_exist) {
        v.push_back(0);
        K++;
    }
    sort(v.begin(), v.end());

    ll zero_idx = lower_bound(v.begin(), v.end(), 0) - v.begin();
    // cout << zero_idx << endl;

    for (int i = 0; i <= N + 1 - K; i++) {
        ll r = i + K - 1;
        ll l = i;
        if (l <= zero_idx && zero_idx <= r) {
            ll tmp = INF;
            // 一直線
            if (v[r] < 0) {
                tmp = min(tmp, abs(v[l])); 
            }
            // 一直線
            if (v[l] > 0) {
                tmp = min(tmp, abs(v[r])); 
            }

            // 右行ってから左
            ll dist = abs(v[r]) * 2 + abs(v[l]);
            tmp = min(tmp, dist);

            // 左行ってから右
            ll dist2 = abs(v[l]) * 2 + abs(v[r]);
            tmp = min(tmp, dist2);

            // cout << i << " " << tmp << " " << dist << " " << dist2 << " " << abs(v[l]) << " " << abs(v[r]) << endl;
            ans = min(ans, tmp);
        }
    }
    if (ans == INF) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {

        int N = NextInt();
        int M = NextInt();
        List<long> card = Enumerable.Range(0, N).Select(v => NextLong()).OrderByDescending(v => v).ToList();
        List<Tuple<int, long>> next = Enumerable.Range(0, M).Select(v => new Tuple<int, long>(NextInt(), NextLong())).ToList().OrderByDescending(v => v.Item2).ToList();
        List<long> ans = new List<long>();
        int card_index = 0, next_index = 0;
        while (ans.Count() < N)
        {
            if (next_index == M || next[next_index].Item2 < card[card_index]) { ans.Add(card[card_index]); card_index++; }
            else { ans.AddRange(Enumerable.Repeat(next[next_index].Item2, next[next_index].Item1)); next_index++; }
        }
        Console.WriteLine(ans.OrderByDescending(x => x).Take(N).Sum());
    }

    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

ans = 0
A.sort(reverse=True)
while A[0] >= N:
    num = A[0] // N
    ans += num
    A[0] %= N
    for i in range(1, N):
        A[i] += num
    A.sort(reverse=True)

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int n,i,j,k,l,add;
    while(scanf("%d",&n)!=EOF)
        {
            add=0;
            for(i=0;i<=9;i++)
            {
                for(j=0;j<=9;j++)
                {
                    for(k=0;k<=9;k++)
                    {
                    for(l=0;l<=9;l++)
                        {
                            if(i+j+k+l==n)add++;
                        }
                    }
                }
            }
          printf("%d\n",add);
    }
    return 0;
}

Measured memory_bytes: 596
#include "./bits/stdc++.h"

#include <vector>
#include <iostream>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define linf 122337203685477000

using namespace std;

typedef long long ll;

/*
vector.push_back()
vector<int> hoge(3,-1); {-1,-1,-1}
vector<vector<int>> hogehoge(2,vector<int>(2,-1)); {{-1,-1},{-1,-1}} 
cin >>temp;
scanf("%d %d %d",&A,&B,&Q);
sort(a.begin(),a.end());
a.push_back(4000000000000);
a.insert(a.begin(),-1000000000000);
upper_bound(a.begin(),a.end(),x); // list[i] > x のイテレータ取得. *itrで数値化 
    std::priority_queue<
      int,
      std::vector<int>,
      decltype(compare) // 比較関数オブジェクトを指定
    > que(comp);
*/
template <typename T> void debug(T arr);
template <typename T> void debug (T arr, int dim);

vector<long long> dijkstra(int n,int start,vector<vector<pair<long long, long long>>> &edge){
    vector<long long> shortest(n,linf);
    priority_queue<pair <long long, long long> ,vector<pair<long long,long long>>,greater<pair<long long,long long>>  > que;
    shortest[start] = 0LL;
    que.push(pair<long long,long long>(0,start));
    while (!que.empty()){
        pair<long long,long long> now = que.top();
        que.pop();
        long long v = now.second;
        if (shortest[v] < now.first){
            continue;
        }else{
            for (int i = 0; i < edge[v].size(); ++i){
                long long to = edge[v][i].first;
                long long cost = edge[v][i].second;
                long long new_cost = shortest[v]+cost;
                if (new_cost < shortest[to]){
                    shortest[to] = new_cost;
                    que.push(pair<long long,long long>(new_cost,to));
                }
            }
        }
    }
    return shortest;
}



int main(void){
    ll n,m;
    ll l,r,c;
    cin >> n >> m;
    vector<vector<pair<long long,long long>>> edge;
    edge.push_back({});
    for (int i = 1; i < n; ++i){
        vector<pair<long long,long long>> temp;
        temp = {pair<long long,long long>(i-1,0)};
        edge.push_back(temp);
    }

    for (int i = 0; i < m; ++i){
        scanf("%lld %lld %lld",&l,&r,&c);
        edge[l-1].push_back(pair<long long,long long>(r-1,c));
    }
 
    vector<long long> shortest;
    shortest = dijkstra(n,0,edge);

    if (shortest[n-1] == linf){
        cout << -1 << endl;
    }else{
        cout << shortest[n-1] << endl;
    }


};


template <typename T> void debug(T arr){
    for (auto col:arr){
        cout << col << " ";
    }
    cout <<endl;
};

template <typename T> void debug (T arr, int dim){
    for (auto raw:arr){
        for(auto col:raw){
            cout << col << " ";
        }
        cout << endl;
    }
};


Measured memory_bytes: 11312
///                                                     ببِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define vec  vector
#define gcd  __gcd
#define pi   acos( -1 )
#define ll   long long
#define ld   long double
#define N    300256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define rep( a, b, c, d )  for( int a = b; a <= c; a += d )
#define rvv( a, b, c, d )  for( int a = b; a >= c; a -= d )
#define en                 printf( "\n" )
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() )
#define numcounts          __builtin_popcount
#define mxn( x, y, z )     max( x, min( y, z ) )
#define mnx( x, y, z )     min( x, max( y, z ) )
const int dx[ ] = { 1, -1, 0, 0 };
const int dy[ ] = { 0, 0, -1, 1 };
using namespace std;
ll ttt = 1;
ll n, k, w[N], v[N], dp[N];
void solve()
{
    cin >> n >> k;
    for( ll i = 1; i <= n; i ++ )
        cin >> w[i] >> v[i];
    for( int i = 100000; i > 0; i -- )dp[i] = I;
    for( ll i = 1; i <= n; i ++ )
    {
        for( ll j = 100000; j > 0; j -- )
        {
            if( j - v[i] >= 0 )dp[j] = min( dp[j], dp[j-v[i]] + w[i] );
        }
    }
    for( int i = 100000; i >= 0; i -- )
    {
        if( dp[i] <= k )
        {
            cout << i;
            off;
        }
    }

}
int main()
{
    //sc( "%I64d", &ttt );
    for( int i = 0; i < ttt; i ++ )
        solve();
}














Measured memory_bytes: 5120
#include<stdio.h>
#include<string.h>

#define MAX 2000001
#define MAX_SCORE 10001

typedef struct {
  int id;
  int score;
  int rank;
} Info;

int n; // number of students
int counter[MAX_SCORE+1], maxi;
Info list[MAX+1], sortedList[MAX+1];


void CountingSort() {
  memset(counter,0,sizeof counter);
  int i;
  for(i=0;i<n;++i) ++counter[list[i].score];
  for(i=1;i<=maxi;++i) counter[i] += counter[i-1];
  for(i=n-1;i>=0;--i) {
    sortedList[--counter[list[i].score]] = list[i];
  }
}

int main() {
  int i, id, score;
  while( scanf("%d",&n) != EOF ) {
    maxi = 0;
    for(i=0;i<n;++i) {
      scanf("%d",&score);
      list[i].score = score;
      if( maxi < score ) maxi = score;
    }
    CountingSort();
    for(i=0;i<n;++i) {
      if( i ) printf(" ");
      printf("%d",sortedList[i].score);
    } puts("");
  }
  return 0;
}



Measured memory_bytes: 48672
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String input_nml = "";
		String[] nml_data = new String[3];
		int n = 0;
		int m = 0;
		int l = 0;
		boolean judge = true;

		input_nml = sc.nextLine();
		nml_data = input_nml.split(" ");
		n = Integer.parseInt(nml_data[0]);
		m = Integer.parseInt(nml_data[1]);
		l = Integer.parseInt(nml_data[2]);

		if ((1 > n || n > 100) || (1 > m || m > 100) || (1 > l || l > 100)) {
			judge = false;
		}

		if (judge == true) {
			String input_AB = "";
			String[] A_in = new String[m];
			int[][] A_out = new int[n][m];
			String[] B_in = new String[l];
			int[][] B_out = new int[m][l];
			long[][] C_out = new long[n][l];
			String[] output_result = new String[n];

			// Aの入力とその値のチェック
			out: for (int i = 0; i < n; i++) {
				input_AB = sc.nextLine();
				A_in = input_AB.split(" ");

				for (int j = 0; j < m; j++) {
					A_out[i][j] = Integer.parseInt(A_in[j]);

					if (A_out[i][j] < 0 || A_out[i][j] > 10000) {
						judge = false;
						break out;
					}

				}

			}// Aの入力ここまで

			if (judge == true) {

				// Bの入力とその値のチェック
				out: for (int k = 0; k < m; k++) {
					input_AB = sc.nextLine();
					B_in = input_AB.split(" ");

					for (int p = 0; p < l; p++) {
						B_out[k][p] = Integer.parseInt(B_in[p]);

						if (B_out[k][p] < 0 || B_out[k][p] > 10000) {
							judge = false;
							break out;
						}

					}

				}

			}// Bの入力ここまで

			if (judge == true) {

				for (int i = 0; i < n; i++) {
					output_result[i] = "";
					for (int j = 0; j < l; j++) {

						for (int k = 0; k < m; k++) {
							C_out[i][j] += A_out[i][k] * B_out[k][j];

						}
						if (j == 0) {
							output_result[i] += "" + C_out[i][j];
						} else {
							output_result[i] += " " + C_out[i][j];
						}
						// System.out.print(C_out[i][j]);

					}

					System.out.println(output_result[i]);
					// System.out.println();
				}

			}

		}

	}
}



Measured memory_bytes: 64416
#include<iostream>
#include<string.h>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack> 
#define  ll long long
using namespace std;

int main()
{
	int a,sum=0;
stack<int>s1;
stack< pair < int,int> >s2;
char ch;
for(int i=0;cin>>ch;i++)
{
	if(ch=='\\')
	s1.push(i);
	else if(ch=='/'&&s1.size()>0)
	{
		int j=s1.top();
		s1.pop();
		sum=sum+(i-j);
		a=i-j;
		while(s2.size()>0&&s2.top().first>j)
		{
			a=a+s2.top().second;
			s2.pop();
		}
		s2.push(make_pair(j,a));
	}
}
vector <int> ans;
while(s2.size()>0)
{
	ans.push_back(s2.top().second);
	s2.pop();
}
reverse(ans.begin(),ans.end());
cout<<sum<<"\n";
cout<<ans.size();
for(int i=0;i<ans.size();i++)
{
	cout<<" ";
	cout<<ans[i];
}
cout<<"\n";

return 0;
}


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

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






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;

int main() {
  int64_t N,M;
  cin>>N>>M;
  int64_t sum=min(M,N*2)/2;
  sum+=max((int64_t)0,M-N*2)/4;
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3556
import math

def dist(p, q):
    return math.sqrt((p[0]-q[0])**2 + (p[1]-q[1])**2)


n = int(input())
L = []
for i in range(n):
    L.append(list(map(int, input().split())))

summation = 0
for i in range(n):

    for j in range(i+1, n):
        d = dist(L[i], L[j])
        
        summation += d

print(summation * 2 / n) 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

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

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

int main(void)
{
    IOS
    int N, M;
    cin >> N >> M;
    string S; cin >> S;
    string T; cin >> T;

    ll xl = lcm(N,M);
    ll ln = xl / N;
    ll lm = xl / M;

    if (N == M && S != T) {
        OUT(-1)
        return 0;
    } else {
        map<ll,char> X;
        REP(i,N) {
            X[ln*i] = S[i];
        }
        REP(i,M) {
            if (!(X[lm*i] == 0 || X[lm*i] == T[i])) {
                OUT(-1)
                return 0;
            }
        }
    }

    cout << xl << '\n';

    return 0;
}

Measured memory_bytes: 10880
#include "bits/stdc++.h"
using namespace std;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n) {
        //for (int i = 0; i < n; i++)par[i] = i;
        for (int i = 0; i < n; i++)par[i] = -1;
    }

    int root(int x) {
        //if (par[x] == x) return x;
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false; // 同じ木に属するのでmergeしない（そのまま）
        if (par[x] > par[y]) swap(x, y); // merge technique（-nがその木の要素数)
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)]; // -nがノード数なのでマイナスかける
    }
};

//using pint = pair<int, int>;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<set<int> > dame(N); // 各人が繋がっている人間の種類を保持
    UnionFind uf(N);

    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        dame[a].insert(b);
        dame[b].insert(a);
        uf.merge(a, b); // 友人なので同じグループに
    }

    for (int i = 0; i < K; ++i) {
        int c, d; cin >> c >> d; --c, --d;
        if (!uf.issame(c, d)) continue; // 別のグループであればカウントする必要がない
        dame[c].insert(d);
        dame[d].insert(c);
    }

    for (int i = 0; i < N; ++i) {
        int mem = uf.size(i) - 1; // 同じ連結成分の「自分以外」の人数
        mem -= dame[i].size(); // その中ですでに友達かブロック関係の人数
        cout << mem << " ";
    }
    cout << endl;
}

Measured memory_bytes: 24704