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

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

int h,w;
char f[100][100];
int di[4] = {0,0,1,-1};
int dj[4] = {1,-1,0,0};

int dfs(int i,int j,char c){
	f[i][j] = 0;
	rep(k,4){
		int ni = i + di[k], nj = j + dj[k];
		if(0<=ni && ni<h && 0<=nj && nj<w && f[ni][nj]==c)dfs(ni,nj,c);
	}
}

int main(void){
	while(cin>>h>>w && (h || w)){
		int count = 0;
		rep(i,h)rep(j,w)cin>>f[i][j];
		rep(i,h)rep(j,w){
			if(f[i][j] != 0){
				dfs(i,j,f[i][j]);
				count++;
			}
		}
		cout<<count<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int inf = 1000000007;

int main() {
    //freopen("in.cpp","r",stdin);
    string s,t;
    cin>>s;
    map<char,char>mp;
    mp['b']='d';
    mp['d']='b';
    mp['p']='q';
    mp['q']='p';
    for(int i=s.size()-1;i>=0;i--)t+=s[i];
    for(int i=0;i<t.size();i++){
        t[i]=mp[t[i]];
    }
    if(t==s)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
    ll a,b,c,i,j;
    string s,t;
    cin>>a>>b;
    cout<<ceil(1.0*a/b)<<'\n';
    return 0;
}


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

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

	if(a*b>c*d) {
		cout << a*b << endl;
	} else if (a*b<c*d) {
		cout << c*d << endl;
	} else {
		cout << a*b << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A+B==C+D){
    cout<<"Balanced"<<endl;
  }
   else if(A+B<=C+D){
     cout<<"Right"<<endl;
   }
  else cout<<"Left"<<endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(usize);
    let ta = get!(u64, u64; n);

    let mut t = ta[0].0;
    let mut a = ta[0].1;

    for &(ti, ai) in &ta[1..] {
        let tt = (t + ti - 1) / ti;
        let aa = (a + ai - 1) / ai;

        if ai * tt >= a {
            t = ti * tt;
            a = ai * tt;
        } else {
            t = ti * aa;
            a = ai * aa;
        }
    }

    println!("{}", t + a);
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio

    lli num1 , num2 ;
    cin >> num1 >> num2 ;
    cout << (num1 <= num2 ? num1 : num1 - 1) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
/***********
* Coded by *
*   ACS    *
***********/

// p: Problem A. Sliding Minimum Elements
// j: VJUDGE
// c: CONTEST 1
#include <bits/stdc++.h>

#define cic(in,n) for(int i=in;i<n;i++)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define All(a) a.begin(),a.end()
#define PB push_back
#define FIND(m,v) (m.find(v) != m.end())
#define print(n) cout<<n<<endl

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int MAX = 1e6 + 100, mod = 1e9 + 7, oo = INT_MAX;

int n, l, a[MAX];
deque<pii> d;

void Insert(int x, int i)
{
	while(d.size() && x < (d.front().first))
		d.pop_front();
	d.push_front(pii(x, i));
}

int GetMax(int i)
{
	while(d.back().second < i) d.pop_back();
	return d.back().first;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> l;
	rep(i,0, n)
	{
		cin >> a[i], Insert(a[i], i);
		if(i >= l-1) cout << GetMax(i - l + 1);
		if(i >= l-1 && i != n-1) cout << " ";
		else if(i >= l-1) cout << "\n";
	}
	
	return 0;
}






Measured memory_bytes: 7232
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int mod=998244353;
int n,m,f[1000005],inv[1000005];
long long C(int n,int m){
	return 1LL*f[n]*inv[m]%mod*inv[n-m]%mod;
}
long long quick_pow(long long a,int b){
	long long ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	if(n<m) swap(n,m);
	f[0]=f[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=1000002;i++) f[i]=1LL*f[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=1000002;i++) inv[i]=1LL*inv[i]*inv[i-1]%mod;
	long long ans=0;
	for(int i=1;i<=m;i++){
		ans=(ans+C(i+i,i)*C(n-i+m-i,n-i))%mod;
	}
	ans=(ans*quick_pow(2*C(n+m,n),mod-2)+n)%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#define INF 1<<30
using namespace std;

int main(){
  
  int N,T,E;
  int a;
  int ans=-1;
  cin >> N >> T >>E;

  for(int i=0;i<N;i++){
    cin >> a;
    for(int j=0;j<=T+E;j++){
      if( T-E<=a*j && a*j<= T+E)ans = i+1;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from math import factorial
import numpy as np
from itertools import product

def check(last):
  for i in range(4):
    t = list(last)
    if i > 0:
      t[i-1], t[i] = t[i], t[i-1]
    if 'AGC' in ''.join(t):
      return False
  return True


def main():
  N = int(input())
  M = 10**9 + 7
  DP = np.ones((4, 4, 4), dtype=np.int)
  g2i = {g:i for i,g in enumerate(list('ATGC'))}
  DP[tuple([g2i[g] for g in 'AGC'])] = 0
  DP[tuple([g2i[g] for g in 'GAC'])] = 0
  DP[tuple([g2i[g] for g in 'ACG'])] = 0
  for i in range(N-3):
    _DP = np.zeros((4, 4, 4), dtype=np.int)
    for last3 in [''.join(x) for x in product(*(['ATGC']*3))]:
      for c in 'ATGC':
        if check(last3+c):
          # print(last3+c)
          _DP[tuple([g2i[g] for g in last3[1:]+c])] += DP[tuple([g2i[g] for g in last3])]
          _DP[tuple([g2i[g] for g in last3[1:]+c])] %= M
    DP = _DP
  # print(DP)
  print(np.sum(DP) % M)

if __name__=='__main__':
  main()

Measured memory_bytes: 14236
def main():
    n = int(input())
    ABs = [list(map(int, input().split())) for _ in range(n)]
    ABs = sorted(ABs, key=lambda x: x[1])
    Count = 0
    for AB in ABs:
        Count += AB[0]
        if Count > AB[1]:
            print("No")
            exit()
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 55184
#include<iostream>

using namespace std;

int main() {
  string a;
  cin >> a;
  char b = a[0];
  
  switch(b) {
    case 'A':
      cout << "T";
      break;
    case 'T':
      cout << "A";
      break;
    case 'C':
      cout << "G";
      break;
    case 'G':
      cout << "C";
      break;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));

ll arr[63];
ll brr[64];
ll mod=1e9+7;
int main()
{
    int n;
    cin>>n;
    brr[0]=1;
    for(int i=1;i<64;i++){
    	brr[i]=brr[i-1]*2;
    	brr[i]%=mod;
	}
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		int count=0;
		while(a){
			arr[count++]+=a%2;
			a/=2;
		}
	}
	ll sum=0;
	for(int i=0;i<63;i++){
		sum+=brr[i]*((arr[i]*(n-arr[i]))%mod);
		sum%=mod;
	}
	cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template<class Cmp=less_equal<int>>
class SparseTableRMQ{
public:
    SparseTableRMQ(){
    }
    SparseTableRMQ(int *ar, int n): n(n), data(n){
        for(int i = 0; i < n;++i) data[i] = ar[i];
        table = buildRMQ();
    }

    int queryPos(int l, int r){
        int k = lgInt(r - l - 1);
        int lid = table[l + n*k], rid = table[r + n*k - (1 << k)];
        return (cmp(data[lid], data[rid])) ? lid : rid;
    }

    int queryValue(int l, int r){
        return data[queryPos(l, r)];
    }
private:
    int n;
    vector<int> data, table;
    Cmp cmp;
    int lgInt(int v){
        static const unsigned b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
        static const unsigned S[] = {1, 2, 4, 8, 16};
        int res = 0;
        for (int i = 4; i >= 0; i--) {
            if (v & b[i]) {
                v >>= S[i];
                res |= S[i];
            }
        }
        return res;
    }

    vector<int> buildRMQ() {
        int logn = 1;
        for (int k = 1; k < n; k *= 2) ++logn;
        vector<int> b(n*logn);
        for(int i = 0; i < n; ++i)b[i] = i;
        int cur = 0;
        for(int k = 1; k < n; k *= 2){
            copy(b.begin() + cur, b.begin() + cur + n, b.begin() + cur + n);
            cur += n;
            for(int i = 0; i < n - k; ++i){
                int idl = b[cur + i], idr = b[cur + i + k];
                if(cmp(data[idl], data[idr])){
                    b[cur + i] = idl;
                } else{
                    b[cur + i] = idr;
                }
            }
        }
        return b;
    }
};
typedef SparseTableRMQ<less_equal<int>> RMinQ;
typedef SparseTableRMQ<greater_equal<int>> RMaxQ;

int N, A[200001];

int main(){
    cin >> N;
    rep(i, N)scanf("%d", &A[i]);
    RMinQ rmq(A, N);

    ll X = 0;
    rep(i, N){
        int l = -1, r = i, m, L, R;
        while(r - l > 1){
            m = (l + r) / 2;
            if(rmq.queryValue(m, i + 1) >= A[i])r = m;
            else l = m;
        }
        L = r;
        l = i+1, r = N+1;
        while(r - l > 1){
            m = (l + r) / 2;
            if(rmq.queryValue(i, m) < A[i])r = m;
            else l = m;
        }
        R = l;
        X += (i-L+1ll)*(R-i)*(ll)A[i];
    }
    cout << X << endl;
}

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

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = st[0];
            int M = st[1];

            int[] all = new int[2 * M];

            for (int i = 0; i < M; i++) {
                var x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                all[2 * i] = x[0];
                all[2 * i + 1] = x[1];
            }

            for (int i = 0; i < N; i++) {
                Console.WriteLine(all.Where(x => x == (i + 1)).Count());

            }

        }
    }
}


Measured memory_bytes: 13396
#coding:utf-8
#1_4_D
def is_carriable(w_lim, trucks, loads):
    """ Check whether w_lim(maximum carrying capacity) is possible or not """
    i = 0
    while trucks > 0:
        w = 0
        while i < len(loads):
            if w + loads[i] > w_lim:
                trucks -= 1
                break
            w += loads[i]
            i += 1
        if i == len(loads):
            return True
    return False

n, trucks = map(int, input().split())
loads = [int(input()) for i in range(n)]

left = max(loads)
right = sum(loads) + 1

while right - left > 1:
    mid = (left + right) // 2
    if is_carriable(mid, trucks, loads):
        ans = mid
        right = mid
    else:
        left = mid

if is_carriable(max(loads), trucks, loads):
    ans = max(loads)

print(ans)

Measured memory_bytes: 11576
#include "bits/stdc++.h"
using namespace std;
const int maxn = 100100;
int main(){
	string s;
	cin >> s;
	set<string> v;
	int len = s.size();
	for(int e = 0; e < len; e++){
		string u;
		for(int f = e, c = 0; f < len && c < 10; c++, f++){
			u.push_back(s[f]);
			v.insert(u);
		}
	}
	int k; cin >> k;
	k--;
	while(k--) v.erase(v.begin());
	cout << *(v.begin()) << endl;
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 998244353
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
    ll n;cin>>n;
    string s;cin>>s;
    
    ll ans=0;
    vector<bool> check(1000,false);
    
    rep(i,1000){
        ll f=i/100,se=(i/10)%10,t=i%10;
        bool okf=false,okse=false,okt=false;
        rep(j,n){
            if(okse && t==(ll)(s[j]-'0')){
                okt=true;
            }
            if(okf && se==(ll)(s[j]-'0')){
                okse=true;
            }
            if(f==(ll)(s[j]-'0')){
                okf=true;
            }
        }
        if(okt){
            check[i]=true;
        }
    }

    rep(i,1000){
        if(check[i]==true) ans++;       
    }

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

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Num 1000000007
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

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

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

template<class T> void chmax(T& a,const T& b){a=max(a,b);}
template<class T> void chmin(T& a,const T& b){a=min(a,b);}

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int N,w[MAX_N];
ll T,L,x[MAX_N];

int main(){
  cin >> N >> L >> T;
  rep(i,N) scanf("%lld %d",x+i,w+i);
  ll cnt = 0LL;
  rep(i,N){
    if(w[i]==1) cnt += (T+x[i])/L;
    else cnt -= (T-x[i]+L-1)/L;
  }
  cnt = (cnt % N + N) % N;
  // rep(i,N) (x[i] += (w[i]==1 ? 1 : -1)*T+L) %= L;
  rep(i,N){
    if(w[i]==1) x[i] = (x[i]+T)%L;
    else x[i] = ((x[i]-T)%L+L)%L;
  }
  sort(x,x+N);
  // 0のantはcntのゼッケン
  rep(i,N) printf("%lld\n",x[(i+cnt)%N]);

  // REP(i,1,N){
  //   if(w[0]==w[i]) continue;
  //   // a回すれ違う -> a-1周してその後1回すれ違う
  //   // T/L周 -> 残り T%L で, 2(T%L) >= dist(0,i) ならすれ違える
  //   ll dist;
  //   if(w[0]==1) dist = (x[i].first-x[0].first+L)%L;
  //   else dist = (x[0].first-x[i].first+L)%L;
  //   if(w[0]==1){
  //     ll rest = T - 
  //   }else{

  //   }
  // }
  return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a == b ) {
            System.out.println(c);
        }
        if (b == c ) {
            System.out.println(a);
        }
        if (c == a ) {
            System.out.println(b);
        }

    }

}


Measured memory_bytes: 22484
# ABC117C - Streamline
def main():
    N, M, *X = map(int, open(0).read().split())
    X = sorted(set(X))
    dist = []
    for i, j in zip(X, X[1:]):
        dist.append(j - i)
    dist.sort(reverse=1)
    ans = sum(dist[N - 1 :])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14972
#include<stdio.h>
#include<math.h>
int main()
{
  int n,i;
  double even=0;
  scanf("%d",&n);
  long int a[n];
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    while(a[i]%2==0){
      a[i] /= 2;
      even++;
    }
  }
  printf("%d",(int)even);
  return 0;
}


Measured memory_bytes: 256
N=int(input())
middle = N//2
a = input().split()



ans=[0 for i in range(N)]
ans[middle]=a[0]

j=1
diff = -1 if N%2 ==0 else 1
for i, aa in enumerate(a[1:]):
    ans[middle + j*diff] = aa
    diff *= -1
    if (i+1)>1 and (i+1)%2==0:
        j+=1
print(" ".join(ans))

Measured memory_bytes: 25504
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=0; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  int n ;
  cin >> n ;
  vector<pair<double,string>> vec(n) ;
  vector<double> mul(n) ;
  double sum = 0 ;
  
  REP(i,n){
    double a ;
    string b ;
    cin >> a >> b ;
    
    vec.at(i) = make_pair(a,b) ;
  }
  REP(i,n){
    if(vec.at(i).second=="JPY"){
      mul.at(i) = vec.at(i).first ;
    }
    else if(vec.at(i).second=="BTC"){
      mul.at(i) = (double)vec.at(i).first*380000.0 ;
    }
  }
  REP(i,n){
    sum += mul.at(i) ;
  }
  
  cout << sum <<endl ;

  return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	int x, a, b; cin >> x >> a >> b;
	int d1 = abs(a - x);
	int d2 = abs(b - x);
	if(d1 < d2) printf("A\n");
	else printf("B\n");
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int a; cin >> a;
    string s; cin >> s;
    cout << (a>=3200? s: "red") << endl;
    return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AEntranceExamination solver = new AEntranceExamination();
        solver.solve(1, in, out);
        out.close();
    }

    static class AEntranceExamination {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            double t = in.nextInt(), x = in.nextInt();

            out.format("%.16f%n", t / x);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22996
# -*- coding: utf-8 -*-
"""
Created on Wed Oct  2 07:56:16 2019

@author: avina
"""
from queue import PriorityQueue as Q
n,t = map(int,input().split())

q = Q()
for i in input().split():
    a = -1*int(i)
    q.put(a)

while t >0:
    a = -1*(q.get())
    a = -1*(a//2)
    q.put(a)
    t-=1

ans = 0
while q.qsize()>0:
    ans += q.get()
print(-1*ans)

Measured memory_bytes: 15432
k, n = map(int,input().split())
alist = list(map(int, input().split()))

saidai=alist[0]-alist[-1]+k
for i in range(n-1):
    if alist[i+1]-alist[i]>saidai:
        saidai=alist[i+1]-alist[i]

print(k-saidai)

Measured memory_bytes: 78412
#include <iostream>
#include <vector>
#include <cstdint>

using i64 = int64_t;
using i32 = int32_t;

i32 popcnt(i32 n) {
    i32 ans = 0;
    while (n > 0) {
        ans += n & 1;
        n >>= 1;
    }
    return ans;
}

void run() {
    i32 n;
    std::cin >> n;
    std::vector<std::vector<std::pair<i32, i32>>> a;
    for (i32 i = 0; i < n; ++i) {
        i32 len;
        std::cin >> len;
        std::vector<std::pair<i32, i32>> b;
        for (i32 j = 0; j < len; ++j) {
            i32 x, y;
            std::cin >> x >> y;
            b.emplace_back(x - 1, y);
        }
        a.emplace_back(b);
    }
    i32 ans = 0;
    for (i32 bit = 0; bit < (1 << n); ++bit) {
        bool ok = true;
        for (i32 i = 0; i < n; ++i) {
            for (auto p : a.at(i)) {
                i32 x, y;
                std::tie(x, y) = p;
                if (((bit >> i) & 1) == 1 && ((bit >> x) & 1) != y) {
                    ok = false;
                }
            }
        }
        if (ok) {
            ans = std::max(ans, popcnt(bit));
        }
    }
    std::cout << ans << '\n';
}

int main() {
    run();
    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>
#define MOD 1000000007
using namespace std;

int n, k;
vector<vector<int>> nextPoint;

long long dfs(int cur, int parent){
    if(k <= nextPoint[cur].size()) return 0;
    long long childColour, ans;
    childColour = ((parent==-1) ? k-1 : k-2);
    ans = ((cur==0) ? k : 1);
    for(int i = 0; i < nextPoint[cur].size(); i++){
        if(nextPoint[cur][i] == parent) continue;
            ans = ans * childColour % MOD;
            childColour--;
    }
    for(int i = 0; i < nextPoint[cur].size(); i++){
        if(nextPoint[cur][i] == parent) continue;
        ans = ans * dfs(nextPoint[cur][i], cur) % MOD;
    }
    return ans;
}

int main(){
    cin >> n >> k;
    nextPoint.resize(n);
    for(int i = 0; i < n-1; i++){
        int a, b; cin >> a >> b;
        nextPoint[a-1].push_back(b-1);
        nextPoint[b-1].push_back(a-1);
    }
    cout << dfs(0, -1) << endl;
    return 0;
}


Measured memory_bytes: 11520
n=int(input())
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list
cnt=0
for i in range(1,n+1,2):
    if len(make_divisor_list(i))==8:
        cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  double a,b,c;
  cin>>a>>b>>c;
  c=c*M_PI/180;
  //cout<<c<<endl;
  cout<<fixed<<setprecision(20)<<0.5*a*b*sin(c)<<endl;
  cout<<a+b+sqrt(a*a+b*b-2*a*b*cos(c))<<endl;
  cout<<b*sin(c)<<endl;
}



Measured memory_bytes: 3516
#include <cstdio>
#include <algorithm>

using namespace std;

int calc(int x) {
    int ans = 0;
    
    while (x > 0) {
        ans += x % 10;
        x /= 10;
    }
    
    return ans;
}

int main() {
    int n, ans = 1e9, i;
    
    scanf("%d", &n);
    
    for (i = 1; i < n; i++) ans = min(ans, calc(i) + calc(n - i));
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    set<string> se;
    rep(i, N) {
        string s;
        cin >> s;
        se.insert(s);
    }
    cout << se.size() << endl;
    return 0;
}

Measured memory_bytes: 19252
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::vector;
using std::cin;
using std::map;
using std::unordered_map;
using std::multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	ll n;
	cin >> n;
	VL v(n);
	REP(i, n) { cin >> v[i]; }

	unordered_map<ll, ll> mp;
	REPC(x, v) {
		if (mp.find(x) == mp.end()) {
			mp[x] = 1;
		} else {
			++mp[x];
		}
	}
	ll c = 0;
	REPC(x, mp) {
		ll p = x.second;
		if (p == x.first) { continue; }
		if (p > x.first) { p-= x.first; }
		c += p;
	}
	cout << c << endl;
}

Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[101]={};
	int r,l,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		sum+=*(a+i);
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&r,&l);
		printf("%d\n",sum+l-*(a+r));
	} 
}

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

