akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> ii;
int N;
struct seg {
    int s, e, m, v;
    seg *l, *r;
    seg(int _s, int _e) {
        s = _s, e = _e, m = (s + e) / 2, v = 0;
        if (s != e) {
            l = new seg(s, m);
            r = new seg(m + 1, e);
        }
    }
    void update(int i, int nv) {
        if (s != e) {
            if (i > m) r -> update(i, nv);
            else l -> update(i, nv);
            v = max(l -> v, r -> v);
        } else v = nv;
    }
    int query(int a, int b) {
        if (s == a && e == b) return v;
        if (a > m) return r -> query(a, b);
        if (b <= m) return l -> query(a, b);
        return max(l -> query(a, m), r -> query(m + 1, b));
    }
} *root;
int a[200001], ans[200001], pos[200001];
vector<int> adjlist[200001];
vector<ii> arr;
void dfs(int v, int p) {
	ans[v] = root -> query(0, lower_bound(arr.begin(), arr.end(), ii(a[v], 0)) - arr.begin()) + 1;
	root -> update(pos[v], ans[v]);
	for (int i: adjlist[v]) {
		if (i != p) dfs(i, v);
	}
	root -> update(pos[v], 0);
}
void dfs2(int v, int p) {
	for (int i: adjlist[v]) {
		if (i == p) continue;
		ans[i] = max(ans[i], ans[v]);
		dfs2(i, v);
	}
}
int main() {
	int u, v;
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &a[i]);
	root = new seg(0, N);
	for (int i = 1; i <= N; ++i) arr.push_back(ii(a[i], i));
	sort(arr.begin(), arr.end());
	for (int i = 0; i < N; ++i) pos[arr[i].second] = i + 1;
	for (int i = 1; i < N; ++i) {
		scanf("%d %d", &u, &v);
		adjlist[u].push_back(v);
		adjlist[v].push_back(u);
	}
	dfs(1, -1);
	dfs2(1, -1);
	for (int i = 1; i <= N; ++i) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 65072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A, B, C;
cin >> A >> B >> C;
int cnt=0;
while (A%2==0 && B%2==0 && C%2==0)
{
  cnt++;
   int a=A/2, b=B/2, c=C/2;
   A=b+c; B=a+c; C=a+b;
  if(A==B && C==B)
  {
    cnt=-1;
    break;
  }
}
cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	forn(i, n) cin >> a[i];
	sort(all(a));
	ll res = 1e18;
			
	forn(i, 101) {
		ll s = 0;
		forn(j, n) {
			s += (a[j]-i)*(a[j]-i);
		}
		res = min(res, s);
	}
	cout << res << endl;
	return 0;
}



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

char getGrade(int m, int f, int r){
   int sum = m + f;
   char grade;
    if ( m == -1 || f == -1 ) {
      grade = 'F';
    } else if ( 80 <= sum ) {
      grade = 'A';
    } else if ( 65 <= sum && sum < 80 ){
      grade = 'B';
    } else if ( 50 <= sum && sum < 65 ){
      grade = 'C';
    } else if ( 30 <= sum && sum < 50 ){
      if ( 50 <= r )  grade = 'C';
      else grade = 'D';
    } else if ( sum < 30 ){
      grade = 'F';
    }
    
    return grade;
}

int main(){
  int m, f, r;
    while(1){
       cin >> m >> f >> r;
       if ( m == -1 && f == -1 && r == -1 ) break;
       cout << getGrade(m, f, r) << endl;
    }
    
    return 0;
}    

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int N;
vector<ll> A;

void solve() {
    vector<ll> plus, minus;
    for (int i = 0; i < N; ++i) {
        if (A[i] >= 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }
    sort(plus.begin(), plus.end(), greater<ll>());
    sort(minus.begin(), minus.end());
    if (minus.empty()) minus.push_back(plus.back()), plus.pop_back();
    if (plus.empty()) plus.push_back(minus.back()), minus.pop_back();

    vector<pair<ll, ll>> res;
    ll cur = minus[0];
    for (int i = 0; i + 1 < plus.size(); ++i) {
        res.push_back({cur, plus[i]});
        cur -= plus[i];
    }
    res.push_back({plus.back(), cur});
    cur = plus.back() - cur;

    for (int i = 1; i < minus.size(); ++i) {
        res.push_back({cur, minus[i]});
        cur -= minus[i];
    }

    cout << cur << endl;
    for (auto p : res) cout << p.first << " " << p.second << endl;
}

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];
    solve();
}

