akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Magatro
{
    private int N;
    string[] S;
    public void Solve()
    {
        N = int.Parse(Console.ReadLine());
        S = new string[N];
        var d = new Dictionary<char, int>[N];
        for (int i = 0; i < N; i++)
        {
            S[i] = Console.ReadLine();
            d[i] = new Dictionary<char, int>();
            for(char c = 'a'; c <= 'z'; c++)
            {
                d[i][c] = 0;
            }
            foreach(char c in S[i])
            {
                d[i][c]++;
            }
        }
        var ans = new Dictionary<char, int>();

        for (char c = 'a'; c <= 'z'; c++)
        {
            ans[c] = int.MaxValue;
        }

        for(int i = 0; i < N; i++)
        {
            for (char c = 'a'; c <= 'z'; c++)
            {
                ans[c] = Math.Min(ans[c], d[i][c]);
            }
        }

        for (char c = 'a'; c <= 'z'; c++)
        {
            for(int i = 0; i < ans[c]; i++)
            {
                Console.Write(c);
            }
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 11232
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector <int>p(n);
	for(int i=0;i<n;i++)
		cin>>p[i];
	int cnt=0;
	for(int i=1;i<n-1;i++)
	{
		if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]<p[i-1]&&p[i]>p[i+1]))
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define push_back emplace_back
#define int long long
typedef pair<int, int> pii; 
typedef vector<pii> vii;
typedef vector<int> vi;
#define ss second
#define ff first
#define pii pair<int, int>
#define max3(a, b, c) max(a, max(b, c))
#define TEST ll t; cin >> t;while (t--)
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define pq priority_queue<int>
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}

void fastio()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int32_t main() {
	fastio();
	int n;
	cin>>n;
	if(n>=30)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	int a, b;
	char op;
	while (cin >> a >> op >> b) {
		if (op == '+')
			cout << a + b << endl;
		else if (op == '-')
			cout << a - b << endl;
		else if (op == '*')
			cout << a * b << endl;
		else if (op == '/')
			cout << a / b << endl;
		else
			break;
	}
	return 0;
}


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

int n;
vector<pair<int, int> > xs;
vector<pair<int, int> > ys;

vector<int> uf;
int getpar(int a) {
	return uf[a] < 0 ? a : (uf[a] = getpar(uf[a]));
}
bool merge(int a, int b) {
	a = getpar(a);
	b = getpar(b);
	if (a == b) return false;
	uf[b] = a;
	return true;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	xs.resize(n), ys.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> xs[i].first >> ys[i].first;
		xs[i].second = ys[i].second = i;
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());
	vector<pair<int, pair<int, int> > > edges;
	edges.reserve(2 * (n-1));
	for (int i = 0; i+1 < n; i++) {
		edges.push_back(make_pair(xs[i+1].first - xs[i].first, make_pair(xs[i].second, xs[i+1].second)));
		edges.push_back(make_pair(ys[i+1].first - ys[i].first, make_pair(ys[i].second, ys[i+1].second)));
	}
	uf.assign(n, -1);
	sort(edges.begin(), edges.end());
	long long tot = 0;
	for (int i = 0; i < int(edges.size()); i++) {
		pair<int, pair<int, int> >& e = edges[i];
		if (merge(e.second.first, e.second.second)) {
			tot += e.first;
		}
	}
	cout << tot << '\n';
}


Measured memory_bytes: 4608
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, C = in.nextInt
  val Dxy = Array.fill(C)(Array.fill(C)(in.nextInt))
  val grid: Array[List[Int]] = Array.fill(3)(Nil)

  for {
    r <- 0 until N
    c <- 0 until N
  } {
    grid((r + c) % 3) = in.nextInt :: grid((r + c) % 3)
  }

  val gridColorChanges: Array[Array[Int]] = {
    grid.map { colors =>
      val colorSizes: List[(Int, Int)] = colors.groupBy(i => i - 1).view.mapValues(_.size).toList
      (0 until C).map(to => colorSizes.map{case (from, size) => Dxy(from)(to) * size}.sum).toArray
    }
  }

  val min = (for {
    p0 <- 0 until C
    p1 <- 0 until C
    if p0 != p1
    p2 <- 0 until C
    if p0 != p2 && p1 != p2
  } yield {
    gridColorChanges(0)(p0) + gridColorChanges(1)(p1) + gridColorChanges(2)(p2)
  }).min
  println(min)
}

Measured memory_bytes: 68552
import collections

N = int(input())
l = [input() for _ in range(N)]


alp_list = list("abcdefghijklmnopqrstuvwxyz")

alp_count = {}

res = ""

for i in l:
    c = collections.Counter(i)
    #print(c)
    for j in alp_list:
        if j in c.keys():
            if j not in alp_count:
                alp_count[j] = c[j]
            else:
                alp_count[j] = min(alp_count[j],c[j])
        else:
            alp_count[j] = 0

#print(alp_count)

for i in alp_list:
    if i in alp_count:
        res += i * alp_count[i]

print(res)

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

int main()
{
    int N, X, min = 1 << 30;
    cin >> N >> X;
    for (int i = 0; i < N; i++)
    {
        int M;
        cin >> M;
        X -= M;
        if (M < min)
        {
            min = M;
        }
    }

    int cnt = N;
    while (X != X % min)
    {
        cnt++;
        X -= min;
    }
    cout << cnt;
}