int main() {
	int a, b;
	string str;
	while (cin >> a >> b){
		if (a * 4 < b){
			cout << "No" << endl;
		}else if (a * 2 == b || a * 4 == b){
			cout << "Yes" << endl;
		}else{
			for (int i = 1; i <= a; i ++){
				if (i * 2 + (a - i) * 4 == b){
					str = "Yes";
					break;
				}else{
					str = "No";
				}
			}
			cout << str << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;



void solve(){

    ll n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    rep(i,n){
        cout << s[i]<<t[i];
    }
    cout << endl;

}

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


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

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)


int main() {
	ll x;
	cin >> x;
	ll c=0;
	//cin >> s;
	ll t = 100;
	while(x>t){
		t *= 1.01;
		t = floor(t);
		c++;
	}
	cout << c << endl;

}


Measured memory_bytes: 3600
s1=list(input())
s2=list(input())
s1.insert(0,0)
s2.insert(0,0)
l=[[0 for i in range(len(s2))] for j in range(len(s1))]
for i in range(len(s1)):
	for j in range(len(s2)):
		if j==0:
			l[i][j]=i
		elif i==0:
			l[i][j]=j
		else:
			if s1[i]==s2[j]:
				c=0
			else:
				c=1
			l[i][j]=min(l[i-1][j]+1,l[i][j-1]+1,l[i-1][j-1]+c)
print(l[len(s1)-1][len(s2)-1])
			



Measured memory_bytes: 43808
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define N 200001

using namespace std;

// input
int n,k;
int h[N];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> n >> k;
  rep(i,n) cin >> h[i];

  sort(h,h+N);

  ll ans = 0;

  for(int i = N-1;i > -1; i--) {
    if(h[i] == 0) break;
    if(k > 0) {
      k--;
    } else {
      ans += h[i];
    }
  }
  cout << ans;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#include<string>
#include<deque>
#include<set>
#include<vector>
#include<map>
#define ll long long
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    int a[100005];
    int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];	
	 } 
	 int ans=0;
	 for(int i=0;i<n;i++)
	 {
	 	if(a[i]==i+1)
	 	{
	 	swap(a[i],a[i+1]);
		 ans++;	
		 }
		 
	 	
	 }
	 if(a[n-1]==n)
	 ans++;
	 cout<<ans<<endl; 
		return 0;
 } 


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int A,B;
	cin>>A>>B;
	
	if(A<=8&&B<=8){
		cout<<"Yay!"<<endl;
	}
	else{
		cout<<":("<<endl;
	}
	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int n, m, x;
