akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
int n;
vector<vi> t;
vi v;
int dp[105][1 << 17];

int solve(int i, int j)
{
	if (i == n) return 0;
	if (dp[i][j] >= 0) return dp[i][j];
	int tmp = j;
	bool f = true;
	REP(k, t[i].size())
	{
		if (((tmp >> t[i][k]) & 1) == 0) tmp |= (1 << t[i][k]);
		else f = false;
	}
	int res;
	if (f) res = max(solve(i + 1, j), solve(i + 1, tmp) + v[i]);
	else res = solve(i + 1, j);
	return dp[i][j] = res;
}

int main()
{
	while (cin >> n, n)
	{
		t.clear();
		t.clear();
		MS(dp, -1);
		t.resize(n);
		v.resize(n);
		REP(i, n)
		{
			int k;
			cin >> k >> v[i];
			REP(j, k)
			{
				int a, b;
				cin >> a >> b;
				while (a != b)
				{
					t[i].push_back(a-6);
					a++;
				}
			}
		}
		cout << solve(0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 54992
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
int modpow(int x, int n, int mod) {
    if (n == 0)return 1;
    int res = modpow(x * x % mod, n / 2, mod);
    if (n & 1)res = res * x % mod;
    return res;
}
signed main(){
    int n;
    cin>>n;
    int a[2][100];
    for(int j=0;j<2;j++){
        for(int i=0;i<n;i++){
            cin>>a[j][i];
        }
    }
    int s[2][100];
    s[0][0]=a[0][0];
    s[1][0]=a[1][0];
    for(int j=0;j<2;j++){
        for(int i=1;i<n;i++){
            s[j][i]=s[j][i-1]+a[j][i];
        }
    }
    int res = max(s[0][0]+s[1][n-1],s[0][n-1]+s[1][n-1]-s[1][n-2]);
    for(int i=1;i<n;i++){
        res = max(res,s[0][i]+s[1][n-1]-s[1][i-1]);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int H, W,i,j;
	
	while(1){
		scanf("%d %d",&H, &W);
		
		if (H == 0 && W == 0)break;
		
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				printf("#");
			}
			printf("\n");
		}
	printf("\n");
	}

	
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];

int main()
{ 
ll n,c;
cin >> n>>c; 
P pa[n];
rep(i,n){
    cin >> pa[i].first>>pa[i].second; 
}
ll r[n];
ll l[n];
ll r2[n];
ll l2[n];
rep(i,n){
    if(i==0)r[i]=pa[i].second-pa[i].first;
    else r[i]=r[i-1]+pa[i].second-pa[i].first+pa[i-1].first;
    r2[i]=r[i]-pa[i].first;
    if(i==0)l[i]=pa[n-1-i].second-c+pa[n-1-i].first;
    else l[i]=l[i-1]+pa[n-1-i].second-pa[n-i].first+pa[n-1-i].first;
    l2[i]=l[i]-c+pa[n-1-i].first;
}
ll ma;
rep(i,n){
    if(i==0)ma=r[i];
    else if(ma>r[i])r[i]=ma;
    else ma=r[i];
}
ans=ma;
rep(i,n){
    if(i==0)ma=l[i];
    else if(ma>l[i])l[i]=ma;
    else ma=l[i];
}
ans=max(ans,ma);
rep(i,n-1){
    ans=max(r2[i]+l[n-i-2],ans);
    ans=max(l2[i]+r[n-i-2],ans);
}

/* for (int i = 0; i < n; ++i) {
    cout << l[i] << " ";
}cout  << endl; */
if(ans<0)ans=0;
cout << ans << endl;
return 0;
} 

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

int main() {
  ll n, ans=0;
  cin >> n;
  for(int i=(int)sqrt(n); i>=1; i--) {
    if(n%i==0)  {
      //cout << i << endl;
      ans+=i-1;
      ans+=n/i-1;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int num1;
		int num2;
		while(scan.hasNext()) {
			num1=scan.nextInt();
			num2=scan.nextInt();
			if(num1==0 && num2==0) {
				break;
			}
			if(num1<num2) {
				System.out.printf("%d %d\r\n",num1, num2);
			}else {
				System.out.printf("%d %d\r\n",num2, num1);
			}

		}
		scan.close();

	}

}


Measured memory_bytes: 41368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  vector<ll>a(101);
  for(ll i=0;i<=100;i++)a[i]=0;
  for(ll i=2;i<=n;i++){
    ll m=i;
    for(ll j=2;j<=i;j++){
      for(;;){
        if(m%j!=0){
          //cout<<j<<endl;
          break;
        }
        a[j]++;
        m=m/j;
      }
    }
  }
  //cout<<a[2]<<" "<<a[3]<<endl;
  ll f[101];
  for(ll i=0;i<=100;i++)f[i]=0;
  for(ll i=2;i<=n;i++){
    if(a[i]>=4)f[4]++;
    if(a[i]>=2)f[2]++;
    if(a[i]>=14)f[14]++;
    if(a[i]>=24)f[24]++;
    if(a[i]>=74)f[74]++;
  }
  //cout<<f[2]<<f[4]<<endl;
  ll ans=0;
  ans+=((f[4]*(f[4]-1))/2)*(f[2]-2);
  ans+=(f[4]-1)*(f[14]);
  ans+=(f[24])*(f[2]-1);
  ans+=f[74];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Magatro
{
   
    static void Main()
    {
        string s = Console.ReadLine();
        int l = s.Length;
        if (s[0] == s[l - 1])
        {
            l++;
        }
        if (l % 2 == 0)
        {
            Console.WriteLine("Second");
        }
        else
        {
            Console.WriteLine("First");
        }
    }
}



Measured memory_bytes: 3032
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

bool flag;
string S;
int len;
vector<bool> sign;

void func(int n){
    if(n == len){
        flag = true;
        return;
    }

    rep(i, 4){
        string a;
        if(i == 0) a = "dream";  if(i == 1) a = "dreamer";
        if(i == 2) a = "erase";  if(i == 3) a = "eraser";
        int al = a.size();
        //cout <<"len:" << len << " n+al:" << n+al << ln;
        if(n + al > len) continue;
        bool same = false;
        string s;
        rep(j, al){
            s += S[n + j];
        }
        if(s == a) same = true;
        //cout << "s:" << s << " a:" << a << ln;
        if(same){
            func(n + al);
        }
    }
}

int main() {
    cin >> S;
    len = S.size();
    flag = false;
    sign.resize(len + 10);

    func(0);

    if(flag) cout << "YES" << ln;
    else cout << "NO" << ln;
}
    

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int x, y, z;
    std::cin >> x >> y >> z;
    std::swap(x, y);
    std::swap(x, z);
    std::cout << x << ' ' << y << ' ' << z << std::endl;

    return 0;
}


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

double sum=0;
double dp[333][333][333]={0};
bool vis[333][333][333]={false};
double dfs(int a, int b, int c) {
    if (min({a,b,c}) < 0) return 0.0;
    if (a+b+c<=0) return 0.0;
    if (vis[a][b][c]) {
        return dp[a][b][c];
    }
    double k = a+b+c;
    vis[a][b][c]=true;
    dp[a][b][c] = sum / k +
            a / k * dfs(a-1,b,c) +
            b / k * dfs(a+1, b-1, c) +
            c / k * dfs(a, b+1, c-1);
    return dp[a][b][c];
}
int main() {
    int n;cin>>n;
    int a=0,b=0,c=0;
    for (int i=0;i<n;i++) {
        int z;cin>>z;
        a += z==1;
        b += z==2;
        c += z==3;
    }
    sum = n;
    printf("%.9f\n", dfs(a, b, c));
}

Measured memory_bytes: 295040
using System;
using System.Linq;

namespace Structured_Program_II
{
    class Grading
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var array = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var m = array[0];
                var f = array[1];
                var r = array[2];
                var sum = m + f;
                if (m == -1 && f == -1 && r == -1) break;
                if (m == -1 || f == -1) Console.WriteLine("F");
                else if (sum >= 80) Console.WriteLine("A");
                else if (sum >= 65 && sum < 80) Console.WriteLine("B");
                else if (sum >= 50 && sum < 65) Console.WriteLine("C");
                else if (sum >= 30 && sum < 50)
                    if (r >= 50) Console.WriteLine("C");
                    else Console.WriteLine("D");
                else Console.WriteLine("F");
            }
        }
    }
}