Measured memory_bytes: 3588
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e5 + 5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)998244353 + 0)
#define NN ((int)1e5 + 7)
#define N ((int)1e4 + 2)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < pair < ll, pair < ll, ll > >,  null_type,  less < pair < ll, pair < ll, ll > > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).




int main()
{
    fastio;
    int x;
    cin>>x;
    cout<<360/__gcd(360,x)<<endl;
    return 0;
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(vr) vr.begin(),vr.end()
#define pi pair<int,int>

typedef long long ll;
namespace myrand
{
    mt19937 mt(chrono::system_clock::now().time_since_epoch() / chrono::microseconds(1));
    ll Int(ll l,ll r) { return uniform_int_distribution<ll> (l,r)(mt); }
}
using namespace myrand;
auto ss=chrono::system_clock::now();
double remain_time()
{
    auto en=chrono::system_clock::now();
    return (chrono::duration_cast<chrono::nanoseconds>(en-ss).count()*1e-9);
}

int red[200005];
int white[200005];
int green[200005];
int x,y,a,b,c,dem,dem1,dem2,cnt;
ll res;
void solve()
{
    cin >> x >> y >> a >> b >> c;
    for(int i=1;i<=a;i++) cin >> red[i];
    for(int i=1;i<=b;i++) cin >> green[i];
    for(int i=1;i<=c;i++) cin >> white[i];
    sort(red+1,red+1+a);
    sort(green+1,green+1+b);
    sort(white+1,white+1+c);
    reverse(red+1,red+1+a);
    reverse(green+1,green+1+b);
    reverse(white+1,white+1+c);
    red[x+1]=-1;
    red[a+1]=-1;
    green[y+1]=-1;
    green[b+1]=-1;
    white[x+y+1]=-1;
    white[c+1]=-1;
    dem = 1;
    dem1= 1;
    dem2 = 1;
    for(int i=1;i<=x+y;i++){
        cnt = max(red[dem],white[dem2]);
        cnt = max(cnt,green[dem1]);
        if (cnt==-1) break;
        if (red[dem]==cnt && dem<=x && dem<=a) {dem++;res+=cnt;continue;}
        if (white[dem2]==cnt && dem2<=c) {dem2++;res+=cnt;continue;}
        if (green[dem1]==cnt && dem1<=y && dem1<=b) {dem1++;res+=cnt;continue;}
    }
    cout << res;
}

int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);cout.tie(0);
   //freopen("input.txt","r",stdin);
   solve();
   return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

ll fx(ll n) {

	V<ll> one(60);
	for (ll i = 0;i < 60;i++) {
		ll p = 1LL << (i + 1);
		one[i] = (((n + 1) / p) * (p / 2) + max(((n + 1) % p) - (p / 2), 0LL)) % 2;
	}

	ll re = 0;
	for (ll i = 0;i < 60;i++)if (one[i])re += 1LL << i;

	return re;
}

int main() {

	ll a, b;
	cin >> a >> b;
	ll ans = fx(b) ^ fx(a - 1);

	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

ll n,x,y,m,k,ans,cnt,mini=N,flag;
ll a[N],cost[N],dp[N];
vector<pair<ll,ll > > v;
string s;
map<char,ll>mp;
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);

    for(int i=3;i<=n;i++){
        dp[i]+=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n];
return 0;
}


Measured memory_bytes: 3072
#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;
const int inf = 100100100;

 
int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  vector<int> c = x;
  sort(c.begin(),c.end());

  int id = n/2-1;

  rep(i,n){
    if(x[i]<=c[id]) cout << c[id+1] << endl;
    else cout << c[id] << endl;
  }
  
}


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

int main()
{
    string s;
    cin>>s;
    if(s=="Sunny" && s!="Rainy")
    {
        cout<<"Cloudy"<<endl;
    }
    else if(s=="Cloudy" && s!="Sunny")
    {
        cout<<"Rainy"<<endl;
    }
    else if(s=="Rainy" && s!="Cloudy")
    {
        cout<<"Sunny"<<endl;
    }
}












Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

int n;

cin >> n;

for(int i = n; i > 0; i--){ 
 for(int j = 2; j <= sqrt(i); j++){
 int num = i;
 while(true){
 if(num % j != 0) break;
 num /= j;
 if(num == 1){
 cout << i << endl; return 0;
   }
  }
 }
}

 cout << 1 << endl;
return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int ans;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d[10001];
    for(int i=1;i<=a;++i){
    cin>>d[i];
    if(d[i]<b||d[i]>=c){
        ans++;  
    }
}
    cout<<ans<<endl; 
    return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;

int main(){
    string s, t;
    cin >> s;
    t = s;
    reverse(t.begin(), t.end());
    int a = s.length() / 2;
    if (s == t) {
        string ss, st;
        rep(i,a) {
            ss += s[i];
        }
        st = ss;
        reverse(st.begin(), st.end());
        if (ss == st) {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    } else {
        cout << "No" << endl;
        return 0;
    }
}

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

int main(){
  long long int n,k,r,s,p,i,j,kotae=0,dpr1,dpr2,dps1,dps2,dpp1,dpp2;
  cin>>n>>k>>r>>s>>p;
  char a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<k;i++){
    dpr1=0;
    dps1=0;
    dpp1=0;
    for(j=i;j<n;j+=k){
      if(a[j]=='r'){
        dpr2=max(dps1,dpp1);
        dps2=max(dpr1,dpp1);
        dpp2=max(dpr1,dps1)+p;
      }else if(a[j]=='s'){
        dpr2=max(dps1,dpp1)+r;
        dps2=max(dpr1,dpp1);
        dpp2=max(dpr1,dps1);
      }else{
        dpr2=max(dps1,dpp1);
        dps2=max(dpr1,dpp1)+s;
        dpp2=max(dpr1,dps1);
      }
      dpr1=dpr2;
      dps1=dps2;
      dpp1=dpp2;
    }
    kotae+=max(max(dpr1,dps1),dpp1);
  }
  cout<<kotae;
}

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