Measured memory_bytes: 5872
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(3)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
ll a[100010];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:\\Users\\LENOVO\\Desktop\\in.txt","r",stdin);
#endif
	int n,m;cin>>n>>m;
	ll gcd;
	ll now=1;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		now=now/__gcd(now,a[i]/2)*a[i]/2;
	}
	for(int i=1;i<=n;i++){
		if(!((now*2/a[i])&1)) {
			cout<<0<<endl;
			return 0;
		}
	}
	cout<<(m+now)/(now*2)<<endl;
	
	return 0;
}



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

int main() {
	int N,M,a=0,p=0;
	cin >> N >> M;
	vector<P> r(M);

	rep(i,M)
		cin >> r.at(i).second >> r.at(i).first;
	sort(r.begin(), r.end());

	rep(i,M)
		if(p <= r.at(i).second) {
			++a;
			p = r.at(i).first;
		}

	cout << a << endl;
}

Measured memory_bytes: 1024
a, b, k = (int(i) for i in input().split())
a_list = []
b_list = []
for i in range(1, a+1):
  if a % i == 0:
    a_list.append(i)
for i in range(1, b+1):
  if b % i == 0:
    b_list.append(i)
list1 = list(set(a_list) & set(b_list))
list2 = sorted(list1, reverse=True)
print(list2[k-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main()
{
  int N,M;
  cin >> N >> M;
  //段数は1-indexedにする(1段目から)
  vector<int> b(N+1, 0);  // 1なら壊れている
  REP(i,0,M) {
    int a;
    cin >> a;
    b[a] = 1;
  }

  vector<int> dp(N+1,0);  // dp[i]: i段目までの移動方法 %MOD

  dp[0] = 1;  // 0段目まで
  dp[1] = b[1] ? 0 : 1;  // 壊れていたら0通り
  REP(i,2,N+1) {
    // dp[i] = 0;
    // i-1段目が壊れてない
    if (!b[i-1]) dp[i] += dp[i-1];
    if (!b[i-2]) dp[i] += dp[i-2];
    dp[i] %= MOD;
  }
  cout << dp[N] << endl;

  return 0;
}


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

int main() {
	long N, c = 0, i = 0;
	bool flg = false;
	cin >> N;
	int* a = new int[N];
	bool* b = new bool[N];
	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		a[i] = t - 1;
		b[i] = false;
	}
	b[0] = true;
	while (true) {
		if (i == 1) {
			cout << c << endl;
			return 0;
		}
		if (b[a[i]]) {
			cout << -1 << endl;
			return 0;
		}
		b[a[i]] = true;
		i = a[i];
		c++;
	}
}

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

const int maxn=(int)2e5+10;
const int pot=(1<<18);
long long tree[pot*2+10];
int h[maxn];
int cost[maxn];

void updt(int a, long long war)
{
	tree[a+=pot]=max(tree[a],war);
	for(a>>=1; a; a>>=1)
		tree[a]=max(tree[a<<1],tree[(a<<1)^1]);
}

long long query(int a, int b)
{
	long long ret=0;
	for(a+=pot-1,b+=pot+1; a/2!=b/2; a>>=1,b>>=1)
	{
		if(!(a&1))
			ret=max(ret,tree[a+1]);
		if(b&1)
			ret=max(ret,tree[b-1]);	
	}
	return ret;
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&cost[i]);
	for(int i=1;i<=n;i++)
	{
		long long a=query(1,h[i]);
		updt(h[i],a+cost[i]);
	}
	printf("%lld",query(1,n));
}

Measured memory_bytes: 5376
from bisect import bisect_left
from math import ceil
import sys
if sys.version_info[0:2] >= (3, 3):
    from collections.abc import Sequence
else:
    from collections import Sequence


class LazySequence(Sequence):
    def __init__(self, f, n):
        self.f = f
        self.n = n

    def __len__(self):
        return self.n

    def __getitem__(self, i):
        if not (0 <= i < self.n):
            raise IndexError
        return self.f(i)


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def __len__(self):
        return self.size

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, v):
        while i <= self.size:
            self.tree[i] += v
            i += i & -i


N = int(input())
a = [0] + [int(s) for s in input().split()]
# a = [0] * (N + 1)


def count_lr(x):
    s = [0] * (N + 1)
    for i in range(1, N + 1):
        s[i] = s[i - 1] + (1 if a[i] >= x else -1)

    ss = sorted(set(s))
    ind = {v: i + 1 for i, v in enumerate(ss)}

    b = Bit(N + 10)
    count = 0
    for i in range(N + 1):
        j = ind[s[i]]
        count += b.sum(j)
        b.add(j, 1)

    return count


# i: 0, 1, ..., 10 ** 9
# x: 10 ** 9, ..., 0
counts = LazySequence(lambda i: count_lr(10 ** 9 - i), 10 ** 9 + 1)
ans = 10 ** 9 - bisect_left(counts, ceil(N * (N + 1) / 4))
print(ans)


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