Measured memory_bytes: 9256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;
    int ans = 0;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        ArrayList<Order> orders = new ArrayList<Order>(Q);
        for (int i = 0; i < Q; i++) {
            orders.add(new Order(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextInt(), sc.nextInt()));
        }

        for(int i=0;i<N;i++){
            int[] A = new int[N];
            expand(A, i, 0, M, orders);
        }
        System.out.println(ans);
    }

    void expand(int[] A, int index, int num, int M, ArrayList<Order> orders){
        if(index == A.length){
            int ret = 0;
            for(Order o:orders){
                if(A[o.b]-A[o.a]==o.c)
                    ret += o.d;
            }
            ans = Math.max(ans,ret);
        }else{
            A[index] = num;
            for(int k=A[index]; k<M;k++){
                int[] B = A.clone();
                expand(B, index+1, k, M, orders);
            }
        }
    }

    class Order {
        int a;
        int b;
        int c;
        int d;

        Order(int a, int b, int c, int d) {
            this.a = a;
            this.b = b;
            this.c = c;
            this.d = d;
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 54568
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n>0)n/=k,ans++;
    cout<<ans<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

int n;
vector<int> G[MAX_N];
vector<PII> edges;
map<PII, int> mp;
bool visited[MAX_N];

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

    cin >> n;
    for (int i=0; i<n-1; i++) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
        u = min(u, v);
        v = max(u, v);
        edges.push_back({u, v});
    }

    int maxDeg = -1;
    for (int i=1; i<=n; i++) {
        if ((int)G[i].size() > maxDeg) {
            maxDeg = G[i].size();
        }
    }

    queue<PII> q;
    q.push({1, -1});

    while (!q.empty()) {
        int node = q.front().first;
        int col = q.front().second;
        q.pop();
        visited[node] = true;
        int cur = 1;
        for (int i=0; i<G[node].size(); i++) {
            int to = G[node][i];
            int u = min(node, to);
            int v = max(node, to);
            if (mp.find({u, v}) != mp.end()) continue;
            if (cur == col) cur++;
            mp[{u, v}] = cur;
            if (!visited[to]) q.push({to, cur});
            cur++;
        }

    }

    cout << maxDeg << "\n";
    for (PII p: edges) {
        cout << mp[p] << "\n";
    }




    return 0;
}