int main(void){
    int n;
    while(cin>>n, n){
        vector<string> s(n);
        // map<char,int> a;
        int a[256] = {};
        // map<char,bool> not_zero;
        bool not_zero[256] = {};
        rep(i,n){
            cin>>s[i];
            int k = s[i].size();
            if(k>1) not_zero[s[i][0]] = true;
            reverse(all(s[i]));
            rep(j,k){
                a[s[i][j]] += pow(10,j)*(i==n-1 ? -1 : 1);
            }
        }
        
        set<char> st;
        rep(i,n){
            for(char c:s[i]){
                st.insert(c);
            }
        }
        string char_list;
        for(char c : st){
            char_list += c;
            // cerr<<a[c]<<" ";
        }
        // cerr<<endl;

        char_list += string(10-(int)st.size(), '-');
        sort(all(char_list));
        int res = 0;

        int perm = 0;
        do{
            perm++;
            if(not_zero[char_list[0]]) continue;
            int sum = 0;
            rep(i,10) sum += i*a[char_list[i]];
            if(sum == 0) res++;
        }while(next_permutation(all(char_list)));
        cout<<res<<endl;
    }

    return 0;
}



Measured memory_bytes: 3228
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int K;

  std::string S;

  std::cin >> K >> S;

  int size = S.size();

  if (size > K) {
    std::cout << S.substr(0, K) << "..." << std::endl;
  }
  else {
    std::cout << S << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL n,m;
LL dp[505][505];
char ch[505][505];

int main(){
	ios::sync_with_stdio(false);
	memset(dp,INF,sizeof(dp));
	cin >> n >> m;
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= m;j ++){
			cin >> ch[i][j];
		}
	}
	if(ch[1][1] == '.') dp[1][1] = 0;
	else dp[1][1] = 1;
	
	
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= m;j ++){
			if(i > 1){
				if(ch[i][j] == ch[i - 1][j]) dp[i][j] = min(dp[i][j],dp[i - 1][j]);
				if(ch[i][j] != ch[i - 1][j]) dp[i][j] = min(dp[i][j],dp[i - 1][j] + 1);
			}
			if(j > 1){
				if(ch[i][j] == ch[i][j - 1]) dp[i][j] = min(dp[i][j],dp[i][j - 1]);
				if(ch[i][j] != ch[i][j - 1]) dp[i][j] = min(dp[i][j],dp[i][j - 1] + 1);
			}
		}
	}
	if(ch[n][m] == '#') dp[n][m] ++;
	dp[n][m] >>= 1;
	cout << dp[n][m] << endl;
	return 0;
}

Measured memory_bytes: 2304
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		char[] s = stdIn.next().toCharArray();
		Arrays.sort(s);
		if(s[0] !=s[1] || s[2] != s[3] || s[1] == s[2]) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}

}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,tot,si[N],fa[N],f[N],head[N],nex[N<<1],to[N<<1],a[N];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
vector<int>v[N];
ll ans[N],s[N];
int top,st[N];
void dfs1(int u,int p)
{
    si[u]=1;fa[u]=p;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p)continue;
        dfs1(v,u);
        si[u]+=si[v];
    }
}
void dfs2(int u,int p)
{
    if(u==1||a[u]==a[p]) f[u]=0;
    else
    {
        f[u]=si[u];
        if(v[a[u]].size())
        {
            f[st[v[a[u]].back()+1]]-=si[u];
        }
    }
    st[++top]=u;
    v[a[u]].push_back(top);
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p)continue;
        dfs2(v,u);
    }
    top--;
    v[a[u]].pop_back();
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),s[a[i]]--,s[i]+=n;
    for(int i=1;i<n;i++)
    {
        int u,v;scanf("%d%d",&u,&v);add(u,v);add(v,u);
    }
    dfs1(1,0);
    dfs2(1,0);
    for(int i=2;i<=n;i++)
    {
        if(f[i]==0) continue;
        int c=a[fa[i]];
        s[c]-=f[i];
        ans[c]+=(ll)f[i]*(f[i]-1)/2+f[i];
    }
    for(int i=1;i<=n;i++)
    {
        ans[i]+=(ll)s[i]*(s[i]-1)/2+s[i];
        printf("%lld\n",(ll)n*(n-1)/2+n-ans[i]);
    }
}


Measured memory_bytes: 38840
n, x = list(map(int, input().split()))

a = list(map(int, input().split()))

def gcd(la, lb):
    if la < lb:
        tmp = a
        la = lb
        lb = tmp

    r = la % lb

    while r != 0:
        la = lb
        lb = r
        r = la % lb

    return lb

ans = 1000000001
for i in range(n):
    v = abs(x - a[i])

    if v < ans:
        ans = v

    g = gcd(v, ans)
    if g < ans:
        ans = g

print(ans)

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

const ll N=333;
ld dp[N+5][N+5][N+5];
ll n;