int pow2(int x, int n) {
  if (n == 0) return 1;
  if (n & 1) return x * pow2(x, n - 1);
  int y = pow2(x, n / 2);
  return y * y;
}

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

  int n;
  cin >> n;
  cout << pow2(2, floor(log2(n))) << '\n';
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='W')ans+=cnt;
        else cnt++;
    }
    Cout(ans);
    return 0;
}


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

#define pb push_back
#define ll long long

using namespace std;

const int N = 2e5 + 123, MAXN = 1e9;

ll n, d, a;

ll t[50 * N], mn[50 * N], add[50 * N], L[50 * N], R[50 * N], sz = 1;
ll ans;

inline void push (int v, int tl, int tr) {
    if (add[v]) {
        t[v] += add[v];
        if (tl != tr) {
            if (!L[v])L[v] = ++ sz;
            if (!R[v])R[v] = ++ sz;
            add[L[v]] += add[v];
            add[R[v]] += add[v];
        }
        add[v] = 0;
    }
}

void upd (int l, int r, ll val, int v = 1, int tl = 1, int tr = MAXN) {
    push (v, tl, tr);
    if (tl > r || l > tr || !v)return;
    if (tl >= l && r >= tr) {
        add[v] += val;
        push (v, tl, tr);
        return;
    }int tm = (tl + tr) >> 1;
    if (!L[v])L[v] = ++ sz;
    if (!R[v])R[v] = ++ sz;
    upd (l, r, val, L[v], tl, tm);
    upd (l, r, val, R[v], tm + 1, tr);
    t[v] = t[L[v]] + t[R[v]];
}

ll get (int pos, int v = 1, int tl = 1, int tr = MAXN) {
    push (v, tl, tr);
    if (tl == tr)return t[v];
    int tm = (tl + tr) >> 1;
    if (pos <= tm) {
        return get (pos, L[v], tl, tm);
    }else {
        return get (pos, R[v], tm + 1, tr);
    }
}

vector <int> v;

int main () {
    scanf("%lld%lld%lld", &n, &d, &a);
    for (ll i = 0, x, h;i < n;i ++) {
        scanf("%lld%lld", &x, &h);
        upd (x, x, h);
        v.pb (x);
    }sort (v.begin (), v.end ());
    for (auto it : v) {
        ll val = get (it), need;
        if (val > 0) {
            need = val / a + (val % a > 0);
            ans += need * 1ll;
            upd (it, min (it + 2 * d, MAXN * 1ll), (need * a * -1ll));
        }
    }
    printf("%lld", ans);
}


Measured memory_bytes: 306292
#include<bits/stdc++.h>
#define ll long long int 
#define mod 998244353
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(15);
	long double bb,aa;
	cin >> aa >> bb;
	long double cc=aa*bb;
	long long int b=floor(cc);
	cout<<b;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

vector<int> res;

void dfs(vector<vector<pii>> &G, int v, int p, int pc){
    int color = 0;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (color == pc) color++;
        res[e.second] = color;
        dfs(G, e.first, v, color);
        color++;
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<pii>> G(n);
    res.assign(n-1, -1);
    int a, b;
    for (int i = 0; i < n-1; ++i) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(pii(b, i));
        G[b].push_back(pii(a, i));
    }

    int deg = 0;
    for (int i = 0; i < n; ++i) {
        chmax(deg, (int)G[i].size());
    }
    dfs(G, 0, -1, -1);

    cout << deg << endl;
    for (int i = 0; i < n-1; ++i) {
        cout << res[i]+1 << endl;
    }
}

Measured memory_bytes: 11032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class Main{
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	public static void main(String[] args) 
	{
		OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        int n = sc.nextInt();
        int mat[][] = new int[n][3];
        for(int i = 0; i < n; i++)
        {
        	for(int j = 0; j < 3; j++)
        	{
        		mat[i][j] = sc.nextInt();
        	}
        }
        int dp[][] = new int[n][3];
        for(int i = 0; i < 3; i++)
        {
        	dp[0][i] = mat[0][i];
        }
        for(int i = 0; i < n-1; i++)
        {
        	for(int j = 0; j < 3; j++)
        	{
        		if(j == 0)
        		{
        			dp[i+1][j+1] = Math.max(dp[i+1][j+1],dp[i][j]+mat[i+1][j+1]);
        			dp[i+1][j+2] = Math.max(dp[i+1][j+2],dp[i][j]+mat[i+1][j+2]);
        		}
        		else if(j == 1)
        		{
        			dp[i+1][j+1] = Math.max(dp[i+1][j+1],dp[i][j]+mat[i+1][j+1]);
        			dp[i+1][j-1] = Math.max(dp[i+1][j-1],dp[i][j]+mat[i+1][j-1]);
        		}
        		else
        		{
        			dp[i+1][j-2] = Math.max(dp[i+1][j-2],dp[i][j]+mat[i+1][j-2]);
        			dp[i+1][j-1] = Math.max(dp[i+1][j-1],dp[i][j]+mat[i+1][j-1]);
        		}
        		
        	}
        	
        }
        int max = Integer.MIN_VALUE;
        for(int j = 0; j < 3; j++)
        {
        	max = Math.max(max,dp[n-1][j]);
        }
        out.println(max);
        out.close();
	}

}