vector<int> c;
vector<vector<int>> v;

int dfs(int cost, int i, vector<int> u) {
  // base case
  if (i >= n) {
    bool b = true;
    for(int val: u) {
      if (val < x) b = false;
    }
    return (b ? cost: INF);
  }

  vector<int> newU(m);
  rep(j,m) newU[j] = u[j] + v[i][j];

  return min(dfs(cost, i+1, u), dfs(cost + c[i], i+1, newU));
}

void solve() {
  cin >> n >> m >> x;
  c.resize(n);
  v.resize(n, vector<int>(m));
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> v[i][j];
  }
  vector<int> u(m,0);
  int ans = dfs(0, 0, u);
  cout << ((ans==INF) ? -1: ans) << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3644
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    a = list(map(int,input().split()))
    p = [a[0]]
    for i in range(1, N):
        p.append(p[i-1]*a[i])
    ans = p[-1]/sum([p[-1]/a[i] for i in range(N)])
    print(ans)
if __name__ == "__main__":
    main()


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

using lli = long long int;

int main(void){
    lli k,a,b;
    cin >> k >> a >> b;
    
    if(a <= b){
        
        if(k <= a){
            cout << 1 << endl;
        }else
            cout << -1 << endl;
    }else{
        if(k <= a){
            cout << 1 << endl;
        }else{
            
            lli res = ( k + a - b - 1) / (a - b);
            
            cerr << res << endl;
            
            while(true){
                if( k > res*a - (res-1)*b ){
                    cerr << res << endl;
                    cout << 2*res+1 << endl;
                    return 0;
                }
                res--;
            }
        }
    }
    
}