ld recur(ll a, ll b, ll c)
{
	ld &ans=dp[a][b][c];
	if(ans!=-1.0) return ans;
	ans=0;
	if(a+b+c==0) return ans;
	if(a > 0) ans += recur(a-1, b, c) * a;
	if(b > 0) ans += recur(a+1, b-1, c) * b;
	if(c > 0) ans += recur(a, b+1, c-1) * c;
	ans /= (a + b + c);
	ans += (ld)n/(a + b + c);	
	return ans;
}

void solve()
{
	cin>>n;
	ll x=0, y=0, z=0;
	for(ll i=0; i<n; i++)
	{
		ll c; cin>>c;
		if(c==1) x++;
		else if(c==2) y++;
		else if(c==3) z++;
	}
	for(ll i=0; i<N; i++) for(ll j=0; j<N; j++) for(ll k=0; k<N; k++)  
	dp[i][j][k]=-1.0;
	
	ld an=recur(x, y, z);
    cout<<fixed<<setprecision(12);
	cout<<an<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
	ll T = 1;
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 596352
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
	int n, w;
	while (cin >> n >> w, n) {
		int cnt[11] = {};
		int maxcnt = 0, maxv = 0;
		double ans = 0.01;
		for (int i = 0; i < n; ++i) {
			int v; cin >> v;
			cnt[v / w]++;
			maxcnt = max(maxcnt, cnt[v / w]);
			maxv = max(maxv, v);
		}
		int column = maxv / w;
		for (int i = 0; i <= column; ++i)
			ans += (double)cnt[i] / maxcnt * (column - i) / column;
		printf("%.10f\n", ans);
	}

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main() {
  int n; cin >> n;
  int ans=0;
  unordered_set<int> s;
  rep(i,n){
    int k; cin >> k;
    if(s.find(k)==s.end()){
      s.insert(k);
    } else {
      s.erase(k);
    }
  }
  
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 4388
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int64 gcd(int64 a, int64 b) {
  while (b) {
    int64 c = a;
    a = b;
    b = c % b;
  }
  return a;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    a[i] /= 2;
  }
  int64 X = a[0];
  for (int i = 1; i < n; ++i) {
    X = X / gcd(X, a[i]) * a[i];
    if (X > m) break;
  }
  if (X > m) {
    puts("0");
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (X / a[i] % 2 == 0) {
      puts("0");
      return 0;
    }
  }
  m /= X;
  m = (m + 1) / 2;
  printf("%d\n", m);
  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> N;
    vector<ll> A(N);
    REP(i, N)
        cin >> A.at(i);
    
    priority_queue<ll, vector<ll>, greater<ll>> Q;
    REP(i,N){
        Q.push(A.at(i));
    }
    //cout << Q.size() << endl;

    ll p = Q.top();

    while(Q.size()>0){
        if(Q.top()==0){
            Q.pop();
        }
        else if(Q.top()<p){
            ll tmp = Q.top();
            Q.pop();
            Q.push(p);
            p = tmp;
        }
        else{
            ll tmp = Q.top();
            Q.pop();
            Q.push(tmp % p);
        }
    }

    ll ans = p;
    cout << ans << endl;
}


Measured memory_bytes: 2168
h,w = map(int,input().split())

maze = [[0] for _ in range(h)]
for i in range(h):
    maze[i] = list(input())

flag = True
prev = 0
for row in maze:
    if "#" not in row:
        flag = False
        break
    left = row.index("#")
    if prev != left:
        flag = False
        break
    for r in range(left,w):
        if row[r] == "#":
            right = r
        else:
            break
    check_r = w-1-row[::-1].index("#")
    if check_r != right:
        flag = False
        break
    prev = right
if flag:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 61996
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail+1==LEN) tail=0;
  else tail=tail+1;
}

P dequeue(){
  P x;
  x=Q[head];
  if(head+1==LEN) head=0;
  else head=head+1;
  return x;
}

int main(){
  int elaps=0, c=0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;
  
  for(i=1;i<=n+c;i++){
      if(Q[head].t<=q){
	elaps+=Q[head].t;
	printf("%s ", Q[head].name);
	printf("%d\n",elaps);
dequeue();
	    }
      else {
	elaps+=q;
	Q[head].t-=q;
	enqueue(Q[head]);
	dequeue();
	c++;
      }
    }
  return 0;
}

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

using namespace std;
typedef long long ll;

ll N;
vector<ll> A;
vector<ll> B;
vector<ll> C;