Measured memory_bytes: 47980
n = int(input())
d,x = map(int,input().split())
a = [int(input()) for i in range(n)]
ans = 0
for i in range(n):
    if d%a[i]!=0:
        ans += d//a[i]
    else:
        ans += d//a[i]-1
print(ans+n+x)

Measured memory_bytes: 3060
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0

for i in range(1, 100000):
    right_idx = bisect.bisect_left(A, i - 1)
    left_idx = bisect.bisect_right(A, i + 1)
    tmp_ans = left_idx - right_idx
    if tmp_ans > ans:
        ans = tmp_ans
print(ans)

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

int N;
double *dp[150005];
bool *used[150005];
double dp2[150005];
bool used2[150005];
int store[150005];
vector<int> V[150005];

double f(int x, int p) {
	if (used[x][p]) return dp[x][p];
	double ans = 0;
	if (!used2[x]) {
		for (int i = 0; i < V[x].size(); i++) {
			if (i == p) continue;
			ans += f(V[x][i], lower_bound(V[V[x][i]].begin(), V[V[x][i]].end(), x) - V[V[x][i]].begin()) / (V[x].size() - 1);
		}
		dp2[x] = ans;
		used2[x] = 1;
		store[x] = p;
	} else {
		ans = dp2[x];
		ans += f(V[x][store[x]], lower_bound(V[V[x][store[x]]].begin(), V[V[x][store[x]]].end(), x) - V[V[x][store[x]]].begin()) / (V[x].size() - 1);
		ans -= f(V[x][p], lower_bound(V[V[x][p]].begin(), V[V[x][p]].end(), x) - V[V[x][p]].begin()) / (V[x].size() - 1);
	}
	used[x][p] = 1;
	return dp[x][p] = ans + 1;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	for (int i = 0; i < N; i++) sort(V[i].begin(), V[i].end());
	for (int i = 0; i < N; i++) {
		dp[i] = new double[V[i].size()];
		used[i] = new bool[V[i].size()];
	}
	for (int i = 0; i < N; i++) {
		double ans = 0;
		for (int j = 0; j < V[i].size(); j++) ans += f(V[i][j], lower_bound(V[V[i][j]].begin(), V[V[i][j]].end(), i) - V[V[i][j]].begin()) / V[i].size();
		printf("%.8lf\n", ans);
	}
}


Measured memory_bytes: 29568
#include<stdio.h>

int main(void)
{
	int n,i,j,a;
	long long int array[10000],b=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&array[i]);
		b+=array[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(array[i]<array[j]){
				a=array[i];
				array[i]=array[j];
				array[j]=a;
			}
		}
	}
	printf("%lld %lld %lld\n",array[0],array[n-1],b);
	return 0;
}