Measured memory_bytes: 13176
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

MOD = 2019


def main(input, print):
    s = input().strip()
    ans = 0
    cnt = [0] * MOD
    k = 1
    t = 0
    # tj - ti-1 = 0 -> tj = ti-1
    cnt[0] = 1  # ti-1の値が必要なため
    for i in reversed(range(len(s))):
        t += int(s[i])*k
        t %= MOD
        ans += cnt[t]
        cnt[t] += 1
        k = k * 10 % MOD
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 73728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}
int N,X,Y,Z;
vector<vector<ll>> dp(41,vector<ll>(1<<17,0));

int main(){
    int N,X,Y,Z;
    cin >> N >> X >> Y >> Z;
    vector<ll> f10(N+1,1);
    rep(i,N){
        f10[i+1]=f10[i]*10%MOD;
    }
    dp[0][0]=1;
    ll ans=0;
    rep(i,N+1){
        rep(bit,1<<17){
            if ((bit&1<<(Z-1))&&(bit&1<<(Y+Z-1))&&(bit&1<<(X+Y+Z-1))){
                ans+=dp[i][bit]*f10[N-i]%MOD;
                ans%=MOD;
            }
            else if (i<N){
                rep(j,10){
                    ll nbit=bit<<(j+1);
                    nbit|=(1<<j);
                    nbit&=(1<<17)-1;
                    dp[i+1][nbit]+=dp[i][bit];
                    dp[i+1][nbit]%=MOD;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 43392
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  string s;
  cin >> s;

  int ans = 0;
  string tmp;
  string div1, div2;

  for (int i = 2; i < s.size(); i = i + 2){
    tmp = s.substr(0, s.size() - i);
    div1 = tmp.substr(0, tmp.size() / 2);
    div2 = tmp.substr(tmp.size() / 2, tmp.size());
    if (div1 == div2){
      break;
    }
  }

  cout << tmp.size() << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll n, k; cin >> n >> k;
	vector<ll> h(n);
	for( auto &t : h ) cin >> t;
	sort( h.begin(), h.end(), greater<ll>() );
	ll sum = 0;
	for( int i = k; i < n; ++i ) sum += h[i];
	cout << sum << endl;
}

Measured memory_bytes: 1792
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;string s;
    cin>>n;
    cin>>s;
    string str="";
    for(int i=0;i<s.length();++i)
    {
    	int ch=s[i]-'A';
    	if(ch+n>=26)
    		ch-=26;
    	str+=(char)(65+ch+n);
    }
    cout<<str<<endl;
}

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

using namespace std;

int main(int argc, char* argv[])
{
    int a, b;
    cin >> a >> b;
    if ( a < b) {
        cout << "a < b" << endl;
        return 0;
    } else if (a > b) {
        cout << "a > b" << endl;
        return 0;
    } else if (a == b) {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3108
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

using namespace std;

typedef long long li;
typedef unsigned long long lu;
const li infl = ~0LLU >> 2;

template <class T>
inline void Min(T &x, T y) {
  if (y < x) x = y;
}
template <class T>
inline void Max(T &x, T y) {
  if (y > x) x = y;
}

const int mod = 1e9 + 7;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}
int Inv(int x) {
  return Pow(x, mod - 2);
}

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

const int maxn = 1e5;

int n;
int A[maxn], B[maxn];
int ord1[maxn], ord2[maxn];
bool use1[maxn], use2[maxn];

struct Node {
  int val;
  int id, type;
} node[maxn * 2];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", A + i, B + i);
    ord1[i] = ord2[i] = i;
  }
  sort(ord1, ord1 + n, [](int i, int j) { return A[i] < A[j]; });
  sort(ord2, ord2 + n, [](int i, int j) { return B[i] < B[j]; });

  li case1 = accumulate(A, A + n, 0LL);
  li case2 = accumulate(B, B + n, 0LL);

  for (int i = 0; i < n; ++i) {
    node[2 * i] = {A[i], i, 0};
    node[2 * i + 1] = {B[i], i, 1};
  }
  sort(node, node + 2 * n, [](const Node &a, const Node &b) {
      return a.val < b.val;
    });
  li sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += node[i].val;
    if (node[i].type == 0) {
      use1[node[i].id] = true;
    }
    if (node[i].type == 1) {
      use2[node[i].id] = true;
    }
  }

  li ans = min(case1, case2);
  for (int i = 0; i < n; ++i) {
    li res = sum;
    int cnt = n, need = 0;
    if (use1[i]) {
      ++need;
      res -= A[i];
    }
    if (use2[i]) {
      ++need;
      res -= B[i];
    }
    while (need > 0 && cnt < 2 * n) {
      if (node[cnt].id != i) {
        res += node[cnt].val;
        --need;
      }
      ++cnt;
    }
    if (need == 0) {
      Min(ans, res);
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>

int main() {
   int n, m;
   int i;
   int cnt = 0;
   scanf("%d %d",&n ,&m);

   for(i = 1; i < n; i++) {
      cnt += i;
   }
   for(i = 1; i < m; i++) {
      cnt += i;
   }

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

   return 0;
}


Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define sortv(a) sort(a.begin(),a.end())
#define sorta(a,n) sort(a,a+n);

 
int main(){
	int n;
	cin>>n;
	if(n%2==1){
		cout<<"No";
		return 0;
	}
	string s;
	cin>>s;
	int a=n/2;
	for(int i=0;a<n;i++,a++){
		if(s[i]!=s[a]){
			cout<<"No";
			return 0;		}
	}
	cout<<"Yes";
}

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

int main() {

    int k, n, max=0;
    cin >> k >> n;
    vector<int> A(n), B(n);

    for(int i = 0;i<n;i++)
    cin >> A[i];

    for(int i = 0;i<n-1;i++){
        if(max <= A[i+1] - A[i])
        max = A[i+1] - A[i];
    }

    if(max <= k - A[n-1] + A[0])
        max = k - A[n-1] + A[0];

    cout << k - max << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>

using namespace std;
int const MAX = 3002;
double prop[MAX][MAX];
double coin[MAX];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    double ans = 0.0;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> coin[i];
    prop[0][0] = 1.0;
    for(int i = 1; i <= n; i++){
        prop[i][0] = prop[i-1][0] * coin[i];
        prop[0][i] = prop[0][i-1] * (1 - coin[i]);
    }
    for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n - i; j++)
        prop[i][j] = prop[i-1][j] * coin[i+j] + prop[i][j-1] * (1 - coin[i+j]);
    
    for(int i = ceil(n/2.0); i <= n; i++)
        ans += prop[i][n-i];
    
    cout.precision(20);
    cout << fixed;
    cout << ans << '\n';

}

Measured memory_bytes: 49876
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
    string s, t;

    cin >> s >> t;

    int min = 100000;

    for (int i = 0; i <= (s.size() - t.size());i++) {
        int sum = 0;
        for (int j = i; j < i + t.size(); j++) {
           

            if (s[j] != t[j-i]) {
                sum++;
            }
        }
    //    cout << sum << endl;
        if (sum < min) {
            min = sum;
        }

    }
    cout << min << endl;

    return 0;
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int r, c;
  fscanf(stdin, "%d %d", &r, &c);
  vector<vector<int> > table(r + 1, vector<int>(c + 1));
  for (int i = 0; i < r; ++i) {
    for (int j = 0; j < c; ++j) {
      fscanf(stdin, "%d", &table[i][j]);
    }
  }
  for (int i = 0; i < r; ++i) {
    for (int j = 0; j < c; ++j) {
      table[i][c] += table[i][j];
      table[r][j] += table[i][j];
    }
    table[r][c] += table[i][c];
  }
  for (int i = 0; i <= r; ++i) {
    for (int j = 0; j <= c; ++j) {
      if (j) { fprintf(stdout, " "); }
      fprintf(stdout, "%d", table[i][j]);
    }
    fprintf(stdout, "\n");
  }
  return 0;
}

Measured memory_bytes: 1256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int, int>>;

int main()
{
  string s;
  cin >> s;
  if(s[0]=='R' && s[1]!='R')
    cout << "1" << endl;  
    else if(s[0]==s[1] &&s[0]=='R'){
      if(s[2]=='R')
        cout << 3 << endl;
        else
          cout << 2 << endl;
    }
    if(s[0]!='R'){
      if(s[1]==s[2] && s[2]=='R')
        cout << 2 << endl;
        else if(s[1]!=s[2])
          cout << 1 << endl;
          else
            cout << 0 << endl;

    }
}

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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define uint unsigned int
#define lli long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()

#define forn(i, n)  for(int i=0;i<n;++i)
#define rforn(i,start) for(int i = start; i >= 0;--i)
#define forsn(i,start,end) for(int i=start;i<end;++i)
#define rforsn(i,start,end) for(int i=start;i>=end;--i)
#define debug(x) cout<<#x<<" = "<<x<<"\n";
const int CONST = 1e9 + 7;
const double pi = 3.14159265358979323846;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	#ifndef ONLINE_JUDGE
    //    freopen("input.txt", "r", stdin);
	//  freopen("output.txt","w",stdout);
	#endif
    
    double a, b, h, m;
    cin>>a>>b>>h>>m;
    double anga = 0.5*h*60 + 0.5*m;
    double angb = 6*m + 6*h*60;

    double ang = abs(anga-angb);
    ang = min(ang, 360-ang);
    ang = ang/180*pi;

    double tmp = a;
    a = min(a, b);
    b= max(b, tmp);

    double hypo = pow((b-a*cos(ang)), 2) + pow(a*sin(ang), 2);
    double ans = sqrt(hypo);
    cout<<fixed<<setprecision(20)<<ans;

	return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

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

    ll e = max(a*c, b*d);
    ll f = max(a*d, b*c);
    out(max(e, f));
}

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


using namespace std;

int P[10010], rk[10010];

void init(int n) {
	for (int i = 0; i < n; i++) {
		P[i] = i;
		rk[i] = 0;
	}
}

int root(int x) {
	if (P[x] == x)return x;
	return P[x] = root(P[x]);
}

void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y)return;

	if (rk[x] < rk[y])P[x] = y;
	else {
		P[y] = x;
		if (rk[x] == rk[y])rk[x]++;
	}
}

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

}