int main(){
    ll t;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> t;
        A.push_back(t);
    }
    for(int i=0;i<N;i++){
        cin >> t;
        B.push_back(t);
    }
    for(int i=0;i<N;i++){
        cin >> t;
        C.push_back(t);
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    ll n = 0;
    for(int i=0;i<N;i++){
        auto itra = lower_bound(A.begin(),A.end(),B[i]);
        auto itrc = upper_bound(C.begin(),C.end(),B[i]);
        ll ap = (ll)(itra - A.begin());
        ll cp = N - (ll)((itrc - C.begin()));
        n += ap * cp;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3316
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

struct BIT {
    vector<int> dat;
    int n;

    BIT(int n, int init) :n(n) { dat.assign(n + 1, init); }
    void init(int n, int init) { n = n; dat.assign(n + 1, init); }

    //[1, i]
    int sum(int i) {
        int m = 0;
        while (i > 0) {
            m += dat[i];
            i -= i & -i;
        }
        return m;
    }

    void add(int i, int x) {
        while (i <= n) {
            dat[i] += x;
            i += i & -i;
        }
    }
};

void compress(vector<ll> &v) {
    vector<ll> new_v = v;
    sort(new_v.begin(), new_v.end());
    new_v.erase(unique(new_v.begin(), new_v.end()), new_v.end());
    map<ll, int> mp;
    rep(i, new_v.size()) mp[new_v[i]] = i + 1;
    rep(i, v.size()) v[i] = mp[v[i]];
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> as(n);
    cin >> as;

    rep(i, n) as[i] -= k;
    vector<ll> sum(n + 1);
    rep(i, n) sum[i + 1] = sum[i] + as[i];
    compress(sum);
    
    BIT bit(500000, 0);
    bit.add(sum[0], 1);
    ll ans = 0;
    repr(i, 1, n + 1) {
        ans += bit.sum(sum[i]);
        bit.add(sum[i], 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 17408
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int  X;
	cin >> X;
	if (X >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    int n,cnt;
    cin>>n;
    vector<int>d1(n);
    vector<int>d2(n);
    rep(i,n){
        cin>>d1.at(i);
        cin>>d2.at(i);
    }
    cnt=0;
    rep(i,n){
        if(d1.at(i)==d2.at(i))cnt++;
        else {cnt=0;}
        if(cnt>=3){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
	"math"
)

var shops [][]int
var ben [][]int
var n int
var ans float64

func dfs(ary []int, d int) {
	if d == 10 {
		// fmt.Printf("%v ", ary)
		var q int
		for q=0; q<10; q++ {
			if ary[q] != 0 {
				break;
			}
		}
		if q == 10 {
			return
		}
		benefit := 0
		// o_c := make([]int, 0)
		for i := 0; i < n; i++ {
			c := 0
			for j := 0; j < 10; j++ {
				if ary[j]&shops[i][j] == 1 {
					// fmt.Println("hit: %v", j)
					c++
				}
			}
			benefit += ben[i][c]
			// o_c = append(o_c, ben[i][c])
		}
		if ans <= float64(benefit) {
			// if benefit == 0 {
			// 	fmt.Println(ary)
			// 	fmt.Println(ben)
			// }
			// fmt.Println(ary)
			ans = float64(benefit)
		}
		// fmt.Printf("%v\n", benefit)
		return
	}
	ary = append(ary, 0)
	dfs(ary, d+1)
	ary = ary[:len(ary)-1]
	ary = append(ary, 1)
	dfs(ary, d+1)
}

func main() {
	ans := math.MinInt32
	fmt.Scan(&n)
	shops = make([][]int, n)
	for i := 0; i < n; i++ {
		shops[i] = make([]int, 10)
		for j:=0; j<10; j++ {
			fmt.Scan(&shops[i][j])
		}
	}

	ben = make([][]int, n)
	for i := 0; i < n; i++ {
		ben[i] = make([]int, 11)
		for j:=0; j<11; j++ {
			fmt.Scan(&ben[i][j])
		}
	}
	// ary := make([]int, 0)
	// for i:=0; i<n; i++ {
	// 	for j:=0; j<10; j++ {
	// 		fmt.Printf("%v ", shops[i][j])
	// 	}
	// 	fmt.Print("\n")
	// }
	// dfs(ary, 0)
	for b:=uint16(1); b<(1<<10); b++ {
		cc := 0
		for i:=0; i<n; i++ {
			c := 0
			for j:=uint16(0); j<10; j++ {
				if (b>>j&1) & uint16(shops[i][j]) > 0{
					c++
				}
			}
			cc += ben[i][c]
		}
		if ans < cc {
			ans = cc
		}
		// ans = math.Max(float64(cc), ans)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long ans = 0;
    for(int a = 1; a <= n; a++) {
      if(((2 * a) % k) == 0) {
        int c = (int)Math.ceil((double)(a + 1) / (double)k);
        int d = (n + a) / k;
        int e = d - c + 1;
        ans += ((long)e * (long)e);
      }
    }
    System.out.println(ans);
  }
}

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

int main() {
    int n;
    cin >> n;
    multiset<int> ds;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        ds.insert(d);
    }
    int d = *max_element(ds.begin(), ds.end());
    if (d % 2 == 0) {
        int D = d;
        while (D > d / 2) {
            if (ds.count(D) < 2) {
                cout << "Impossible" << endl;
                return 0;
            }
            ds.erase(ds.find(D));
            ds.erase(ds.find(D));
            D--;
        }
        if (ds.count(D) < 1) {
            cout << "Impossible" << endl;
            return 0;
        }
        ds.erase(ds.find(D));
        for (int a : ds) {
            if (a <= D) {
                cout << "Impossible" << endl;
                return 0;
            }
        }

        cout << "Possible" << endl;
        return 0; 
    }

    int D = d;
    while (D > d / 2) {
        if (ds.count(D) < 2) {
            cout << "Impossible" << endl;
            return 0;
        }
        ds.erase(ds.find(D));
        ds.erase(ds.find(D));
        D--;
    }
    for (int a : ds) {
        if (a <= D + 1) {
            cout << "Impossible" << endl;
            return 0;
        }
    }

    cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int MAX=1;
  rep(i,n){
    cin >> a[i];
    MAX = max(MAX,a[i]);
    --a[i];
  }
  vector<set<int>> p(MAX,set<int>());
  rep(i,n) p[a[i]].emplace(i);
  
  if(p[0].empty()){
    cout << -1 << endl;
    return 0;
  }
  int pos = -1;
  int ans = 0;
  int rem = n;
  rep(i,MAX){
    auto itr = p[i].upper_bound(pos);
    if(itr==p[i].end()){
      ans += rem;
      break;
    }
    if (rem < p[i].size() - 1) {
      ans += rem;
      break;
    }
    ans += p[i].size() - 1;
    pos = *itr;
    rem -= p[i].size();
  }
  cout << ans << endl;
}


Measured memory_bytes: 15104
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a > b) {
			if (a > c) {
				if (c > b) {
					int tmp = b;
					b = c;
					c = tmp;
				}
			} else {
				int tmp = a;
				a = c;
				c = tmp;
				if (c > b) {
					tmp = b;
					b = c;
					c = tmp;
				}
			}
		} else {
			int tmp = a;
			a = b;
			b = tmp;
			if (a > c) {
				if (c > b) {
					tmp = b;
					b = c;
					c = tmp;
				}
			} else {
				tmp = a;
				a = c;
				c = tmp;
				if (c > b) {
					tmp = b;
					b = c;
					c = tmp;
				}
			}
		}
		System.out.println(c + " " + b + " " + a);
		sc.close();
	}
}



Measured memory_bytes: 26232
#include<iostream>
using namespace std;
int f(int a, int b){
    if(b==0)    return a;
    else    return f(b, a%b);
}
int main(){
    //ios::sync_with_stdio(false);
    int a, b;
    cin>>a>>b;
    if(a>b)
        cout<<f(a,b)<<endl;
    else
        cout<<f(b,a)<<endl;
    return 0;
}


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

using namespace std;

int N, M;
vector <pair<int,long long>> D[100001];
long long D1[100001], D2[100001], W1[100001], W2[100001], G[100001], MOD=1000000007;

void Dij(int AA, int BB, long long DP[], long long W[])
{
    priority_queue <pair<long long,int>, vector<pair<long long,int>>, greater<pair<long long,int>>> Q;
    W[AA] = 0;
    DP[AA] = 1;
    Q.push({0, AA});
    for (int i = 1; i <= N; i++)
    {
        G[i] = 1;
    }
    while (Q.size() > 0)
    {
        while (Q.size() > 0 && G[Q.top().second] == 0)
        {
            Q.pop();
        }
        if (Q.size() == 0)
        {
            break;
        }
        int I = Q.top().second, a, b, wp;
        long long w = Q.top().first;
        G[I] = 0;
        Q.pop();
        for (int i = 0; i < D[I].size(); i++)
        {
            a = D[I][i].first;
            wp = D[I][i].second;
            if (W[I] + wp < W[a])
            {
                W[a] = W[I] + wp;
                DP[a] = DP[I];
                Q.push({W[a],a});
            }
            else if (W[I] + wp == W[a])
            {
                DP[a] += DP[I];
                DP[a] %= MOD;
            }
        }
    }
}

int main()
{
    int S, T;
    cin >> N >> M >> S >> T;
    int A[M], B[M], W[M];
    for (int i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i] >> W[i];
        D[A[i]].push_back({B[i],W[i]});
        D[B[i]].push_back({A[i],W[i]});
    }
    for (int i = 1; i <= N; i++)
    {
        D1[i] = 0;
        D2[i] = 0;
        W1[i] = 200000000000000000;
        W2[i] = 200000000000000000;
    }
    Dij(S, T, D1, W1);
    Dij(T, S, D2, W2);
    long long Bu = D1[T] * D1[T], WW = W1[T], MI;
    Bu %= MOD;
    for (int i = 1; i <= N; i++)
    {
        if (W1[i] + W2[i] == WW && W1[i] == WW/2 && W2[i] == WW/2)
        {
            MI = ((D1[i] * D1[i]) % MOD) * ((D2[i] * D2[i]) % MOD);
            MI %= MOD;
            Bu -= MI;
            if (Bu < 0)
            {
                Bu += MOD;
            }
        }
    }
    for (int i = 0; i < M; i++)
    {
        int a=A[i], b=B[i];
        if (W2[a] < W1[a])
        {
            swap(a,b);
        }
        if (W1[a] + W2[b] + W[i] == WW && W1[a] < WW / 2 && W2[b] < WW / 2)
        {
            MI = ((D1[a] * D1[a]) % MOD) * ((D2[b] * D2[b]) % MOD);
            MI %= MOD;
            Bu -= MI;
            if (Bu < 0)
            {
                Bu += MOD;
            }
        }
    }
    cout << Bu;
    return 0;
}


Measured memory_bytes: 23076
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    int cnt = X / 100;
    X %= 100;
    if (X <= cnt * 5) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2*10**5)#必要に応じて

class UnionFind:#再帰上限に引っかかることがあるので
    def __init__(self,n):
        self.l=list(range(n))
        self.n=n
        self.rank=[0 for i in range(n)]
    def find(self,x):
        if self.l[x]==x:
            return x
        self.l[x]=self.find(self.l[x])
        return self.l[x]
    def union(self,x,y):
        if x==y:return
        if self.rank[x]>self.rank[y]:
            return self.union(y,x)
        a,b=self.find(x),self.find(y)
        self.l[a]=b
        self.rank[a]=max(self.rank[b]+1,self.rank[a])
    def isSame(self,x,y):
        return self.find(x)==self.find(y)
n,m=map(int,input().split())
u=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    u.union(a-1,b-1)
d=set()
for i in range(n):
    d.add(u.find(i))
print(len(d)-1)

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

int main() {
	int n;
	cin >> n;
	while(true) {
		long long j = 2;
		bool ok = true;
		for(j = 2; j * j <= n; ++j) {
			if(n % j == 0)
				ok = false;
		}
		if(ok)
			return cout << n, 0;
		++n;
	}
}


Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
//#include <stdlib.h>

int main(void) {
	int r, c;
	int i, j;
	int fig[1001][101] = { 0 };

	scanf("%d %d", &r, &c);


	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			scanf("%d", &fig[i][j]);
			fig[i][c] += fig[i][j];
			fig[r][j] += fig[i][j];
			fig[r][c] += fig[i][j];
		}
	}

	for (i = 0; i <= r; i++) {
		for (j = 0; j <= c; j++) {
			printf("%d", fig[i][j]);
			if (j != c)
				printf(" ");
		}
			printf("\n");
	}

	//system("pause");
	
	return 0;
}