Measured memory_bytes: 256
import java.util.Scanner;

 class Main {  
				public static void main(String[] args) {
				Scanner reader =new Scanner (System.in);
				int arr[]=new int [101010];
				int k;
			   int n;
			   int cnt=0;
			   n=reader.nextInt();
			   k=reader.nextInt();
			   for(int i=0;i<n;i++)
			   {
				   arr[i]=reader.nextInt();
			   }
			   for(int i=0;i<n;i++)
			   {
				   if(arr[i]>=k)
				   {
					   cnt++;
				   }
			   }
			   System.out.println(cnt);
			}
	}

Measured memory_bytes: 49236
import java.util.Scanner;

/**
 * 問題B<BR>
 * 部分文字列においてDの個数と、
 * PDの個数を総和を最大とする文字列を出力しろ。
 */
public class Main {
    /** D, Pどちらでも良い文字列 */
    private static final char FREE_CHARACTOR = '?';
    /** 文字D */
    private static final char D = 'D';
    /** 文字P */
    private static final char P = 'P';

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

        String t = sc.next().trim();
        char[] chs = t.toCharArray();

        for (int i = 0; i < chs.length; i++) {
            if (chs[i] == FREE_CHARACTOR) {
                chs[i] = D;
            }
        }

        System.out.println(new String(chs));
    }
}

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