int main(void) {

	int n, q;
	cin >> n >> q;
	init(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com)cout << same(x, y) << endl;
		else unite(x, y);
	}
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  set<char> c;
  for(ll i=0;i<3;i++) {
    c.insert(s[i]);
  }
  if(c.size()==2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/**
     **author : _KMS_
     **created : 29-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+10,MOD=998244353;
typedef long long ll;
ll dp[107][M];
vector<pair<ll,ll>>v;
int main() {
   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,w;
  cin>>n>>w;
  for(int i=1;i<=n;i++)
 {
  ll a,b;
  cin>>a>>b;
  v.push_back({a,b});
 }
 sort(v.begin(),v.end());
  for(int i=1;i<=n;i++)
  {

    for(int j=1;j<=w;++j)
    {
      if(v[i-1].first<=j)
      {
        dp[i][j]=max(dp[i-1][j],v[i-1].second+dp[i-1][j-v[i-1].first]);
      }
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  cout<<dp[n][w]<<"\n";


  return 0;
} 

Measured memory_bytes: 79360
// verified
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_A&lang=jp
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B&lang=jp

#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

class DAG {
public:
    DAG(const vector<vector<int>> &edges)
    : tsort_done(false), acyc(false) {
        V = edges.size();
        E.resize(V);
        for(int i = 0; i < V; ++i) {
            for(int to : edges[i]) {
                E[i].push_back(to);
            }
        }
    }

    bool tsort() {
        vector<int> indeg(V, 0);
        for(int i = 0; i < V; ++i) {
            for(int to : E[i]) ++indeg[to];
        }

        queue<int> done;
        for(int i = 0; i < V; ++i) {
            if(indeg[i] == 0) done.push(i);
        }

        while(!done.empty()) {
            int cur = done.front();
            done.pop();
            order.push_back(cur);
            for(int to : E[cur]) {
                --indeg[to];
                if(indeg[to] == 0) done.push(to);
            }
        }

        tsort_done = true;
        acyc = (order.size() == V);
        return acyc;
    }

    int longest_path() {
        if(!tsort_done) tsort();
        if(!acyc) return -1;

        dp.resize(V);
        for(int i = 0; i < V; ++i) {
            int cur = order[i];
            for(int to : E[cur]) {
                dp[to] = max(dp[to], dp[cur] + 1);
            }
        }

        return *max_element(begin(dp), end(dp));
    }

    bool acyclic() {
        if(!tsort_done) tsort();
        return acyc;
    }

    int operator[](int i) {
        if(!tsort_done) tsort();
        return order[i];
    }

private:
    int V;
    vector<vector<int>> E;
    vector<int> order;
    bool tsort_done;
    bool acyc;
    vector<int> dp;
};



#include <iostream>
int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<int>> edges(V);
    while(E--) {
        int s,t;
        cin >> s >> t;
        edges[s].push_back(t);
    }

    DAG dag(edges);
    dag.tsort();
    vector<int> res(V);
    for(int i=0; i<V; ++i) res[i] = dag[i];
    for(int i=0; i<V; ++i) {
        cout << res[i] << endl;
    }
}



// function only
bool tsort(vector<int> &order, const vector<vector<int>> &edges) {
    int V = edges.size();

    vector<int> indeg(V, 0);
    for(int i = 0; i < V; ++i) {
        for(int to : edges[i]) ++indeg[to];
    }

    queue<int> done;
    for(int i = 0; i < V; ++i) {
        if(indeg[i] == 0) done.push(i);
    }

    while(!done.empty()) {
        int cur = done.front();
        done.pop();
        order.push_back(cur);
        for(int to : edges[cur]) {
            --indeg[to];
            if(indeg[to] == 0) done.push(to);
        }
    }

    return order.size() == V;
}



Measured memory_bytes: 4288
def f(num,N,S):
    alphabet = ["a","b","c","d","e","f","g","h","i","j"]
    if N == num:
        for i in range(len(S)):
            print(S[i])
        return
    else:
        tmp = []
        length = len(S)
        for i in S:
            ttmp = sorted(list(i))
            for j in range(alphabet.index(ttmp[-1])+2):
                tmp.append(i+alphabet[j])
        f(num+1,N,tmp)
 
N = int(input())
f(1,N,["a"])

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

#define int long long

int memo[10000];

signed main() {
    string s;
    cin >> s;
    for(int i=0; i<s.size(); ++i) memo[s[i]] = 1;

    int cnt = 0;
    for(int i='E'; i<='W'; ++i) if(memo[i]==1) cnt++;
    if(cnt==4) cout << "Yes" << endl;
    else if(cnt==3||cnt==1) cout << "No" << endl;
    else {
        if(memo['N']&&memo['S']||memo['E']&&memo['W']) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1000
void push(int x);
int pop(void);
int isEmpty(void);
int isFull(void);
int keisan(char *s);
int is_digit(char *s){
  if (*s == '+' || *s =='-') {
		s++;
		if (*s >= '0' && *s <= '9') return 1;
		return 0;
	}
  if (*s >= '0' && *s <= '9') return 1;
	return 0;
}
int get_number(char *s)
{
	int sign = 0, n = 0;
	if (*s == '+') {
		s++;
	} else if (*s == '-') {
		sign = 1;
		s++;
	}
	while (*s >= '0' && *s <= '9') {
		n = n * 10 + (*s - '0');
		s++;
	}
	if (sign==1) return -n;
	return n;
}
int top=0;
int S[1000];
int main(){
  int i,x=0,y=0;
  char s[1000];
  scanf("%[^\n]*s", s);
    
  printf("%d\n",keisan(s));

  return 0;
}
int isEmpty(void ){
  if( top== 0)return 0;
  return 1;
}
int isFull(void ){
  if( top >= MAX - 1)return 0;
  return 1;
}
void push(int x){
  if(isFull == 0)printf("error\n");
  
  S[top++] = x;
  
}
int pop(void ){
  
  if(isEmpty == 0)printf("error\n");
  return S[--top];
}
int keisan(char *s){
  int x,y,n;
   while (*s) {
if (is_digit(s)) {
			n = get_number(s);
			push(n);
			while (*s == '-' || *s == '+') {
				s++;
			}
			while (n) {
				n /= 10;
				s++;
			}
			} else {
			switch (*s) {
			case '+':
				x = pop();
				y = pop();
				push(x+y);
				break;
			case '-':
				x = pop();
				y = pop();
				push(y-x);
				break;
			case '*':
				x = pop();
				y = pop();
				push(y*x);
				break;
			case '/':
				x = pop();
				y = pop();
				if (x == 0) break;
				push(y/x);
				break;
			case '%':
				x = pop();
				y = pop();
				if (x == 0) break;
				push(y%x);
			}
			s++;
		}
   }
   return pop();
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int x=0,ans=0;
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='I')
        x++;
        else
        x--;
        ans=max(ans,x);
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 998244353

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 100010
int n;

int main() {
    cin >> n;
    if (n % 10 == 9 || n / 10 == 9) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
L = []
ans = 0
for i in range(N):
  L.append(list(map(int,input().split())))
L.sort()
for i in range(N):
  if L[i][1]<=M:
    M -= L[i][1]
    ans += L[i][0]*L[i][1]
  else:
    ans += L[i][0]*M
    break
print(ans)

Measured memory_bytes: 85896
/************************************/
//
//???????????´??°?????????????????????????????????????°??????????????????????????????????????????°??????
//
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_C&lang=jp
/************************************/

#include<stdio.h>

#define MIN 0
#define MAX 100

int main()
{
	int a,b,c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if((a>=MIN) && (a<=MAX) && (b>=MIN) && (b<=MAX) && (c>=MIN) && (c<=MAX))
	{
		if((a<b) && (b<c))
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	else
	{
		/* ERROR */
		return -1;
	}
	
	return 0;
}

Measured memory_bytes: 1808
#include<stdio.h>
#include <math.h> 
int main(){
    double n;
    scanf("%lf",&n);
    if(fmod(n, 2)==0){
        printf("%lf\n",1.0/2);
    }
    else{
        printf("%lf\n",((floor(n/2)+1)/n));
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

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

int main()
{
    int n, p;
    while(cin >> n && n)
    {
        vector<int> points;
        int ans = 0;

        REP(n)
        {
            cin >> p;
            points.push_back(p);
        }

        sort(points.begin(), points.end());
        
        for(int i= 1; i < n -1;i++) ans += points[i];

        cout << ans / (n - 2)<< endl;
    }

    return 0;
}

Measured memory_bytes: 0
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9000000000000000000;
const double PI = acos(-1);

int dp[1010][1010];
int main() {
	string s, ss;
	cin >> s >> ss;
	s = " " + s;
	ss = " " + ss;
	for (int i = 0; i <= s.size(); i++)dp[i][0] = i;
	for (int i = 0; i <= ss.size(); i++)dp[0][i] = i;
	for (int i = 1; i < s.size(); i++) {
		for (int j = 1; j < ss.size(); j++) {
			if (s[i] == ss[j]) {
				dp[i][j] = dp[i - 1][j - 1];
			}
			else {
				dp[i][j] = (min({ dp[i - 1][j],dp[i][j - 1],dp[i - 1][j - 1] })+1);
			}
		}
	}
	cout << dp[s.size() - 1][ss.size() - 1] << endl;
}

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		long[] p = new long[a + 1];
		long[] q = new long[b + 1];
		long[] r = new long[c + 1];
		for (int i = 0; i < a; i++) {
			p[i] = sc.nextLong();
		}
		p[a] = -100;
		for (int i = 0; i < b; i++) {
			q[i] = sc.nextLong();
		}
		q[b] = -100;
		for (int i = 0; i < c; i++) {
			r[i] = sc.nextLong();
		}
		r[c] = -100;
		Arrays.sort(p);
		Arrays.sort(q);
		Arrays.sort(r);
		int pn = a;
		int qn = b;
		int rn = c;
		long sum = 0;
		int mu = 0;
		while (x + y > mu && (x > 0 || y > 0)) {
			if (x > 0 && y > 0) {
				if (p[pn] >= q[qn] && p[pn] >= r[rn]) {
					sum += p[pn];
					pn--;
					x--;
				} else if (q[qn] >= p[pn] && q[qn] >= r[rn]) {
					sum += q[qn];
					qn--;
					y--;
				} else {
					sum += r[rn];
					rn--;
					mu++;
				}
			} else if (x > 0) {
				if (p[pn] >= r[rn]) {
					sum += p[pn];
					pn--;
					x--;
				} else {
					sum += r[rn];
					rn--;
					mu++;
				}
			} else {
				if (q[qn] >= r[rn]) {
					sum += q[qn];
					qn--;
					y--;
				} else {
					sum += r[rn];
					rn--;
					mu++;
				}
			}
		}
		System.out.println(sum);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 27468
#include <iomanip>
#include <iostream>


using namespace std;

#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

typedef double dbl;

int n, k;
dbl ans;

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

	REP1C(die, n)
	{
		int score = die;
		dbl p = 1;
		while (score < k)
			p /= 2.0, score <<= 1;

		ans += p / n;
	}

	cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));
ll atusa[51]={1};
ll paty[51]={1};

ll dp(ll n,ll x){
	if(n==0){
		if(x>0)return 1;
		else
		 return 0;
	}
	else if(x<=1+atusa[n-1])
		return dp(n-1,x-1);
	else
		return paty[n-1]+1+dp(n-1,x-2-atusa[n-1]);
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	ll N,X;
	cin>>N>>X;
	eFOR(i,1,N){
		atusa[i]=atusa[i-1]*2+3;
		paty[i]=paty[i-1]*2+1;
	}
	cout<<dp(N,X)<<endl;
	
	return 0;
}




















Measured memory_bytes: 256
use std::io::stdin;
fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let y:Vec<char> = st.chars().collect();
    let mut x:i32 = 0;
    for i in y {
        if x == 0 {
            if i == 'C' {
                x += 1;
            };
        } else {
            if i == 'F' {
                x += 1;
            }
        }
    };
    if x >= 2 {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2104
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <limits>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

int main(int, char *[])
{
    int C;
    cin >> C;
    if(C < 1200)
        cout << "ABC" << endl;
    else if(C < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
import math

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in itertools.permutations(xy, n):
    nagasa = 0
    for j in range(1, n):
        nagasa += ((i[j][0] - i[j - 1][0]) ** 2 + (i[j][1] - i[j - 1][1]) ** 2) ** 0.5
    ans += nagasa
ans /= math.factorial(n)
print(ans)

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

int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll              long double
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
const ll N=2e5+4;

int main()
{
    IOS
    long long n;
    cin>>n;
    ll ans=(ll)(n/2+(n%2))/n;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256