Measured memory_bytes: 2196
<?php
$stdins = array();
while (true) {
  $stdin = trim(fgets(STDIN));
  if ($stdin === '') {
    break;
  }
  $stdins[] = $stdin;
}
$num = $stdins[0];

$length = explode(' ',$stdins[1]);

rsort($length);

$count = 0;
for ($i=0;$i < count($length); $i++) {
  if ($i%2 != 0) {
    $count += $length[$i];
  }
}

print_r($count."\n");
?>


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

//2点間での最短を求める
int calc(int x1, int y1, int x2, int y2) { //ループを使う方法(オーダが大きくなる)
    int ret = 0;
    int diffx = x2 - x1, diffy = y2 - y1;
    while(true) {
        if(!(diffx | diffy)) break; //差が0になったら終了
        //処理
        if(diffx >= 1 && diffy >= 1)        { diffx--; diffy--; }
        else if(diffx <= -1 && diffy <= -1) { diffx++; diffy++; }
        else if(diffx >= 1)                   diffx--;
        else if(diffy >= 1)                   diffy--;
        else if(diffx <= -1)                  diffx++;
        else if(diffy <= -1)                  diffy++;
        //通った道を記録
        ret++;
    }
    return(ret);
}

int calc2(int x1, int y1, int x2, int y2) {//ループを使わない方法
    int diffx = abs(x2 - x1);
    int diffy = abs(y2 - y1);
    if(x1 > x2 ^ y1 > y2) return(diffx + diffy); //右上から左下に行く場合、もしくは左上から右下に行く場合
    else if(diffx == diffy) return(diffx);
    else return(max(diffx, diffy));
}

