akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long  long
#define INF 1000000000000000000LL
#define pll pair<long long , long long>
const int MAX=5e6+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{
    int n , x, t;
    cin>>n>>x>>t;
    int ans = 0;
    int now = 0;
    while(now<n){
        ans = ans+t;
        now = now+x;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#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 d, t, s;
  cin >> d >> t >> s;

  if (d <= t*s) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3592
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    #endif
    ll n;
    cin>>n;
    vector<ll> A(n);
    input(A,n);
    ll prod = 1;
    for(ll i=0;i<n;i++){
        if(A[i]==0){
            cout<<0<<'\n';
            return 0;
        }
    }
    for(ll i=0;i<n;i++){
        prod = prod*A[i];
        if(prod>(ll)(1e18) or prod<=0){
            cout<<-1;
            return 0;
        }
    }
    cout<<prod;
    return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;

const double PI = acos(-1.0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin>>N;
    string S;
    cin>>S;
    if(N%2 == 1){
        cout<<"No"<<endl;
        return 0;
    }
    string T1 = "";
    string T2 = "";
    rep(i,N){
        if(i < N/2)T1.push_back(S[i]);
        else T2.push_back(S[i]);
    }
    if(T1 == T2){
        cout<<"Yes"<<endl;
        return 0;
    }
    else{
        cout<<"No"<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
Ans = [0] * (10**5 + 10)

for _ in range(N):
    a, b = map(int, input().split())
    Ans[a] += b

for i, ans in enumerate(Ans):
    K -= ans
    if K <= 0:
        print(i)
        exit()



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

using namespace std;

#define ll long long

int main()
{
	ll N, W;
	cin >> N >> W;
	ll w[N], v[N];
	ll min = 1000000;
	for(ll i = 0; i < N; i++)
	{
		cin >> w[i] >> v[i];
		if(min > w[i])
			min = w[i];
	}
	ll M = W/min;
	ll ans[N][W+1];
	// for(ll i = 0; i < W+1; i++)
	// {
	// 	ans[0][i] = v[0]*(i/w[0]);
	// 	weight[0][i] = i%w[0];
	// }
	// for(ll i = 1; i < N; i++)
	// {
	// 	for(ll j = 0; j < W+1; j++)
	// 	{
	// 		ans[i][j] = -1;
	// 		for(ll k = 0; k <= j; k++)
	// 		{
	// 			ll temp = ans[i-1][k] + ((j-k + weight[i-1][k])/w[i])*v[i];
	// 			if(temp > ans[i][j])
	// 			{
	// 				ans[i][j] = temp;
	// 				weight[i][j] = (j-k + weight[i-1][k])%w[i];
	// 			}
	// 		}

	// 	}
	// }
	for(ll i = 0; i < W+1; i++)
	{
		if(i >= w[0])
			ans[0][i] = v[0];
		else
			ans[0][i] = 0;
	}
	for(ll i = 1; i < N; i++)
	{
		for(ll j = 0; j < W+1; j++)
		{
			if(j-w[i] < 0)
				ans[i][j] = ans[i-1][j];
			else
				ans[i][j] = max(ans[i-1][j], ans[i-1][j-w[i]] + v[i]);
		}
	}

	cout << ans[N-1][W];

}

Measured memory_bytes: 78336
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int x = sc.nextInt();
    	int t = sc.nextInt();
    	
    	if(n%x == 0) {
    		System.out.println(n/x*t);
    	}else {
    		System.out.println((n/x+1)*t);
    }
}
}

Measured memory_bytes: 35624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  ll a, b, x;
  cin >> a >> b >> x;

  if (a==0){
    cout << b/x + 1 << "\n";
  } else {
    cout << b/x - (a-1)/x << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <stack>
using namespace std;

int main(){
	stack<int> st;
	int n, a;

	while(cin >> n){
		if(n!=0){
			st.push( n );
		}else{
			a = st.top();
			cout << a << endl;
			st.pop();
		}
	}
}

Measured memory_bytes: 3000
using System;
using System.Linq;
using System.Text;

namespace ABC133.D {
    class Program {
        static void Main(string[] args) {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var totalD = a.Sum();

            var mlist = new long[n];
            mlist[0] = CalcM1(n, a, totalD);
            for (int i = 1; i < n; i++)
                mlist[i] = CalcM2(a[i - 1], mlist[i - 1]);

            var s = new StringBuilder();
            foreach (var item in mlist)
                s.Append(item).Append(" ");
            Console.WriteLine(s.ToString());
        }

        private static long CalcM1(int n, long[] a, long total) {
            var tmp = 0L;
            for (int i = 1; i < n; i += 2)
                tmp += a[i]*2;
            return total - tmp;
        }

        private static long CalcM2(long d, long mBefore) {
            return d * 2 - mBefore;
        }
    }
}


Measured memory_bytes: 32996
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define REP(n) FOR(i,n)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define ntuples(type1,type2,type3,v,n) vector<tuple<type1,type2,type3>> v(n);for(size_t i=0;i<(n);i++){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)


int main() {
  int n,m;
  cin>>n>>m;
  npairs(int,string,p,m);
  vector<int> v(n,0);
  for (int i = 0; i < m; i++) {
    if (v[p[i].first-1]<200000) {
      if (p[i].second=="AC") {
        v[p[i].first-1]+=200000;
      }else{
        v[p[i].first-1]+=1;
      }
    }
  }
  int se=0,pe=0;
  for (int i = 0; i < n; i++) {
    //cout<<v[i]<<endl;
    if (v[i]>=200000) {
      se+=1;
      pe+=(v[i]-200000);
    }
  }
  cout<<se<<" "<<pe;
}

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

using namespace std;

int a1,a2,a3,a4;

int main(){

	int a,b,c;
	int h[4];
	while(cin >> h[0] >> h[1] >> h[2]){
		sort(h,h+3);
		a = h[0];
		b = h[1];
		c = h[2];

		if(a+b > c){
			a1++;
			if(a*a + b*b == c*c)a2++;
			else if(a*a + b*b > c*c)a3++;
			else a4++;
		}else{
			printf("%d %d %d %d\n",a1,a2,a3,a4);
			break;
		}
	}
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vvi = vector< vector<int> >;
using vi = vector<int>;
using vvb = vector< vector<bool> >;
using vb = vector<bool> ;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define ar array
#define endl '\n'
#define all(x) x.begin(), x.end()


const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){



}

void solve(){    

    ll n;
    cin >> n;
    ll a[n+1];
    map<ll,ll> MAP[2];
    for(ll i=1;i<=n;i++){
        cin >> a[i];
        MAP[i&1][a[i]]++;
    }
    vector<pair<ll,ll>>  A[2];
    for(ll i=0;i<2;i++){
        for(auto it : MAP[i]){
            A[i].pb({it.ss,it.ff});
        }
    }
    for(ll i=0;i<2;i++)
        sort(all(A[i]),greater<pair<ll,ll>>());
    ll ans = n/2 - A[0][0].ff;
    if(A[1][0].ss != A[0][0].ss){
        ans += n/2 - A[1][0].ff;
    }else{
        if(A[1].size() > 1){
            ans += n/2 - A[1][1].ff;
            if(A[0].size() > 1){
                ll tmp = n/2 - A[0][1].ff;
                tmp += n/2 - A[1][0].ff;
                ans = min(ans , tmp);
            }
        }else{
            ans -= n/2 - A[0][0].ff;
            if(A[0].size() > 1){
                ans += n/2 - A[0][1].ff;
            }else{
                ans += n/2;
            }
        }
    }
    cout << ans << endl;

}   

int main(){
    
    IOS;
    pre();
    ll T = 1;
    //cin >> T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 9592
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll N, M;
	cin >> N >> M;
	vector<vector<ll>> g(N + 1);
	repn(i, M) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<ll> p;
	vector<ll> see(N + 1, 0);

	ll v = 1;
	p.push_back(v);
	see[1] = 1;


	while (1 == 1) {
		ll bo = 0;

		for(ll w:g[v]) {
			if (see[w] == 0) {
				p.push_back(w);
				see[w] = 1;
				v = w;
				bo = 1;
				break;
			}
		}

		if (bo == 0) { break; }
	}

	vector<ll> q;
	v = 1;
	q.push_back(v);

	while (1 == 1) {
		ll bo = 0;

		for (ll w : g[v]) {
			if (see[w] == 0) {
				q.push_back(w);
				see[w] = 1;
				v = w;
				bo = 1;
				break;
			}
		}

		if (bo == 0) { break; }
	}

	cout << p.size() + q.size() - 1 << endl;
	for (ll i = q.size() - 1; i > 0; i--) { cout << q[i] << " "; }
	rep(i, p.size()) { cout << p[i] << " "; }


	system("PAUSE");
}


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

int main(){
  int n,m;cin>>n>>m;
  vector<int> x(n+1);
  vector<int> y(m+1);
  cin>>x[0]>>y[0];
  for(int i=1;i<n+1;i++){
    cin>>x[i];}
  for(int i=1;i<m+1;i++){
    cin>>y[i];}
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  if((y[0]-x[n])<=0)
    cout<<"War"<<endl;
  else cout<<"No War"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
#define maxn 100005
using namespace std;

#define INF 1000000000000000000LL
ll A[maxn];
ll lim[maxn];

int main(){
    int n;
    cin >> n;
    rep(i, n+1) cin >> A[i];
    lim[0] = 1;
    for(int i = 1; i < n + 1; i++){
        ll m = (lim[i-1]-A[i-1])*2LL;
        if(m < 0){
            cout << -1 << endl;
            return 0;
        }
        lim[i] = min(INF, m);
    }

    if(lim[n] < A[n]){
        cout << -1 << endl;
        return 0;
    }
    ll ret = A[n], now = A[n];
    for(int i = n - 1; i >= 0; i--){
        now += A[i];
        now = min(now, lim[i]);
        ret += now;
    }
    cout << ret << endl;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    ll n; cin >> n;
    vector<ll> a(n); rep(i, n) cin >> a[i];
    ll mon = 1000;
    rep(i, n-1) {
        if(a[i] < a[i+1]) {
            ll cap = mon / a[i];
            mon %= a[i];
            mon += a[i+1] * cap;
        }
    }
    cout << mon << endl;
}


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

using namespace std;

int main()
{
    int64_t A,B,v,w,T;
    cin>>A>>v;
    cin>>B>>w;
    cin>>T;
    if(T*(v-w)>=abs(A-B))
        cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

template <typename T>
struct edge {
    T to;
    T cost;
};

typedef pair<int, long long> P;

using Graph = vector<vector<edge<long long>>>;
Graph Ga;
Graph Gb;

void dijkstra(const Graph& G, int s, vector<long long>& d) {
    priority_queue<P, vector<P>, greater<P>> que;
    d.assign(G.size(), LINF);

    que.push({s, 0});
    d[s] = 0;
    while (!que.empty()) {
        P p = que.top();
        que.pop();

        int v = p.first;
        int cost = p.second;

        // cout << "(v, cost) = " << v << ", " << cost << endl;
        // cout << "d[v] = " << d[v] << endl;

        if (cost > d[v]) {
            continue;
        }

        for (size_t i = 0; i < G[v].size(); i++) {
            const edge<long long>& e = G[v][i];
            // cout << "edge: " << e.to << ", " << e.cost << endl;
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push({e.to, d[e.to]});
            }
        }
    }
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    --s;
    --t;

    Ga.assign(n, vector<edge<long long>>());
    Gb.assign(n, vector<edge<long long>>());

    for (int i = 0; i < m; i++) {
        int ui, vi, ai, bi;
        cin >> ui >> vi >> ai >> bi;
        --ui;
        --vi;

        Ga[ui].push_back({vi, ai});
        Ga[vi].push_back({ui, ai});
        Gb[ui].push_back({vi, bi});
        Gb[vi].push_back({ui, bi});
    }

    vector<long long> d_from_s(n);
    vector<long long> d_to_t(n);

    dijkstra(Ga, s, d_from_s);
    dijkstra(Gb, t, d_to_t);

/*
    for (int i = 0; i < n; i++) {
        cout << "d_from_s[" << i << "] = " << d_from_s[i] << endl;
    }
    for (int i = 0; i < n; i++) {
        cout << "d_to_t[" << i << "] = " << d_to_t[i] << endl;
    }
*/

    vector<long long> ans(n);
    long long minAns = LINF;
    for (int i = n - 1; i >= 0; --i) {
        long long cost = d_from_s[i] + d_to_t[i];
        // cout << "ans cost = " << cost << endl;
        minAns = min(cost, minAns);
        ans[i] = minAns;
    }

    for (int i = 0; i < n; i++) {
        cout << static_cast<long long>(1e15 - ans[i]) << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,t;
    cin>>a>>b>>t;
    ll ans=0;

    cout<<t/a*b<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 250

int main(){

  int A[MAX],i,num;
  scanf("%d",&num);

  for(i=1;i<=num;i++){
    scanf("%d",&A[i]);
  }

for(i=1;i<=num;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if( i != 1)printf("parent key = %d, ",A[i/2]);
    if(i*2 <= num)printf("left key = %d, ",A[i*2]);
    if(i*2+1 <= num)printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-
from collections import defaultdict

d = defaultdict(int)
_input = input()

for word in _input.split():
    d[word] += 1

times = sorted(d.items(), key=lambda item: item[1], reverse=True)
lengths = sorted(d.items(), key=lambda item: len(item[0]), reverse=True)

print(times[0][0], end=' ')
print(lengths[0][0])

Measured memory_bytes: 7748
ss=[]
n=int(input())
i=0
while i!=n:

    s=list(input())
    s.sort()
    ss.append(s)
    i+=1
ans=0
i=1
ss.sort()
mians=0

s=ss[0]
while i!=n:
    if s==ss[i]:
        ans+=1
        mians+=1


    else:
        while mians!=0:
            mians-=1
            ans+=mians
    s=ss[i]
    i += 1
while mians != 0:
    mians -= 1
    ans += mians

print(ans)


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

using namespace std;

int main()
{
//    freopen("in.txt","r",stdin);

    int n,x;

    while(cin>>n>>x&&(x||n))
    {
        int ans=0;
        for(int i=1;i<n;i++)
            for(int j=i+1;j<n;j++)
        {
            if(x-i-j<=n&&x-j-i>j)
                ans++;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var xCityNum = input[0];
        var yCityNum = input[1];
        var xCapital = input[2];
        var yCapital = input[3];
        var xNums = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var yNums = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        Array.Sort(xNums);
        Array.Sort(yNums);
        var max = xNums[xCityNum - 1];
        var min = yNums[0];
        if (max >= min) { WriteLine("War"); return; }
        if (xCapital >= yCapital||xCapital>=min||yCapital<=max) { WriteLine("War");return; }
        WriteLine("No War");
    }
}

Measured memory_bytes: 13268
N, M = map(int, input().split())
a = [0] * M # 鍵の値段
c = [[]] * M
INF = 100000001
dp = [INF for i in range(2 ** N)]
for i in range(M):
    a[i], _ = map(int, input().split())
    c[i] = list(map(int, input().split()))

b = []
for l in c:
    g = 0
    for n in l:
        g |= 1 << (n - 1)
    b.append(g)
l = 2 ** N
dp[0] = 0
for s in range(l):
    for i in range(M):
        p = s | b[i]#i番目の鍵に対応したbit数列
        dp[p] = min(dp[p], dp[s] + a[i])

ans = dp[-1]
if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 46296
#include <iostream>


main() {
        int x[3000], y[3000], i, num;

        num = 0;
        while( 1==1 ){
                std::cin >> x[num] >> y[num];
                if( x[num] == 0 && y[num] == 0) break;
                num++;
        }
        for( i=0; i<num; i++ ){
             if( x[i] > y[i] ){
                    std::cout << y[i] << " " << x[i] << std::endl;
             } else {
                    std::cout << x[i] << " " << y[i] << std::endl;
             }
        }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int x,a,b; cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
const int M = 1000000007;
int n, l, A[100];
int dp[100002][2];
bool game(int sum, int turn)
{
	if (sum < 0)
	{
		return 0;
	}
	if (dp[sum][turn] != -1)
	{
		if(dp[sum][turn])
		return 0;
		return 1;
	}
	loop(i, 0, n)
		if(sum-A[i]==0 || game(sum - A[i], (turn + 1) % 2))
			dp[sum][turn] = 1;
	if(dp[sum][turn]>0)return 0;
	dp[sum][turn]=0;
	return 1;
}
int main()
{
	cin >> n >> l;
	memset(dp, -1, sizeof(dp));
	loop(i, 0, n)
	{
		cin >> A[i];
	}
	game(l,0);
	if (dp[l][0])
	{
		cout<<"First";
		return 0;
	}
	cout << "Second";
}



Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long 
#define int long long 
#define Mod 10000000000007 
#define maxn 200005
#define MAX 4294967296  // 2^32
const int M=1e9+7;
#define ip pair<int,int>
#define test(t) ll t;cin>>t;while(t--)
  
using namespace std;

long long gcd(int x,int y){
    if(y>x)swap(x,y);
    if(y==0)return x;
    return gcd(y,x%y);
}


void solve(){

int n;
cin>>n;
int sum=0;
if(n==2){cout<<1;return ;}
else{

   for(int i=1;i*i<n;i++){
    int t=n/i;
    if(n%i!=0)t++;
    t-=(1+i);
    sum+=t*2;
   }
   if(floor(sqrt(n))==ceil(sqrt(n)))sum+=sqrt(n)-1;
  else sum+=sqrt(n);


}
cout<<sum;

}

signed main(){


    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);
   
solve();


  


}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> mat(n, vector<int>(m));
    vector<int> b(m);
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            cin >> mat.at(i).at(j);
        }
    }

    for (int i=0; i<m; i++)
    {
        int bi;
        cin >> bi;
        b.at(i) = bi;
    }
    for (int i=0; i<n; i++)
    {
        int ci=0;
        for (int j=0; j<m; j++)
        {
            ci += mat.at(i).at(j) * b.at(j);
        }
        cout << ci << endl;
    }

}


Measured memory_bytes: 3172
import java.util.*;
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();
      int semi = (a + b + c) / 2;
      System.out.println((int)Math.sqrt(semi * (semi - a) * (semi - b) * (semi - c)));
   }
}

Measured memory_bytes: 22996
n,*L = map(int,open(0).read().split())

sum1 = sum(L)
L = [x for x in L if x%10 != 0]
if  not L:
    print(0)
    exit()
L.sort()
if  sum1%10 == 0:
    print(sum1-L[0])
else:
    print(sum1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N =3*1e6+1;
char ch[N];
int ch2[N],n;
int dpr[N],dpl[N],ans=0x7fffffff;
int main()
{
	scanf("%d %s",&n,ch+1);
	for(int i=1;i<n;i++)
	{
		if(ch[i]=='W') dpl[i+1]=dpl[i]+1;
		else dpl[i+1]=dpl[i];
//		printf("%d ",dpl[i]);
	}
//	puts(" ");
	for(int i=n;i>1;i--)
	{
		if(ch[i]=='E') dpr[i-1]=dpr[i]+1;
		else dpr[i-1]=dpr[i];
//		printf("%d ",dpr[i]);
	}
	for(int i=1;i<=n;i++)
	{
		ans=min(ans,dpr[i]+dpl[i]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main(){
	int A,B;
	int ans[3];
	int answer=-10000000;
	cin>>A>>B;
	
	ans[0]=A+B;
	ans[1]=A-B;
	ans[2]=A*B;
	
	for(int i=0;i<3;i++){
		if(answer<ans[i]){
			answer=ans[i];
		}
	}
	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>S>>T>>Q;
    vec s(S.size() + 1,0), t(T.size() + 1,0); //Aの数
    rep(i,S.size()) s[i+1] = (s[i] + (S[i] == 'A'))%3;
    rep(i,T.size()) t[i+1] = (t[i] + (T[i] == 'A'))%3;
    rep(i,Q){
        cin>>A>>B;
        ll sa = s[B] - s[A - 1], sb = B - A - sa;
        cin>>A>>B;
        ll ta = t[B] - t[A - 1], tb = B - A - ta;
        (sb += 3 - sa)%=3;
        (tb += 3 - ta)%=3;
        cout<<(sb == tb ? "YES" : "NO")<<endl;
    }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(){

    vector<string> data(200,"a");
    string str,c;
    getline(cin,str);
    stringstream ss{str};
    int i=0;
    while(getline(ss,c,' ')){
        data.at(i)=c;
        i++;
    }

    stack<int> s;
    for(int i=0;i<200;i++){
        if(data.at(i)=="a"){
            break;
        }
        if((data.at(i)!="+")&&(data.at(i)!="-")&&(data.at(i)!="*")){
            s.push(stoi(data.at(i)));
        }
        if(data.at(i)=="+"){
            int x=s.top();
            s.pop();
            int y=s.top();
            s.pop();
            s.push(x+y);
        }
        if(data.at(i)=="-"){
            int x=s.top();
            s.pop();
            int y=s.top();
            s.pop();
            s.push(y-x);
        }
        if(data.at(i)=="*"){
            int x=s.top();
            s.pop();
            int y=s.top();
            s.pop();
            s.push(x*y);
        }
    }
    cout<<s.top()<<endl;
}


Measured memory_bytes: 3172
import java.util.Scanner
import scala.collection.mutable.Stack 

object Main extends App { 
  val sc = new Scanner(System.in)
  val N = sc.nextInt()
  val list = (for (i <- 0 until N) yield sc.nextLong()).toList

  class Histgram(list:List[Long]) {
    val bars:Array[Long] = list.toArray
    var stack = Stack[Int]()

    @scala.annotation.tailrec
    final def solver(i:Int, m:Long):Long = {
      def compute(i:Int, m:Long):Long = {
        if (stack.isEmpty || i < N && bars(stack.top) <= bars(i)) m
        else {
          val t = stack.pop
          val n = bars(t) * (if (stack.isEmpty) i else (i -stack.top -1))

          compute(i, n max m)
        }
      }

      if (i == N) compute(i, m)
      else if (stack.isEmpty || bars(stack.top) <= bars(i)) {
        stack.push(i)
        solver(i+1, m)
      }
      else solver(i, compute(i, m))
    }
  }

  val hst = new Histgram(list)

  println(hst.solver(0, 0))

}


Measured memory_bytes: 141856
N,M = map(int,input().split())
A_list = list(map(int,input().split()))
A_list.sort(reverse = True)

count = 0
judge = sum(A_list) / (4*M)

for i in range(0,len(A_list)):
    if A_list[i] >= judge:
         count += 1

if count >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

main :: IO ()
main = do
  n <- readInt
  print $ f n

f :: Int -> Int
f n = head . filter (<= n) $ [2^i | i<-[6,5 .. 0]]

Measured memory_bytes: 380
# N = input()

# chk= 0
# for s in N:
#     chk += int(s)

# if chk % 9 == 0:
#     print('Yes')
# else:
#     print('No')

N = int(input())

if (N % 9) == 0:
    print('Yes')
else:
    print('No')

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

int main() {
  int N;
  cin >> N;
  int a[3 * N];
  for (int i = 0; i < 3 * N; i++) {
    cin >> a[i];
  }
  sort(a, a + 3 * N, greater<int>());
  int64_t sum = 0;
  for(int i = 0; i < 2 * N; i++) {
    if (i % 2 == 1) {
      sum += a[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1408
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(S: int, W: int):
    if W >= S:
        ret = 'unsafe'
    else:
        ret = 'safe'
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(S, W)

if __name__ == '__main__':
    main()


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

int read(void)
{
	int s = 0, w = 0; char c = getchar();
	while (c < '0' or c > '9') w |= c == '-', c = getchar();
	while (c >= '0' and c <= '9') s = s*10+c-48, c = getchar();
	return w ? -s : s;
}

using namespace std;
const int N = 110000;

int n;
long long cnt;
int a[N], S[500000], v[N];

int ask(int x,int ans = 0) {
	x += n+1;
	for (register int i=x;i;i-=i&-i)
	    ans += S[i];
	return ans;
}

void add(int x,int v) {
	x += n+1;
	for (register int i=x;i<=n*2+1;i+=i&-i)
	    S[i] += v;
	return;
}

bool check(int x)
{
	for (register int i=1;i<=n;++i)
	    a[i] = v[i] >= x ? 1 : -1;
	for (register int i=1;i<=n;++i)
	    a[i] += a[i-1];
	add(a[0],1);
	long long ans = 0;
	for (int i=1;i<=n;++i) 
	{
		ans += 1LL * ask(a[i]);
		add(a[i],1);
	}
	for (int i=0;i<=n;++i)
	    add(a[i],-1);
	if (cnt & 1) return ans > cnt / 2;
	else return ans >= cnt / 2;
}

int main(void)
{
	int Min = INT_MAX;
	int Max = INT_MIN;
	n = read();
	cnt = 1LL * n * (n+1) / 2;
	for (int i=1;i<=n;++i)
	{
		v[i] = read();
		Max = max(Max,v[i]);
		Min = min(Min,v[i]);
	}
	int l = Min, r = Max, mid;
	while (l + 1 < r) {
		mid = l+r >> 1;
		check(mid) ? l = mid : r = mid;
	}
	printf("%d\n", check(r) ? r : l);
	return 0;
}

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

#define ll long long
#define mx 100005

int ar[mx];
char ch[mx];

int n,m;

void solve()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&& s[4]==s[5])cout<<"Yes\n";
    else cout<<"No\n";
}

int main()
{
    int t=1;
    while(t--)solve();

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
k=[list(map(int,input().split()))for i in range(m)]
p=list(map(int,input().split()))
d=0
for i in range(2**n):
    t=bin(i)[2:]
    t="0"*(n-len(t))+t
    for j in range(m):
        c=0
        for h in range(1,k[j][0]+1):
            if t[k[j][h]-1]=="1":
                c+=1
        else:
            if c%2!=p[j]:
                break
    else:
        d+=1
print(d)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        System.out.println(solve(N, M));
    }

    private static long solve(long N, long M) {
        if (M < N) return solve(M, N);
        if (N == 1 && M == 1) return 1;
        if (N == 1 && M == 2) return 0;
        if (N == 1)           return M-2;
        if (N == 2) return 0;

        long sum = N*M;

        sum -= N*2 + M*2 - 4;

        return sum;
    }
}

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

int solve(int N, int P) {
	int K = 1;
	while (K <= N) K *= P;
	K /= P;
	int ans = 0;
	while (N > 0) {
		while (K > N) K /= P;
		int i = N / K;
		N -= K * i;
		ans += i;
	}
	return ans;
}

int main() {
	int N;
	cin >> N;
	int MIN = N;
	for (int i = 0; i <= N; i++) MIN = min(solve(i, 6) + solve(N - i, 9), MIN);
	cout << MIN << endl;
}


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

int main(){
  int H, R;
  cin>>H>>R;

  if(H < 0 && R == -H) cout<<0<<endl;
  if(-H < R) cout<<1<<endl;
  if(-H > R) cout<<-1<<endl;
  return 0;
}



Measured memory_bytes: 3096
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

k = int(input())
a = [[0] * k for _ in range(k)]
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        a[i - 1][j - 1] = gcd(i, j)
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            ans += gcd(a[i - 1][j - 1], l)
print(ans)

Measured memory_bytes: 69068
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int k = input.nextInt();
        int answer = 0;
        int[] array = new int[n];
        for (int i = 0; i < n; i++)
            array[i] = input.nextInt();
        Arrays.sort(array);
        for (int i = 0; i < k; i++)
            answer += array[i];
        System.out.println(answer);
    }
}


Measured memory_bytes: 38952
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int X;
	cin >> X;
	int n = X / 500;
	int ans = n * 1000;
	X -= n * 500;
	n = X / 5;
	ans += n * 5;
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    m/=1000;
    rep(i,n+1){
        int y=m-n-9*i;
        int z=5*n-m+5*i;
        if(y>=0 && z>=0 && y%4==0 && z%4==0){
            cout<<i<<' '<<y/4<<' '<<z/4<<endl;
            return 0;
        }
    }   
    cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    int a[N+2];
    for(int i=1;i<=N;i++)cin>>a[i];a[0]=0;a[N+1]=0;
    int left[N+1],right[N+1];left[0]=0;right[N]=0;
    for(int i=1;i<=N;i++)left[i]=left[i-1]+abs(a[i]-a[i-1]);
    for(int i=N-1;i>=0;i--)right[i]=right[i+1]+abs(a[i+1]-a[i+2]);
    for(int i=1;i<=N;i++)
        cout<<left[i-1]+right[i]+abs(a[i+1]-a[i-1])<<endl;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  ll a,b; cin >> a >> b;
  ll d = b - a;

  auto ones = [&] (ll x, ll p) {
    if(x==0) return 0LL;
    ll ones_per_cycle = p / 2;
    ll cycle = x / p;
    ll amari = x % p;
    ll nokori = max(0LL, amari - ones_per_cycle + 1);
    return cycle * ones_per_cycle + nokori;
  };
  
  ll ans = 0;
  ll p = 1;
  rep(i, 60) {
    ll bit = (1LL<<i);
    p *= 2;
    ll c = ones(b, p) - ones(a-1, p);
    if(c%2) ans += (p/2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  const int MAX_CARDS = 9;

  int T;
  scanf("%d", &T);
  for (int t = 0; t < T; ++t) {
    vector<int> gates(MAX_CARDS), jackie(MAX_CARDS);
    for (int i = 0; i < MAX_CARDS; ++i)
      scanf("%d", &gates[i]);
    for (int i = 0; i < MAX_CARDS; ++i)
      scanf("%d", &jackie[i]);
    sort(gates.begin(), gates.end());
    sort(jackie.begin(), jackie.end());

    int win_g = 0, win_j = 0;
    do {
      int cnt_g = 0, cnt_j = 0;
      for (int i = 0; i < MAX_CARDS; ++i) {
	if (gates[i] > jackie[i])
	  cnt_g += (gates[i]+jackie[i]);
	else
	  cnt_j += (gates[i]+jackie[i]);
      }
      if (cnt_g > cnt_j)
	++win_g;
      else
	++win_j;
    } while (next_permutation(jackie.begin(), jackie.end()));
    printf("%.5f %.5f\n", win_g/static_cast<double>(win_g+win_j), win_j/static_cast<double>(win_g+win_j));
  }
  return 0;
}

Measured memory_bytes: 844
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		long n = scan.nextInt();
		long m = scan.nextInt();
		long ans = 0;
		for (long i=1;i * i <= m;i++) {
			if (m % i != 0)continue;
			long j = m/i;

			if(n * j <= m)ans = Math.max(ans,j);
			if(n * i <= m)ans = Math.max(ans, i);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 22996
// Contest.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n, r;
    cin >> n >> r;
    int dig = (int)(floor(log(n) /
        log(r)) + 1);
    cout << dig;
}



Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, y;
    cin >> n >> y;
    rep(i, 0, n+1) rep(j, 0, n+1){
        if(i + j <= n && (y - 5000*i - 1000*j) % 10000 == 0 && (y - 5000*i - 1000*j)/10000 == n - i - j){
            cout << n - i - j << " " << i << " " << j << endl;
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int N, L, a;
    int apple[200];
    cin >> N >> L;
    REP(i, N){
        apple[i] = i + L;
    }
    int sum = accumulate(apple, apple + N, 0);
    int index = 0;
    REP(i, N){
        if(abs(apple[i]) < abs(apple[index])){
            index = i;
        }
    }
    PRINT(sum - apple[index]);
    return 0;
}

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

int main(){
  string N;
  cin >> N;
  if(N.at(0)=='7'||N.at(1)=='7'||N.at(2)=='7'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
s = gets.chomp

def delete_candidate_suffix(str)
  return nil if str.nil?
  candidates = %w[dream dreamer erase eraser]
  candidates.each do |c|
    after = str.chomp(c)
    return after if after.size < str.size
  end
  nil
end

loop do
  s = delete_candidate_suffix(s)
  if s.nil?
    puts 'NO'
    exit 0
  elsif s.empty?
    puts 'YES'
    exit 0
  end
end


Measured memory_bytes: 49660
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int y, m, d; char c;
	cin >> y >> c >> m >> c >> d;
	if (20190430 >= y * 10000 + m * 100 + d)puts("Heisei");
	else puts("TBD");
}

Measured memory_bytes: 256
class BIT():
    def __init__(self, N):
        self.N = N
        self.bit = [0 for i in range(N+1)]
    def add(self, a, w):
        x = a
        while 1:
            self.bit[x] += w
            x += x & -x
            if x > self.N:
                break
    def sum(self, a):
        ret = 0
        x = a
        while 1:
            ret += self.bit[x]
            x -= x & -x
            if x <= 0:
                break
        return ret
    
def compress(arr):
    *XS, = set(arr)
    XS.sort()
    return {e: i for i, e in enumerate(XS)}

N, K = map(int, input().split())
a = []
B = []
sum_a = 0
for i in range(N):
    a_ = int(input())
    a.append(a_)
    sum_a += a_
    B.append(sum_a - K*(i+1))

B_C = compress(B)
ans = sum([1 for i in B if i >= 0])
B = [B_C [i]+1for i in B] # 1-indexed

N = max(B)
f_tree = BIT(N)
for i in B:
    ret = f_tree.sum(i)
    f_tree.add(i, 1)
    ans += ret
print(ans)

Measured memory_bytes: 57664
#include <bits/stdc++.h>
#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 a, b;
  cin >> a >> b;
  if (a >= 10 || b >= 10) {
    cout << -1 << endl;
  } else {
    cout << a * b << endl;
  }
  return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <iostream>

using namespace std;

int main(void){
	int N;
	string S;
	string a = "("; //l
	string b = ")"; //r
	int l=0;
	int r=0;
	string ans = "";
	cin >> N;
	cin >> S;
	for(int i=0; i<N; i++){
		if(S[i] == '('){
			l++;
			ans = ans + '(';
		}else{
			if(l > 0){
				l--;
				ans = ans + ')';
			}else{
				ans = '('+ ans + ')';
			}
		}
	}

	while(l){
		ans += ')';
		l--;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;


const int INF = 1001001001;

int main(){
    int n, m, x; cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> A(n, vector<int>(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> A[i][j];
    }
    int ans = INF;
    for(int bit = 0; bit < (1<<n); bit++){
        int money = 0;
        vector<int> cnt(m, 0);
        for(int i = 0; i < n; i++){
            if(bit & (1<<i)){
                money += c[i];
                for(int j = 0; j < m; j++){
                    cnt[j] += A[i][j];
                }
            }
        }
        bool isOK = true;
        for(int i = 0; i < m; i++){
            if(cnt[i] < x)isOK = false;
        }
        if(isOK) {
            ans = min(ans, money);
        }
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    forn(i, 0, n) cin >> a[i];
    sort(all(a));
    int l = -1, r = n;
    while (l < r - 1) {
        int m = (l + r) / 2;
        ll sum = 0;
        fore(i, 0, m) sum += a[i];
        bool ok = true;
        forn(i, m + 1, n) {
            if ((ll)a[i] > 2 * sum) {
                ok = false;
                break;
            }
            sum += a[i];
        }
        if (ok) r = m;
        else l = m;
    }
    cout << n - r << '\n';
}


Measured memory_bytes: 640