Measured memory_bytes: 680
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define sz(v) (int)v.size()
#define len(s) (int)s.length()
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
typedef double db ;
typedef long double ldb ;
const int mod = 1e9 + 7;
const int cmod = 998244853 ;
const ll inf = 1e18 + 5;
const db cpi = 3.14159265358 ;
ll powmod(ll a, ll b) { ll ret = 1 ; while(b) { if(b&1) ret = (ret*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return ret ; }
const int maxn = 1e6 + 5;
ll q, h, s, d ;
ll n ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> q >> h >> s >> d >> n ;
    ll x = n/2 ;
    int y = n%2 ;
    ll res = min(d, min(2*s, min(4*h, 8*q)))*x + min(s, min(2*h, 4*q))*y ;
    cout << res << "\n" ;

    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using namespace std;
using ll = long long;
int main()
{
  int n;
  int ans=0;
  vector<vector<int>> a(3, vector<int>(3));
  rep(i,3){
    rep(j,3){
       scanf("%d",&a.at(i).at(j));
    }
  }
  scanf("%d",&n);
  int b;
  rep(i,n){
    scanf("%d",&b);
    rep(i,3){
      rep(j,3){
        if(b == a.at(i).at(j)) a.at(i).at(j) = 0;
      }
    }
  }
  
  if(a.at(0).at(0)+a.at(0).at(1)+a.at(0).at(2)==0) ans=1;
  if(a.at(1).at(0)+a.at(1).at(1)+a.at(1).at(2)==0) ans=1;
  if(a.at(2).at(0)+a.at(2).at(1)+a.at(2).at(2)==0) ans=1;
  if(a.at(0).at(0)+a.at(1).at(0)+a.at(2).at(0)==0) ans=1;
  if(a.at(0).at(1)+a.at(1).at(1)+a.at(2).at(1)==0) ans=1;
  if(a.at(0).at(2)+a.at(1).at(2)+a.at(2).at(2)==0) ans=1;
  if(a.at(0).at(0)+a.at(1).at(1)+a.at(2).at(2)==0) ans=1;
  if(a.at(2).at(0)+a.at(1).at(1)+a.at(0).at(2)==0) ans=1;

  if(ans) printf("Yes");
  else printf("No");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a[1000000] = {0};
  a[0] = 1;
  scanf("%d", &a[1]);

  int stop = 1;
  while(stop){
    a[0]++;
    a[a[0]] = a[a[0]-1]%2 ? a[a[0]-1]*3+1 : a[a[0]-1]/2;
    for(int i=1; i<=a[0]-1; i++){
      if(a[i] == a[a[0]]){
	printf("%d\n", a[0]);
	stop = 0;
	break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int x,n;
  cin>>x>>n;
  if(n==0){
    cout<<x<<endl;
    return 0;
  }
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
 
  }
  for(int i=0;i<=101;i++){
    for(int j=0;j<=101;j++){
      if(abs(x-j)==i){
       
        int flag=1;
        for(int k=0;k<n;k++){
         
          if(a[k]==j) flag=0;
        }
        if(flag){
          cout<<j<<endl;
          return 0;
        }
      }
    }
  }
}


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

using namespace std;

const int MAXN=1e5+7;
const int INF=(1<<30);
int dist[MAXN],n;
vector<pair<int,int> > G[MAXN];
bool dfs(int v)
{
    bool ok=1;
    for (int i=0;i<G[v].size()&&ok;i++)
    {
        pair<int,int> u=G[v][i];
        if (dist[u.first]==-INF)
        {
            dist[u.first]=dist[v]+u.second;
            ok&=dfs(u.first);
        }
        else if (dist[u.first]!=dist[v]+u.second)
        {
            ok=0;
        }
    }
    return ok;
}
int main()
{
    ios::sync_with_stdio(0);
    int m;
    cin >> n >> m;
    for (int i=0;i<m;i++)
    {
        int l,r,x;
        cin >> l >> r >> x;
        --l,--r;
        G[l].push_back(make_pair(r,x));
        G[r].push_back(make_pair(l,-x));
    }
    fill(dist,dist+n,-INF);
    bool ok=1;
    for (int i=0;i<n&&ok;i++)
    {
        if (dist[i]==-INF)
            dist[i]=0,ok&=dfs(i);
    }
//    for (int i=0;i<n;cout <<dist[i++]<<" ");
//    cout << endl;
    cout <<(ok?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 12032
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

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

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

int main(int argc, const char * argv[]) {
    int N=0;
    int L[101];
    int Ans=0;
    
    cin >> N;
    
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    
    sort(L, L+N);
    
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            for(int k=j+1; k<N; k++){
                
                if(L[i]<L[j] && L[j]<L[k]){
                    int l = L[i] + L[j] + L[k];
                    int r = max(L[k], max(L[j], L[i]));
                    
                    if(r<l-r) Ans++;
                }
                
            }
        }
    }
    
    cout << Ans << endl;
    
    return 0;
}


Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys


def solve(S: str):
    parsed = S.split("/")
    year = int(parsed[0])
    month = int(parsed[1])
    day = int(parsed[2])
    if year < 2018:
        print("Heisei")
    elif year >= 2020:
        print("TBD")
    else:
        if month <= 4:
            print("Heisei")
        elif month >= 5:
            print("TBD")
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,m, j, n, dp[3010][3010];
string s, t;
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> s >> t;
    n = s.size();
    m = t.size();
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            if(s[i-1]==t[j-1])
                dp[i][j] = dp[i-1][j-1]+1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    string ans = "";
    i = n;
    j = m;
//    for(i=0;i<=n;i++)
//    {
//        for(j=0;j<=m;j++)
//            cout << dp[i][j]<< " ";
//        cout << endl;
//    }
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans = s[i-1]+ ans;
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 74188
n, x, y = map(int, input().split())

# 結果のカウント
answers = [ 0 for _ in range(n) ]


for i in range(1, n):
    for j in range(i+1, n+1):
        normalRoute = j - i
        warpRoute = abs(x-i) + abs(y-j) + 1
        answers[min(normalRoute, warpRoute)] += 1



for ans in answers[1:]:
    print(ans)

Measured memory_bytes: 3572
#include <iostream>
 using namespace std ;
 int main()
 {
 	int a[4][14] , r = 1 , n , i , x , y , z ;
 	char q ;
 	cin >> n ;
 	n <= 54 ;
 	for ( i = 0 ; i < 4 ; i ++ ){
 		for ( z = 1 ; z < 14 ; z ++ )
 		{
 			a[i][z] = 0 ;
 		}
 	}
 	for ( i = 0 ; i < 4 ; i ++ ){
 		for ( z = 1 ; z < 14 ; z ++ )
 		{
 			while ( r <= n ){
 			cin >> q >> x ;
 			if ( q == 'S'){
 				y = 0 ;
 				a[y][x] = 1 ;
 			}
 			else if ( q == 'H' ){
 				y = 1 ;
 				a[y][x] = 1 ;
 			}
 			else if ( q == 'C' ){
 				y = 2 ;
 				a[y][x] = 1 ;
 			}
 			else if ( q == 'D' ){
 				y = 3 ;
 				a[y][x] = 1 ;
 			}
 			r ++ ;
 		}
 		  }
 	}
    for ( i = 0 ; i < 4 ; i ++ ){
    	for ( z = 1 ; z < 14 ; z ++ ){
             if ( i == 0  && a[i][z] == 0 )
             {
             	cout << "S" << " " << z << endl ;
             }
             else if ( i == 1 && a[i][z] == 0 ){
             	cout << "H" <<" " << z << endl ;
             }
             else if ( i == 2 && a[i][z] == 0 ){
             	cout << "C" << " "<< z << endl ; 
             }
             else if ( i == 3 && a[i][z] == 0 ){
             	cout << "D" << " "<< z << endl ;
             }
    		}
 	}
 }

Measured memory_bytes: 1160
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }


  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt

    val frequency = scala.collection.mutable.Map[(Int, Int), Int]()
    for (i <- 1 to n) {
      val f = getFreqKey(i)
      if (frequency.contains(f)) frequency(f) += 1
      else frequency.put(f, 1)
    }

    var ans = 0
    for (i <- 1 to n) {
      val tmp = getFreqKey(i)
      val f = (tmp._2, tmp._1)
      if (frequency.contains(f)) ans += frequency(f)
    }

    println(ans)
  }

  def getFreqKey(x: Int): (Int, Int) = {
    val a = x % 10
    var b = 0
    var tmp = x
    while (tmp != 0) {
      b = tmp
      tmp = tmp / 10
    }
    (a, b)
  }
}


Measured memory_bytes: 38064
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in1(n);
	string s;
	cin>>s;
	int w = 0, r;
	rep(i, 0, n) if(s[i] == 'W') w += 1;
	r = n - w;
	int tmp = r;
	rep(i, 0, r) if(s[i] == 'R') tmp -= 1;
	int ans = min(tmp, w);
	cout<<ans<<endl;
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}