class Disjointset{
  public:
    vector<int> rank, p;

    Disjointset(){}
    Disjointset(int size){
      rank.resize(size, 0);
      p.resize(size, 0);
      for(int i = 0; i<size; i++) makeSet(i);
    }

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

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

    void unite(int x, int y){
      link(findSet(x), findSet(y));
    }

    void link(int x, int y){
      if(rank[x] > rank[y]){
        p[y] = x;
      }else{
        p[x] = y;
        if(rank[x] == rank[y]){
          rank[y]++;
        }
      }
    }

    int findSet(int x){
      if(x != p[x]){
        p[x] = findSet(p[x]);
      }
      return p[x];
    }
};

int main(){
  int n, q;
  int command, x, y;
  cin >> n >> q;
  Disjointset ds = Disjointset(n);

  rep(i,q){
    cin >> command >> x >> y;
    if(command == 0) ds.unite(x,y);
    else if(command == 1){
      if(ds.same(x, y)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }



  return 0;
}


Measured memory_bytes: 3196
from fractions import Fraction
from math import ceil


N = int(input())
for h in range(ceil(N / 4), ceil(N / 4)*1000):
    r = Fraction(4, N) - Fraction(1, h)
    if r.numerator > 0:
        n = ceil(r.denominator / r.numerator)
    else:
        h, n = h+1, h * (h+1)
        r = Fraction(4, N) - Fraction(1, h)

    r -= Fraction(1, n)
    if r.numerator > 0:
        w = ceil(r.denominator / r.numerator)
        r -= Fraction(1, w)
    else:
        n, w = n+1, n*(n+1)
        r = Fraction(4, N) - Fraction(1, h) - Fraction(1, n) - Fraction(1, w)

    if r == 0:
        print(h, n, w)
        break

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

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

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

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

/********************* MODULAR ARITHMETIC *******************************/

ll MOD = 1000000007;

void mod(ll &a){ if(a > MOD) a %= MOD; }
ll add(ll a, ll b) { a += b; mod(a); return a; }
ll mul(ll a, ll b) { mod(a); mod(b); a *= b; mod(a); return a; }
ll sub(ll a, ll b) { mod(a); mod(b); a -= b; a += MOD; mod(a); return a; }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

ll inv(ll a) { return powr(a, (MOD - 2)); }

/******************************** START *********************************/
const int N = 303;
int n;
ld dp[N][N][N];

ld func(int a, int b, int c)
{
  if(dp[a][b][c] > -1) {
    return dp[a][b][c];
  }

  if(a + b + c == 0) {
    return 0.0;
  } 
  ld res = 0;
  if(a > 0) {
    res += (a * 1.0 / (a + b + c) * 1.0) * func(a - 1, b, c);
  } 
  if(b > 0) {
    res += (b * 1.0 / (a + b + c) * 1.0) * func(a + 1, b - 1, c);
  }
  if(c > 0) {
    res += (c * 1.0 / (a + b + c) * 1.0) * func(a, b + 1, c - 1);
  }
  res += (n * 1.0) / (a + b + c) * 1.0;
  return dp[a][b][c] = res;
}

int main()
{
  ifalse;
  cin >> n;
  int a[4] = {0};
  for(int i = 0; i < n; i ++) {
    int x;
    cin >> x;
    a[x] ++;
  }

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

  prec(16);
  cout << func(a[1], a[2], a[3]), nl;
  return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#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 pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n;
  cin >> n;
  vector<ll> a(n);
  scan(a);
  sort(all(a));

  ll count = 0;
  ll m = a[0];
  int m_index = 0;
  while (count != n - 1) {
    count = 0;
    rep(i, 0, n) {
      if (i == m_index) continue;
      a[i] %= m;
      if (a[i] == 0) {
        count++;
        continue;
      }
      chmin(m, a[i]);
      m_index = i;
    }
  }

  put(m);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

#define rep1(i,x) for(ll i=1;i<=(x);++i)

ll imos[100002];
ll P[100002];
ll A[100002], B[100002], C[100002];

int main()
{
	ll N, M; scanf("%lld %lld", &N, &M);

	scanf("%lld", &P[0]);
	ll pre = P[0];

	rep1(i, M - 1) {
		scanf("%lld", &P[i]);
		if (pre < P[i]) {
			imos[pre]++; imos[P[i]]--;
		} else {
			imos[P[i]]++; imos[pre]--;
		}

		pre = P[i];
	}

	rep1(i, N - 1) scanf("%lld %lld %lld", &A[i], &B[i], &C[i]);

	ll ans = 0;

	rep1(i, N - 1) {
		imos[i] += imos[i - 1];
		ans += min(A[i] * imos[i], C[i] + B[i] * imos[i]);
	}

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

Measured memory_bytes: 4928
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

void Sequence() {
	int a, b, c;
	cin >> a >> b >> c;
	if (((a + b) == c) || (a + c == b) || (b + c == a) ) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

}
int main() {
	Sequence();
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

std::vector<int> r(100);

void rec(const int N, const int M, const int D, int curr, int prev, int cost) {
  if (curr == M) {
    if (cost != 4) {
      return;
    }
    std::cout << cost << ": ";

    for (int i = 0; i < M; i++) {
      std::cout << r[i] << (i + 1 == M ? "\n" : ", ");
    }
  } else {
    for (int i = 1; i <= N; i++) {
      r[curr] = i;
      rec(N, M, D, curr + 1, i, cost + (std::abs(prev - i) == D ? 1 : 0));
    }
  }
}

int main() {
  int N, M, D;
  std::cin >> N >> M >> D;

  double answer = 1.0 * (D == 0 ? N : (N - D) * 2) / N / N * (M - 1);

  printf("%.10f\n", answer);
}


Measured memory_bytes: 256