void solve(int n) {
    //訪れる交差点を入力
    vector<P> visit(n);
    for(int r = 0; r < n; r++) {
        cin >> visit[r].first >> visit[r].second;
    }
    //処理
    P now = visit[0];
    int sum = 0;
    for(int r = 1; r < n; r++) {
        sum += calc2(now.first, now.second, visit[r].first, visit[r].second);
        now = visit[r];
    }
    //出力
    cout << sum << endl;
}

int main(void) {
    int width, height, n;
    cin >> width >> height >> n;
    solve(n);
    
    return(0);
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

int main() {
  int n,m;
  cin>>n>>m;
	COMinit();
  
 vector <pair<int, int>> vec;
    int p=0;
while (m >= 2) {
	bool so = true;
	for (int i = 2; i*i <= m; i++) {
		if (m%i == 0) {
			vec.push_back(pair<int, int>(i,1));
			m /= i;
          while(m%i==0){
            vec[p].second++;
            m/=i;
          }
			so = false;
             p++;
			break;
		}
     
	}
	if (so) {
		vec.push_back(pair<int, int>(m,1));
		break;
	}
}

  ll ans=1;
  rep(i, vec.size()){
    ans*=COM(n+vec[i].second-1, vec[i].second);
    ans%=MOD;
  }
  
	cout << ans << endl;
}


Measured memory_bytes: 12160
package main

import (
	"fmt"
	"io"
	"os"
)

func answer(reader io.Reader, writer io.Writer) {
	var a, b int
	_, _ = fmt.Fscan(reader, &a)
	_, _ = fmt.Fscan(reader, &b)
	if a < 6 {
		_, _ = fmt.Fprintf(writer, "0")
	} else if a < 13 {
		_, _ = fmt.Fprintf(writer, "%d", b / 2)
	} else {
		_, _ = fmt.Fprintf(writer, "%d", b)
	}
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ").map{ it.toInt() }
    val c = readLine()!!.split(" ").map{ it.toInt() }

    (0..n-1).map{ v[it]-c[it] }.filter { it > 0 }.sum().let { println(it) }
}

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


struct udE{
	int x, y;
	ll c, u, d;
};
namespace udcf{
	ll inf=1e9;
	namespace mincf{
		const int E=101000;
		const int V=1010;
		
		struct R{
			int to,nex;
			ll cost,flow;
		}r[E];
		int st,en,n,cnt,hea[V];
		
		void A(int u,int v,ll c,ll f){
			r[++cnt]=(R){v,hea[u],c,f}; hea[u]=cnt;
			r[++cnt]=(R){u,hea[v],-c,0};hea[v]=cnt;
		}
		void resta(int n_,int st_,int en_){
			memset(hea,0,sizeof hea);
			cnt=1;
			n=n_; st=st_; en=en_;
		}
		
		int pv[V],pe[V],in[V];
		queue<int>q;
		ll fl,f[V],d[V],ans,sf,inf;
		
		bool spfa(){
			while (!q.empty()) q.pop();
			memset(in,0,sizeof in);
			memset(d,62,sizeof d);
			f[st]=inf=d[0]; d[st]=0;
			ll x,y,z;
			for (q.push(st);!q.empty();q.pop()){
				x=q.front(); in[x]=0;
				for (int i=hea[x];i>0;i=r[i].nex) if (r[i].flow){
					y=r[i].to; z=d[x]+r[i].cost;
					if (z<d[y]){
						d[y]=z; f[y]=min(f[x],r[i].flow);
						pv[y]=x; pe[y]=i;
						if (!in[y]){ in[y]=1; q.push(y); }
					}
				}
			}
			return d[en]!=inf;
		}
		
		ll realmain(){
			sf=ans=0;
			while (spfa()){
				sf+=fl=f[en];
				ans+=fl*d[en];
				for (int x=en;x!=st;x=pv[x]){
					r[pe[x]].flow-=fl;
					r[pe[x]^1].flow+=fl;
				}
			}
			return ans;
		}
	}
	pair<int,ll> realmain(int n,int s,int t,vector<udE>e){
		int ss=n+1, tt=n+2;
		mincf::resta(n,ss,tt);
		mincf::A(t,s,0,inf);
		ll aim=0, bas=0;
		for (unsigned it=0;it<e.size();++it){
			udE E=e[it];
			if (E.u<E.d) return (pair<int,ll>){-1,-1ll};
			if (E.d){
				aim+=E.d; bas+=E.d*E.c;
				mincf::A(ss,E.y,0,E.d);
				mincf::A(E.x,tt,0,E.d);
			}
			if (E.u-E.d){
				mincf::A(E.x,E.y,E.c,E.u-E.d);
			}
		}
		ll res=mincf::realmain();
		if (mincf::sf!=aim) return (pair<int,ll>){-1,-1ll};
		return (pair<int,ll>){1,res+bas};
	}
}

int n, xl[111], xr[111], yl[111], yr[111];
vector<udE>org, vec;

int m, a[333], b[333];
char ty[333];

int main(){
	cin>>n;
	for (int i=1;i<=n;++i){
		ll x, y, v;
		cin>>x>>y>>v; ++x; ++y;
		org.push_back({x,y+102,-v,1,0});
	}
	cin>>m;
	for (int i=1;i<=m;++i){
		cin>>ty[i]>>a[i]>>b[i];
		++a[i];
	}
	ll ans=0;
	for (int tot=1;tot<=n;++tot){
		vec=org;
		memset(xl,0,sizeof xl); xl[101]=tot;
		memset(xr,1,sizeof xr); xr[101]=tot;
		memset(yl,0,sizeof yl); yl[101]=tot;
		memset(yr,1,sizeof yr); yr[101]=tot;
		for (int i=1;i<=m;++i){
			if (ty[i]=='L') xr[a[i]]=min(xr[a[i]],b[i]);
			if (ty[i]=='R') xl[a[i]-1]=max(xl[a[i]-1],tot-b[i]);
			if (ty[i]=='D') yr[a[i]]=min(yr[a[i]],b[i]);
			if (ty[i]=='U') yl[a[i]-1]=max(yl[a[i]-1],tot-b[i]);
		}
		for (int i=1;i<=101;++i){
			vec.push_back({i+1,i,0,xr[i],xl[i]});
			vec.push_back({i+102,i+1+102,0,yr[i],yl[i]});
		}
		pair<int,ll> res=udcf::realmain(204,102,204,vec);
		cerr<<tot<<' '<<res.first<<' '<<res.second<<endl;
		if (res.first==1) ans=max(ans,-res.second);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    for (int i=0;i<n;i++) {
        double h,m;
        char c;
        cin>>h>>c>>m;
        double angle_h=30.0*h+30.0*m/60.0;
        double angle_m=m*6;
        double angle=min(abs(angle_h-angle_m),abs(angle_m-angle_h));
        if (angle>=180) {
            angle=360-angle;
        }
        //cout<<angle_h<<" "<<angle_m<<" "<<angle<<endl;
        if (angle<30) {
            cout<<"alert"<<endl;
        } else if (angle>=90&&angle<=180) {
            cout<<"safe"<<endl;
        } else {
            cout<<"warning"<<endl;
        }
    }
}


Measured memory_bytes: 3164
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {
    def main(args: Array[String]): Unit = { 
        digit(readLine().split(" ").map(_.toDouble))
    }   

    @tailrec
    def digit(n: Seq[Double]): Unit = {
       val d: Double = n(1) * n(3) - n(0) * n(4)
       val x: Double = zero((n(1) * n(5) - n(4) * n(2)) / d)
       val y: Double = zero((n(2) * n(3) - n(0) * n(5)) / d)
       println(f"$x%.3f $y%.3f")
       val next: String = readLine()
       if(next == null) Unit else digit(next.split(" ").map(_.toDouble))
    }

    def zero(n: Double): Double = if(Math.abs(n) == 0) 0 else n
    //def round(n: Double): Double = Math.round(n * 1000) / 1000
}

Measured memory_bytes: 44164