Measured memory_bytes: 3680
import bisect
from operator import add, sub

n, l, t = map(int, input().split())

ope = [None, add, sub]
ants = [tuple(map(int, input().split())) for _ in range(n)]
ants_pos = [ope[w](x, t) % l for x, w in ants]

if n == 1:
    print(ants_pos[0])
    exit()

x0, w0 = ants[0]
crash_cnt = 0
crash_check = (lambda x: t - (x - x0) / 2) if w0 == 1 else (lambda x: t - (l - x + x0) / 2)
for x, w in ants[1:]:
    if w == w0:
        continue
    d = crash_check(x)
    if d >= 0:
        crash_cnt += 2 * d // l + 1

ant_alt0 = (0, 1, -1)[w0] * int(crash_cnt) % n
sorted_pos = sorted(ants_pos)
pos_i = bisect.bisect_left(sorted_pos, ants_pos[0])
if pos_i < n - 1 and sorted_pos[pos_i] == sorted_pos[pos_i + 1] and w0 == 1:
    pos_i += 1
pos0_i = (pos_i - ant_alt0) % n
for pos in sorted_pos[pos0_i:]:
    print(pos)
for pos in sorted_pos[:pos0_i]:
    print(pos)


Measured memory_bytes: 20056
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb emplace_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<"\n";
}


Measured memory_bytes: 3636
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
string s,t="";
bool ok(string tmp){
    int len=tmp.length();
    for (int i=0,j=len-1;i<j;i++,j--){
        if (tmp[i]!=tmp[j]) return false;
    }
    return true;
}
int main(){
    cin>>s;
    for (int i=0;i<(int)s.length();i++){
        if (s[i]!='x') t=t+s[i];
    }
    if (!ok(t)) puts("-1");
    else{
        if (ok(s)) puts("0");
        else{
            int cnt=0,cnt2=0,ans=0;
            int len=((int)t.length()+1)/2;
            queue<int>S;
            for (int i=0;i<(int)s.length();i++){
                if (s[i]=='x') cnt++;
                else{
                    cnt2++;
                    S.push(cnt);
                    cnt=0;
                }
                if (cnt2==len) break;
            }
            cnt2=0;
            for (int i=(int)s.length()-1;i>=0;i--){
                if (s[i]=='x') cnt++;
                else{
                    int num=S.front();S.pop();
                    ans+=abs(cnt-num);
                    cnt=0;
                    cnt2++;
                }
                if (cnt2==len) break;
            }
            printf("%d\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 696
def my_gcd(p, q):
    if p < q:
        tmp = q
        q = p
        p = tmp
    r = p % q
    while r > 0:
        p = q
        q = r
        r = p % q
    return q

k = int(input())
gcd_list = [[my_gcd(m + 1, n + 1) for n in range(k)] for m in range(k)]
sum = 0
for a in range(k):
    for b in  range(k):
        for c in range(k):
            sum += gcd_list[a][gcd_list[b][c] - 1]
print(sum)

Measured memory_bytes: 9484
#include <stdio.h>
int main()
{
	int n,a,b,c,d,sum;
	while(scanf("%d",&n)!=EOF){
		sum=0;
		a=n/1000;
		b=(n-a*1000)/100;
		c=(n-a*1000-b*100)/10;
		d=(n-a*1000-b*100-c*10);
		if(a==b&&b==c){
			sum=1;
		}
		if(b==c&&c==d)sum=1;

		if(sum==1)printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
int main() {
	int val[3],k;
	scanf("%d %d %d %d",&val[0],&val[1],&val[2], &k);
	sort(val,val+3);
	int res = val[2]*(1<<k);
	printf("%d\n",res+val[0]+val[1]);
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 3e2 + 1;

double dp[MAX][MAX][MAX], n;

double f(int i, int j, int k) {
    if (i == 0 and j == 0 and k == 0) 
        return 0;
    double& res = dp[i][j][k];
    if (res != -1) return res;
    double m = i + j + k;
    res = n / m;
    if (i > 0) res += i * f(i - 1, j, k) / m;
    if (j > 0) res += j * f(i + 1, j - 1, k) / m;
    if (k > 0) res += k * f(i, j + 1, k - 1) / m;
    return res;
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    cin >> n;
    int arr[3] = {};
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        arr[x - 1]++;
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                dp[i][j][k] = -1;
            }
        }
    }
    cout << fixed << setprecision(9)
        << f(arr[0], arr[1], arr[2]) << '\n';
}

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

int main()
{
	string a;
	cin >> a;
	if (((a[0] == a[1]) && (a[1] == a[2])) || ((a[1] == a[2]) && (a[2] == a[3]))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n, t ,a;
    cin >> n >> t >> a;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    double diff = INF;
    int ans;
    rep(i,n) {
        double temp = t - h[i] * 0.006;
        if (abs(a-diff) > abs(a-temp)) {
            diff = temp;
            ans = i + 1;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

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


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

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

long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

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

Measured memory_bytes: 256
// 実装3:42 テスト込み4:21
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
ok = False
for i in range(n-2):
    if d[i][1] == d[i][0]:
        if d[i+1][1] == d[i+1][0]:
            if d[i+2][1] == d[i+2][0]:
                ok = True
if ok == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9184
n = int(input())
tList = input().split(' ')

for i in range(len(tList)):
    tList[i] = int(tList[i])

m = int(input())
pList = []
xList = []

for j in range(m):
    p, x = input().split(' ')
    pList.append(int(p))
    xList.append(int(x))

for k in range(m):
    tListCopy = list(tList)
    tListCopy[pList[k]-1] = xList[k]
    print(sum(tListCopy))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        String s = sc.next();
        long rCount = 0;
        long gCount = 0;
        long bCount = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'R') {
                rCount++;
            } else if (s.charAt(i) == 'G') {
                gCount++;
            } else {
                bCount++;
            }
        }



        long opposite = 0;

        // 同じものが2個ある
        opposite += (rCount * (rCount - 1) /  2) * (n - rCount);
        opposite += (gCount * (gCount - 1) /  2) * (n - gCount);
        opposite += (bCount * (bCount - 1) /  2) * (n - bCount);

//        debug((long)4000 * (4000 - 1) * (4000 - 2) / 6);
        // 3個
        opposite += (rCount * (rCount - 1) * (rCount - 2) / 6);
        opposite += (gCount * (gCount - 1) * (gCount - 2) / 6);
        opposite += (bCount * (bCount - 1) * (bCount - 2) / 6);

        // j - i == k - j
        for (int i = 2; i < n; i = i + 2) {
            for (int j = 0; j <= n - i - 1; j++) {
                if (s.charAt(j) != s.charAt(j + (i / 2)) && s.charAt(j + (i / 2)) != s.charAt(j + i) && s.charAt(j) != s.charAt(j + i)) {
                    opposite++;
                }
            }
        }

        long total = n * (n - 1) * (n - 2) / 6;
        debug(total);

        System.out.println(total - opposite);


    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 28728
N = int(input())
a = list(map(int, input().split()))

check = [0] * 9
for i in range(N):
    if 1 <= a[i] <= 399:
        check[0] += 1
    elif 400 <= a[i] <= 799:
        check[1] += 1
    elif 800 <= a[i] <= 1199:
        check[2] += 1
    elif 1200 <= a[i] <= 1599:
        check[3] += 1
    elif 1600 <= a[i] <= 1999:
        check[4] += 1
    elif 2000 <= a[i] <= 2399:
        check[5] += 1
    elif 2400 <= a[i] <= 2799:
        check[6] += 1
    elif 2800 <= a[i] <= 3199:
        check[7] += 1
    elif 3200 <= a[i]:
        check[8] += 1

tmp = 0
for i in range(len(check) - 1):
    if check[i] >= 1:
        tmp += 1

ans_min = max(1, tmp)
ans_max = tmp + check[-1]

ans = str(ans_min) + ' ' + str(ans_max)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b=0;
	for(int i=0;i<3;i++){
		cin>>a;
		b+=a;
	}
	if(b>=22){
		cout<<"bust"<<endl;
	}else{
		cout<<"win"<<endl;
	}
	return 0;
}

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;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#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
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B;
	int sum = 0;
	cin >> A >> B;
	REP(i, B) {
		int a; cin >> a;
		sum += a;
	}
	int ans = A - sum;
	if (ans < 0)ans = -1;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3656
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define timesdo(X) for (int times_i = 0; times_i < X; times_i++)

using namespace std;

vector<int> vx;
vector<int> vy;

double dist(int a, int b) {
  return sqrt((vx[a] - vx[b]) * (vx[a] - vx[b]) +
              (vy[a] - vy[b]) * (vy[a] - vy[b]));
}

double length(const vector<int> &v) {
  double ret = 0;
  for (int i = 0; i < v.size() - 1; i++) {
    ret += dist(v[i], v[i + 1]);
  }
  return ret;
}

void solve() {
  int N;
  cin >> N;

  timesdo(N) {
    int x, y;
    cin >> x >> y;
    vx.push_back(x);
    vy.push_back(y);
  }

  vector<int> v;
  for (int i = 0; i < N; i++) {
    v.push_back(i);
  }

  double ans = 0;
  do {
    ans += length(v);
  } while (next_permutation(v.begin(), v.end()));

  int base = 1;
  for (int i = 1; i <= N; i++) {
    base *= i;
  }

  ans /= base;
  printf("%.10lf\n", ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include <math.h>

#define LL long long
#define MOD 1000000007
#define rep(i,n) for(int i = 0;i < (n);i++)

using namespace std;

int main(){

    LL A,B,N;
    cin >> A >> B >> N;
    double ansX = 0;
    if(N > B-1)
        ansX = B-1;
    else
    {
        ansX = N;
    }
    cout << floor(A*ansX/B) - A * floor(ansX/B) << endl;

    return 0;

}

Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;

const int N = 2e5+1000;
#define ll long long
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x) scanf(" %c",&x)
#define sread(x,y,z) scanf("%d%d%d",&x,&y,&z)
ll f[N];
map<ll,ll> hap;
int main()
{
    int n,m;
    Read(n,m);
    for(int i = 1;i <= n;++i){
        scanf("%lld",&f[i]);
        f[i] += f[i-1];
    }
    for(int i = 1;i <= n;++i){
        f[i] = (f[i] - i) % m;
    }
    m --;
    m = min(m,n);
    for(int i = 0;i < m;i ++ ){
        hap[f[i]] ++;
    }
    ll sum = 0;
    for(int i = m ;i <= n;++i){
        hap[f[i]] ++;
        sum += hap[f[i-m]] - 1;
        hap[f[i-m]] --;
    }
    for(int i = n-m + 1;i <= n;++i){
        sum += hap[f[i]] - 1;
        hap[f[i]] --;
    }
    cout<<sum;
}

Measured memory_bytes: 14336